def test_tpfa_cart_grid_2d_boundary_face(self):

        g = create_grids.cart_2d()

        boundary_face = 3
        cells = [2]

        reg = ia_reg.extract_tpfa_regions(g, faces=[boundary_face])[0]

        fn = g.face_nodes.indices.reshape((2, -1), order="f")

        fn_loc = fn[:, boundary_face]

        known_surfaces = np.array([
            [cells[0], fn_loc[0]],
            [cells[0], fn_loc[1]],
            [fn_loc[0], fn_loc[1]],  # boundary surface
        ])

        self.assertTrue(
            test_utils.compare_arrays(known_surfaces.T, reg.surfaces.T))

        for et in reg.edge_node_type:
            self.assertTrue(et == ("cell", "node"))

        for surf, bound_info, node_types in zip(reg.surfaces,
                                                reg.surface_is_boundary,
                                                reg.surface_node_type):
            if np.all(np.isin(surf, fn_loc)):
                # This is a boundary surface
                self.assertTrue(bound_info == True)
                self.assertTrue(node_types == ("node", "node"))
            else:
                self.assertTrue(bound_info == False)
                self.assertTrue(node_types == ("cell", "node"))
    def test_3d_internal_tpfa(self):
        g = create_grids.cart_3d()
        interior_face = 4

        reg = ia_reg.extract_tpfa_regions(g, faces=[interior_face])[0]

        reg.mesh()
def test_tpfa_2d_internal_boundary():
    gb = pp.meshing.cart_grid([np.array([[0, 1], [1, 1]])], np.array([1, 2]))
    g = gb.grids_of_dimension(2)[0]
    frac_faces = np.where(g.tags["fracture_faces"])[0]

    if g.cell_faces[frac_faces[0], 0] != 0:
        cells = [0, 1]
    else:
        cells = [1, 0]
    nodes = [
        g.face_nodes[:, frac_faces[0]].indices,
        g.face_nodes[:, frac_faces[1]].indices,
    ]

    for i, fi in enumerate(frac_faces):
        reg = ia_reg.extract_tpfa_regions(g, [fi])[0]

        known_surfaces = np.array([
            [cells[i], nodes[i][0]],
            [cells[i], nodes[i][1]],
            [nodes[i][0], nodes[i][1]],
        ])

        assert test_utils.compare_arrays(known_surfaces.T, reg.surfaces.T)

        known_edges = np.array([[cells[i], nodes[i][0]],
                                [cells[i], nodes[i][1]]])

        assert test_utils.compare_arrays(known_edges.T, reg.edges.T)
    def test_2d_boundary_tpfa(self):
        g = create_grids.cart_2d()
        boundary_face = 3

        reg = ia_reg.extract_tpfa_regions(g, faces=[boundary_face])[0]

        reg.mesh()
    def test_2d_boundary_tpfa_with_fracture(self):
        g = create_grids.cart_2d()
        face = 3

        reg = ia_reg.extract_tpfa_regions(g, faces=[face])[0]
        p = np.array([[0.0, 1.3], [1.1, 1.5]])
        edges = np.array([[0], [1]])

        reg.add_fractures(points=p, edges=edges)
        reg.mesh()
    def test_2d_internal_tpfa_with_fracture(self):
        g = create_grids.cart_2d()
        interior_face = 4

        reg = ia_reg.extract_tpfa_regions(g, faces=[interior_face])[0]
        p = np.array([[0.7, 1.3], [1.5, 1.5]])
        edges = np.array([[0], [1]])

        reg.add_fractures(points=p, edges=edges)
        reg.mesh()
    def test_tpfa_boundary_domain_2d_with_fractures(self):
        g = create_grids.cart_2d()
        reg = ia_reg.extract_tpfa_regions(g, faces=[3])[0]

        # Two crossing fractures. One internal to the domain, one crosses the boundary
        p = np.array([[-0.7, 1.3, 0.1, 0.5], [1.2, 1.2, 0.9, 1.7]])
        e = np.array([[0, 2], [1, 3]])
        reg.add_fractures(points=p, edges=e)

        local_gb = LocalGridBucketSet(2, reg)
        local_gb.construct_local_buckets()
    def test_3d_boundary_tpfa_with_fracture(self):
        g = create_grids.cart_3d()
        interior_face = 3

        reg = ia_reg.extract_tpfa_regions(g, faces=[interior_face])[0]

        frac = pp.Fracture(
            np.array([[0.0, 0.3, 0.3, 0.0], [1.5, 1.5, 1.5, 1.5],
                      [0.2, 0.2, 0.8, 0.8]]))
        reg.add_fractures(fractures=[frac])
        reg.mesh()
    def test_tpfa_internal_domain_3d_with_fractures(self):
        g = create_grids.cart_3d()
        reg = ia_reg.extract_tpfa_regions(g, faces=[4])[0]

        f_1 = pp.Fracture(
            np.array([[0.7, 1.4, 1.4, 0.7], [0.5, 0.5, 1.4, 1.4], [0.6, 0.6, 0.6, 0.6]])
        )
        f_2 = pp.Fracture(
            np.array([[1.1, 1.1, 1.1, 1.1], [0.7, 1.4, 1.4, 0.7], [0.2, 0.2, 0.8, 0.8]])
        )
        reg.add_fractures(fractures=[f_1, f_2])

        local_gb = LocalGridBucketSet(3, reg)
        local_gb.construct_local_buckets()
    def test_tpfa_boundary_domain_3d_with_fractures(self):
        g = create_grids.cart_3d()
        reg = ia_reg.extract_tpfa_regions(g, faces=[3])[0]

        f_1 = pp.Fracture(
            np.array(
                [[-0.7, 1.4, 1.4, -0.7], [0.4, 0.4, 1.4, 1.4], [0.6, 0.6, 0.6, 0.6]]
            )
        )
        f_2 = pp.Fracture(
            np.array([[0.1, 0.1, 0.1, 0.1], [0.3, 1.4, 1.4, 0.3], [0.1, 0.1, 0.9, 0.9]])
        )
        reg.add_fractures(fractures=[f_1, f_2])

        local_gb = LocalGridBucketSet(3, reg)
        local_gb.construct_local_buckets()
    def test_tpfa_cart_grid_3d_interior_face(self):

        g = create_grids.cart_3d()

        interior_face = 4
        cells = [2, 3]

        reg = ia_reg.extract_tpfa_regions(g, faces=[interior_face])[0]

        fn = g.face_nodes.indices.reshape((4, -1), order="f")

        fn_loc = fn[:, interior_face]

        known_surfaces = np.array([
            [cells[0], fn_loc[0], fn_loc[1]],
            [cells[0], fn_loc[1], fn_loc[2]],
            [cells[0], fn_loc[2], fn_loc[3]],
            [cells[0], fn_loc[3], fn_loc[0]],
            [cells[1], fn_loc[0], fn_loc[1]],
            [cells[1], fn_loc[1], fn_loc[2]],
            [cells[1], fn_loc[2], fn_loc[3]],
            [cells[1], fn_loc[3], fn_loc[0]],
        ])

        self.assertTrue(
            test_utils.compare_arrays(known_surfaces.T, reg.surfaces.T))

        known_edges = np.array([
            [cells[0], fn_loc[0], cells[1]],
            [cells[0], fn_loc[1], cells[1]],
            [cells[0], fn_loc[2], cells[1]],
            [cells[0], fn_loc[3], cells[1]],
        ])
        self.assertTrue(test_utils.compare_arrays(known_edges.T, reg.edges.T))

        for et in reg.edge_node_type:
            self.assertTrue(et == ("cell", "node", "cell"))
 def test_regions_different_grids(self):
     # Run through all prepared simple grids, check that the creation does not break
     for g in create_grids.create_grids():
         _ = ia_reg.extract_tpfa_regions(g)
         _ = ia_reg.extract_mpfa_regions(g)
 def test_tpfa_internal_domain_3d(self):
     g = create_grids.cart_3d()
     reg = ia_reg.extract_tpfa_regions(g, faces=[4])[0]
     local_gb = LocalGridBucketSet(3, reg)
     local_gb.construct_local_buckets()
 def test_tpfa_boundary_domain_2d(self):
     g = create_grids.cart_2d()
     reg = ia_reg.extract_tpfa_regions(g, faces=[3])[0]
     local_gb = LocalGridBucketSet(2, reg)
     local_gb.construct_local_buckets()
示例#15
0
 def _interaction_regions(self, g):
     for fi in range(g.num_faces):
         yield ia_reg.extract_tpfa_regions(g, fi)[0]