-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I believe I have identified a bug in the GMSH2OPS.create_element_cmds function. When following the Gmsh2OPS: Case 2 example, I encounter this error on line [11]:
Domain::addElement - element with tag 43 already exists in model
ERROR could not add element to domain.OpenSeesError Traceback (most recent call last)
File c:\users\isaqu\onedrive\área de trabalho\tcc\teste2.py:165
154 # plotter.show()
155
156 # plotter = opst.vis.pyvista.plot_eigen(
(...) 160
161 # plotter.show(jupyter_backend="jupyterlab")
163 pressure = -1
--> 165 load_ele_tags = GMSH2OPS.create_element_cmds(
166 ops_ele_type="TriSurfaceLoad", # OpenSeesPy element type---TriSurfaceLoad
167 ops_ele_args=[pressure], # Additional arguments for the element
168 physical_group_names=["Load"],
169 )
170 # # 1. Obter as entidades (dim, tag) do grupo "Load"
171 # load_entities = GMSH2OPS.gmsh_physical_groups["Load"]
172
(...) 229 # fig.show(jupyter_backend="jupyterlab")
230 # # fig.show()File ~\anaconda3\envs\openseespy\Lib\site-packages\opstool\pre\io_read_gmsh.py:417, in Gmsh2OPS.create_element_cmds(self, ops_ele_type, ops_ele_args, dim_entity_tags, physical_group_names)
415 etag = (int(etag[0]), int(etag[1]))
416 for tag, ntags in self.gmsh_eles[etag].items():
--> 417 ops.element(ops_ele_type, tag, *ntags[:-1], *ops_ele_args)
418 ele_tags.append(tag)
419 return ele_tags
OpenSeesError: See stderr output
The issue occurs because the create_element_cmds function reuses the Gmsh element tags rather than creating new global tags for OpenSees elements. Since these tags may already exist in the OpenSees model (for instance, from previously created elements), attempting to create new surface load elements with duplicate tags consistently triggers this error.
To work around this problem, I implemented the following solution:
`
pressure = -1.0
1. Get entities (dim, tag) from the "Load" group
load_entities = GMSH2OPS.gmsh_physical_groups["Load"]
2. Extract face connectivities
faces = []
for dim, etag in load_entities:
if dim != 2:
raise ValueError("TriSurfaceLoad requires 2D entities (faces)")
for _, ntags in GMSH2OPS.gmsh_eles[(dim, etag)].items():
faces.append(ntags[:-1]) # remove ele_type
start_tag = max(ops.getEleTags()) + 1
load_ele_tags = []
for nodes in faces:
ops.element("TriSurfaceLoad", start_tag, *nodes, pressure)
load_ele_tags.append(start_tag)
start_tag += 1
`