Found no facets matching domain for BCs only for larger domains

I am trying to solve the NS equations on a square mesh with Dirichlet BCs at the top and bottom vertices and periodic BCs on the left and right vertices. When I increase the domain size of the simulation, I get the warning “Found no facets matching the domain for boundary condition” which seems to be an error that people have encountered with fundamental mesh issues.

My code looks like this:

#Stuff for boundary conditions
class PeriodicBoundary(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary and (near(x[0], 0.0))

    # Map RightBoundary to LeftBoundary
    def map(self, x, y):
        y[0] = x[0] - DOMAIN_SIZE
        y[1] = x[1]


# Define a simple mesh
N = 5
# mesh = UnitSquareMesh(N,N)
mesh = RectangleMesh(Point(0.0, 0.0), Point(DOMAIN_SIZE, DOMAIN_SIZE), N, N)

# Define Taylor-Hood Elements
# First order finite element for pressure
F1 = FiniteElement("P", mesh.ufl_cell(), 1)
# Second order finite element for velocity
F2 = VectorElement("P", mesh.ufl_cell(), 2)

#Mixed finite element and function space
ME = MixedElement([F2,F1])
NS = FunctionSpace(mesh,ME, constrained_domain=PeriodicBoundary())

#Dirichlet Boundary Conditions
def top(x, on_boundary):
    return x[1] > DOMAIN_SIZE - DOLFIN_EPS

def bottom(x, on_boundary):
    return x[1] < DOLFIN_EPS

lid_velocity = (1.0, 0.0)

fixed_wall_velocity = (0.0,0.0)

boundary_conditions = [
    DirichletBC(NS.sub(0), lid_velocity, top),
    DirichletBC(NS.sub(0), fixed_wall_velocity, bottom)
]

When I change DOMAIN_SIZE between 1.0-4.0, there is no issues, however when i increase it to 5.0 for example, the warning starts appearing and the solution is trivially the initial conditions.

Increase the size of the epsilon in the top condition, to for instance


#Dirichlet Boundary Conditions
def top(x, on_boundary):
    return x[1] > DOMAIN_SIZE - 2*DOLFIN_EPS
1 Like

Awesome! Thanks so much! That did the trick!