Hi, I’m working with stokes flow on porous medium. To generate the porous medium mesh, I used nanomesh using a binary image. The problem is that I don’t know how to set the no-slip condition on the inner grains. I labeled the porous space as 1 and the solid phase as 2.
How can i establish the inner boundary conditions?
You’d have to mark the interface between 1 and 2 with a facet label. This is done with the MeshFunction object in dolfin and with meshtags in dolfinx. Please search the forum for how to use them, or a the very least clarify whether you are using legacy FEniCS or FEniCSx.
from dolfin import *
def generate_interface(mesh, subdomains, subdomain_ids):
assert isinstance(subdomain_ids, set)
assert len(subdomain_ids) == 2
D = mesh.topology().dim()
# Initialize empty MeshFunction
mesh_function = MeshFunction("size_t", mesh, D - 1)
mesh_function.set_all(0)
# Mark mesh_function based on subdomain ids
for f in facets(mesh):
subdomains_ids_f = set(subdomains[c] for c in cells(f))
assert len(subdomains_ids_f) in (1, 2)
if subdomains_ids_f == subdomain_ids:
mesh_function[f] = 1
# Return
return mesh_function
# Read in mesh
# TODO
# Read in subdomains as a MeshFunction
# TODO
# Generate interface as a MeshFunction
interface = generate_interface(mesh, subdomains, {1, 2})
There may be some small mistakes since I can’t test this because of the lack of your mesh files, but hopefully it should be enough for you to get started.
Hi Francesco, I managed to solve the problem. I combined part of these tutorials to solve it:
1- Nanomesh
2- Marking subdomains
Thank you for your replies.