# TetGen for Adaptation using residual error indicator

**URL:** https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751
**Category:** General Discussion
**Created:** [May 18, 2022, 6:44am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751 "2022-05-18T06:44:26Z")
**Posts on this page:** 11
**Page:** 2

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [June 22, 2022, 10:29am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/21 "2022-06-22T10:29:47Z")

</div>

> [@](#):
>
> Then you can do
> 
> ```auto
> real[int] D;
> createPartition(Th, D, P0);
> 
> ```
> 
> and use the same condition as above (`abs(D[i]) < 1e-4`) to get the list of ghost elements.

Thanks, this worked like a charm!  
Sorry about the minimal example, I’ll try better next time. The 2D code now runs as I want it 🙂

Where I’m stuck now is again in the 3D case. I get the following error:

> Primary job terminated normally, but 1 process returned  
> a non-zero exit code. Per user-direction, the job has been aborted.  
> mpiexec noticed that process rank 0 with PID 0 on node tl1 exited on signal 11 (Segmentation fault).

Am I right in assuming that this is a memory problem? Should I free memory e.g. at the end of my macros, or is this already done anyway?

---

<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, 2022, 10:40am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/22 "2022-06-22T10:40:49Z")

</div>

This is a very generic error, no idea of where the problem could come from, you should include the full stack.

---

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [June 22, 2022, 11:02am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/23 "2022-06-22T11:02:23Z")

</div>

I’m not sure I understand what you mean by including the full stack, there is not more to the error message. I attach a screenshot of the console, the last thing before is just the output from parmmg3d.

 ![Screenshot from 2022-06-22 12-58-31](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/4/429b6b8579dbbef76774650a3a69456b4a4e25b3.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: [June 22, 2022, 11:11am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/24 "2022-06-22T11:11:36Z")

</div>

OK, I can’t help you on this one without being able to run the code. Does it work for smaller meshes? That one is quite huge and it’s not ideal for debugging.

---

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [June 22, 2022, 5:09pm UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/25 "2022-06-22T17:09:27Z")

</div>

Yes it does run to completion for smaller meshes. With big meshes it also does what it should do, taking longer and longer as the mesh size increases, until at some point it takes a very very long time and then aborts with the above error message.

---

<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, 2022, 5:14pm UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/26 "2022-06-22T17:14:23Z")

</div>

I see. Well, probably not enough memory or enough processes. I’m not sure there is much we can do about it.

---

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [June 24, 2022, 10:06am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/27 "2022-06-24T10:06:30Z")

</div>

I’m in contact with IT to see what we can do about the memory.  
In the meantime, I have another question regarding `parmmg3d`: What is the purpose of the input parameter `metric`? Can it have the same role as a Vh(Th, Pk) function passed in `adaptmesh`, in my case giving the newly desired mesh size (like in section 5.1.9 Adaptation using residual error indicator in the documentation)?  
And on the same topic, what does `mshmet` do?

---

<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 25, 2022, 7:44am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/28 "2022-06-25T07:44:44Z")

</div>

Yes, you should be able to do that, please go through Mmg documentation [https://www.mmgtools.org](https://www.mmgtools.org).

---

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [August 12, 2022, 6:55am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/29 "2022-08-12T06:55:33Z")

</div>

Good morning,

> [@prj](#):
>
> You’ll need two n2o arrays, one for local no overlap to local with overlap, and another for local with overlap to global.

I am trying to reduce the eigenfunction I obtain after remeshing onto the global mesh. But right now I have the problem that I don’t have a global mesh that contains the refinements I made using ParMmg, since the output from ParMmg is a local mesh with no overlap. You’ve showed me the command `reconstructDmesh` which makes a local mesh with overlap out of a local mesh with no overlap.  
Is there also a command that makes a global mesh out of a local mesh with overlap?  
Thanks in advance.

---

<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: [August 12, 2022, 7:07am UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/30 "2022-08-12T07:07:00Z")

</div>

> Is there also a command that makes a global mesh out of a local mesh with overlap?

No. First go from local with overlap to local with no overlap, then from local with no overlap to global. This is extremely inefficient, if you can afford to store the global eigenvectors, it means you can afford to store the global mesh, so there is no need for all this and I would just call ParMmg centralized (instead of distributed) interface.

---

<div class="post-metadata">

### Author: ![Curiin](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Curiin](https://community.freefem.org/u/Curiin)
#### Post date: [August 17, 2022, 7:27pm UTC](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751/31 "2022-08-17T19:27:37Z")

</div>

This absolutely makes sense.  
I was thinking that in the end, after all the remeshing when I’ve arrived at satisfying precision, I could go back to global, honestly just to see the whole function and have a nice plot 😆

[Previous page](https://community.freefem.org/t/tetgen-for-adaptation-using-residual-error-indicator/1751.md?page=1)
