Hi everyone,
I got stuck trying to simulate Stokes flow against a cylinder inside a rectangular domain in 3D.
The geometry is designed in FreeCAD and meshed in GMSH (3D mesh), then i’ve converted the file with success through ubuntu in .xml; i obtained three files, geometry.xml, geometry_physical_region.xml and geometry_facet_region.xml. Simulation works but not at all levels (see attached images), it seems that doesn’t consider any element volume inside rectangle, despite the bcs are well setted and recognized from Fenics.
# Create mesh
mesh = Mesh("geom3.xml")
markers = fn.MeshFunction("size_t", mesh, 'geom3_physical_region.xml')
sub_domains = fn.MeshFunction('size_t', mesh, 'geom3_facet_region.xml')
dx = fn.Measure('dx', domain=mesh, subdomain_data=markers)
# Define function space
P2 = VectorElement('P', tetrahedron, 2)
P1 = FiniteElement('P', tetrahedron, 1)
TH = P2 * P1
W = FunctionSpace(mesh, TH)
# Define boundary conditions
bcu_walls = DirichletBC(W.sub(0), Constant((0, 0, 0)), sub_domains, 16)
bcp_inflow = DirichletBC(W.sub(1), Constant(50), sub_domains, 17)
bcp_outflow = DirichletBC(W.sub(1), Constant(0), sub_domains, 16)
bcu_cylinder = DirichletBC(W.sub(0), Constant((0, 0, 0)), sub_domains, 1)
bcu = [bcp_inflow, bcu_cylinder, bcu_walls, bcp_outflow]
# Define variational problem
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
a = inner(grad(u), grad(v))*dx - p*div(v)*dx + div(u)*q*dx
f = Constant((0, 0, 0))
L = dot(f, v)*dx
# Compute solution
w = Function(W)
solve(a == L, w, bcu, solver_parameters={'linear_solver':'mumps'})
# Split the mixed solution
(u, p) = w.split(True)
# Save for PARAVIEW
vel = File('S_velocity.pvd')
vel << u
pre = File('S_pressure.pvd')
pre << p

