Splitting expressions involving boundary normals
I am trying to split an Expression into subcomponents, where this Expression is to be used as a boundary condition.
A simple example is found below. When splitting, I get the error:
"...
cell.normal(
TypeError: expected positive 'int' for argument 2"
Tried to add a try/except block within the eval-method as well, but do not get any results as anticipated. Any ideas?
from dolfin import *
class MyExpression(
def __init__(self, mesh):
self.mesh = mesh
def eval_cell(self, value, x, ufc_cell):
# Find normal
cell = Cell(self.mesh, ufc_cell.index)
normal = cell.normal(
value[0] = 0.1*normal.x()
value[1] = 0.2*normal.y()
value[2] = 0.3*normal.z()
def value_shape(self):
return (3,)
class Boundary(
def inside(self, x, on_boundary):
return on_boundary
N = 8
mesh = UnitCube(N,N,N)
exp = MyExpression(mesh)
# This works fine!
V = VectorFunctionS
u = Function(V)
bc = DirichletBC(V, exp, Boundary())
bc.apply(
plot(u, interactive=True)
# Splitting the expression does not work...
Q = FunctionSpace(mesh, "CG", 1)
u = [Function(Q)]*3
for i in range(3):
bc = DirichletBC(Q, exp[i], Boundary()) # Adding only the i'th component of the Expression
bc.
plot(u[i], interactive=True)
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Øyvind Evju
- Solved:
- Last query:
- Last reply: