GDML Tessellated Object

We are trying to debug a new option of the GDML workbench that creates a “Minimum Mesh” using Gmsh. It essentially uses an option of Gmsh to create a STL Mesh from a Brep solid and then performs a recombination operation that where possible combines Tri Facets to Quad Facets, so the Tessellated Object ends up a mixture of Tri and Quad Facets.

We did have a problem with some solids where a degenerate Mesh was being created but have addressed this by specifying a MinimumCharactersticLength.

The problem is a bit challenging to debug in that visually the Mesh/Tessellation looks the same in FreeCAD, native Gmsh ( We assume we have have used the same parameters ) and if we load into Geant4
![141CEEAF-7107-449C-B085-B037E1374A55|690x358]
(upload://tTcvlM6BvNpCH8bbgMJYD3xEzDZ.jpeg)

Geant is giving us these errors
-------- WWWW ------- G4Exception-START -------- WWWW -------

*** ExceptionHandler is not defined ***

*** G4Exception : GeomSolids1001

issued by : G4QuadrangularFacet::G4QuadrangularFacet()

Facet has three or more collinear vertices.

P0 = (-19.9911,0.477272,57.8305)
P1 = (-19.4955,0.238636,58.1609)
P2 = (-19,-8e-15,58.4914)
P3 = (-20.65,-8e-15,57.5)

Height in P0-P1-P2 = 2.2045e-15
Height in P1-P2-P3 = 0.240279
Height in P2-P3-P4 = 0.480559
Height in P4-P0-P1 = 0.342227

*** This is just a warning message. ***

-------- WWWW ------- G4Exception-END -------- WWWW -------

-------- WWWW ------- G4Exception-START -------- WWWW -------

*** ExceptionHandler is not defined ***
*** G4Exception : GeomSolids1002
issued by : G4TessellatedSolid::AddFacet()
Attempt to add facet not properly defined.
*** This is just a warning message. ***
-------- WWWW ------- G4Exception-END -------- WWWW -------


FACET TYPE = G4QuadrangularFacet
ABSOLUTE VECTORS =
P[0] = (-19.9911,0.477272,57.8305)
P[1] = (-19.4955,0.238636,58.1609)
P[2] = (-19,-8e-15,58.4914)
P[3] = (-20.65,-8e-15,57.5)


-------- WWWW ------- G4Exception-START -------- WWWW -------

So I am assuming the wrong values are being exported to Geant4, so I added code in FreeCAD at the point of exporting the Quad to create a OCC polygon shape and check its area. I get no errors and area are all > 0

1 Like

I should add that with some test shapes we don’t see any errors or problems.

We are testing with load_gdml in G01, wondering how hard it would be to change to output vertex name(s) on exceptions.

Indeed, the warning message is a bit confusing. A correct message should be like the following:

Height in P0-P1-P2 = 2.2045e-15
Height in P1-P2-P3 = 0.240279
Height in P2-P3-P0 = 0.480559
Height in P3-P0-P1 = 0.342227

It looks that first three vertices are lying on the same line, the minimal height in the triangle P0-P1-P2 is too small, it should be at least 10^-9 mm. The issue can be easily fixed by subdividing the face in two triangles, P0-P1-P3 and P1-P2-P3

We are also seeing warning messages like the followiing


FACET TYPE = G4TriangularFacet
ABSOLUTE VECTORS =
P[0] = (-23.4911,-0.477272,73.1695)
P[1] = (-22.9955,-0.238636,72.8391)
P[2] = (-22.5,-8e-15,72.5086)


-------- WWWW ------- G4Exception-START -------- WWWW -------

*** ExceptionHandler is not defined ***
*** G4Exception : GeomSolids1001
issued by : G4TriangularFacet::G4TriangularFacet()
Facet is too small or too narrow.
Triangle area = 3.41991e-15
P0 = (-21.5089,-0.477272,73.1695)
P1 = (-22.5,-8e-15,72.5086)
P2 = (-22.0045,-0.238636,72.8391)
Side1 length (P0->P1) = 1.2833
Side2 length (P1->P2) = 0.641648
Side3 length (P2->P0) = 0.641648
*** This is just a warning message. ***

Although it is just a warning, I assume it means that geant4 will ignore this Facet in its Calculations?

What is the minimum/cutoff area size as far as it is geant4 concerned. Where would I find this documented?

Thanks

In reality the check, that resulted in this warning, calculates the minimal height of the triangle, not the face area. The height should be greater than default surface thickness 10^-9 mm. If not, then the face will be marked as improperly defined.

Improperly defined faces are ignored at the construction of G4TessellatedSolid, but this may result in some other warnings, like:

G4TessellatedSolid::AddFacet()
Attempt to add facet not properly defined.
...

This is not documented, you should look in the code of the function that issued the warnings.