Hi,
I'm starting to use FEniCS and i'm modelling a flow machine using FEniCS and i have to solve:
where, omega is a vector, for example ( 0.0, 0.0, 10.0), u is the velocity, W the test function.
So i'm trying to use (first part):
from dolfin import *
from dolfin_adjoint import *
set_log_level(INFO)
omega = Constant((0.0, 0.0, vel_angular))
rho = 1.0
rect = Rectangle(0.0,0.0,1.0,1.0)
mesh = Mesh(rect,100)
U = VectorFunctionSpace(mesh, "CG", 3) # velocity function space -U
P = FunctionSpace(mesh, "CG", 1) # pressure function space -P
W = MixedFunctionSpace([U, P]) # mixed Taylor-Hood function space
def BC_1(x, on_boundary):
return on_boundary and \
near(x[0],0.0) or near(x[1],1.0) or near(x[0],1.0)
def BC_2(x, on_boundary):
return on_boundary and \
near(x[1],0.0)
Gamma1 = DirichletBC(W.sub(1),0.0,BC_1)
Gamma2 = DirichletBC(W.sub(1),10.0,BC_2)
bcs = [Gamma1, Gamma2]
def forward(rho):
w = Function(W)
(u, p) = split(w)
(v, q) = TestFunctions(W)
F = (2.0*rho*inner(cross(omega,u),v)*dx)
solve(F == 0, w, bcs)
return w
if __name__ == "__main__":
w = forward(rho)
(u, p) = split(w)
Then i get the error:
ufl.log.UFLException: Cross product requires arguments of rank 1
I think this is because i'm trying to use u on the cross product. I've also tried to use:
F=(2.0*rho*inner(-omega[2]*u[1] + omega[2]*u[0] , v)*dx )
Is it possible to solve this kind of functionals that have cross products of valued vectors using fenics?
I really appreciate any help you can provide