Setting initial condition on irregular boundary from marked input mesh

I am solving a diffusion equation in the domain and I would like to set initial conditions such that the domain is different from the blue boundary. I have the relevant boundary labelled and I can find them using:

with io.XDMFFile(comm, "mesh/laminate/tria.xdmf", "r") as xdmf:
    domain = xdmf.read_mesh(cpp.mesh.GhostMode.shared_facet, name="Grid")
    ct = xdmf.read_meshtags(domain, name="Grid")

domain.topology.create_connectivity(domain.topology.dim, domain.topology.dim - 1)
with io.XDMFFile(comm, "mesh/laminate/line.xdmf", "r") as xdmf:
    ft = xdmf.read_meshtags(domain, name="Grid")

left_facet = ft.find(markers.left_bndry)

# set for bulk
u.x.array[:] = 10
#?? change value to 0 on left boundary

However, I am unclear on how to change the value to 0 on the left boundary.

Use a Dirichlet bc to set values on that particular boundary.

left_dofs = dolfinx.fem.locate_dofs_topological(V, domain.topology.dim-1, left_facets)
bc_init= dolfinx.fem.dirichletbc(init_value, left_dofs, V)
dolfinx.fem.petsc.set_bc(u.vector, [bc_init])

I have tried that but I don’t end up with the correct regions marked. I am using mixed elements and would like to set the bc on the first variable

c_init = 1.0
init_value = 0.0
u.sub(0).x.array[:] = c_init
bc_init = dolfinx.fem.dirichletbc(init_value, left_cc_dofs0, V0)
dolfinx.fem.petsc.set_bc(u.sub(0).vector, [bc_init])



Your code is not complete, ie. it is missing crucial definitions of variables, thus I cannot tell you what is wrong. Please have a look at examples with mixed space Dirichlet bcs such as