-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
48 lines (30 loc) · 814 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var Poisson = require('.');
//Set conditions
var conditions = {
w: 1,
h: 1,
n: 50,
m: 50
};
//Initialize solver
var poisson = new Poisson(conditions);
var N = [];
var S = [];
var E = [];
var W = [];
for (var i = 0; i < conditions.n; i++) {
N[i] = S[i] = E[i] = W[i] = 0;
}
//Set boundary conditions to zero
poisson.setBoundaryConditions(N, S, E, W);
//Maximum number of iterations allowed
var maxItterations = 100000000;
//Maximum residue allowed
var maxResidue = 1E-9 ;
//Run solver
var output = poisson.solver( maxItterations, maxResidue);
console.log('Solver converged with', output.iterations, 'iterations and', output.residue, 'residue.');
//Print
poisson.print('./field.txt', poisson.u.old);
poisson.analytical();
poisson.print('./analytical.txt', poisson.u.analytical);