I have a periodic mesh, with the target boundary marked using a MeshFunction. In all the examples that I have found, the periodic boundary condition is created with a SubDomain using the geometric coordinates of the points. Since my geometry is quite complex, I am not able to do this approach. Is there any way to use the MeshFunction with the marked boundary?
Found a hack to solve the problem. I defined a function equal to one in the target faces, and define the SubDomain as f(x) == 1.0. The code is something like:
mesh, markers = makeMesh(n)
E = FiniteElement('CG', mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, E)
f = Function(V)
bc = DirichletBC(V,1.0,markers,targetFacesId)
bc.apply(f.vector())
f.set_allow_extrapolation(True)
class PeriodicBC(SubDomain):
def inside(self,x,on_boundary):
return f(x) == 1.0
def map(self,x,y):
y[:] = transform(x)