check_midpoint argument to DirichletBC


280
views
4
9 months ago by
How do I use the check_midpoint flag with DirichletBC? I think this used to work:

bc = DirichletBC(V, Constant(0.), Gamma, check_midpoint=False)

where V is a function space and Gamma is a routine defined via def Gamma(x, on_boundary):.... But, under FEniCS 2017.1.0, when I run this I get

TypeError: (size_t) expected positive 'int' for argument 3

For a complete example, this program fails:

from fenics import *
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, 'CG', 1)
def Gamma(x, on_boundary):
    return near(x[0], 1.) and on_boundary
bc = DirichletBC(V, Constant(0.), Gamma, check_midpoint=False)
Community: FEniCS Project
1
Apparently a bug in SWIG wrappers which does not occur in new pybind11 wrappers. As there is a simple workaround, mentioned by the answers of others, and SWIG will be removed soon, there is no need to fix this.
written 8 months ago by Jan Blechta  
1
Glad to hear that the bug is fixed in the upcoming versions, and I agree that in the mean time there is a simple workaround.  Thanks to all.
written 8 months ago by Douglas N Arnold  

2 Answers


2
9 months ago by
micro  
Hi, consider the following

from dolfin import *
from mshr import *


def main(check_midpoint):
    domain = Circle(Point(0, 0), 1)
    mesh = generate_mesh(domain, 40)
    
    V = FunctionSpace(mesh, 'CG', 1)
    bc = DirichletBC(V, Constant(0), 'near(x[0]*x[0]+x[1]*x[1], 1.)',
                     method='topological', check_midpoint=check_midpoint)
    return len(bc.get_boundary_values())

assert main(False) > 0
assert main(True) == 0​
2
9 months ago by
bc = DirichletBC(V, Constant(0.0), Gamma, method='topological', check_midpoint=False)

method='topological' is the default method.

Please login to add an answer/comment or follow this question.

Similar posts:
Search »