Automatic generation of new curves while adding curve loops
I'm trying to use the python api of gmsh to build a meshing tool for airfoils. In order to assign specific mesh properties (for a transfinite mesh) to an offset geometry I generate multiple plane surfaces and therefore multiple curve loops. However, I face a problem with the tags of the given curve tag list during this operation.
The following code yields to the problem. The existing curve tags, which should form the curve loop are added to the tag list called curve_list
, which is then used to generate a new instance of CurveLoop and PlaneSurfaces.
for index_spline, spline in enumerate(self.upper_offsetSplines['spline']):
curve_list = []
curve_list.append(self.upper_connection_lines[index_spline])
curve_list.append(spline)
curve_list.append(self.upper_connection_lines[index_spline + 1])
curve_list.append(self.airfoil.upper_splines['spline'][index_spline])
self.inner_planeSurfaces.append(PlaneSurface([CurveLoop(curve_list)]))
gmsh.model.occ.synchronize()
print(f"Surface {self.inner_planeSurfaces[-1].tag}: expected = {[curve.tag for curve in curve_list]} / actual = {[boundary[1] for boundary in gmsh.model.getBoundary([(2,self.inner_planeSurfaces[-1].tag)], combined = False, oriented = True, recursive = False)]}")
The code uses the following two classes to handle curve loops and plane surfaces.
class CurveLoop:
def __init__(self, line_list):
self.line_list = line_list
self.dim = 1
# generate the Lines tag list to folow
self.tag_list = [line.tag for line in self.line_list]
# create the gmsh object and store the tag of the geometric object
self.tag = gmsh.model.occ.addCurveLoop(self.tag_list)
class PlaneSurface:
def __init__(self, geom_objects):
self.geom_objects = geom_objects
self.dim = 2
if all(isinstance(geom_object, CurveLoop) for geom_object in geom_objects):
self.tag_list = [geom_object.tag for geom_object in self.geom_objects]
# create the gmsh object and store the tag of the geometric object
self.tag = gmsh.model.occ.addPlaneSurface(self.tag_list)
else:
# close_loop() will form a close loop object and return its tag
self.tag_list = [geom_object.close_loop() for geom_object in self.geom_objects]
# create the gmsh object and store the tag of the geometric object
self.tag = gmsh.model.occ.addPlaneSurface(self.tag_list
I would expect that the boundaries a plane surface should be the curves given by the curve list. However, for the given geometry in the image (numbers are curve tags) this is only partially true for my code as you can see in the following output. For some reason sometimes new curves are generated when a new curve loop is created (I believe curve loop is the problem since the 1D entity count increases right after adding the loop).
Surface 1: expected = [12, 4, 13, 1] / actual = [12, 4, -13, -1]
Surface 2: expected = [13, 7, 14, 6] / actual = [13, 21, -14, -20]
Surface 3: expected = [14, 10, 15, 9] / actual = [14, 9, -15, -10]
Surface 4: expected = [16, 5, 17, 2] / actual = [16, 22, -17, -2]
Surface 5: expected = [17, 7, 18, 8] / actual = [17, 24, -18, -23]
Surface 6: expected = [18, 10, 19, 11] / actual = [18, 11, -19, -10]
As a result the transfinite meshing fails. The initial curves shown in the image are set to transfinite. However, the transfinite surfaces contain non-transfinite curves due to the generation of new boundary curves. I would appreciate some feedback on this issue. I tried to break down the issue on this code example but I can provide the github link to the full project if needed. Does the order of the curve tags, that I input to the method gmsh.model.occ.addCurveLoop(curveTags) matter? And has anyone an idea why new curves are only created for spline curves except the airfoil?