# Call PETSc matrix operator MatDiagonalSet (…)

**URL:** <https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050>\
**Category:** General Discussion\
**Created:** [June 21, 2021, 12:41pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050 "2021-06-21T12:41:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 21, 2021, 12:41pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/1 "2021-06-21T12:41:33Z")

</div>

Dear all,

I need to set a pressure reference point in my parallel FSI code by modifying the matrix, and I realise the following PETSc function may allow me to do this:

**MatDiagonalSet (…)**

Has this been implemented in FreeFEM (seems I cannot directly call it in my FreeFEM code)?

More generally, what’ the best way to set a zero-pressure reference in FreeFEM code (I found a zero-pressure reference is more stable than a penalty method in the weak form – tested by a serial code)?

Best,  
Yongxing.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 22, 2021, 1:35pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/2 "2021-06-22T13:35:34Z")

</div>

There is no real need for the PETSc interface. You can set the diagonal of your local `matrix`, and then put that into your parallel `Mat`.

```auto
matrix Af = ...;
real[int] diagofA(Af.n);
diagofA = Af.diag; // get the diagonal of the matrix
...; // some operations on diagofA
Af.diag = diagofA ; // set the diagonal of the matrix
Ap = Af; // where Ap is a PETSc Mat
```

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 22, 2021, 2:47pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/3 "2021-06-22T14:47:22Z")

</div>

Thank you very much Pierre! I watched your online talk about parallel interpolation between two meshes, is there a apiece of template code of doing this?  
Best,  
Yongxing.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 22, 2021, 3:36pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/4 "2021-06-22T15:36:43Z")

</div>

> [@Copy variables between different meshes with PETSc](https://community.freefem.org/t/copy-variables-between-different-meshes-with-petsc/390):
>
> Dear Sir or Madam, I would like to use different 2 meshes with PETSc. Additionally, variables want to be copied from each other. However, as shown following codes, the direct copy, such as “v=u”, does not work. Would you please let me know how to do it? Thank you very much in advance. Best regards, Tak // $ ff-mpirun -np 4 script.edp -wg -ne load “PETSc” macro dimension()2// EOM include “macro\_ddm.idp” meshN Sh1=square(30,30,[x,y]); meshN Sh2=square(50,50,[x,y]); buildDmesh(Sh1) b…

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 24, 2021, 6:20am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/5 "2021-06-24T06:20:49Z")

</div>

Thank pjr, I can see the interpolation of values from the post, but can we have the interpolation matrix like a serial code?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 24, 2021, 6:22am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/6 "2021-06-24T06:22:53Z")

</div>

Search for the keyword `transferMat`.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 27, 2021, 4:52pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/8 "2021-06-27T16:52:29Z")

</div>

Thank you very much!  
I have found an example of _PtAP-2d-PETSc.edp_ which uses transferMat().  
It seems this is only implemented in FreeFEM v4.7, does this version have a docker image?  
I can only use docker image on the university’s ARC system.  
Best,  
Yongxing.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 27, 2021, 6:33pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/9 "2021-06-27T18:33:00Z")

</div>

[https://hub.docker.com/r/freefem/freefem](https://hub.docker.com/r/freefem/freefem)

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 27, 2021, 8:13pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/11 "2021-06-27T20:13:27Z")

</div>

It seems be working if the following is not an error:

Mat Object: 2 MPI processes  
type: mpiaij  
rows=1681, cols=1681  
total: nonzeros=18721, allocated nonzeros=18721  
total number of mallocs used during MatSetValues calls=0  
not using I-node (on process 0) routines  
Mat Object: 2 MPI processes  
type: mpiaij  
rows=521, cols=521  
total: nonzeros=17109, allocated nonzeros=17109  
total number of mallocs used during MatSetValues calls=0  
using nonscalable MatPtAP() implementation  
not using I-node (on process 0) routines

Do we also have v4.7 for Windows?

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 6:14am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/12 "2021-06-28T06:14:11Z")

</div>

**Good morning. Do we have v4.7 or above for Windows? when I install FreeFem on Ubuntu (make -j), I came across the following errors:**

\n\n \*\*\*\*\*\* mshmet \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mshmet’  
make[5]: Nothing to be done for ‘all-local’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mshmet’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* yams \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/yams’  
make[5]: Nothing to be done for ‘all-local’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/yams’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* mmg3d \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mmg3d’  
make[5]: Nothing to be done for ‘all-local’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mmg3d’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* mmg \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mmg’  
…/getall -o mmg -a  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/src/libMesh’  
make[4]: Nothing to be done for ‘all’.  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/src/libMesh’  
test -f …/src/libMesh/libMesh.a  
mkdir -p include/libMesh  
cp …/src/libMesh/\*h include/libMesh  
echo libMesh LD -L@DIR@/lib -lMesh \> lib/WHERE.libMesh  
echo libMesh INCLUDE -I@DIR@/include/libMesh \>\> lib/WHERE.libMesh  
cp …/src/libMesh/libMesh.a lib/libMesh.a  
mmg mmg.zip done  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mmg’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* gmm \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/gmm’  
make[5]: Nothing to be done for ‘gmm’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/gmm’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* nlopt \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/nlopt’  
make[5]: Nothing to be done for ‘all’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/nlopt’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* mumps-seq \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mumps-seq’  
make[5]: Nothing to be done for ‘all-local’.  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/mumps-seq’  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[4]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
\n\n \*\*\*\*\*\* ipopt \*\*\*\*\*\* \n\n  
grep: WHERE-LD: No such file or directory  
make[5]: Entering directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/ipopt’  
cd Ipopt-3.12.4 ;   
./configure --disable-dependency-tracking   
–disable-shared --enable-static   
–with-mumps=’-L/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/lib -ldmumpsFREEFEM-SEQ -lzmumpsFREEFEM-SEQ -lmumps\_commonFREEFEM-SEQ -lpordFREEFEM-SEQ -lmpiseqFREEFEM-SEQ’   
–without-hsl   
–with-mumps-incdir=’/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/include/mumps\_seq’   
CXX=‘g++’ CXXFLAGS=’-g -DNDEBUG -O3 -mmmx -mavx -std=c++14 -DBAMG\_LONG\_LONG -DNCHECKPTR -fPIC -I/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/include/mumps\_seq’   
CC=‘gcc’ CFLAGS=’-g -DNDEBUG -O3 -mmmx -mavx -fPIC -I/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/include/mumps\_seq’   
F77=‘gfortran’ FFLAGS=’-g -O2 -fPIC’   
FLIBS=’-L/usr/lib/gcc/x86\_64-linux-gnu/9 -L/usr/lib/gcc/x86\_64-linux-gnu/9/…/…/…/x86\_64-linux-gnu -L/usr/lib/gcc/x86\_64-linux-gnu/9/…/…/…/…/lib -L/lib/x86\_64-linux-gnu -L/lib/…/lib -L/usr/lib/x86\_64-linux-gnu -L/usr/lib/…/lib -L/usr/lib/gcc/x86\_64-linux-gnu/9/…/…/… -lgfortran -lm -lquadmath’   
CXXCPP=’@CXXCPP@’ CPP=’@CXXCPP@’ MPICC=’’ MPICXX=’’ MPIFC=’’   
–with-blas-lib=’-llapack -lblas -lm’ --with-lapack=’-llapack -lblas -lm’ --prefix=’/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
checking build system type… x86\_64-unknown-linux-gnu  
checking whether we want to compile in debug mode… no  
checking for C compiler default output file name… a.out  
checking whether the C compiler works… yes  
checking whether we are cross compiling… no  
checking for suffix of executables…  
checking for suffix of object files… o  
checking whether we are using the GNU C compiler… yes  
checking whether gcc accepts -g… yes  
checking for gcc option to accept ANSI C… none needed  
configure: C compiler options are: -g -DNDEBUG -O3 -mmmx -mavx -fPIC -I/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/include/mumps\_seq  
checking whether we are using the GNU C++ compiler… yes  
checking whether g++ accepts -g… yes  
checking whether C++ compiler g++ works… yes  
configure: C++ compiler options are: -g -DNDEBUG -O3 -mmmx -mavx -std=c++14 -DBAMG\_LONG\_LONG -DNCHECKPTR -fPIC -I/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/include/mumps\_seq  
configure: Trying to determine Fortran compiler name  
checking whether we are using the GNU Fortran 77 compiler… yes  
checking whether gfortran accepts -g… yes  
configure: Fortran compiler options are: -g -O2 -fPIC  
checking for egrep… grep -E  
checking whether ln -s works… yes  
checking for a BSD-compatible install… /usr/bin/install -c  
checking whether build environment is sane… yes  
checking for gawk… gawk  
checking whether make sets $(MAKE)… yes  
checking for style of include used by make… GNU  
checking dependency style of gcc… none  
checking dependency style of g++… none  
checking whether to enable maintainer-specific portions of Makefiles… no  
checking host system type… x86\_64-unknown-linux-gnu  
checking for a sed that does not truncate output… /usr/bin/sed  
checking for ld used by gcc… /usr/bin/ld  
checking if the linker (/usr/bin/ld) is GNU ld… yes  
checking for /usr/bin/ld option to reload object files… -r  
checking for BSD-compatible nm… /usr/bin/nm -B  
checking how to recognise dependent libraries… pass\_all  
checking how to run the C preprocessor… @CXXCPP@  
configure: error: C preprocessor “@CXXCPP@” fails sanity check  
See `config.log’ for more details.  
make[5]: \*\*\* [Makefile:42: Ipopt-3.12.4/FAIT] Error 1  
make[5]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty/ipopt’  
make[4]: \*\*\* [Makefile:991: compile-dir] Error 2  
make[4]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[3]: \*\*\* [Makefile:1000: tag-compile-pkg] Error 1  
make[3]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[2]: \*\*\* [Makefile:593: all-recursive] Error 1  
make[2]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master/3rdparty’  
make[1]: \*\*\* [Makefile:798: all-recursive] Error 1  
make[1]: Leaving directory ‘/home/yongxing/Downloads/FreeFem-sources-master’  
make: \*\*\* [Makefile:748: all] Error 2

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 28, 2021, 9:03am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/13 "2021-06-28T09:03:52Z")

</div>

Where do you see an error?

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 9:51am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/15 "2021-06-28T09:51:32Z")

</div>

Thank you Prof. Pierre Jolivet. Let me try to fix the install errors first, and I may come back to you if I will not fix it. Can I ask you a question about **transferMat()**, it seems the vectorial fespace function is not allowed? I did

func PV1=[P2,P2,P1];  
func PV2=[P2,P2];

Mat A,K,P;  
buildDmesh(Th);  
{  
macro def(i)[i, i#B, i#C]//  
macro init(i)[i, i, i]//  
createMat(Th, A, PV1)  
}  
buildDmesh(Ths);  
{  
macro def(i)[i, i#B]//  
macro init(i)[i, i]//  
createMat(Ths, K, PV2)  
}  
transferMat(Ths, PV2, K, Th, PV1, A, P)

and I came across the follow errors:

[scsywan@login2.arc4 fsi\_two\_meshes]$ singularity run -e --env OMP\_NUM\_THREADS=1 --bind /nobackup:/nobackup …/freefem.sif ff-mpirun -n 2 $PWD/fsi\_2d.edp -v 0  
‘/usr/freefem/ff-petsc/r/bin/mpiexec’ -n 2 /usr/freefem/bin/FreeFem+±mpi -nw /nobackup/scsywan/fsi\_two\_meshes/fsi\_2d.edp -v 0  
the array size must be 2 not 1  
current line = 1304 mpirank 1 / 2  
the array size must be 2 not 1

Error line number 1304, in file macro: transferBase in /usr/freefem/lib/ff++/4.7-1/idp/macro\_ddm.idp, before token ;  
Invalide array size for vectorial fespace function  
current line = 1304 mpirank 0 / 2  
Compile error : Invalide array size for vectorial fespace function  
line number :1304, ;  
error Compile error : Invalide array size for vectorial fespace function  
line number :1304, ;  
code = 1 mpirank: 0

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 28, 2021, 10:02am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/16 "2021-06-28T10:02:26Z")

</div>

Different number of components are not allowed yet (but could be added in the future if there is a real need). In the meantime, stick to three components all the way:

```auto
{
macro def(i)[i, i#B, i#C]//
macro init(i)[i, i, i]//
Mat B;
createMat(Ths,B,PV1)
transferMat(Ths, PV1, B, Th, PV1, A, P)
}

```

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 10:53am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/17 "2021-06-28T10:53:08Z")

</div>

Great! it works. Can I now do similar operations of matrices multiplication and plus? such as

P’ \* B \*P + A

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 10:53am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/18 "2021-06-28T10:53:26Z")

</div>

Great! it works. Can I now do similar operations of matrices multiplication and plus? such as

P’ \* B \*P + A or matrix vector multiplication such as: real[int] rhs = P’\*rhs2 ?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 28, 2021, 10:54am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/19 "2021-06-28T10:54:56Z")

</div>

Just look at the examples for crying out loud…

```auto
Mat C;
MatPtAP(B, P, C);
A += C;

```

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 11:28am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/21 "2021-06-28T11:28:01Z")

</div>

Sorry, but **A+=C** seems not allowed, and also matrix vector multiplication

real[int] rhs = P ’ \* rhs2

is illegal too. I have examples _diffusion-mg-2d-PETSc.edp_ and _PtAP-2d-PETSc.edp_, but there are no such operations

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 28, 2021, 11:28am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/22 "2021-06-28T11:28:59Z")

</div>

Neither are illegal, you need version 4.9. For a rectangular `Mat`, you need to do `rhs = P' * rhs2;` and declare `rhs` before the multiplication.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 11:31am UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/23 "2021-06-28T11:31:26Z")

</div>

Thanks. OK, maybe version is the problem. I will try to build the source code…

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 28, 2021, 5:52pm UTC](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050/24 "2021-06-28T17:52:16Z")

</div>

Dear Prof. Pierre Jolivet,

Sorry for bothering you again. I have now installed v4.9 for Windows, and all the operations can work now. However,

when I use one processor, everything is right: the results are the same as my serial code; **but when I use two processors** , I can see from the plot that interpolation is wrong.

Sorry for sending you the code (attached), but you may directly run it. The problem is a benchmark FSI problem: **a vertical leaflet in channel flow**. The channel flow is discretised by on a stationary mesh Th, and the vertical leaflet is discretised by a separate mesh Ths which is moving. The interaction is implemented by FEM interpolation, and I developed this method with Olivier Pironneau.

Thank you very much for all your help!

Best,  
Yongxing.  
[fsi\_2d.edp](https://community.freefem.org/uploads/short-url/upxk6cnuWnKml9zHOtGygtV62Yf.edp) (4.0 KB)

[Next page](https://community.freefem.org/t/call-petsc-matrix-operator-matdiagonalset/1050.md?page=2)
