Setting free surface BC
I am trying to perform a simulation of a 3D free surface flow. I already have the mesh, and now I have to set the BCs for it.
The mesh geometry is really complex, so I mark all exterior faces as no_slip first, then I mark the inflow and outflow, and the free surface remains to be marked (it was previously marked as no_slip).
The code I append is a little long, but the key is really only in the on_free_surface function, so you may skip the rest.
I am trying to do it this way:
#First define class to gather surface nodes data
class FS_coordinates:
def __init_
self.x = x
self.y = y
self.z = z
FS_coor = FS_coordinates(
#TEST WITH SIMPLE MESH. Gather points on surface x = 1
mesh = UnitCube(3,3,3)
coor = mesh.coordinates()
tol = 1e-5
nodes_x = []
nodes_y = []
nodes_z = []
for i in coor:
if abs(i[0]) > 1-tol:
FS_coor = FS_coordinates(
#Define inside_function
def on_free_surface(x, on_boundary):
fsc = FS_coor
tol = 1e-6
is_on_FS = False
print x
for y in range(len(fsc.x)):
p = [fsc.x[y], fsc.y[y], fsc.z[y]]
dist = 0.
for m in range(3): dist += (p[m] - x[m])**2
dist = sqrt(dist)
if dist <tol:
break
return on_boundary and is_on_FS
#Define additional BC
def walls_bcs(x, on_boundary):
return on_boundary and(near(x[0], 0.) or near(x[0], 1.) or near(x[1], 0.)\
#Create mesh function
mf = FaceFunction(
mf.set_all(0)
#Mark boundaries
inlet = FlowSubDomain(
walls = FlowSubDomain(
#Save file for further visualisation
file = File("free_
file << mf
Thanks,
Marcos
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- CBC.PDESys Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: