quentin
(H.Weng)
May 14, 2025, 12:28pm
1
I am trying to solve a 2D lid-driven cavity in parallel to test numerical schemes. The result sometimes looks strange in the overlapping region. For instance, the code diverges quickly running with -n 4
, but shows a plausible result with non-overlapping mesh(-n 0
).
Such discrepancies always lead to a divergence.
I am not sure the reason. suggestions would be appreciated.
Best regards.
Such things can happen easily by improperly handling the overlapping parts. However, without the code, it is impossible to help.
prj
May 15, 2025, 5:21am
3
See, e.g., the role of the function exchange()
in FreeFem-tutorial - Section 8 - example2.edp and the named parameter exchange
in the function ChangeNumbering()
described slide 50 of https://joliv.et/FreeFem-tutorial/main.pdf
quentin
(H.Weng)
May 15, 2025, 7:47am
4
Thank you for all your helpful comments.
I put part of my code below because the whole code is too long:
/* u1[]=Au1^-1*rhsu1;
u2[]=Au2^-1*rhsu2; */
ChangeNumbering(Au1,rhsu1,u1PETSc);
ChangeNumbering(Au2,rhsu2,u2PETSc);
KSPSolve(Au1,u1PETSc,u1xPETSc);
KSPSolve(Au2,u2PETSc,u2xPETSc);
ChangeNumbering(Au1,u1[],u1xPETSc, inverse = true, exchange = true);
ChangeNumbering(Au2,u2[],u2xPETSc, inverse = true, exchange = true);
UpdateVecDk(u)
real[int] rhsp=PRHS(0,Mh,tgv=-1);
/* phi[]=Ap^-1*rhsp; */
ChangeNumbering(Ap,rhsp,pPETSc);
KSPSolve(Ap,pPETSc,pxPETSc);
ChangeNumbering(Ap,phi[],pxPETSc, inverse = true, exchange = true);
dxu1=nu*dx(u1p);
dyu2=nu*dy(u2p);
//update p by p=\phi+2p^{n}-p^{n-1}-\nu div(1.5u^{n+1}-2u^{n}+0.5u{n-1})
p[]=phi[];
p[]+=pe[];
p[]-=dxu1[];
p[]-=dyu2[];
The complete code is attached also:
Cavity2D.edp (6.2 KB)
I think the exchange=true
argument should make the solution consistent, but the issue remains.
prj
May 15, 2025, 8:01am
5
The derivatives won’t be consistent, so you need to exchange those values.
quentin
(H.Weng)
May 15, 2025, 10:41am
6
You are right. It is essential to ensure every involved variable to be consistent.
Now these derivatives are exchanged:
dxu1=nu*dx(u1p);
dyu2=nu*dy(u2p);
exchange(Ap,dxu1[]);
exchange(Ap,dyu2[]);
Thanks for your insight.