def create_bcs(Lx, Ly, mesh, grid_spacing, rad, num_obstacles,
surface_charge, solutes, enable_NS, enable_EC,
p_lagrange, V_lagrange,
**namespace):
""" The boundaries and boundary conditions are defined here. """
data = np.loadtxt(
"meshes/periodic_porous_Lx{}_Ly{}_rad{}_N{}_dx{}.dat".format(
Lx, Ly, rad, num_obstacles, grid_spacing))
centroids = data[:, :2]
rad = data[:, 2]
# Find a single node to pin pressure to
x_loc = np.array(mesh.coordinates())
x_proc = np.zeros((size, 2))
ids_notboun = np.logical_and(
x_loc[:, 0] > x_loc[:, 0].min() + df.DOLFIN_EPS,
x_loc[:, 1] > x_loc[:, 1].min() + df.DOLFIN_EPS)
x_loc = x_loc[ids_notboun, :]
d2 = (x_loc[:, 0]+Lx/2)**2 + (x_loc[:, 1]+Ly/2)**2
x_bottomleft = x_loc[d2 == d2.min()][0]
x_proc[rank, :] = x_bottomleft
x_pin = np.zeros_like(x_proc)
comm.Allreduce(x_proc, x_pin, op=MPI.SUM)
x_pin = x_pin[x_pin[:, 0] == x_pin[:, 0].min(), :][0]
info("Pinning point: {}".format(x_pin))
pin_code = ("x[0] < {x}+{eps} && "
"x[0] > {x}-{eps} && "
"x[1] > {y}-{eps} && "
"x[1] < {y}+{eps}").format(
x=x_pin[0], y=x_pin[1], eps=1e-3)
boundaries = dict(
obstacles=[Obstacles(Lx, centroids, rad, grid_spacing)]
)
# Allocating the boundary dicts
bcs = dict()
bcs_pointwise = dict()
for boundary in boundaries:
bcs[boundary] = dict()
noslip = Fixed((0., 0.))
if enable_NS:
bcs["obstacles"]["u"] = noslip
if not p_lagrange:
bcs_pointwise["p"] = (0., pin_code)
if enable_EC:
bcs["obstacles"]["V"] = Charged(surface_charge)
if not V_lagrange:
bcs_pointwise["V"] = (0., pin_code)
return boundaries, bcs, bcs_pointwise
评论列表
文章目录