Gmsh 2d mesh1/20/2024 ![]() Mf = (mesh, mvc)įile(Wri_path+"Dolfin_circle_facets.pvd").write(mf) With XDMFFile(Wri_path+"mf.xdmf") as infile: Mvc = MeshValueCollection("size_t", mesh, 1) With XDMFFile(Wri_path+"mesh.xdmf") as infile:įile(Wri_path+"Dolfin_circle_mesh.pvd").write(mesh) Meshio.write(“Box.xdmf”, meshio.Mesh(points=msh.points, cells=)) I have 2 examples of mesh that I wish to work with: 1) Box.msh (2D) 2) Cylinder (3D) Top_bottom_edgeFile = XDMFFile('top_bottom_edge.Hi all, I understand there is a previous thread on a similar issue: but I’m not sure if this problem has to do with the version of gmsh. Top_bottom_t_value(p2, line_data)īcs.append(DirichletBC(UV.sub(1), Constant(1.0), top_bottom_edge, 1, method='pointwise'))īcs.append(DirichletBC(UV.sub(1), Constant(-1.0), top_bottom_edge, 2, method='pointwise')) Top_bottom_edge = MeshFunction("size_t", dolfin_mesh, dolfin_mesh.topology().dim()-2) Define meshfunction to assign the subfunction v of the top edge of lower squre to be 1.0, and the bottome to be -1. ![]() Volumes = MeshFunction("size_t", dolfin_mesh, dolfin_mesh.topology().dim())īc = DirichletBC(UV.sub(1), Constant(0.0), volumes, 1, method='pointwise') Define meshfunction to assign the subfunction v of the upper squre(whose volumes = 1) to be zero. UV = FunctionSpace(dolfin_mesh, UV_ELEMENT) UV_ELEMENT = MixedElement(U_ELEMENT, V_ELEMENT) V = FunctionSpace(dolfin_mesh, V_ELEMENT) V_ELEMENT = FiniteElement("CG", dolfin_mesh.ufl_cell(), 1) U = FunctionSpace(dolfin_mesh, U_ELEMENT) U_ELEMENT = FiniteElement("CG", dolfin_mesh.ufl_cell(), 1) Me.add_cell(c,, triangle_cells, triangle_cells]) Line_data = np.concatenate((line_data,msh.cell_data_dict)) Triangle_data = np.concatenate((triangle_data,msh.cell_data_dict)) Line_cells = np.concatenate((line_cells,cell.data))įor key in msh.cell_data_dict.keys(): Triangle_cells = np.concatenate((triangle_cells,cell.data)) In order to apply the boundary condition I create 2 meshfunctions volumes and top_bottom_edge. Then I imported the mesh using meshio, and reconstructed the mesh using mesheditor of dolfin. The mesh file “demo.msh” is generated by: If you have a look at cf.xdmf and v.xdmf, you will observe that the dofs corresponding to each cell has been marked by the boundary condition XDMFFile("v.xdmf").write_checkpoint(v, "v", 0) However, for me to be of proper help it would be beneficial if you could create a minimal example such a that I can get a proper idea of what you want to achieve.Īs far as I can understand, you would like to do something like this: from dolfin import *Ĭf = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)įf = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)įacets = cell.entities(mesh.topology().dim()-1) Since you are trying to deactivate all the dofs in a given cell, you need to map these regions to a mesh function of facets. ![]() I get (I have ommited the output for “points”, “cells”, “point_Data”, “cell_data”) (1, 4, “bottom”)Īnd then use meshio to get the mesh data, with dict import meshio I generated the following mixed mesh with python code, in the mesh there are two physical surface “quad” and “triangle” corresponding to the upper rectangle and lower rectangle respectively ,and two physical curve “top” and “bottom” correspoing to top line and bottom line respectively: import gmsh and also split the quad at this stage.Īnd I have a problem about meshio’s data structure, what does the “field_data”, “cell_sets” mean? msh file and then with all the information stored in meshio::Mesh object, I can use dolfin.MeshEditor() to construct the whole mesh without converting into XDMF. I think it is better to use meshio to read the mesh form gmsh. You’re right, I need to split the quad before convert to xdmf format.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |