Parallelize Navier Stokes with moving boundary

Dear all,

I already implement the sequential version of NS equation with moving boundary in FreeFem++, the code is
sequential_moving_boundary.edp (2.4 KB)

Now I want to parallelize it using PETSc, just change little, for example changing matrix to Mat. And it shows error like this on my Windows machine

and the parallel version code is
parallel_moving_boundary.edp (2.5 KB)

Can anyone give me any advice? Many thanks.

Your A is uninitialized line 59, so you need to fix that.

Thank you for your reminder, Professor. It’s a stupid mistake. I have fixed the initialization of Mat like this

However, there still exists error as shown below

Do you know what’s wrong? Thanks a lot.
parallel_moving_boundary_2.edp (2.6 KB)

You are trying to initialize with the same macro a Mat with two fields and another one with three fields, hence the error.

Sorry for my late reply. Thank you very much for your reply. It’s another stupid mistake. Now I fix it as following

And it’s the latest code
parallel_moving_boundary_3.edp (2.7 KB)

However, there still exists error shown as

Do you know the reason?

Sorry, I know the reason for the last error. It was because I entered the wrong file name. This time, the specific error occurred as the following

Do you know its reason?

This is the exact same error.

Thank you very much for your reply. Now my code can be run
parallel_moving_boundary_3.edp (2.7 KB)
But it looks not converge

Apptainer> ff-mpirun -n 10 parallel_moving_boundary_3.edp -wg -v 0
‘/usr/freefem/ff-petsc/r/bin/mpiexec’ -n 10 /usr/freefem/bin/FreeFem+±mpi -nw ‘parallel_moving_boundary_3.edp’ -wg -v 0
KSP final norm of residual 4.42545e+15
KSP final norm of residual 2.2619e+15
NS Time: 0.001
KSP final norm of residual 1.03851e+16
KSP final norm of residual 3.69771e+15
NS Time: 0.002
KSP final norm of residual 1.58529e+16
KSP final norm of residual 7.00204e+15

It can be run in my Linux machine with’ff-mpirun’, but it still exists errors on my computer machine with ‘mpiexec -n freefem+±mpi’

Probably because you are using the default tgv value.

Thank you very much, professsor. I change ‘tgv=-1’, and then it truly converges

Dear professor, I have one last question, that is I find it calculates very slowly with ‘-pc_type lu’, is there other options can accelerate?

A proper preconditioner could help things out.