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

Defining a subdomain from a value map

0 votes

Hello!

I have an expression such as:

class Pcmap(Expression):
    def eval(self, value, x):
    value[0] = 0
    # Row 1
    if x[0] > 0.339 and x[0] < 0.361 and x[1] > 0.019 and x[1] < 0.031:
        value[0]=1
    if x[0] > 0.339 and x[0] < 0.361 and x[1] > 0.069 and x[1] < 0.081:
        value[0]=1
    if x[0] > 0.039 and x[0] < 0.061 and x[1] > 0.019 and x[1] < 0.031:
        value[0]=1
    if x[0] > 0.039 and x[0] < 0.061 and x[1] > 0.069 and x[1] < 0.081:
        value[0]=1
    if x[0] > 0.139 and x[0] < 0.161 and x[1] > 0.019 and x[1] < 0.031:
        value[0]=1
    if x[0] > 0.139 and x[0] < 0.161 and x[1] > 0.069 and x[1] < 0.081:
        value[0]=1
    if x[0] > 0.239 and x[0] < 0.261 and x[1] > 0.019 and x[1] < 0.031:
        value[0]=1
    if x[0] > 0.239 and x[0] < 0.261 and x[1] > 0.069 and x[1] < 0.081:
        value[0]=1

It sets values for a domain variable ("E") according to the space coordinates. For now, I define a subspace in the same region as the areas where "E" assumes value "1". So I've got:

class Mappcmrho(SubDomain):
def inside(self, x, on_boundary):
    return (x[0] > 0.339 and x[0] < 0.361 and x[1] > 0.019 and x[1] < 0.031) or (x[0] > 0.339 and x[0] < 0.361 and x[1] > 0.069 and x[1] < 0.081) or (x[0] > 0.039 and x[0] < 0.061 and x[1] > 0.019 and x[1] < 0.031) or (x[0] > 0.039 and x[0] < 0.061 and x[1] > 0.069 and x[1] < 0.081) or (x[0] > 0.139 and x[0] < 0.161 and x[1] > 0.019 and x[1] < 0.031) or (x[0] > 0.139 and x[0] < 0.161 and x[1] > 0.069 and x[1] < 0.081) or (x[0] > 0.239 and x[0] < 0.261 and x[1] > 0.019 and x[1] < 0.031) or (x[0] > 0.239 and x[0] < 0.261 and x[1] > 0.069 and x[1] < 0.081)

However, the first map will not always be created from an expression like in the example and I need a subdomain where "E" have values equals to "1".

Is it possible to create a subdomain from the "E" values?

Att.
Diego

asked Nov 5, 2015 by prado.dis FEniCS Novice (230 points)

However, the first map will not always be created from an expression
like in the example

In what form will it be available then?

1 Answer

0 votes

It comes from a function projected in the mesh. For example E = x[0]*x[1].

What I want to tell the software is:

class Mappcmrho(SubDomain):
def inside(self, x, on_boundary):
    return (E > 0.5)

I'm trying to avoid something like:

class Mappcmrho(SubDomain):
def inside(self, x, on_boundary):
    return (x[0]*x[1] > 0.5)

Was just wondering if this is possible.

Att.
Diego

answered Nov 9, 2015 by prado.dis FEniCS Novice (230 points)
...