dokken
April 11, 2021, 2:17pm
6
The point is that you should write a triangular mesh (as shown in the tutorial) alongside your tetrahedral mesh.
You then read in the triangular mesh and load it into a MeshValueCollection
, as described here:
This can be done using meshio and writing the explicit data to xdmf file.
import meshio
msh = meshio.read("test.msh")
meshio.write("mesh.xdmf", meshio.Mesh(points=msh.points, cells={"tetra": msh.cells["tetra"]}))
meshio.write("mf.xdmf", meshio.Mesh(points=msh.points, cells={"triangle": msh.cells["triangle"]},
cell_data={"triangle": {"name_to_read": msh.cell_data["triangle"]["gmsh:physical"]}}))
from dolfin import *
mesh = Mesh()
with XDMFFile("mesh.xdmf") …
Then, you can use DirichletBC in the way shown here:
Here is an example of what you would like to do:
from dolfin import *
mesh = UnitSquareMesh(10,10)
V = VectorFunctionSpace(mesh, "CG", 1)
x = SpatialCoordinate(mesh)
u = project(as_vector((0.05*sin(pi*x[1]), 0)), V)
class LeftOnBoundary(SubDomain):
def inside(self, x, on_boundary):
return x[0] < DOLFIN_EPS and on_boundary
mf = MeshFunction("size_t", mesh, 1, 0)
LeftOnBoundary().mark(mf, 1)
bc = DirichletBC(V, u, mf, 1)
u_boundary = Function(V)
bc.apply(u_boundary.vector())
prin…