Hello,
I am trying to solve the Stokes equation for a flow in a channel. The mesh consists of two parts (solid representing the walls of the channel and fluid representing the region where I want to solve the Stokes flow)
The code provides zero values for velocity and pressure when I try to define the simulation to run in the fluid region by using dx(simulationRegion) , when I remove (simulationRegion) , the code below works but provides incorrect results because it does not distinguish between solid and fluid. How to correctly tell the model run only in the fluid region ?
Note: bcs_Dirichlet includes the interface mesh elements between the solid and fluid (internal wall elements)
Here is my code:
for idx, material in enumerate(meshNGSolve.GetMaterials()):
domainType = domainDetails[idx].getDomainType()
if domainType == 'Fluid':
simulationRegion = material
V = VectorH1(meshNGSolve, order=order,
dirichlet=bcs_Dirichlet)
Q = H1(meshNGSolve, order=order - 1)
fes = V * Q
u, p = fes.TrialFunction()
v, q = fes.TestFunction()
bodyForceCoeffFun = CoefficientFunction((bodyForce[0], bodyForce[1], bodyForce[2]))
stokes = viscosity * InnerProduct(grad(u), grad(v)) + div(u) * q + div(v) * p - 1e-10 * p * q
a = BilinearForm(fes, symmetric=True, check_unused=False)
a += stokes * dx(simulationRegion)
a.Assemble()
# right hand side
f = LinearForm(fes)
f += -bodyForceCoeffFun * v * dx(simulationRegion)
f.Assemble()
gfu = GridFunction(fes)
dicBCValues = self.getDicBCValues()
values_list = [ (0.0, 0.0, 0.0)]
gfu.components[0].Set(CoefficientFunction(values_list),definedon=meshNGSolve.Boundaries(bcs_Dirichlet))
inv_stokes = a.mat.Inverse(freedofs=fes.FreeDofs(), inverse="sparsecholesky")
gfu.vec.data = inv_stokes * f.vec