l3 = geom.add_line(p2, p1) l4 = geom.add_line(p7, p5) l5 = geom.add_line(p5, p6) l6 = geom.add_line(p6, p8) l7 = geom.add_line(p4, p7) l8 = geom.add_line(p7, p8) l9 = geom.add_line(p8, p3) ll1 = geom.add_line_loop(lines=[l2, l3, l1, l7, l4, l5, l6, l9]) ps1 = geom.add_plane_surface(ll1) ll2 = geom.add_line_loop(lines=[l6, -l8, l4, l5]) ps2 = geom.add_plane_surface(ll2) # Tag line and surface geom.add_physical(l3, label="LEFT") geom.add_physical(l2, label="TOP") geom.add_physical([l9, l8, l7], label="RIGHT") geom.add_physical(l1, label="BOTTOM") geom.add_physical(ps1, label="DOMAIN") geom.add_physical(ps2, label="OBSTACLE") #print("\n".join(geom._GMSH_CODE)) msh = generate_mesh(geom) points, cells, cell_data, boundary = msh.points, msh.cells, msh.cell_data, msh.field_data mesh = dolfin.cpp.mesh.Mesh( dolfin.MPI.comm_world, dolfin.cpp.mesh.CellType.Type.triangle,
mesh_ele_size = .1 p0 = geom.add_point([0, 0, 0], lcar=mesh_ele_size) p1 = geom.add_point([1, 0, 0], lcar=mesh_ele_size) p2 = geom.add_point([1, 1, 0], lcar=mesh_ele_size) p3 = geom.add_point([0, 1, 0], lcar=mesh_ele_size) l0 = geom.add_line(p0, p1) l1 = geom.add_line(p1, p2) l2 = geom.add_line(p2, p3) l3 = geom.add_line(p3, p0) ll = geom.add_line_loop(lines=[l0, l1, l2, l3]) ps = geom.add_plane_surface(ll) # Tag line and surface geom.add_physical(l3, label="LINE") geom.add_physical(ps, label="SURFACE") #print("\n".join(geom._GMSH_CODE)) mesh = generate_mesh(geom) points, cells, cell_data, boundary = mesh.points, mesh.cells, mesh.cell_data, mesh.field_data comm = dolfin.MPI.comm_world rank = comm.Get_rank() print('My rank is ', rank) mesh_from_array = dolfin.cpp.mesh.Mesh(dolfin.MPI.comm_world, dolfin.cpp.mesh.CellType.Type.triangle, points, cells['triangle'], [], dolfin.cpp.mesh.GhostMode.none)
mesh_ele_size = .1 p0 = geom.add_point([0, 0, 0], lcar=mesh_ele_size) p1 = geom.add_point([1, 0, 0], lcar=mesh_ele_size) p2 = geom.add_point([1, 1, 0], lcar=mesh_ele_size) p3 = geom.add_point([0, 1, 0], lcar=mesh_ele_size) l0 = geom.add_line(p0, p1) l1 = geom.add_line(p1, p2) l2 = geom.add_line(p2, p3) l3 = geom.add_line(p3, p0) ll = geom.add_line_loop(lines=[l0, l1, l2, l3]) ps = geom.add_plane_surface(ll) # Tag line and surface geom.add_physical(l3, label=444) geom.add_physical(ps, label=456) print("\n".join(geom._GMSH_CODE)) mesh = generate_mesh(geom) points, cells, cell_data = mesh.points, mesh.cells, mesh.cell_data meshio.write("input/mesh_2d.xdmf", meshio.Mesh(points=points, cells={"triangle": cells["triangle"]})) meshio.write( "input/mvc_1d.xdmf", meshio.Mesh(points=points, cells={"line": cells["line"]}, cell_data={ "line": {
mesh_ele_size = 0.5 p0 = geom.add_point([0, 0, 0], lcar=mesh_ele_size) p1 = geom.add_point([1, 0, 0], lcar=mesh_ele_size) p2 = geom.add_point([1, 1, 0], lcar=mesh_ele_size) p3 = geom.add_point([0, 1, 0], lcar=mesh_ele_size) l0 = geom.add_line(p0, p1) l1 = geom.add_line(p1, p2) l2 = geom.add_line(p2, p3) l3 = geom.add_line(p3, p0) ll = geom.add_line_loop(lines=[l0, l1, l2, l3]) ps = geom.add_plane_surface(ll) # Tag line and surface geom.add_physical(l0, label="BOTTOM") geom.add_physical(l1, label="RIGHT") geom.add_physical(l2, label="TOP") geom.add_physical(l3, label="LEFT") geom.add_physical(ps, label="DOMAIN") # print("\n".join(geom._GMSH_CODE)) mesh = generate_mesh(geom) points, cells, cell_data, boundary = mesh.points, mesh.cells, mesh.cell_data, mesh.field_data comm = dolfin.MPI.comm_world rank = comm.Get_rank() print('My rank is ', rank) mesh_from_array = dolfin.cpp.mesh.Mesh(dolfin.MPI.comm_world,