Hello,
Please find a part of my code where I apply periodic boundary condition.
coord = mesh.coordinates()
xmax = max(coord[:,0]); xmin = min(coord[:,0])
ymax = max(coord[:,1]); ymin = min(coord[:,1])
def inside_2D(x, on_boundary):
return bool(on_boundary and (dolfin.near(x[0], xmin, self.tol) or dolfin.near(x[1], ymin, self.tol)) and not (dolfin.near(x[0], xmax, self.tol) or dolfin.near(x[1], ymax, self.tol)))
def map_2D(self, x, y):
# Vertex
if (dolfin.near(x[0], xmax, self.tol) \
and dolfin.near(x[1], ymax, self.tol))\
or (dolfin.near(x[0], xmax, self.tol) \
and dolfin.near(x[1], ymin, self.tol))\
or (dolfin.near(x[0], xmin, self.tol) \
and dolfin.near(x[1], ymax, self.tol)):
y[0] = xmin
y[1] = ymin
# Edges
elif dolfin.near(x[0], xmax, self.tol):
y[0] = self.xmin
y[1] = x[1]
elif dolfin.near(x[1], ymax, self.tol):
y[0] = x[0]
y[1] = ymin
else:
y[0] = -1.
y[1] = -1.
But, the problem is that I can’t apply this to a geometry like the following (as the left and the right boundaries are not along the y-axis), unless I can find the left and right boundary vertices. Well, I already know the vertices as I have created the mesh, but how can I find them directly in Dolfin?
Thanks in advance!