Mesh of non manifold solids

Hello forum
consider the case of a non manifold solid, made of two cubes sharing a portion of a face.
See Fig. 1.

Let the shared face, for simplicity, be a square.
See Fig. 2.

If I mesh the initial non manifold solid the mesh at the shared face is obviously conformal,
since a unique triangulation of the shared face is given as input. See Fig. 3, in which some
faces have been hidden)

Now decompose the composite solid in two solids: the two cubes.
See Fig. 4: here the solids have been departed in order to show the boundary of the shared face.

Then surface mesh with mmg the two cubes, one by one, by calling two times mmg.
See Fig, 5 (“Top” cube), and Fig, 6 (“Bottom” cube).

The triangulations of the “ex” shared face for meshing the two cube are identical.
See Fig. 7.

I would expect that when meshing separately the two cubes, the grids at the two green faces
should be identical.

It is not: see Fig. 8 (mesh of the “Bottom” cube), and Fig. 9 (mesh of the “Top” cube
Grazie mille
GiovannicompositeSolid.pdf (109.2 KB)

MMG will optimise the meshes through mesh manipulation. It uses several operations for that. The algorithms are deterministic but the operations and the order they are apply depend on the mesh. Your two meshes are not 100% identical in their description of the topology I assume (and the coordinates are not identical for obvious reasons). So you should always expect different results in the end though by luck you might get the same. Most meshers work like that and getting conformal meshes requires extra effort.

Thank you very much Johannes for your answer.

A detail I did not mention for being short.

The shared face of the composite solid is represented by two triangles:
{A,B,C} {C,D,B}


A{x_A, y_A, z_A}
B{x_B, y_B, z_B}
C{x_C, y_C, z_C}
D{x_D, y_D, z_D}

The two faces of the two solids, that “were” the shared face,
are represented by the same triangles, in the sense that,
knowing what you underlined, I copied them from the composite solid,
(in particular copying the opencascade MeshVS_DataSource(s))

The two “input” meshes are exactly the same, by definition:
coordinates, nodal ordering, … all
Buona serata e grazie