How to solve PDE in subdomain with mesh import from Gmsh?
5 months ago by
I have a 2 phase problem to solve, it is like the figure below:
Now I want to solve a navier-stoke equation in the liquid part, which is labelled as 2.
And its boundary is labelled as 3.
I generate my mesh from Gmsh.
The code is like:
mesh = Mesh("filename.xml") cd = MeshFunction('size_t', mesh, "filename_physical_region.xml") cdl = MeshFunction('size_t', mesh, "filename_facet_region.xml") subdomain = CellFunction("size_t", mesh) subdomain.set_all(0) subdomain.array()[cd.array()==1] = 1 subdomain.array()[cd.array()==2] = 2 boundary = FacetFunction("size_t", mesh) boundary.set_all(0) boundary.array()[cdl.array()==3] = 3 # Now I guess in order to solve the navier stokes equation only in subdomain 2, # I need to create a submesh and a FunctionSpace in the subdomain like: submesh = SubMesh(mesh, subdomain, 2) W = FunctionSpace(submesh, 'P', 1) # but how do I set the Dirichlet boundary condition on the curve 3? # I tried: bcw = Dirichlet(W, Constant(0.0), cdl, 3) # of course I got the error's reason: User MeshFunction and FunctionSpace meshes are different
Community: FEniCS Project
5 months ago by
if I understood correctly and you succeeded in creating the submesh for subdomain 2, a straightforward solution could be:
def nolisp(x, on_boundary): if on_boundary: if near(x, Right, tol) or near(x, Left, tol) or near(x, Bottom, tol): return False else: return True else: return False bcw = DirichletBC(V, Constant(0.0), nolisp)
Please login to add an answer/comment or follow this question.