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_mpfa_cart_grid_2d_interior_node(self):
        g = create_grids.cart_2d()

        interior_node = 4
        # cells = [0, 1, 2, 3]
        # faces = [1, 4, 11, 12]

        reg = ia_reg.extract_mpfa_regions(g, interior_node)[0]

        known_edges = np.array([[0, 11, 2], [0, 1, 1], [1, 12, 3], [2, 4, 3]])

        known_surfaces = np.array([[0, 1], [1, 1], [0, 11], [2, 11], [2, 4],
                                   [3, 4], [3, 12], [1, 12]])

        self.assertTrue(
            test_utils.compare_arrays(known_surfaces.T, reg.surfaces.T))
        self.assertTrue(test_utils.compare_arrays(known_edges.T, reg.edges.T))
    def test_mpfa_cart_grid_2d_boundary_node(self):
        g = create_grids.cart_2d()

        interior_node = 3
        cells = [0, 2]
        faces = [0, 3, 11]

        reg = ia_reg.extract_mpfa_regions(g, interior_node)[0]

        known_edges = np.array([[0, 0], [0, 11, 2], [2, 3]])

        known_surfaces = np.array([[0, 0], [0, 11], [2, 11], [2, 3], [0, 3],
                                   [3, 3]])

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

        for i in range(reg.edges.size):
            if len(reg.edges[i]) == 2:
                self.assertTrue(reg.edge_node_type[i] == ("cell", "face"))
            if len(reg.edges[i]) == 3:
                self.assertTrue(reg.edge_node_type[i] == ("cell", "face",
                                                          "cell"))

        for surf, bound_info, node_types in zip(reg.surfaces,
                                                reg.surface_is_boundary,
                                                reg.surface_node_type):
            if "node" in node_types:
                # This is a boundary surface
                self.assertTrue(bound_info == True)
                self.assertTrue(node_types == ("face", "node"))
                self.assertTrue(surf[-1] == interior_node)
                self.assertTrue(np.any(surf[0] == faces))
            else:
                self.assertTrue(bound_info == False)
                self.assertTrue(node_types == ("cell", "face"))
    def test_tpfa_cart_grid_2d_interior_face(self):

        g = create_grids.cart_2d()

        interior_face = 4
        cells = [2, 3]

        fn = g.face_nodes.indices.reshape((2, -1), order="f")
        fn_loc = fn[:, interior_face]

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

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

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

        for et in reg.edge_node_type:
            self.assertTrue(et == ("cell", "node", "cell"))
 def test_mpfa_boundary_domain_2d(self):
     g = create_grids.cart_2d()
     reg = ia_reg.extract_mpfa_regions(g, nodes=[3])[0]
     local_gb = LocalGridBucketSet(2, reg)
     local_gb.construct_local_buckets()
 def test_tpfa_internal_domain_2d(self):
     g = create_grids.cart_2d()
     reg = ia_reg.extract_tpfa_regions(g, faces=[4])[0]
     local_gb = LocalGridBucketSet(2, reg)
     local_gb.construct_local_buckets()