# Reading mesh MPI

**URL:** <https://community.freefem.org/t/reading-mesh-mpi/854>\
**Category:** General Discussion\
**Created:** [March 14, 2021, 6:07pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854 "2021-03-14T18:07:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [March 14, 2021, 6:07pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/1 "2021-03-14T18:07:20Z")

</div>

Dear forum,

I am running FreeFEM++ 4.8 version on Windows 10. I am trying to run the program in parallel. I started to study the examples available but it seems I have an error when it comes to reading existing mesh files. _laplace-2d-SLEPc-complex_ example works perfectly fine but _navier-stokes-2d-SLEPc-complex_ doesn’t load. In this example it seems that the reading mesh command is: _loadDmesh(Th, “navier-stokes-2d”)_ .I also tried another file with the “classical” _mesh Th=readmesh(“Mesh.msh”);_ and I get the same error. I attach a screenshot with the error and the way I call the file. Is there another command to read the mesh when using MPI? Thank you in advance for the help.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/4006003b6101cdd55fee2b89f14bae6fecf5be1b.png)

---

<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:** [March 14, 2021, 8:04pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/2 "2021-03-14T20:04:01Z")

</div>

This is a linear stability analysis solver, you first need to run `navier-stokes-2d-PETSc.edp`. Did you do so?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [March 14, 2021, 8:26pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/3 "2021-03-14T20:26:35Z")

</div>

Hello @prj

I did run _navier-stokes-2d-PETSc.edp_, it computes the mesh, I mean I can see the plot with the mesh but I still get an error. I attached you the error from PETSc. Also, due to the error it doesn’t save the mesh.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/ff8e221866bbc8bb0636800b344eff1a5b1e6d68.png)

---

<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:** [March 14, 2021, 8:36pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/4 "2021-03-14T20:36:29Z")

</div>

Maybe you don’t have write access to the folder, do you launch your terminal as an administrator?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [March 14, 2021, 8:56pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/5 "2021-03-14T20:56:48Z")

</div>

Thank you, it seems that running it as administrator solved the problem. However I would have 2 more questions:

1. From the PETSc file  
There is the command: saveDmesh(Th, “navier-stokes-2d”), but when the simulation ends, it doesn’t save the file. What type of file is it? Should I write something in terminal to save it?
2. -np calls the number of the cores or the logical processors? I’m asking because I did the test on a laptop with 4 cores/8 logical cores but when I set -np 10, for example, it still works.

---

<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:** [March 14, 2021, 9:05pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/6 "2021-03-14T21:05:35Z")

</div>

1. the mesh is saved in a distributed fashion, hence the `D` in `saveDmesh`. It should create multiple `.msh` files, each corresponding to a specific subdomain. The naming convention is `navier-stokes-2d_X_Y.msh` where `Y` is the number of MPI ranks, and `X` is the MPI rank (ranging from 0 to `Y`).
2. `-np` is the number of MPI ranks, it is independent of the number of cores or logical processors, i.e., you can [oversubscribe](https://www.open-mpi.org/faq/?category=running#oversubscribing), but it’s best to set the value to the number of logical cores.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [March 14, 2021, 9:45pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/7 "2021-03-14T21:45:03Z")

</div>

Thank you very much for the explanations!  
Is it possible to run a parallel simulation with SLEPc-complex if you already have a mesh which is not saved in a distributed fashion or which is another type than .msh? Or with MUMPS?

For example, now I already have the flow solution from another simulation which was done one a single core and the mesh but when I try to read the mesh I get the attached error (current line = 5 is the line with the readmesh command)

> load “SLEPc-complex”  
> // READING THE MESH //
> 
> mesh Th=readmesh(“Mesh.msh”);   
> plot (Th, cmm=“Mesh.msh”, wait=true);

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/b3401fba79c05cf9b03f49bd0e6cdad85e8ed0b7.png)

---

<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:** [March 14, 2021, 9:48pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/8 "2021-03-14T21:48:47Z")

</div>

Yes, of course, it’s possible, most of the example from the distribution actually assume that you start from an initial global mesh, like what you want to do. Regarding you problem, I’m guessing it’s just a problem of I/O, probably your mesh file is not at the proper location.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [March 14, 2021, 10:01pm UTC](https://community.freefem.org/t/reading-mesh-mpi/854/9 "2021-03-14T22:01:20Z")

</div>

The mesh is in the same directory with the .edp file. Usually it is enough to call it. I manually added the path in the .edp file and now it works.  
Thank you again for your time!

> load “SLEPc-complex”  
> // READING THE MESH //
> 
> mesh Th=readmesh(“D:\\Test\\Mesh.msh”);   
> plot (Th, cmm=“Mesh.msh”, wait=true);
