def test_transmissibility_tpfa_no_micro_fractures(self): g = create_grids.cart_2d() macro_bc = pp.BoundaryCondition(g) discr = Tpfa_DFM() internal_faces = [1, 4, 7, 11, 12, 13, 14] for reg in discr._interaction_regions(g): # consider only the internal faces if np.all(np.isin(reg.reg_ind, internal_faces)): local_gb = LocalGridBucketSet(g.dim, reg) local_gb.construct_local_buckets() basis_functions, cc_assembler, cc_bc_values = lp.cell_basis_functions( reg, local_gb, discr, {"bc": macro_bc}) _, _, trm = lp.compute_transmissibilies( reg, local_gb, basis_functions, cc_assembler, cc_bc_values, g, discr, {"bc": macro_bc}, ) self.assertTrue(np.allclose(np.abs(trm), 1)) self.assertTrue(np.allclose(np.sum(trm), 0))
def test_partition_unity_tpfa_multiple_boundary_intersecting_local_micro_fracture( self, ): g = create_grids.cart_2d() pts = np.array([[0.7, 0.9, 0.815, 0.95], [1.1, 1.4, 1.35, 1]]) edges = np.array([[0, 2], [1, 3]]) internal_faces = [4] self._check_partition_unity(g, internal_faces, Tpfa_DFM(), pts, edges)
def test_partition_unity_tpfa_multiple_intersecting_local_micro_fractures( self): g = create_grids.cart_2d() pts = np.array([[0.8, 1.2, 1.1, 1.1], [1.3, 1.6, 1.4, 1.8]]) edges = np.array([[0, 2], [1, 3]]) internal_faces = [4] self._check_partition_unity(g, internal_faces, Tpfa_DFM(), pts, edges)
def main(): # example in 2d file_name = "network.csv" write_network(file_name) # load the network and split it, we assume 2d domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} global_network = pp.fracture_importer.network_2d_from_csv(file_name, domain=domain) global_network = global_network.split_intersections() # select a subsample of the fractures macro_network, micro_network = split_network(global_network, Criterion.every) # NOTE: the explicit network is empty so far # create the macroscopic grid mesh_size = 2 mesh_kwargs = { "mesh_size_frac": mesh_size, "mesh_size_min": mesh_size / 20 } gb = macro_network.mesh(mesh_kwargs) # plot the suff pp.plot_fractures(micro_network.pts, micro_network.edges, micro_network.domain) pp.plot_grid(gb, info="c", alpha=0) # construct the solver tpfa_dfm = Tpfa_DFM() # Set data for the upscaling problem g = gb.grids_of_dimension(gb.dim_max())[0] d = gb.node_props(g) # store the # EK: We probably need to initialize some of the nested dictionaries d[pp.PARAMETERS][tpfa_dfm.keyword][ tpfa_dfm.network_keyword] = micro_network # set parameters and discretization variables # EK: This must be done in this run-script - it is not the responsibility of the # discretization. We may want to construct a model for this. # tpfa_dfm.set_parameters(gb) # tpfa_dfm.set_variables_discretizations(gb) # discretize with the assembler assembler = pp.Assembler(gb) assembler.discretize() A, b = assembler.assemble_matrix_rhs() # Solve and distribute x = spsolve(A, b) assembler.distribute_variable(x)
def test_partition_unity_tpfa_single_local_micro_fracture(self): g = create_grids.cart_2d() pts = np.array([[0.8, 1.2], [1.3, 1.6]]) edges = np.array([[0], [1]]) internal_faces = [4] self._check_partition_unity(g, internal_faces, Tpfa_DFM(), pts, edges)
def test_partition_unit_tpfa_no_micro_fractures(self): g = create_grids.cart_2d() internal_faces = [1, 4, 7, 11, 12, 13, 14] self._check_partition_unity(g, internal_faces, Tpfa_DFM())