Invalid array size in the code with PETSc for solving the fluid-structure coupling problem

Dear all,

I am facing a problem. I want to solve the fluid-structure coupling problem with PETSc. However, the code always report the error, as shown in the below figure,


I have debugged this code for long time. I realized that the error maybe caused by the difference in the array size between the two fespaces for the coupling problem, while I still did not know how I could solve this problem.
The code is attached to here.
NS_parallel_2D.edp (5.5 KB)
Please give me some advice. Thank you in advance.
Best,
Liu

You need these lines FreeFem-sources/elasticity-2d-PETSc.edp at master · FreeFem/FreeFem-sources · GitHub before createMat() when you are dealing with vectorial finite element spaces.

Thank you very much for your reply.
Actually, I have add these lines, while the code still gave me the same error report.
I think the reason maybe that the array size of the elastic problem is two (u, uB), while the array size of the fluid problem is three (uu1,uu2,p). How could I solve this problem? I have tried for the below code:
“…
macro def(i)[i, i#B]// EOM // vector field definition
macro init(i)[i, i]// EOM // vector field initialization
func Pk = [P1, P1]; // finite element space
fespace Vh(Th,Pk); // for the elastic problem
Vh [u,uB], [v,vB],…;

func Pm=[P1,P1,P1];
fespace Xh(fracture,Pm); // for the fluid problem
Xh [uu1,uu2,p], [vv1,vv2,q];
…”
I have also tried the below code:
“…
macro def(i)[i, i#B]// EOM // vector field definition
macro init(i)[i, i]// EOM // vector field initialization
func Pk = [P1, P1]; // finite element space
fespace Vh(Th,Pk); // for the elastic problem
Vh [u,uB], [v,vB],…;

func Pm = [P1,P1];
fespace Xh(fracture, Pm); // for the fluid problem
Xh [uu1, uu2, p], [vv1, vv2, q];
fespace Mh (fracture, P1); //
Mh p,q;
…”
The above two codes still gave me the same error reports. Did I miss something?

Look at the examples in the folder examples/hpddm.

Ok, thank you very much, professor.

Dear professor,

I am facing a problem.
Now my code could normally run when it only solve the elastic problem.
However, as you know, I am trying to solve a fluid-structure problem, and the code can not run normally.
For the fespace describing fluid, the code is as following,
" …
fespace Mh(fracture, P1); //definition of the pressure space
Mh up1=0.,up2=0.;

fespace Xh(fracture, Pm); //definition of the velocity component space
Xh [uu,uuB,p]=[0.,0.,0.],[vv,vvB,q]=[0.,0.,0.];// //def1(uu),def1(vv);

Mat B;
//buildMat(fracture, getARGV(“-split”, 1), B, Pk, mpiCommWorld)
createMat(fracture, B, Pm)

macro grad(uu)[dx(uu),dy(uu)]//EOM
macro div1(uu)( dx(uu)+dy(uu#B) )//EOM

varf NS ([uu,uuB,p],[vv,vvB,q])=
int2d(fracture)(idt * (uu * vv+uuB * vvB)+(nu * grad(uu) ’ * grad(vv) +grad(uuB) ’ * grad (vvB)) -div1(uu)q-div1(vv)p + pq1e-10)
+int2d(fracture)(-idt * convect([up1,up2],-dt,up1) * vv-idt * convect([up1,up2],-dt,up2)* vvB)
+on(9,10,11,12, uu=(u-u1f) *idt, uuB=(uB-u2f) * idt)//boundary condition
;
…"
The code reports that is posted as below,

When I modify “createMat(fracture, B, Pm)” to “createMat(fracture, B, [P2,P2])”, the code can run normally, although the results are still wrong.
I do not know the reason. The code file is uploaded to here. Please give me some advice.
NS_parallel_2D.edp (5.7 KB)
Thank you very much.

Best,
Liu

Why are you copy/pasting this question on two different threads?

Sorry, professor. My remember is wrong. The question is following this thread. I have deleted the question on the another thread.

If you want to mix different vectorial finite element spaces, again, just look at the examples, e.g., FreeFem-sources/stokes-block-2d-PETSc.edp at master · FreeFem/FreeFem-sources · GitHub.

Ok, professor, I missed this example. I just focused on the example of stokes-2d-PETSc.edp. Thank you very much for your advice.

Professor, are there any example for the fluid structure coupling problem with PETSc?

Not openly available, to the best of my knowledge, but it’s doable, cf. slide #20 of http://joliv.et/FreeFem-tutorial/2019.pdf.

Thank you very much, professor.
Give you my best wishes.

Dear Professor,

According to your advice, I have revised the code, and the code could run. However, the code can only provide the first solution, and can not iteratively run. The error reported from the code is as shown below,


The code is uploaded here.
NS_parallel_2D.edp (5.9 KB)
Please give me some advice.
Best,
Liu

Dear professor,

I switched the additional parameter in my sparams to set(B, sparams = “-ksp_converged_reason -pc_type lu”, bs=1);. The code can run. While the terminal window has a report in each iteration, as shown below,




Could you tell me where is the problem?

Best,
Liu

The problem is resolved.
Thank you very much.