I am writing some code for carrying out FE simulations on an elastic arch I have created the arch using the following pygmsh file:
import pygmsh
import meshio
Lam = float(sys.argv[1])
resolution = 2
R = 100
Theta = 0.1*Lam/(np.sqrt(3)*6)
w = np.sqrt(12*R**2*Theta**4/Lam**2)
h = 3*w
R2 = R+w/2
R1 = R-w/2
tol = 1e-1
# Define Non-dimensionalisation
U_tilde = R*Theta**2/10
L_tilde = R*Theta/100
# Now we rescale our geometric parameters
wtilde = w/L_tilde
Rtilde = R/L_tilde
R1tilde = R1/L_tilde
R2tilde = R2/L_tilde
htilde = h/L_tilde
with pygmsh.geo.Geometry() as geom:
poly = geom.add_polygon(
[
[-R1tilde*np.sin(Theta),R1tilde*np.cos(Theta), -htilde/2],
[-R1tilde*np.sin(Theta),R1tilde*np.cos(Theta), htilde/2],
[-R2tilde*np.sin(Theta),R2tilde*np.cos(Theta), htilde/2],
[-R2tilde*np.sin(Theta),R2tilde*np.cos(Theta), -htilde/2],
],
mesh_size=10,
)
Arch = geom.revolve(poly,[0.0,0.0,-htilde/2],[0.0,0.0,htilde/2],angle=2*Theta)
lhp1 = geom.add_point([-Rtilde*np.sin(Theta)+tol,Rtilde*np.cos(Theta)+tol,-htilde/2+tol],resolution)
lhp2 = geom.add_point([-Rtilde*np.sin(Theta)+tol,Rtilde*np.cos(Theta)+tol,htilde/2-tol],resolution)
rhp1 = geom.add_point([Rtilde*np.sin(Theta)-tol,Rtilde*np.cos(Theta)+tol,-htilde/2+tol],resolution)
rhp2 = geom.add_point([Rtilde*np.sin(Theta)-tol,Rtilde*np.cos(Theta)+tol,htilde/2-tol],resolution)
crown = geom.add_point([0.0,R1tilde,0.0],2*resolution)
Left_hinge_line = geom.add_line(lhp1,lhp2)
Right_hinge_line = geom.add_line(rhp1,rhp2)
Hinge_field = geom.add_boundary_layer(
edges_list=[Left_hinge_line,Right_hinge_line],
lcmin=0.5,
lcmax=2,
distmin=0.1,
distmax=25,
)
Crown_field = geom.add_boundary_layer(
nodes_list=[crown],
lcmin=0.5,
lcmax=2,
distmin=0.1,
distmax=45,
)
geom.set_background_mesh([Hinge_field,Crown_field], operator="Min")
geom.add_physical([Left_hinge_line,Right_hinge_line],"Hinges")
geom.add_physical([crown],"Crown")
geom.add_physical(Arch[1],"Arch")
geom.synchronize()
mesh = geom.generate_mesh(dim=3)
gmsh.write("mesh.msh")
mesh_from_file = meshio.read("mesh.msh")
output_dir = '../../../mnt/c/Users/oc18456/Documents/Test_Results/'
for key in mesh_from_file.cells_dict:
if key == "line":
line_cells = mesh_from_file.cells_dict[key]
elif key == "tetra":
tetra_cells = mesh_from_file.cells_dict[key]
for key in mesh_from_file.cell_data_dict["gmsh:physical"].keys():
if key == "line":
line_data = mesh_from_file.cell_data_dict["gmsh:physical"][key]
elif key == "tetra":
tetra_data = mesh_from_file.cell_data_dict["gmsh:physical"][key]
tetra_mesh = meshio.Mesh(points=mesh_from_file.points, cells={"tetra": tetra_cells})
line_mesh = meshio.Mesh(points=mesh_from_file.points,
cells=[("line", line_cells)],
cell_data={"Hinges":[line_data]})
meshio.write(f"tetra.xdmf", tetra_mesh)
meshio.write(f"line.xdmf", line_mesh)
Then when i try and load it in using the following:
with df.XDMFFile("tetra.xdmf") as infile:
infile.read(mesh)
mvc = df.MeshValueCollection("size_t", mesh, 0)
with df.XDMFFile("line.xdmf") as infile:
infile.read(mvc,"Hinges")
I get the following error:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to find entity in map.
*** Reason: Error reading MeshValueCollection.
*** Where: This error was encountered inside HDF5File.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 77c758717da1cb8017bf95109363bb1a91a4f8e5
*** -------------------------------------------------------------------------