Fusing more than two subdomains in gmsh

Dear all,

I am using gmsh to build a geometry.
This geometry is composed by several simple subdomains (for example boxes), so I was thinking on defining each of them separately and then use the boolean operation gmsh.model.occ.fuse.

However, it seems that it is only allowed to fuse two geometries (and not three or more). For example, if we consider the following minimal example (fusing three simple boxes):

# Initialise meshing process
import gmsh
gmsh.initialize()

# Subdomains
box1 = gmsh.model.occ.addBox(-1.5, -0.5, 0, 1, 1, 1)
box2 = gmsh.model.occ.addBox(-0.5, -0.5, 0, 1, 1, 1)
box3 = gmsh.model.occ.addBox(0.5, -0.5, 0, 1, 1, 1)

# Fuse subdomains into a single domain
gmsh.model.occ.fuse([(3,box1)], [(3,box2)], [(3,box3)])

I get an error in the last line.
Is there an alternative way of performing this operation? I know that a solution would be to define each surface of the final domain, but fusing geometries would be much simpler for my real geometry.

Many thanks in advance.

What about:
gmsh.model.occ.fuse([(3,box1)], [(3,box2), (3,box3)])

In general, for purely gmsh related questions, I would strongly encourage people to ask these questions to the gmsh developers: gmsh / gmsh · GitLab. Otherwise the forum gets filled with questions that doesn’t relate to FEniCS

1 Like

That makes sense, thank you for sharing the link!