Error when assigning boundary markers

Hi all,

I am having the following error when I try to assign the boundary markers:

Error : Unknown OpenCASCADE entity of dimension 2 with tag -1

The simplified version of my code is:

# Geometry
L = 1
H = 0.05
if rank == 0:
    fluid = gmsh.model.occ.addBox(-L/2, -H/2, -H/2, L, H, H)
    gmsh.model.occ.synchronize()

# Domain markers
fluid_marker = 1
if rank == 0:
    volumes = gmsh.model.getEntities(dim=gdim)
    gmsh.model.addPhysicalGroup(volumes[0][0], [volumes[0][1]], fluid_marker)
    gmsh.model.setPhysicalName(volumes[0][0], fluid_marker, "Fluid")

# Boundary markers
inlet_marker = 2
outlet_marker = 3
walls_marker = 5
inlet = []
outlet = []
walls = []
if rank == 0:
    boundaries = gmsh.model.getBoundary(volumes)
    for boundary in boundaries:
        center_of_mass = gmsh.model.occ.getCenterOfMass(boundary[0], boundary[1])

The error refers to the last line of the previous code: center_of_mass = gmsh.model.occ.getCenterOfMass(boundary[0], boundary[1])

Therefore, I printed the variable boundaries to see what is happening:

print(boundaries)
[(2, -1), (2, 2), (2, -3), (2, 4), (2, -5), (2, 6)]

As you can see, there are three negative indices that are causing the error (the output should be [(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)])

The dolfinx version that I am using is:

0.3.0 35d705001bdd42b859ac7f32f124cbf9a41d9b3b

Does anybody know what I am doing wrong?

Thank you very much in advance.

Please note that this is a GMSH and not a Dolfin question.
The solution is to add the flag oriented=False
to Get boundary, as shown in:

https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html?highlight=orient

 edges = gmsh.model.getBoundary(other_surfaces, oriented=False)
1 Like