I want to decompose a 3D mesh (sphere) into multiple subdomains and export the stiffness matrices / load vectors to solve the problem with an external CG solver.
Unfortunately it seems that the local matrices are non-symmetric.
// ff-mpirun -np 4 sphere2.edp -wg -ffddm_overlap 2 -ffddm_schwarz_method asm
macro dimension 3 // EOM
verbosity = 0;
load "msh3"
load "tetgen"
// load "medit"
// load "iovtk"
include "MeshSurface.idp"
include "ffddm.idp"
real radius = 5;
real hh = radius * 0.1;
meshS ThS = Sphere(radius, hh, 1, 0., 0., 0., 1);
// meshS ThS = Sphere(radius, 500., 500., 500., hh, 1, 1); // laut Doku
// plot(ThS,wait=1);
real[int] domain =[0.,0.,0.,1,hh^3]; // x, y, z, attrib, max_vol
mesh3 Th3 = tetg(ThS, switch="pqaAAQYY", nbofregions=1, regionlist=domain);
// savevtk("sphere.vtu", Th3);
// Mesh refinement
cout << "Num vertices coarse: " << Th3.nv << ", hmax = " << Th3.hmax << endl;
// medit("Coarse", Th3);
int refineSteps = 0;
for (int i = 0; i < refineSteps; i++)
{
Th3 = trunc(Th3, 1, split=2);
cout << "Num vertices fine: " << Th3.nv << ", hmax = " << Th3.hmax << endl;
}
// medit("Fine", Th3);
func bc = x^3*z^2*sin(y);
macro Grad3(u) [dx(u),dy(u),dz(u)] // EOM
macro Varf(varfName, meshName, VhName)
varf varfName(u,v) = int3d(meshName)(Grad3(u)'* Grad3(v)) + on(1, u=bc);
// EOM
// Domain decomposition
ffddmbuildDmesh( LapMesh , Th3 , mpiCommWorld )
// medit("sphere" + mpirank, LapMeshThi);
int[int] ll = labels(LapMeshThi);
meshS surf = extract(LapMeshThi, label=ll);
cout << "Rank " << mpirank << ": Num vertices " << LapMeshThi.nv << ", extracted vertices: " << surf.nv << endl;
// savevtk("Th" + mpirank + ".vtk", LapMeshThi);
macro def(u) u// EOM
macro init(u) u// EOM
ffddmbuildDfespace(LapFE, LapMesh, real, def, init, P1)
ffddmsetupOperator( PB , LapFE , Varf )
func f = -6*x*z^2*sin(y)+x^3*z^2*sin(y) -2*x^3*sin(y);
macro myVarfrhs(varfName, meshName, VhName)
varf varfName(u,v) = int3d(meshName)(f*v) + on(1, u=bc); // f + Laplace g
// EOM
real[int] rhsi(0);
ffddmbuildrhs(PB, myVarfrhs, rhsi)
if (mpisize == 1)
{
ofstream fout("A_global.txt");
fout << PBaRd[0] << endl;
}
else
{
ofstream fout("A_local" + mpirank + ".txt");
fout << PBaRd[mpirank] << endl;
}
if (mpisize == 1)
{
ofstream fout("R_global.txt");
fout << LapFERih[0] << endl;
}
else
{
ofstream fout("R_local" + mpirank + ".txt");
fout << LapFERih[mpirank] << endl;
}
if (mpisize == 1)
{
ofstream fout("rhs_global.txt");
fout << rhsi << endl;
}
else
{
ofstream fout("rhs_local" + mpirank + ".txt");
fout << rhsi << endl;
}
if (mpisize == 1)
{
ofstream fout("PoU_global.txt");
fout << LapFEDih[0] << endl;
}
else
{
ofstream fout("PoU_local" + mpirank + ".txt");
fout << LapFEDih[mpirank] << endl;
}