def set_param_flow(self, gb, no_flow=False, kn=1e3): # Set up flow field with uniform flow in y-direction gb.add_node_props(["param"]) for g, d in gb: param = Parameters(g) perm = tensor.SecondOrderTensor(g.dim, kxx=np.ones(g.num_cells)) param.set_tensor("flow", perm) aperture = np.power(1e-3, gb.dim_max() - g.dim) param.set_aperture(aperture * np.ones(g.num_cells)) if g.dim == 2: b_val = np.zeros(g.num_faces) bound_faces = bc.face_on_side(g, ["ymin", "ymax"]) if no_flow: b_val[bound_faces[0]] = 1 b_val[bound_faces[1]] = 1 bound_faces = np.hstack((bound_faces[0], bound_faces[1])) labels = np.array(["dir"] * bound_faces.size) param.set_bc("flow", bc.BoundaryCondition(g, bound_faces, labels)) bound_faces = bc.face_on_side(g, "ymax")[0] b_val[bound_faces] = 1 param.set_bc_val("flow", b_val) d["param"] = param gb.add_edge_props("kn") for e, d in gb.edges(): mg = d["mortar_grid"] gn = gb.nodes_of_edge(e) d["kn"] = kn * np.ones(mg.num_cells)
def boundary_condition(g, left_to_right): if left_to_right: dirfaces_four = bc.face_on_side(g, 'xmin')[0] dirfaces_one = bc.face_on_side(g, 'xmax')[0] else: dirfaces_one = bc.face_on_side(g, 'ymin')[0] dirfaces_four = bc.face_on_side(g, 'ymax')[0] dirfaces = np.concatenate((dirfaces_four, dirfaces_one)) labels = ['dir'] * dirfaces.size bc_val = np.zeros(g.num_faces) bc_val[dirfaces_four] = np.ones(dirfaces_four.size) * 4 bc_val[dirfaces_one] = np.ones(dirfaces_one.size) return dirfaces, labels, bc_val
def bc_val(self): bc_values = np.zeros(self.grid().num_faces) if self.grid().dim > 0 and abs(self.grid().face_centers[0, 0] - .5) > 1e-3: # p_D = 1-x for the two Dirichlet grids bc_values[bc.face_on_side(self.grid(), 'xmin')[0]] = 1 return bc_values
def bc_object(g): if g.dim < 3: return bc.BoundaryCondition(g) # Neumann on all but two boundaries dirfaces = bc.face_on_side(g, ['xmin', 'xmax']) dirfaces = np.concatenate(dirfaces) labels = np.array(['dir'] * dirfaces.size) return bc.BoundaryCondition(g, dirfaces, labels)
def boundary_face_type(g): """ Extract the faces where Dirichlet conditions are to be set. """ if g.dim < 2: return np.array([]) if g.dim == 2 and not np.isclose(g.cell_centers[0, 0], g.cell_centers[0, 1]): return np.array([]) bound_faces = bc.face_on_side(g, ["ymin", "ymax"]) return np.array(np.concatenate(bound_faces))
def bc(self): # Default values (Neumann) on the vertical fracture and # 0D grid if self.grid().dim < 1 or abs(self.grid().face_centers[0, 0] - .5) < 1e-3: return bc.BoundaryCondition(self.grid()) # Dirichlet on the two other dirfaces = bc.face_on_side(self.grid(), ['xmin', 'xmax']) dirfaces = np.asarray(dirfaces).flatten() labels = np.array(['dir'] * dirfaces.size) return bc.BoundaryCondition(self.grid(), dirfaces, labels)
def bc_val(self): bc_values = np.zeros(self.grid().num_faces) # p_D = 1-x for highest dimension: if self.grid().dim > 2: bc_values[bc.face_on_side(self.grid(), 'xmin')[0]] = 1 return bc_values