Sorry, here’s the code :
// run with MPI: ff-mpirun -np 4 script.edp -wg
// NBPROC 8
load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"
verbosity=1;
real cpu = clock();
int up = 1000, down = up -1, right = down-1, left = right-1, CURVE=up+1;
tgv=1e300;
////////////////////////Mesh: soil geometry////////////////////////////////////////////
//method parameters
real NN = 100, dt=0.001, t=0., tfin=100000, L=100; int i;
func real curve(real t) {
return L * (0.1 * (1 - cos(pi * (t/(L)))) + 0.45) /* (t <= 50) ? 50 : 50 + 0.5 * (t-50) */;
}
Mat A, D;
border DOWN(t=0,L){x=t; y=0; label=down;}
border right1(t=0, curve(L)){x=L; y=t; label = right;}
border curvee(t=L,0){x=t; y=curve(t); label = CURVE;}
border left1(t=curve(0),0){x=0; y=t; label=left;}
border left2(t=L,curve(0)){x=0; y=t; label = left;}
border UP(t=L,0){x=t; y=L; label=up;}
border right2(t=curve(L),L){x=L; y=t; label = right;}
real coef1=curve(L)*1./L, coef2=curve(0)*1./L;
mesh Th = buildmesh(DOWN(NN)+right1(coef1*NN)+curvee(NN)+left1(coef2*NN)+left2((1-coef2)*NN)+UP(NN)+right2((1-coef1)*NN));
fespace Ph(Th,P0);
fespace Vh(Th, P1);
fespace Wh(Th, [P0,P0]);
DmeshCreate(Th);
{
macro def(i)i//
macro init(i)i//
MatCreate(Th, A, P1);
}
{
macro def(i)[i, i#B]//
macro init(i)[i, i]//
MatCreate(Th, D, [P0,P0]);
}
//buildDmesh(Th);
for(i=1; i*dt <= tfin ; i++){
matrix B=Bmat(Wh,Vh);
matrix C=Cmat(Vh,Wh);
real[int] rhvflux = Leftsidepcap(0,Wh),rhvs = Leftsides(0,Vh);
A=Amat(Vh,Vh);
D=Dmat(Wh,Wh);
Mat dC(A,D, C);
Mat dB(D,A, B);
Mat AA = [[A,dB],
[dC,D]];
set(AA, sparams = "-pc_type lu -pc_factor_mat_solver_type mumps");
real[int] rhs(rhvflux.n + rhvs.n);
rhs(0:rhvs.n - 1) = rhvs;
rhs(rhvs.n: rhvflux.n + rhvs.n - 1) = rhvflux;
real[int] sol = AA^-1 * rhs;
/* VhV def2(solV);
solV[] = sol(0:sol.n - VhP.ndof - 1); */
Vh solS;
solS[] = sol(0: rhvs.n - 1);
t=i*dt;
//richardPcap;
//if(i%60==0){savevtk(vtkfolder+"100x100_saturation.vtu",Th,s,dataname="saturation", append = 1);}
sold=s;
toplot=s*phi + thetar;
if(mpirank == 0) {cout << "Time : " << t << "-----" << s[].min << endl;}
if(i%1==0){
macro params(toplot)wait=0,prev=1, dim=2, fill=1, value = 1,viso=viso(0:viso.n-1), nbiso=30,cmm= "min: " +toplot[].min+" || max: "+toplot[].max+ "|| Time: "+t// EOM
plotD(Th, toplot, params(toplot));}
}