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

Cannot get geometric dimension from an expression with no domains

0 votes

I define an piecewise constant expression, which can be called using AS.a1 - AS.a6. The following code works when a1-a6 are constant expression. I get the error message "Cannot get geometric dimension from an expression with no domains" after changing it from constant to piecewise constant (two pieces). Thanks in advance.

class Inflow(SubDomain):
def __init__(self, F, cell,domain):
    self.A = F       
    SubDomain.__init__(self) # Call base class constructor
def inside(self, x, on_boundary):
    bfs = 0 ## sign of the boundary flux
    if x[0] < DOLFIN_EPS :
        bfs = -1.0*(AS.a1(x)*self.A[0](x) + AS.a4(x)*self.A[1](x) + AS.a6(x)*self.A[2](x))
    if x[0] > 1.0 - DOLFIN_EPS :
        bfs =  1.0*(AS.a1(x)*self.A[0](x) + AS.a4(x)*self.A[1](x) + AS.a6(x)*self.A[2](x))
    if x[1] < DOLFIN_EPS :
        bfs = -1.0*(AS.a4(x)*self.A[0](x) + AS.a2(x)*self.A[1](x) + AS.a5(x)*self.A[2](x))
    if x[1] > 1.0 - DOLFIN_EPS :
        bfs =  1.0*(AS.a4(x)*self.A[0](x) + AS.a2(x)*self.A[1](x) + AS.a5(x)*self.A[2](x))
    if x[2] < DOLFIN_EPS :
        bfs = -1.0*(AS.a6(x)*self.A[0](x) + AS.a5(x)*self.A[1](x) + AS.a3(x)*self.A[2](x))
    if x[2] > 1.0 - DOLFIN_EPS :
        bfs =  1.0*(AS.a6(x)*self.A[0](x) + AS.a5(x)*self.A[1](x) + AS.a3(x)*self.A[2](x))

    if bfs > 0 :
        return True and on_boundary
    else:
        return False
asked Jul 29, 2015 by Lingyun FEniCS Novice (170 points)
...