3D mesh mirror - Unknown curve error
Hi,
I am trying to make 3D mesh with mirrored (perfectly symmetric) simple cube on the YZ plane (I want to get rectangular prism at the end). It is relatively simple but throwing and error;
File "/home/ee331/Dev/Venvs/dolfinxcomplex/lib/python3.8/site-packages/gmsh.py", line 1004, in addDiscreteEntity raise Exception(logger.getLastError()) Exception: Unknown curve 9999 in surface 10001
Here is the code;
import gmsh
import os
import sys
import numpy as np
dir_path = os.path.dirname(os.path.realpath(__file__))
mesh_name = "cube"
model = gmsh.model
factory = model.occ
gmsh.initialize()
# Options
gmsh.option.setNumber("General.Terminal", 0)
gmsh.option.setNumber("Mesh.MinimumCurvePoints", 2)
gmsh.option.setString('Geometry.OCCTargetUnit', 'M')
model.add(mesh_name)
path = os.path.dirname(os.path.abspath(__file__))
factory.importShapes(os.path.join(path, mesh_name+'.step'))
factory.synchronize()
gmsh.option.setNumber("Mesh.MeshSizeMin", 0.01)
# gmsh.option.setNumber("Mesh.MeshSizeMax", 0.001)
gmsh.model.mesh.generate(3)
# get the mesh data
m = {}
for e in gmsh.model.getEntities():
bnd = gmsh.model.getBoundary([e])
nod = gmsh.model.mesh.getNodes(e[0], e[1])
ele = gmsh.model.mesh.getElements(e[0], e[1])
m[e] = (bnd, nod, ele)
# transform the mesh and create new discrete entities to store it
def transform(m, offset_entity, offset_node, offset_element, tx, ty, tz):
for e in sorted(m):
gmsh.model.addDiscreteEntity(e[0], e[1] + offset_entity,
[b[1] + offset_entity for b in m[e][0]])
coord = []
for i in range(0, len(m[e][1][1]), 3):
x = m[e][1][1][i] * tx
y = m[e][1][1][i + 1] * ty
z = m[e][1][1][i + 2] * tz
coord.append(x)
coord.append(y)
coord.append(z)
gmsh.model.mesh.addNodes(e[0], e[1] + offset_entity,
m[e][1][0] + offset_node, coord)
gmsh.model.mesh.addElements(e[0], e[1] + offset_entity, m[e][2][0],
[t + offset_element for t in m[e][2][1]],
[n + offset_node for n in m[e][2][2]])
if (tx * ty * tz) < 0: # reverse the orientation
gmsh.model.mesh.reverse([(e[0], e[1] + offset_entity)])
transform(m, 10000, 1000000, 1000000, -1, 1, 1)
gmsh.model.mesh.removeDuplicateNodes()
gmsh.write("{}.msh".format(dir_path +"/"+mesh_name))
if '-nopopup' not in sys.argv:
gmsh.fltk.run()
gmsh.finalize()
I didn't understand why it is throwing this error while generating new nodes.I am attaching the cube.step file;
I checked this issue but it didn't help.
Thanks for your answer in advance.