A simple question of PETSc

Hello Everyone

I have studied FreeFEM++ and its parallelization with lectures in Youtube made by Pierre Jolivet and TuxRiders. During self-studies, I got a simple question but making me slightly confused of.

The thing is, buildDmesh and createMat

As far as I know, buildDmesh is a function of decomposing the whole domain to subdomains based on the number of allocated MPI processors. One the other hand, createMat is to distribute a PETSc matrix from “Mat” in PETSc library for parallel computation.

So, I could see that in Pierre’s lecture, he used buildDmesh and createMesh together while TuxRiders’s recent video ([FreeFEM 11] Domain decomposition and high-performance finite element simulations - YouTube) used createMesh without buildDMesh. This makes me slightly confused.

Thus, my question is, is it fine to use createMesh only without buildDmesh?

Thanks

Both macros are defined in macro_ddm.idp and this is also the place where you can find the answer to your question.

If I get this right, createMat checks if buildDmesh has been executed previously and if not, then it automatically calls buildDmesh. So it is indeed fine to use createMat only without buildDmesh.

1 Like

Thank you so much. It helps a lot!

Just to further expand on the accepted answer, this will be true only if this is on the same scope.
I.e.,

buildDmesh(Th, ...);
{
  createMat(Th, ...);
}

is equivalent to just:

createMat(Th, ...);

but different than:

{
  buildDmesh(Th, ...);
}
{
  createMat(Th, ...);
}
1 Like

thank you for kind explanation!