# How to trunc in a parallel code

**URL:** <https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909>\
**Category:** General Discussion\
**Created:** [May 11, 2025, 4:28pm UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909 "2025-05-11T16:28:56Z")\
**Posts on this page:** 8\
**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:** [May 11, 2025, 4:28pm UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/1 "2025-05-11T16:28:56Z")

</div>

Dear all,

Is there a command to trunc in parallel code.  
For example, when I solve fluid structure interaction problem, I need to trunc the solid part. It is easy to implement in sequential code like Ths = trunc(Th,region==solid) , however, in parallel code, the mesh is seperated and then I find it will report error if I directly copy from sequential code without change. So my question is how to trunc partial mesh in a parallel code?

---

<div class="post-metadata">

**Author:** ![quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quentin](https://community.freefem.org/u/quentin)\
**Post date:** [May 11, 2025, 6:54pm UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/2 "2025-05-11T18:54:43Z")

</div>

You can trunc your global mesh before domain(mesh) decomposition.

---

<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:** [May 12, 2025, 3:33am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/3 "2025-05-12T03:33:20Z")

</div>

Yes, I know that. But my mesh will move every time step, so I still need trunc every time to track the solid part. For example,

 ![be89b0f9ec73afbb6e6cf8fadb33bd8](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/2/2f2fdd4d23736ce8c999a95d0f3fed0cced11527.png)  
 ![7633e08164a872ea76916fff391eb91](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/cee7362b6349d6d4ff872fec6b2c95d3e1ea0ce7.png)  
these are two different time configuration, I need to trunc the solid part every time step to calculate the solid part equation. If not, my code is wrong, so it’s inevitable to trunc the solid part after domain decomposition.

So is there method to achieve this?

---

<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:** [May 12, 2025, 4:13am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/4 "2025-05-12T04:13:47Z")

</div>

It is not inevitable, why are you saying this?

---

<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:** [May 12, 2025, 4:43am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/5 "2025-05-12T04:43:56Z")

</div>

Sorry, I’m being too absolute. Just in my code, it’s inevitable to trunc the solid part, because in my equation, the solid part is keeping changing, I need to track it every time step.

 ![bd821376cb24dda00381ec35e0770f2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/cd41f54288ca8eb647e8530fc6a2bf9499c16933.png)

---

<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:** [May 12, 2025, 4:48am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/6 "2025-05-12T04:48:55Z")

</div>

[new\_ale\_method.edp](https://community.freefem.org/uploads/short-url/crAfldwzBfTc7VmrhkLHVoErmJd.edp) (3.5 KB)  
This is my sequential fsi code, now I want to parallelize it. And the problem is how I change this line in parallel version

 ![c81413514ff0dcabd8aa0c48dc7a24c](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/d/d4294dd9a4cf6c3549c72f35e0b0a8423f6994fb.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:** [May 12, 2025, 5:06am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/7 "2025-05-12T05:06:47Z")

</div>

Keep a backup of the global mesh, centralize your distributed solution, move your mesh, perform the domain decomposition. It’s done in multiple examples in the `examples/hpddm` folder.

---

<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:** [May 12, 2025, 6:10am UTC](https://community.freefem.org/t/how-to-trunc-in-a-parallel-code/3909/8 "2025-05-12T06:10:14Z")

</div>

Thank you very much for your precious advice, professor. Let me have a look.
