Closed fredrikekre closed 2 years ago
that's weird since
https://github.com/Ferrite-FEM/FerriteGmsh.jl/pull/16/files#diff-9bbe337b49a8f3ed93419ee748bd1cabb01e589a0fea7bce2492c780eb87a551R75
calls always with tag=-1
to get all elements with dim
help?> gmsh.model.mesh.getElements
gmsh.model.mesh.getElements(dim = -1, tag = -1)
Get the elements classified on the entity of dimension dim and tag tag. If tag < 0, get the elements for all entities of dimension dim.
can you post or send an example mesh file?
Yea, I was also surprised about that, but
using FerriteGmsh: gmsh, saved_file_to_grid
# Initialize gmsh
gmsh.initialize()
# Add points
p1 = gmsh.model.geo.add_point(0.0, 0.0, 0.0)
p2 = gmsh.model.geo.add_point(1.0, 0.0, 0.0)
p3 = gmsh.model.geo.add_point(1.0, 1.0, 0.0)
p4 = gmsh.model.geo.add_point(0.0, 1.0, 0.0)
# Add the lines
l1 = gmsh.model.geo.add_line(p1, p2)
l2 = gmsh.model.geo.add_line(p2, p3)
l3 = gmsh.model.geo.add_line(p3, p4)
l4 = gmsh.model.geo.add_line(p4, p1)
# Create the closed curve loop
loop = gmsh.model.geo.add_curve_loop([l1, l2, l3, l4])
# Create the surface
surf = gmsh.model.geo.add_plane_surface([loop])
# Synchronize the model
gmsh.model.geo.synchronize()
# Create the physical domains
gmsh.model.addPhysicalGroup(1, [l1], -1, "1")
gmsh.model.addPhysicalGroup(1, [l2], -1, "2")
gmsh.model.addPhysicalGroup(1, [l3], -1, "3")
gmsh.model.addPhysicalGroup(1, [l4], -1, "4")
# gmsh.model.addPhysicalGroup(2, [surf])
# Synchronize the model
gmsh.model.geo.synchronize()
# Generate a 2D mesh
gmsh.model.mesh.generate(2)
# Save the mesh
gmsh.write("test.msh")
# Read the mesh
grid = saved_file_to_grid("test.msh")
errors without the gmsh.model.addPhysicalGroup(2, [surf])
.
https://stackoverflow.com/a/64428785/5087136 gave me the hint to add also a physical entity for 2D.
If there are no elements found in the model a very non-descriptive error is thrown. This can happen if you e.g. have a D-dimensional mesh, and add some physical groups for D-1 dimension, but none for D.