Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if no elements found in the model #16

Merged
merged 1 commit into from
Sep 24, 2022
Merged

Conversation

fredrikekre
Copy link
Member

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.

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.
@koehlerson
Copy link
Member

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?

@fredrikekre
Copy link
Member Author

fredrikekre commented Sep 24, 2022

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]).

@fredrikekre
Copy link
Member Author

https://stackoverflow.com/a/64428785/5087136 gave me the hint to add also a physical entity for 2D.

@koehlerson koehlerson merged commit 793d0d7 into master Sep 24, 2022
@koehlerson koehlerson deleted the fe/error branch September 24, 2022 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants