def read_mesh_from_file(): comm = MPI.COMM_WORLD # encoding = dolfinx.cpp.io.XDMFFile.Encoding.ASCII encoding = XDMFFile.Encoding.HDF5 path = "square.xdmf" infile = XDMFFile(comm, path, 'r', encoding) fenics_mesh = infile.read_mesh(name='square') print(fenics_mesh.name)
def load_virus(): path = "./1igt.xdmf" comm = MPI.COMM_WORLD encoding = XDMFFile.Encoding.HDF5 infile = XDMFFile(comm, path, 'r', encoding) mesh = infile.read_mesh(name='Grid') name = "virus" mesh.name = name return mesh
parser.add_argument("--out") parser.add_argument("--steps", type=int) parser.add_argument("--end", type=float) parser.add_argument("--tp", type=float, help="Time at loading") args = parser.parse_known_args()[0] # # Convert and read mesh and tags # meshname = args.mesh filedir = os.path.dirname(__file__) t0 = time() infile = XDMFFile(MPI.COMM_WORLD, os.path.join(filedir, "mesh/{}.xdmf".format(meshname)), "r") mesh = infile.read_mesh(name="Grid") mesh.topology.create_connectivity_all() mt_cell = infile.read_meshtags(mesh, "Grid") infile.close() infile = XDMFFile( MPI.COMM_WORLD, os.path.join(filedir, "mesh/{}_triangle.xdmf".format(meshname)), "r") mt_facet = infile.read_meshtags(mesh, "Grid") infile.close() # External boundary facets ds = ufl.Measure("ds", domain=mesh, subdomain_data=mt_facet, metadata={"quadrature_degree": 2})
# following way:: import matplotlib.pyplot as plt import numpy as np import dolfinx from dolfinx import MPI, DirichletBC, Function, FunctionSpace, solve from dolfinx.io import XDMFFile from dolfinx.fem import locate_dofs_topological from dolfinx.plotting import plot from ufl import (FiniteElement, TestFunctions, TrialFunctions, VectorElement, div, dx, grad, inner) # Load mesh and subdomains xdmf = XDMFFile(MPI.comm_world, "../dolfin_fine.xdmf") mesh = xdmf.read_mesh(dolfinx.cpp.mesh.GhostMode.none) sub_domains = xdmf.read_mf_size_t(mesh) cmap = dolfinx.fem.create_coordinate_map(mesh.ufl_domain()) mesh.geometry.coord_mapping = cmap # Next, we define a :py:class:`FunctionSpace # <dolfinx.function.FunctionSpace>` built on a mixed finite element # ``TH`` which consists of continuous piecewise quadratics and # continuous piecewise linears:: # Define function spaces P2 = VectorElement("Lagrange", mesh.ufl_cell(), 2) P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1) TH = P2 * P1