-
Notifications
You must be signed in to change notification settings - Fork 8
/
9-FF_preconditioning_hpc.edp
executable file
·61 lines (45 loc) · 1.37 KB
/
9-FF_preconditioning_hpc.edp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// run with: $ mpirun -n 4 FreeFem++-mpi 9-FF_preconditioning_hpc.edp -v 0
load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"
// verbosity = 0;
real cpuTime, assemTime, solveTime;
func Pk = P1;
func f=x*y;
bool writeFile = false;
int meshSize = 4000; // a big mesh to evaluate performance, you may even want to increae it
border C(t=0,2*pi){x=2*cos(t);y=sin(t);}
mesh Th = buildmesh(C(meshSize));
int dofBeforePartition; // just for displaying
if (mpirank == 0)
{
fespace VhDoF(Th, Pk);
dofBeforePartition = VhDoF.ndof;
}
fespace Vh(Th, Pk);
Mat A;
createMat(Th, A, Pk)
varf weak(u, v) = intN(Th)(dx(u)*dx(v) + dy(u)*dy(v)) + int2d(Th)(f*v) + on(C,u=0);
if (mpirank == 0) {cpuTime = mpiWtime();}
matrix Loc = weak(Vh, Vh);
real[int] b = weak(0, Vh);
A = Loc;
// set(A, sparams="-ksp_view -pc_type lu");
// -pc_type gamg -ksp_type gmres -mat_type mpiaijcusparse
// -pc_type hypre
set(A, sparams="-ksp_view -pc_type hypre");
Vh u;
u[] = A^-1 * b;
if (mpirank == 0) {solveTime = mpiWtime() - cpuTime;}
if (writeFile)
{
int[int] Order = [1];
string DataName = "u";
savevtk("poisson.vtu", Th, u, dataname=DataName, order=Order, append=false);
}
if (mpirank == 0)
{
cout << "DOF Total: " << dofBeforePartition << endl;
cout << "DOF: " << Vh.ndof << endl;
cout << "Solver time: " << solveTime << " s" << endl;
}