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

Inflow boundary condition with parameter passing

+1 vote

I would like to set a inflow boundary condition (Dirichlet). The direction of the flow is calculated using dot production of the normal vector and a vector field A. This boundary condition is used in iterations and the field A changes. My question is : how to pass a parameter to DirichletBC()?
Then I can use the code similar to the following:

def inflowBd(x,A):
    if x[0] < DOLFIN_EPS:
        if A(x[0],x[1])[0] > 0:
            return True

inBc = DirichletBC(V, Constant(0.2), inflowBd(x,A))
asked Apr 30, 2015 by Lingyun FEniCS Novice (170 points)

You can do something like this

while iter < maxIter:
   inBc = DirichletBC(V, Constant(0.2), inflowBd(x,A))
   ...

, i.e. you can redefine inlet BC in every iteration step. But I guess that you dont want to do that this way, right?

The code in my question doesn't work because A can't be passed to DirichletBC()
I have to use

inBc = DirichletBC(V, Constant(0.2), inflowBd)

I solve this problem by redefining the subdomain(sub boundary domain) in each iteration.

1 Answer

0 votes
def inflowBd(x, on_boundary, A):
    return on_boundary and x[0] < DOLFIN_EPS and A(x)[0] > 0.0 

inBc = DirichletBC(V, Constant(0.2), lambda x, on_boundary: inflowBd(x, on_boundary, A))

I'm not sure whether this script works or not. Just a suggestion.

answered May 12, 2015 by Chao Zhang FEniCS User (1,180 points)
edited May 12, 2015 by Chao Zhang
...