Hi everyone,
I want to specify initial values on specific boundaries of my 2D mesh in dolfin. The mesh is imported from gmsh with boundary and domain markers via:
mesh = Mesh()
mvc_domain = MeshValueCollection("size_t", mesh, 2)
with XDMFFile("mesh/gap_mesh.xdmf") as infile:
infile.read(mesh)
infile.read(mvc_domain)
mvc = MeshValueCollection("size_t", mesh, 1)
with XDMFFile("mesh/gap_mf.xdmf") as infile:
infile.read(mvc, "Boundary")
domain = cpp.mesh.MeshFunctionSizet(mesh, mvc_domain)
boundaries = cpp.mesh.MeshFunctionSizet(mesh, mvc)
Markers for the boundaries are stored in boundaries
and markers for the domain are stored in domain
. I know that initial values can be specified for the domain with markers by using:
def initial_values(material1):
W = FunctionSpace(mesh, "DG", 0)
x = W.tabulate_dof_coordinates()
E = Function(W, name="initial_values")
for i in range(x.shape[0]):
if domain.array()[i] == domain_marker:
E.vector().vec().setValueLocal(i,material1)
return E
My approach was to change if domain.array()[i] == domain_marker:
to if boundaries.array()[i] == boundary_marker:
which did not produce the desired results. Any ideas how to proceed?