Inconsistent behavior finding facets

Issue #179 invalid
ggranzow created an issue
# This script displays strange behavior.
# Changing the domain size very slightly causes the program to display
# *** Warning: Found no facets matching domain for boundary condition.

from dolfin import *

for decimal_places in (12,13,14):

# The variable "a" is the minimal coordinate value of a cubic domain

  a = round(-178.92682926829275, decimal_places)
  print '\n%d: a = %.14f' % (decimal_places, a)

# Define the function space

  mesh = BoxMesh(a,a,a, 1,1,1, 5,5,5)
  V = FunctionSpace(mesh, 'Lagrange', 1)

# Boundary conditions

  class Bottom(SubDomain):
    def inside(self, x, on_boundary):
      return on_boundary and near(x[2], a)

  mesh_facets = MeshFunction("size_t", mesh, 2)
  mesh_facets.set_all(1)
  Bottom().mark(mesh_facets, 2)
  bc = DirichletBC(V, 0.0, mesh_facets, 2)

# Define and solve a variational form

  any_form = TrialFunction(V) * TestFunction(V) * dx
  solution = Function(V)
  solve(lhs(any_form) == rhs(any_form), solution, bc)

##### Here is the output I got (dolfin-version 1.2.0+) #####

12: a = -178.92682926829301
Solving linear variational problem.

13: a = -178.92682926829269
Solving linear variational problem.
  *** Warning: Found no facets matching domain for boundary condition.

14: a = -178.92682926829275
Solving linear variational problem.

Comments (1)

  1. Jan Blechta

    Use

      class Bottom(SubDomain):
        def inside(self, x, on_boundary):
          return on_boundary and near(x[2], a, decimal_places)
    
  2. Log in to comment