# Problem with mesh

**URL:** <https://discourse.opengeosys.org/t/problem-with-mesh/1592>\
**Category:** Help & Support\
**Created:** [March 20, 2025, 3:35pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592 "2025-03-20T15:35:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maripicod](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/maripicod/32/1209_2.png) [@maripicod](https://discourse.opengeosys.org/u/maripicod)\
**Post date:** [March 20, 2025, 3:35pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/1 "2025-03-20T15:35:18Z")

</div>

Dear all,

I am trying to do a simulation of a pile that is embedded in a soil with multiple layers and I created my mesh in gmsh and I am using 6-noded-triangle elements. I am converting the .msh file into .vtu using the mshtovtu tool. However, when I try to run the model, I get an error saying that the det J is negative.

I have already read all the posts here regarding this issue and I have tried also using the tools ./checkMesh and ./NodeReordering, but even when I reorder the mesh, the error keeps appearing. Is there anything else I am missing? Do I have to change also the vtu files with the boundaries after reordering the mesh?  
I also check if there were other elements and used ./checkMesh again after reordering and it seems to be okay (attached picture).

 ![image](https://discourse.opengeosys.org/uploads/default/original/2X/7/7fe630cfbde3b27c1ac12f092b5fc2401652f11d.png)

 ![image](https://discourse.opengeosys.org/uploads/default/original/2X/2/200b8e56a4d6266c77d94361240920c7c71851bb.png)

I would really appreciate if someone could help me, I really don’t know what else I can try!

Thank you in advanced 😃

María

---

<div class="post-metadata">

**Author:** ![chleh](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/chleh/32/854_2.png) [@chleh](https://discourse.opengeosys.org/u/chleh)\
**Post date:** [March 20, 2025, 9:40pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/2 "2025-03-20T21:40:43Z")

</div>

Hi María,

the nodes of the offending triangle have that order (if made no mistake):

 ![test](https://discourse.opengeosys.org/uploads/default/original/2X/f/fac2826c3c527befbc64ebe2909cfdaa72264826.png)

I think the numbering of the higher order nodes at the edge center is wrong. Node no. 3 should be between 0 and 1 etc., see the sketch in `MeshLib/Elements/TriRule6.h` in the OGS source code (GitLab is irresponsive ATM so I cannot add a link, here).

```auto
 * 2
 * o
 * / \
 * / \
 * 5/ \4
 * / \
 * / \
 * 0-----------1
 * 3

```

I hope that helps.

Best regards,  
Christoph

---

<div class="post-metadata">

**Author:** ![chleh](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/chleh/32/854_2.png) [@chleh](https://discourse.opengeosys.org/u/chleh)\
**Post date:** [March 20, 2025, 9:42pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/3 "2025-03-20T21:42:32Z")

</div>

And if you do node reordering you have to recreate boundary meshes, too, because the mapping to bulk mesh nodes (via `bulk_node_ids`) might become invalid by node reordering.

---

<div class="post-metadata">

**Author:** ![chleh](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/chleh/32/854_2.png) [@chleh](https://discourse.opengeosys.org/u/chleh)\
**Post date:** [March 21, 2025, 7:35am UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/4 "2025-03-21T07:35:25Z")

</div>

Btw.: the wrong triangle from the error message is part of a mesh produced by the NodeReordering tool?  
Then there might be a bug in that tool. Could you open a bug report in gitlab and add your input/output meshes?

You are using [`msh2vtu` from OGSTools](https://ogstools.opengeosys.org/stable/auto_user-guide/plot_msh2vtu.html). Which OGSTools version do you have? Maybe an update to the latest version changes something. There could have been some changes in `msh2vtu`, but I’m not entirely sure.

In the meantime a workaround could be the following (if you have linear geometries, i.e., no curved surfaces that you want to resolve as precisely as possible):

1. generate a mesh with 1st order elements with gmsh
2. convert that to vtu (`msh2vtu`)
3. do NodeReordering on all meshes from step 2
4. convert the meshes from step 3 to 2nd order: createQuadraticMesh
5. “connect” boundary meshes and the bulk mesh via `identifySubdomains` for each boundary mesh.

---

<div class="post-metadata">

**Author:** ![maripicod](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/maripicod/32/1209_2.png) [@maripicod](https://discourse.opengeosys.org/u/maripicod)\
**Post date:** [March 21, 2025, 8:04am UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/5 "2025-03-21T08:04:45Z")

</div>

Hi Christoph,

Thank you for your quick response. I am doing the reordering with the NodeReordering tool, but I also have some physical groups generated with the msh2vtu that I am not changing again after the reordering. Do I have to recreate them again? and if so, how can I do that?

Because I saw the ./ExtractBoundary tool, but I don’t know how to have the boundary separated in a way I can apply my boundary conditions (I want to have the top, bottom, left and right boundary as in the picture) and also I have .vtu for the different materials, which I am not changing after the reordering. Is this my problem?

 ![image](https://discourse.opengeosys.org/uploads/default/original/2X/1/1a90f0bd9ac7058b5ffff19eabcfff865c396338.png)

I will also try your last suggestion, and let you know.

Thank you!  
María

---

<div class="post-metadata">

**Author:** ![chleh](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/chleh/32/854_2.png) [@chleh](https://discourse.opengeosys.org/u/chleh)\
**Post date:** [March 21, 2025, 10:18am UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/6 "2025-03-21T10:18:40Z")

</div>

For very simple use cases you can extract the full boundary with `ExtractBoundary` and then clip it with `removeMeshElements`. See [Mesh Tutorial](https://www.opengeosys.org/docs/tutorials/mesh_tutorial/#mesh-clipping).  
But that’s the opposite of convenient.

`msh2vtu` outputs boundary meshes, e.g., `pile_THM_physical_group_Soil3.vtu`. You don’t have to recreate them after mesh reordering.  
But you have to update the `bulk_node_ids` if the bulk mesh is reordered.  
That can be done with the `identifySubdomains` tool, see [Identify subdomains in bulk mesh.](https://www.opengeosys.org/docs/tools/meshing-submeshes/identifysubdomains/).  
E.g., in your case (not tested, but should work):  
`identifySubdomains -m pile_THM_domain.vtu -s 1e-6 -o new_ -- pile_THM_physical_group_Soil3.vtu`  
That should output a file `new_pile_THM_physical_group_Soil3.vtu` that you then have to use in the OGS prj file.

But the problematic triangle is in the bulk mesh in your axial symmetric case. So, `identifySubdomains` is important, but your first problem is in the bulk mesh.

---

<div class="post-metadata">

**Author:** ![felikskiszkurno](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/felikskiszkurno/32/968_2.png) [@felikskiszkurno](https://discourse.opengeosys.org/u/felikskiszkurno)\
**Post date:** [March 25, 2025, 2:58pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/7 "2025-03-25T14:58:32Z")

</div>

Hi @maripicod,  
Has the suggestion from @chleh solved your problem? I am facing a similar one.  
Could you let us know what version of Gmsh you are using?  
Thank you and best,  
Feliks

---

<div class="post-metadata">

**Author:** ![maripicod](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/maripicod/32/1209_2.png) [@maripicod](https://discourse.opengeosys.org/u/maripicod)\
**Post date:** [March 25, 2025, 4:41pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/8 "2025-03-25T16:41:20Z")

</div>

Hi Christoph,

I realized my problem was that I was not doing the NodeReordering for all the meshes, only for the bulk mesh. I followed your steps and now the simulation runs.

Thank you!

---

<div class="post-metadata">

**Author:** ![maripicod](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/maripicod/32/1209_2.png) [@maripicod](https://discourse.opengeosys.org/u/maripicod)\
**Post date:** [March 25, 2025, 4:42pm UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/9 "2025-03-25T16:42:59Z")

</div>

Hi @felikskiszkurno,

I followed the suggestions by @chleh in this comment [Problem with mesh - #4 by chleh](https://discourse.opengeosys.org/t/problem-with-mesh/1592/4) and now it works 🙂

I hope it can be useful for you too!  
Regards,  
María

---

<div class="post-metadata">

**Author:** ![felikskiszkurno](https://discourse.opengeosys.org/user_avatar/discourse.opengeosys.org/felikskiszkurno/32/968_2.png) [@felikskiszkurno](https://discourse.opengeosys.org/u/felikskiszkurno)\
**Post date:** [March 26, 2025, 7:18am UTC](https://discourse.opengeosys.org/t/problem-with-mesh/1592/10 "2025-03-26T07:18:57Z")

</div>

Great, thank you very much!
