This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

SubDomain marking does not always work

0 votes

Consider the exmaple below. In the first case there is a zero at the interface instead of 1 or 2. The second case works.

It looks like the between function already accounts for DOLFIN_EPS but this does not make subdomain marking robust enough. Why do I have to define mesh dependent epsilons for my regions to overlap correctly in this case? It seems to me both regions are defined correctly plus minus DOLFIN_EPS.

from dolfin import *

mesh = UnitIntervalMesh(101)

def region1(x,on_boundary):
        return between(x[0],(0.0,0.5))

def region2(x, on_boundary):
        return between(x[0],(0.5,1.0))

r1 = AutoSubDomain(region1)
r2 = AutoSubDomain(region2)

f = CellFunction('size_t',mesh)

r1.mark(f,1)
r2.mark(f,2)

print f.array() #missing a cell here

hmin = mesh.hmin()

def region1(x,on_boundary):
        return between(x[0],(0.0,0.5+hmin))

def region2(x, on_boundary):
        return between(x[0],(0.5,1.0))

r1 = AutoSubDomain(region1)
r2 = AutoSubDomain(region2)

f = CellFunction('size_t',mesh)

r1.mark(f,1)
r2.mark(f,2)

print f.array() #all cells are marked
asked Sep 4, 2015 by chaffra FEniCS User (1,830 points)

1 Answer

+1 vote

Change 101 to 3 to make it clearer. Then draw the mesh on paper. Which of your regions is the middle cell within?

answered Sep 4, 2015 by martinal FEniCS User (2,800 points)

Got it. Thanks!

...