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))
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.
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.