Hi everyone,
I’m new in this forum and I’m facing a problem that I’m struggling to understand.
My goal il quite simple: I’m solving the Incompressible Steady Navier Stokes Equations with no forcing trying to obtain the base flow.
from dolfin import *
Re = 40
nu = Constant(1 / Re)
mesh = Mesh()
with HDF5File(MPI.comm_world, "./Mesh.h5", "r") as h5file:
h5file.read(mesh, "mesh", False)
facet = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
h5file.read(facet, "facet")
VelocityElement = VectorElement("CG", mesh.ufl_cell(), 2)
PressureElement = FiniteElement("CG", mesh.ufl_cell(), 1)
Space = FunctionSpace(mesh, VelocityElement * PressureElement)
w = Function(Space)
u, p = split(w)
F_base = Function(Space)
F_base.interpolate(Constant((0.0, 0.0, 0.0)))
f_base, _ = split(F_base)
v, q = TestFunctions(Space)
bcs= []
bcs.append(DirichletBC(Space.sub(0), Constant((1.0, 0.0)), facet, 1))
bcs.append(DirichletBC(Space.sub(0), Constant((0.0, 0.0)), facet, 2))
bcs.append(DirichletBC(Space.sub(0).sub(1), Constant(0.0), facet, 3))
bcs.append(DirichletBC(Space.sub(1), Constant(0.0), facet, 4))
G = (+nu*inner(grad(u), grad(v))
+ inner(grad(u)*u, v)
- inner(p, div(v))
+ inner(q, div(u))
+ inner(f_base, v)
) * dx
J = derivative(G, w)
problem = NonlinearVariationalProblem(G, w, bcs, J)
solver = NonlinearVariationalSolver(problem)
solver.solve()
By doing so, I obtain the base flow of this case (Note that I enforced a source (or forcing) term f_base to be 0 everywhere: norm(F_base) = 0.)
Now, If I simply try to compute f_base back from the Incompressible Steady Navier Stokes Equations
f_base = project( -nu * div(grad(u)) + dot(grad(u), u) + grad(p))
I get something which is no more 0 (norm(f_base != 0)).
What It’s wrong here?
Thank you all for you help.
Have a great day!