Hello,
I’m interested in solving a problem on a mesh similar to:
It consists basically of a square domain where is added an embedded line where boundary conditions are to be applied.
The mesh is created with gmsh and converted to dolfinx with the following script:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import dolfinx
from mpi4py import MPI
import numpy as np
import gmsh
#
#======================
# Create the gmsh mesh
#======================
#
gmsh.initialize()
gmsh.model.add("t1")
s1_lower_left = gmsh.model.geo.addPoint(0.0, 0.0, 0, 0.4)
s1_lower_right = gmsh.model.geo.addPoint(1.0, 0.0, 0, 0.4)
s1_upper_right = gmsh.model.geo.addPoint(1.0, 1.0, 0, 0.4)
s1_upper_left = gmsh.model.geo.addPoint(0.0, 1.0, 0, 0.4)
s1_left = gmsh.model.geo.addLine(s1_lower_left, s1_upper_left)
s1_right = gmsh.model.geo.addLine(s1_lower_right, s1_upper_right)
s1_lower = gmsh.model.geo.addLine(s1_lower_left, s1_lower_right)
s1_upper = gmsh.model.geo.addLine(s1_upper_left, s1_upper_right)
s1_surface = gmsh.model.geo.addPlaneSurface([gmsh.model.geo.addCurveLoop([-s1_left, s1_lower, s1_right, -s1_upper])])
embed_left_point = gmsh.model.geo.addPoint(0.5, 0.5, 0, 0.4)
embed_line = gmsh.model.geo.addLine(embed_left_point, s1_upper_right)
gmsh.model.geo.synchronize()
gmsh.model.mesh.embed(1, [embed_line], 2, s1_surface)
gmsh.model.geo.synchronize()
MARKER = 2
gmsh.model.addPhysicalGroup(2, [s1_surface], 1)
gmsh.model.addPhysicalGroup(1, [s1_left, s1_lower, s1_right, s1_upper, embed_line], MARKER)
gmsh.model.mesh.generate(2)
#
#=========================
# Convert to dolfinx mesh
#=========================
#
msh, cell_tags, facet_tags = dolfinx.io.gmshio.model_to_mesh(gmsh.model, comm=MPI.COMM_WORLD, rank=0, gdim=2)
bdry = dolfinx.mesh.locate_entities_boundary(msh, 1, lambda x: np.full_like(x[0], 1, dtype=np.int8))
print('Number of tags: ',facet_tags.values.size)
print('Number of boundary ',bdry.size)
# gmsh.fltk.run()
gmsh.finalize()
The output of this script is:
Number of tags: 14
Number of boundary 12
This shows that actually locate_entities_boundary
does not locate the embedded boundary. This is quite a problem for me because I usually use locate_dofs_topological(function_space, 1, bdry[facet_tags==MARKER])
to impose boundary conditions. How can this be done for embedded boundary conditions?
Best,
Lucas