Hi everyone,
i´m trying to solve the Navier-Stokes-Equation and struggling with the Acceleration-Term in Fenics 1.4.
from dolfin import *
A = 0.2 # High Inlet/Outlet
Cellnumber = 10
radius = 1.0
### Create Initial Mesh/Boundary:
mesh = Mesh(Circle(0.0, 0.0, radius),Cellnumber)
V = VectorFunctionSpace(mesh, "CG", 2)
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q
class Inlet(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and (x[0]<0) and (abs(x[1])<A) \
and ((sqrt(x[0]**2 + x[1]**2)-radius)<DOLFIN_EPS)
class Outlet(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and x[0]>0 and abs(x[1])<A \
and ((sqrt(x[0]**2 + x[1]**2)-radius)<DOLFIN_EPS)
class Shape(SubDomain):
def inside(self, x, on_boundary):
return on_boundary \
and not(x[0]<0 and abs(x[1])<A and ((sqrt(x[0]**2 + x[1]**2)-radius)<DOLFIN_EPS)) \
and not(x[0]>0 and abs(x[1])<A and ((sqrt(x[0]**2 + x[1]**2)-radius)<DOLFIN_EPS))
boundaries = FacetFunction("size_t", mesh)
boundaries.set_all(0)
Inlet().mark(boundaries, 1)
Outlet().mark(boundaries, 2)
Shape().mark(boundaries, 3)
inflow = Expression(('-x[0]-0.9', '0.0'))
bc0 = DirichletBC(W.sub(0), inflow, boundaries, 1)
bc1 = DirichletBC(W.sub(0), (0.0,0.0), boundaries, 3)
bc2 = DirichletBC(W.sub(1), 0.0, boundaries, 2)
bcs = [bc0, bc1, bc2]
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
f = Constant((0.0, 0.0))
g = Constant(0.0)
n = FacetNormal(mesh)
ds = Measure("ds")[boundaries]
#a = (inner(nabla_grad(u),nabla_grad(v)) - p*div(v) + div(u)*q)*dx + (inner(p*n,v) \
# - inner(nabla_grad(u)*n,v))*ds(1)
# + inner(u[0]*u.dx(0),v)*dx
# + inner(dot(nabla_grad(u),u),v)*dx
#L = (inner(f, v) + g*q)*dx
F = (inner(nabla_grad(u),nabla_grad(v)) - p*div(v) + div(u)*q)*dx + (inner(p*n,v) \
- inner(nabla_grad(u)*n,v))*ds(1) - (inner(f, v) + g*q)*dx
U = Function(W)
#solve(a == L, U, bcs)
solve(F==0,U,bcs)
u, p = U.split()
plot(u)
interactive()
When i use solve(a == L, U, bcs)
with the terms inner(u[0]*u.dx(0),v)*dx
or inner(dot(nabla_grad(u),u),v)*dx
i´m getting the error :
Exception: Unable to extract all indices.
When i use solve(F==0,U,bcs)
i´m getting the error:
All terms in form must have same rank.
In this example, it works with inner(grad(u)*u, v)*dx
, but it gives also the 'indices'-error.
Could you please help to find my error? What i´m missing?