# Is it possible to directly merge the dispatched meshes into a whole mesh

**URL:** <https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133>\
**Category:** General Discussion\
**Created:** [November 12, 2025, 6:29pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133 "2025-11-12T18:29:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [November 12, 2025, 6:29pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/1 "2025-11-12T18:29:07Z")

</div>

Dear all,

I know that if we need the information of global mesh after DmeshCreate(Th), we need to save the global mesh as a backup in advance.

I just wonder if it is possible to directly merge the dispatched mesh into a whole mesh without prior backup.

---

<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:** [November 12, 2025, 7:45pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/2 "2025-11-12T19:45:41Z")

</div>

Yes, look for `DmeshReconstruct()` in the examples.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [November 12, 2025, 9:36pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/3 "2025-11-12T21:36:17Z")

</div>

Many thanks. I have tried the command `DmeshReconstruct()`, I find it can generate a distributed overlapping mesh from some dispatched non-overlapping meshes.

```auto
mesh ThGlobal = square(40,40);
fespace Ph(ThGlobal, P0);
Ph part;
if(mpirank == 0) {
    partitionerSeq(part[], ThGlobal, mpisize);
}
partitionerPar(part[], ThGlobal, mpiCommWorld, mpisize);
mesh Th = trunc(ThGlobal, abs(part - mpirank) < 1.0e-2, renum = 1, label = -111112);
DmeshReconstruct(Th);

```

I have a further question, is it possible to generate a whole non-overlapping mesh?

---

<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:** [November 13, 2025, 4:57am UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/4 "2025-11-13T04:57:02Z")

</div>

Please reformulate your last question.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [November 13, 2025, 12:47pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/5 "2025-11-13T12:47:13Z")

</div>

Sorry, let me restate my question, that is

I have a global mesh Th, for example, generated by `mesh Th = square(40, 40));`at this time, every processor share the same global Th,

 ![Screenshot from 2025-11-13 12-37-12](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/107149a7d6706db8c2b5ee5f6a303d6b15a15f7f.png)

after `DmeshCreate(Th)`; it becomes an overlapping distribted mesh, and every piece belongs to one processor, at this time, every processor has its own local different Th,

 ![Screenshot from 2025-11-13 12-41-41](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/5/5f68ad8a4674d8771f50921390bc9cbae9ab96f6.png)

my question is that if it is possible directly recover the global mesh like Picture 1 from dispatched meshes like Picture 2 so that every processor has the same global Th again.

---

<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:** [November 13, 2025, 12:59pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/6 "2025-11-13T12:59:56Z")

</div>

You could just save the initial global mesh in a backup variable.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [November 13, 2025, 1:13pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/7 "2025-11-13T13:13:02Z")

</div>

Sorry to bother you again, professor, I have another irrelevant question,

I want to calculate the running time of my parallel program. At the beginning, I use `mpiWtime()`, but I find it returns different values from different processors. like the following picture shows

 ![Screenshot from 2025-11-13 13-08-00](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/805324e9e053f7a309e5dd6b24d4a626db79c319.png)

I am not sure if it is reliable when I only count the running time of processor 0. (I want to compare the time of 4,16, 64 ,256 processors)

I know another way is use linux command `time` like

`time ff-mpirun -n 6 ex7-compute_pi_parallel.edp -v 0`

How can I compare the running time of different number of processors reliably?

---

<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:** [November 13, 2025, 1:38pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/8 "2025-11-13T13:38:27Z")

</div>

Use PETSc `-log_view` with stages in your script.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [November 13, 2025, 3:44pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/9 "2025-11-13T15:44:01Z")

</div>

Thank you very much. `-log_view` works well and I got some valuable information.

 ![Screenshot from 2025-11-13 15-39-10](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/13a267df576d48969963646f68aa7ba3ac46413f.png)

By the way, do you think the average time (here is the Time row and Avg column) is a good factor to compare the parallel efficiency? And are there other good factors to measure the parallel efficiency?

---

<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:** [November 13, 2025, 3:53pm UTC](https://community.freefem.org/t/is-it-possible-to-directly-merge-the-dispatched-meshes-into-a-whole-mesh/4133/10 "2025-11-13T15:53:17Z")

</div>

You’ll find help in the PETSc manual. Below the numbers you are reporting, there is a column “Ratio” which highlights the load imbalance between processes.
