awslabs / palace

3D finite element solver for computational electromagnetics
https://awslabs.github.io/palace/dev
Apache License 2.0
224 stars 50 forks source link

Error “MFEM abort: Gmsh file : vertex index doesn't exist” #231

Closed CosimoMV closed 2 months ago

CosimoMV commented 2 months ago

Hi, this is the first time I'm using Palace and I get This error:

MFEM abort: Gmsh file : vertex index doesn't exist
 ... in function: void mfem::Mesh::ReadGmshMesh(std::istream&, int&, int&)
 ... in file: /home/cosimo/palace/palace/build/extern/mfem/mesh/mesh_readers.cpp:2173

I'm trying to simulate two coupled through hole vias that connect two differential microstrip lines on different layers (top and bottom) of a PCB.

First I imported all the geometry files in .step format from my electric cad to freecad. I finished them so I had a collection of non compenetrating solids and then I exported them singularly in the step format to gmesh, where I created a “Physical group” for each one. I meshed all the volumes (using msh22 output format) with the mesh 3d command, then I used “Optimize 3D” and “set order 3”. I also created the external boundaries planes and the planes for the wave ports.For the planes I followed the same procedure as for the volumes: I exported them in brp format, imported them into gmesh, created a 2d physical group for each of them and meshed them 2d with "Set order 3". Then I imported all the meshes into gmesh using the import command to create a single file that I used for Palace.

To create the .json file I used the json from this example and I manually removed all the unnecessary part (to my knowledge) and created the new Domains and Materials to match the Physical groups from my meshes.

Someone can help me? Is the error linked to a wrong mesh format?

I have attached the json file p_01.json . The mesh file is 500MB (maybe is too big, and this is the problem?) so these are the first lines where are defined the Physical groups:

$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
18
2 20 "down_surface"
2 21 "laterale_01"
2 22 "laterale_02"
2 23 "porta_down"
2 24 "porta_down_stop"
2 45 "porta_up"
2 46 "porta_up_stop"
2 47 "up_surface"
3 2 "via_01"
3 3 "via_02"
3 4 "aria"
3 5 "dielectric_up"
3 6 "dielectric_centrale"
3 7 "dielectric_down"
3 8 "sopra_solid"
3 9 "sotto_solid"
3 30 "ground_sopra"
3 31 "ground_sotto"
$EndPhysicalNames
$ParametricNodes
2615714
1 121.718898773193 87.3342781066895 -2.9466 2 1 0 0
2 124.381930090029 84.4621174563582 -2.9466 2 1 0 0
3 124.447414398193 90.0627937316895 -2.9466 2 1 0 0
4 128.0212840847 88.1014728733078 -2.9466 2 1 0 0
sebastiangrimberg commented 2 months ago

Hi @CosimoMV, thanks for your interest in Palace. This error gets thrown when your mesh file lists element(s) which have nodes which are outside of the nodes given in the mesh. I think the issue, looking at what you have provided, is the appearance of $ParametricNodes in your Gmsh file. This should just be $Nodes in the 2.2 format as described here, with an index followed by 3 floating point values for the coordinates.

Fixing this when you generate your mesh with Gmsh and save it to file should resolve the problem in Palace.

CosimoMV commented 2 months ago

Thank you @sebastiangrimberg for your reply. I did as you said and recreated the mesh so that I have a file that conforms to the 2.2 format. Now the first lines of my mesh file are:

$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
18
2 20 "down_surface"
2 21 "laterale_01"
2 22 "laterale_02"
2 23 "porta_down"
2 24 "porta_down_stop"
2 45 "porta_up"
2 46 "porta_up_stop"
2 47 "up_surface"
3 2 "via_01"
3 3 "via_02"
3 4 "aria"
3 5 "dielectric_up"
3 6 "dielectric_centrale"
3 7 "dielectric_down"
3 8 "sopra_solid"
3 9 "sotto_solid"
3 30 "ground_sopra"
3 31 "ground_sotto"
$EndPhysicalNames
$Nodes
331363
1 121.718898773193 87.3342781066895 -2.9466
2 124.381930090029 84.4621174563582 -2.9466
3 124.447414398193 90.0627937316895 -2.9466
4 128.0212840847 88.1014728733078 -2.9466

Now I think everything is correct, but when I run Palace I get this error:

Gmsh reader: all element attributes were zero.
MFEM only supports positive element attributes.
Setting element attributes to 1.

But PhysicalNames are correctly defined in my mesh file (or so I think). What am I doing wrong?

sebastiangrimberg commented 2 months ago

Each "physical name" has an associated "physical tag" (the integer after the dimension). In the $Elements section of your mesh file, each element is formatted as elm-number elm-type number-of-tags < tag > … node-number-list (See https://gmsh.info/doc/texinfo/gmsh.html#Legacy-formats). Typically the number of tags is 2, and the first tag is the "geometric tag", the second is the "physical tag" which is parsed by the MFEM mesh parser. It appears your mesh is missing the "physical tag" or has them all set to zero. So, you have defined the physical groups but perhaps not assigned the various boundary and domain geometries to them.

CosimoMV commented 2 months ago

Thank you very much for your help (and also for your patience with my dumb question). I recreated the mesh and linked the various geometries to their “physical tags” and now MFEM sees them. I also have another question about wave ports and symmetries, but I will ask it in another thread.