def test_add_networks_domains(self): network_1 = pp.FractureNetwork2d(self.p, self.e, self.domain) p2 = np.array([[0, 2, 1, 1], [0, 0, 0, 1]]) + 2 e2 = np.array([[0, 2], [1, 3]]) # A network with no domain network_2 = pp.FractureNetwork2d(p2, e2) # Add first to second, check domain together = network_1.add_network(network_2) self.assertTrue(self.compare_dictionaries(self.domain, together.domain)) # Add second to first, check domain together = network_2.add_network(network_1) self.assertTrue(self.compare_dictionaries(self.domain, together.domain)) # Assign domain, then add network_2.domain = self.domain together = network_1.add_network(network_2) self.assertTrue(self.compare_dictionaries(self.domain, together.domain)) # Assign different domain, check that the sum has a combination of the # domain dicts network_2.domain = self.small_domain together = network_1.add_network(network_2) combined_domain = {"xmin": -1, "xmax": 5.0, "ymin": -1, "ymax": 5} self.assertTrue( self.compare_dictionaries(combined_domain, together.domain))
def test_nested_simple(self): # Simple test of the nested generation. Both 2d and 3d domains. # Main check: The refinement is indeed by splitting mesh_args = {"mesh_size_frac": 1, "mesh_size_bound": 1} num_ref = 3 params = { "mode": "nested", "num_refinements": num_ref, "mesh_param": mesh_args, } network_2d = pp.FractureNetwork2d( domain={"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} ) network_3d = pp.FractureNetwork2d( domain={"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1, "zmin": 0, "zmax": 1} ) for network in [network_2d, network_3d]: factory = pp.refinement.GridSequenceFactory(network, params) num_cells_prev = 0 for counter, gb in enumerate(factory): assert counter < num_ref dim = gb.dim_max() if counter > 0: assert gb.num_cells() == num_cells_prev * (2 ** dim) num_cells_prev = gb.num_cells()
def test_add_networks_no_domain(self): network_1 = pp.FractureNetwork2d(self.p, self.e) p2 = np.array([[0, 2, 1, 1], [0, 0, 0, 1]]) + 2 e2 = np.array([[0, 2], [1, 3]]) network_2 = pp.FractureNetwork2d(p2, e2) together = network_1.add_network(network_2) p_known = np.hstack((self.p, p2)) self.assertTrue(test_utils.compare_arrays(p_known, together.pts)) # The known edges has 2 rows, thus by testing for equality, we implicitly # verify there are no tags in the joint network e_known = np.array([[0, 2, 4, 6], [1, 3, 5, 7]]) self.assertTrue(test_utils.compare_arrays(together.edges, e_known))
def create_grid(self): """ Define a fracture network and domain and create a GridBucket. This setup has two fractures inside the unit cell. The method also calls a submethod which sets injection points in one of the fractures. """ # Domain definition self.box = {"xmin": 0, "ymin": 0, "xmax": 1, "ymax": 1} # self.frac_pts = np.array([[0.2, 0.6, 0.4, 0.8], # [0.5, 0.4, 0.6, 0.5]]) self.frac_pts = np.array([[0.2, 0.6, 0.4, 0.8], [0.3, 0.4, 0.6, 0.6]]) frac_edges = np.array([[0, 2], [1, 3]]) # Each column is one fracture network = pp.FractureNetwork2d(self.frac_pts, frac_edges, domain=self.box) # Generate the mixed-dimensional mesh gb = network.mesh(self.mesh_args) pp.contact_conditions.set_projections(gb) self.gb = gb self.Nd = self.gb.dim_max() self.well_cells() return gb
def create_grid(self): """ Method that creates a GridBucket of a 2D domain with one fracture and sets projections to local coordinates for all fractures. The method requires the following attribute: mesh_args (dict): Containing the mesh sizes. The method assigns the following attributes to self: frac_pts (np.array): Nd x (number of fracture points), the coordinates of the fracture endpoints. box (dict): The bounding box of the domain, defined through minimum and maximum values in each dimension. gb (pp.GridBucket): The produced grid bucket. Nd (int): The dimension of the matrix, i.e., the highest dimension in the grid bucket. """ # List the fracture points self.frac_pts = np.array([[0.2, 0.8], [0.5, 0.5]]) # Each column defines one fracture frac_edges = np.array([[0], [1]]) self.box = {"xmin": 0, "ymin": 0, "xmax": 1, "ymax": 1} network = pp.FractureNetwork2d(self.frac_pts, frac_edges, domain=self.box) # Generate the mixed-dimensional mesh gb = network.mesh(self.mesh_args) # Set projections to local coordinates for all fractures pp.contact_conditions.set_projections(gb) self.gb = gb self.Nd = self.gb.dim_max()
def test_three_pairs(self): # Test identification of parallel fractures. # Test should find pairs between all fractures self.setUp() p = np.array([[0, 2, 1, 3, 0, 2], [0, 0, 1, 1, 2, 2]]) e = np.array([[0, 2, 4], [1, 3, 5]]) network = pp.FractureNetwork2d(p, e, self.domain) generator = self.generator(network) pairs = generator.parent_pairs self.assertTrue(pairs.size == 6) self.assertTrue(test_utils.compare_arrays(pairs, np.array([[0, 0, 1], [1, 2, 2]]))) i_first = generator.interval_first[(0, 2)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[0, 1], [0, 0]]))) i_sec = generator.interval_second[(0, 2)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[0, 1], [2, 2]]))) i_first = generator.interval_first[(0, 1)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[1, 2], [0, 0]]))) i_sec = generator.interval_second[(0, 1)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[1, 2], [1, 1]]))) i_first = generator.interval_first[(1, 2)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[1, 2], [1, 1]]))) i_sec = generator.interval_second[(1, 2)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[1, 2], [2, 2]])))
def test_unstructured(self): # Use unstructured meshing, no relation between grids on different levels mesh_args = [ {"mesh_size_frac": 1, "mesh_size_bound": 1}, {"mesh_size_frac": 0.5, "mesh_size_bound": 0.5}, ] num_ref = len(mesh_args) params = { "mode": "unstructured", "num_refinements": num_ref, "mesh_param": mesh_args, } # Add a single fracture to the network pts = np.array([[0.3, 0.7], [0.5, 0.5]]) edges = np.array([[0], [1]]) domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} network = pp.FractureNetwork2d(pts, edges, domain) factory = pp.refinement.GridSequenceFactory(network, params) for gb in factory: # It is not really clear what we can test here. pass
def test_nested_pass_grid_args(self): # Check that grid arguments to the fracture network meshing ('grid_param' below) # are correctly passed mesh_args = {"mesh_size_frac": 1, "mesh_size_bound": 1} num_ref = 2 # Add a single fracture to the network pts = np.array([[0.3, 0.7], [0.5, 0.5]]) edges = np.array([[0], [1]]) domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} network = pp.FractureNetwork2d(pts, edges, domain) params = { "mode": "nested", "num_refinements": num_ref, "mesh_param": mesh_args, # The fracture is a constraint "grid_param": {"constraints": np.array([0])}, } factory = pp.refinement.GridSequenceFactory(network, params) for counter, gb in enumerate(factory): dim = gb.dim_max() for dim in range(dim): # Since there are no true fractures in the network (only constraints) # there should be no lower-dimensional grids assert len(gb.grids_of_dimension(dim)) == 0
def make_grid(mesh_size=2.0, L=[100.0, 10.0]): """ Create an unstructured triangular mesh using Gmsh. Parameters: mesh_size (scalar): (approximated) size of triangular elements [-] L (array): length of the domain for each dimension [m] Returns: gb (PorePy object): PorePy grid bucket object containing all the grids In this case we only have one grid. """ domain = {"xmin": 0.0, "xmax": L[0], "ymin": 0.0, "ymax": L[1]} network_2d = pp.FractureNetwork2d(None, None, domain) target_h_bound = target_h_fracture = target_h_min = mesh_size mesh_args = { "mesh_size_bound": target_h_bound, "mesh_size_frac": target_h_fracture, "mesh_size_min": target_h_min, } gb = network_2d.mesh(mesh_args) return gb
def test_angle(self): network = pp.FractureNetwork2d(self.p, self.e) angle = network.orientation() known_orientation = np.array([0, np.pi / 2]) self.assertTrue( np.logical_or(angle == known_orientation, angle - np.pi == known_orientation).all())
def create_grid(self): """ Method that creates the GridBucket of a 3D domain with the two fractures defined by self.fractures(). The grid bucket is represents the mixed-dimensional grid. """ """ Single-fracture tetrahedral gb. """ self._fractures() if self.params.get("simplex"): self.network = pp.FractureNetwork2d(self.fracs[0], self.frac_edges, domain=self.box) gb = self.network.mesh(self.mesh_args) else: nc = self.params["n_cells"] dims = [self.box["xmax"], self.box["ymax"]] gb = pp.meshing.cart_grid(self.fracs, nc, physdims=dims) pp.contact_conditions.set_projections(gb) self.gb = gb self.Nd = self.gb.dim_max() self.n_frac = len(gb.grids_of_dimension(self.Nd - 1))
def test_auxiliary(self): domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} mesh_args = {"mesh_size_frac": 1} subdomain_start = np.array([[0.25], [0.5]]) subdomain_end = np.array([[0.5], [0.5]]) p = np.hstack((subdomain_start, subdomain_end)) e = np.array([[0], [1]]) network = pp.FractureNetwork2d(p, e, domain=domain) mesh_args = {"mesh_size_frac": 1} gb = network.mesh(mesh_args, constraints=np.array([0])) g = gb.grids_of_dimension(2)[0] tag = np.where(g.tags["domain_boundary_1_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 0)) tag = np.where(g.tags["domain_boundary_2_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 1)) tag = np.where(g.tags["domain_boundary_3_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 1)) tag = np.where(g.tags["domain_boundary_4_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 0)) fc = g.face_centers[:2] tag = g.tags["auxiliary_0_faces"] dist, _ = pp.distances.points_segments(fc, subdomain_start, subdomain_end) self.assertTrue(np.allclose(dist[tag, 0], 0)) self.assertTrue( np.all(np.logical_not(np.allclose(dist[np.logical_not(tag), 0], 0))) )
def test_auxiliary_2_refined(self): domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} network = pp.FractureNetwork2d(domain=domain) mesh_args = {"mesh_size_frac": 0.125} subdomain = { "points": np.array([[0, 0.5, 0.75, 0.75], [0.5, 0.5, 0.25, 0.75]]), "edges": np.array([0, 1, 2, 3]).reshape((2, -1), order="F"), } gb = network.mesh(mesh_args, constraints=subdomain) g = gb.grids_of_dimension(2)[0] tag = np.where(g.tags["domain_boundary_0_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 0)) tag = np.where(g.tags["domain_boundary_1_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 1)) tag = np.where(g.tags["domain_boundary_2_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 1)) tag = np.where(g.tags["domain_boundary_3_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 0)) known = [14, 17, 112, 118] tag = np.where(g.tags["auxiliary_4_faces"])[0] self.assertTrue(np.allclose(known, tag)) known = [22, 29, 128, 134] tag = np.where(g.tags["auxiliary_5_faces"])[0] self.assertTrue(np.allclose(known, tag))
def test_three_parents_four_pairs(self): # Test identification of parallel fractures. # The critical point is that two fractures meet in two intervals self.setUp() p = np.array([[0, 3, 1, 2, 0, 3], [0, 0, 1, 1, 2, 2]]) e = np.array([[0, 2, 4], [1, 3, 5]]) network = pp.FractureNetwork2d(p, e, self.domain) generator = self.generator(network) pairs = generator.parent_pairs self.assertTrue(pairs.size == 6) self.assertTrue(test_utils.compare_arrays(pairs, np.array([[0, 0, 1], [1, 2, 2]]))) i_first = generator.interval_first[(0, 2)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[0, 1], [0, 0]]))) i_sec = generator.interval_second[(0, 2)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[0, 1], [2, 2]]))) i_first = generator.interval_first[(0, 2)][1] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[2, 3], [0, 0]]))) i_sec = generator.interval_second[(0, 2)][1] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[2, 3], [2, 2]]))) i_first = generator.interval_first[(0, 1)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[1, 2], [0, 0]]))) i_sec = generator.interval_second[(0, 1)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[1, 2], [1, 1]]))) i_first = generator.interval_first[(1, 2)][0] self.assertTrue(test_utils.compare_arrays(i_first, np.array([[1, 2], [1, 1]]))) i_sec = generator.interval_second[(1, 2)][0] self.assertTrue(test_utils.compare_arrays(i_sec, np.array([[1, 2], [2, 2]])))
def test_one_fracture_one_constraint(self): self.setUp() network = pp.FractureNetwork2d(self.p2, self.e2, domain=self.domain) gb = network.mesh(self.mesh_args, constraints=np.array(1)) self.assertTrue(len(gb.grids_of_dimension(2)) == 1) self.assertTrue(len(gb.grids_of_dimension(1)) == 1) self.assertTrue(len(gb.grids_of_dimension(0)) == 0)
def test_two_fractures(self): self.setUp() network = pp.FractureNetwork2d(self.p2, self.e2, domain=self.domain) gb = network.mesh(self.mesh_args) self.assertTrue(len(gb.grids_of_dimension(2)) == 1) self.assertTrue(len(gb.grids_of_dimension(1)) == 2) self.assertTrue(len(gb.grids_of_dimension(0)) == 1)
def create_grid(self): """ Method that creates and returns the GridBucket of a 2D domain with six fractures. The two sides of the fractures are coupled together with a mortar grid. """ rotate_fracture = getattr(self, "rotate_fracture", False) if rotate_fracture: self.frac_pts = np.array([[0.7, 0.3], [0.3, 0.7]]) else: self.frac_pts = np.array([[0.3, 0.7], [0.5, 0.5]]) frac_edges = np.array([[0], [1]]) self.box = {"xmin": 0, "ymin": 0, "xmax": 1, "ymax": 1} network = pp.FractureNetwork2d(self.frac_pts, frac_edges, domain=self.box) # Generate the mixed-dimensional mesh gb = network.mesh(self.mesh_args) # Set projections to local coordinates for all fractures pp.contact_conditions.set_projections(gb) self.gb = gb self.Nd = gb.dim_max()
def grid(self): domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} mesh_size = {"mesh_size_frac": 0.3, "mesh_size_bound": 0.3} network = pp.FractureNetwork2d(domain=domain) gb = network.mesh(mesh_size) return gb.grids_of_dimension(2)[0]
def test_constrain_to_domain(self): network = pp.FractureNetwork2d(self.p, self.e, self.domain) new_network = network.constrain_to_domain() self.assertTrue(test_utils.compare_arrays(self.p, new_network.pts)) small_network = network.constrain_to_domain(self.small_domain) known_points = np.array([[0, 1.5, 1, 1], [0, 0, 0, 1]]) self.assertTrue(test_utils.compare_arrays(known_points, small_network.pts))
def test_no_snapping(self): p = np.array([[0, 1, 0, 1], [0, 0, 1, 1]]) e = np.array([[0, 2], [1, 3]]) network = pp.FractureNetwork2d(p, e) pn, conv = network._snap_fracture_set(p, snap_tol=1e-3) self.assertTrue(np.allclose(p, pn)) self.assertTrue(conv)
def test_copy(self): network_1 = pp.FractureNetwork2d(self.p, self.e) copy = network_1.copy() num_p = self.p.shape[1] network_1.pts = np.random.rand(2, num_p) self.assertTrue(np.allclose(copy.pts, self.p))
def test_snap_to_segment(self): p = np.array([[0, 1, 0.5, 1], [0, 0, 1e-4, 1]]) e = np.array([[0, 2], [1, 3]]) network = pp.FractureNetwork2d(p, e) pn, conv = network._snap_fracture_set(p, snap_tol=1e-3) p_known = np.array([[0, 1, 0.5, 1], [0, 0, 0, 1]]) self.assertTrue(np.allclose(p_known, pn)) self.assertTrue(conv)
def test_no_snap_to_vertex_small_tol(self): # No snapping because the snapping tolerance is small p = np.array([[0, 1, 0, 1], [0, 0, 1e-4, 1]]) e = np.array([[0, 2], [1, 3]]) network = pp.FractureNetwork2d(p, e) pn, conv = network._snap_fracture_set(p, snap_tol=1e-5) self.assertTrue(np.allclose(p, pn)) self.assertTrue(conv)
def main(): h = 0.125 tol = 1e-6 mesh_args = {"mesh_size_frac": h} domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 2} folder = "case3" # Point coordinates, as a 2xn array p = np.array([[0, 1], [1, 1]]) # Point connections as a 2 x num_frac arary e = np.array([[0], [1]]) # Define a fracture network in 2d network_2d = pp.FractureNetwork2d(p, e, domain) # Generate a mixed-dimensional mesh gb = network_2d.mesh(mesh_args) #pp.plot_grid(gb, alpha=0, info="all") # the flow problem time_step = 0.1 end_time = 1 param = { "domain": gb.bounding_box(as_dict=True), "tol": tol, "k": 1, "aperture": 1e-2, "kf_t": 1e2, "kf_n": 1e8, "mass_weight": 1.0/time_step, # inverse of the time step "num_steps": int(end_time/time_step), "L": 1, # l-scheme constant "beta": 1, # non-linearity constant } # create the Darcy problem flow = Flow(gb, folder, tol) flow.data(param, bc_flag) # create the matrix A, M, b, block_dof, full_dof = flow.matrix_rhs() # solve the problem x = np.zeros(A.shape[0]) for n in np.arange(param["num_steps"]): # define the rhs for the current step x = flow.solve(A, b + M.dot(x)) # extract and export the solution flow.extract(x, block_dof, full_dof) flow.export(n) # export the pdv file flow.export_pvd(np.arange(param["num_steps"])*time_step)
def test_fracture_auxiliary(self): domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} frac_start = np.array([[0.5], [0.25]]) frac_end = np.array([[0.5], [0.75]]) p = np.hstack((frac_start, frac_end)) e = np.array([0, 1]).reshape((2, -1), order="F") network = pp.FractureNetwork2d(p, e, domain) mesh_args = {"mesh_size_frac": 1} subdomain_start = np.array([[0.25], [0.5]]) subdomain_end = np.array([[0.5], [0.5]]) subdomain = { "points": np.hstack((subdomain_start, subdomain_end)), "edges": np.array([0, 1]).reshape((2, -1), order="F"), } gb = network.mesh(mesh_args, constraints=subdomain) g = gb.grids_of_dimension(2)[0] tag = np.where(g.tags["domain_boundary_0_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 0)) tag = np.where(g.tags["domain_boundary_1_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 1)) # domain_boundary_2 should be at y=1 tag = np.where(g.tags["domain_boundary_2_faces"])[0] self.assertTrue(np.allclose(g.face_centers[1, tag], 1)) tag = np.where(g.tags["domain_boundary_3_faces"])[0] self.assertTrue(np.allclose(g.face_centers[0, tag], 0)) fc = g.face_centers[:2] tag = g.tags["fracture_4_faces"] dist, _ = pp.distances.points_segments(fc, frac_start, frac_end) self.assertTrue(np.allclose(dist[tag, 0], 0)) self.assertTrue( np.all(np.logical_not(np.allclose(dist[np.logical_not(tag), 0], 0))) ) tag = g.tags["auxiliary_5_faces"] dist, _ = pp.distances.points_segments(fc, subdomain_start, subdomain_end) self.assertTrue(np.allclose(dist[tag, 0], 0)) self.assertTrue( np.all(np.logical_not(np.allclose(dist[np.logical_not(tag), 0], 0))) )
def test_angle_0_pi(self): num_frac = 10 start = np.zeros((2, num_frac)) end = 2 * np.random.rand(2, num_frac) - 1 p = np.hstack((start, end)) e = np.vstack((np.arange(num_frac), num_frac + np.arange(num_frac))) network = pp.FractureNetwork2d(p, e) angle = network.orientation() self.assertTrue(np.all(angle >= 0)) self.assertTrue(np.all(angle < np.pi))
def create_gb(mesh_size): domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1} delta = 0.00125 frac_pts = np.array([[0.1, 0.9], [0, 0.8]]) norm = np.array( [[-frac_pts[1, 1] + frac_pts[1, 0], frac_pts[0, 1] - frac_pts[0, 0]]]) norm /= np.linalg.norm(norm) pts = np.hstack( (frac_pts, frac_pts + delta * norm.T, frac_pts - delta * norm.T)) edges = np.array([[0, 2, 4], [1, 3, 5]]) # assign the flag for the low permeable fractures mesh_kwargs = { "mesh_size_frac": mesh_size, "mesh_size_min": mesh_size / 200 } # Generate a mixed-dimensional mesh network = pp.FractureNetwork2d(pts, edges, domain) # Generate a mixed-dimensional mesh gb = network.mesh(mesh_kwargs, constraints=[1, 2]) for _, d in gb.edges(): d[pp.PRIMARY_VARIABLES] = {} d[pp.COUPLING_DISCRETIZATION] = {} d[pp.DISCRETIZATION_MATRICES] = {} d[pp.STATE] = {} # identification of layer and fracture for g, d in gb: d[pp.PRIMARY_VARIABLES] = {} d[pp.DISCRETIZATION] = {} d[pp.DISCRETIZATION_MATRICES] = {} d[pp.STATE] = {} if g.dim < gb.dim_max(): g.name += ["fracture"] # save the identification of the fracture if "fracture" in g.name: d[pp.STATE]["fracture"] = np.ones(g.num_cells) d[pp.STATE]["layer"] = np.zeros(g.num_cells) # save zero for the other cases else: d[pp.STATE]["fracture"] = np.zeros(g.num_cells) d[pp.STATE]["layer"] = np.zeros(g.num_cells) return gb
def test_no_pairs(self): # Test identification of parallel fractures. # Test should find no pairs self.setUp() p = np.array([[0, 1, 2, 3], [0, 0, 1, 1]]) e = np.array([[0, 2], [1, 3]]) network = pp.FractureNetwork2d(p, e, self.domain) generator = self.generator(network) pairs = generator.parent_pairs self.assertTrue(len(pairs) == 0) self.assertTrue(len(generator.interval_first) == 0) self.assertTrue(len(generator.interval_second) == 0)
def test_snap_fractures(self): p = np.array([[0, 2, 1, 1], [0, 0, 1e-3, 1]]) e = np.array([[0, 2], [1, 3]]) network = pp.FractureNetwork2d(p, e) snapped = network.snap(tol=1e-2) known_points = np.array([[0, 2, 1, 1], [0, 0, 0, 1]]) self.assertTrue(test_utils.compare_arrays(known_points, snapped.pts)) snapped_2 = network.snap(tol=1e-4) self.assertTrue(test_utils.compare_arrays(p, snapped_2.pts))
def test_add_networks_preserve_tags(self): network_1 = pp.FractureNetwork2d(self.p, self.e) p2 = np.array([[0, 2, 1, 1], [0, 0, 0, 1]]) + 2 # Network 2 has tags tag2 = 1 e2 = np.array([[0, 2], [1, 3], [1, 1]]) network_2 = pp.FractureNetwork2d(p2, e2) # Add networks, check tags together = network_1.add_network(network_2) self.assertTrue(np.all(together.edges[2, 2:4] == tag2)) # Add networks reverse order together = network_2.add_network(network_1) self.assertTrue(np.all(together.edges[2, :2] == tag2)) # Assign tags to network1 tag1 = 2 network_1.edges = np.vstack((network_1.edges, tag1 * np.ones(2))) together = network_1.add_network(network_2) known_tags = np.array([tag1, tag1, tag2, tag2]) self.assertTrue(np.all(together.edges[2] == known_tags))