Hello to the community,
I am trying to compute the inf-sup condition of the Navier-Stokes equations.
For this I need to define the operator Tp
given a pressure p
as the solution to the following, call this equation [1],
inner(v, Tp) * dx + inner(grad(v), grad(Tp)) * dx = inner(p, div(v)) * dx
Given an arbitrary pressure p
I can solve this easily with,
from fenics import *
# Define mesh and function spaces
mesh = UnitSquareMesh(16, 16)
V = VectorFunctionSpace(mesh, 'Lagrange', 2)
Q = FunctionSpace(mesh, 'Lagrange', 1)
inflow = 'near(x[0], 0) && (x[1]>3.5/5 && x[1]<4.5/5)'
outflow = 'near(x[1], 0) && (x[0]>3.5/5 && x[0]<4.5/5)'
walls = 'near(x[0], 1) || near(x[1], 1) || (near(x[1],0) && (x[0]<=3.5/5 || x[0]>=4.5/5)) || (near(x[0],0) && (x[1]<=3.5/5 || x[1]>=4.5/5))'
stab_bdc = [DirichletBC(V, Constant((0, 0)), walls),
DirichletBC(V, Constant((0, 0)), inflow),
DirichletBC(V, Constant((0, 0)), outflow)
]
# Define trial and test functions
v = TestFunction(V)
z = TrialFunction(V)
p = Function(Q)#Replace with your pressure of choice
# Tq solution to:
Tp_lhs = inner(v, z) * dx + inner(grad(v), grad(z)) * dx
Tp_rhs = inner(p, div(v)) * dx
# Solve the variational problem
Tp = Function(V)
solve(Tp_lhs == Tp_rhs, Tp,bcs=stab_bdc))
Now I am interested in the inf-sup condition.
To get the Inf-Sup condition I need to find the smallest eigenvalue satisfying the problem:
inner(Tq,Ttheta) * dx + inner(grad(Tq), grad(Ttheta)) * dx = lambda inner(q,theta)
where theta
is the eigenvector corresponding to the eigenvalue lambda and q
is the Testfunction
in Q
. Tq
and Ttheta
are solutions to equation [1] corresponding to q
and theta
.
I understand there is an eigenproblem solver in fenics, SLEPcEigenSolver
, but I do not see how I can use it in this case, especially with the left hand-side I have.