← Back to team overview

dolfin team mailing list archive

[Question #155649]: Changing a stokes problem to navier-stokes with a non-linear term

 

New question #155649 on DOLFIN:
https://answers.launchpad.net/dolfin/+question/155649

I am using the method of solving a non-linear problem directly.

My first change was:
problem = VariationalProblem(a, L, bcs)
to
problem = VariationalProblem(a, L, bcs, nonlinear=True) 

Next I added a non-linear term to my a variable:
a = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u))*dx
to
a = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) + inner(inner(u,grad(u)),v))*dx

What are the steps that I should take from here? 


#Full Code so far

from dolfin import *

# MESHING
mesh = Rectangle(0.0, -1.0, 20.0, 1.0, 20, 10, "right/left")

# FUNCTION SPACE
scalar = FunctionSpace(mesh, "CG", 1) #Pressure
vector = VectorFunctionSpace(mesh, "CG", 2) #Velocity
system = vector * scalar #Mixed Function Space

# BOUNDARIES
right = compile_subdomains('x[0] == 20.0')
left = compile_subdomains('x[0] == 0.0')
top = compile_subdomains('x[1] == 1.0')
bottom = compile_subdomains('x[1] == -1.0')

# NO-SLIP BC FOR TOP-BOTTOM
noslip = Constant((0.0, 0.0))
bc0 = DirichletBC(system.sub(0), noslip, top)
bc3 = DirichletBC(system.sub(0), noslip, bottom)

# INFLOW VELOCITY BC FOR LEFT
bc1 = DirichletBC(system.sub(0).sub(0), Constant(2.0), left)

# OUTFLOW PRESSURE BC FOR RIGHT
zero = Constant(0)
bc2 = DirichletBC(system.sub(1), zero, right)

# STORAGE OF BCs
bcs = [bc1, bc0, bc2, bc3]

# VARIATIONAL PROBLEM
(v, q) = TestFunctions(system)
(u, p) = TrialFunctions(system)

f = Constant((0, 0))
nu = 1.0

a = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) + inner(inner(u,grad(u)),v))*dx
L = inner(v, f)*dx

# SET UP PDE
problem = VariationalProblem(a, L, bcs, nonlinear=True)

# SOLVE PDE
(U, P) = problem.solve().split()

# FILES FOR PARAVIEW
ufile_pvd = File("velocity.pvd")
ufile_pvd << U
pfile_pvd = File("pressure.pvd")
pfile_pvd << P

# PLOTS
plot(U)
plot(P)
interactive()

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.