def test_x_intersection_2d(self): """ Check that no error messages are created in the process of creating a split_fracture. """ f_1 = np.array([[0, 2], [1, 1]]) f_2 = np.array([[1, 1], [0, 2]]) f_set = [f_1, f_2] nx = [3, 3] grids = structured.cart_grid_2d(f_set, nx, physdims=nx) num_grids = [1, 2, 1] for i, g in enumerate(grids): assert len(g) == num_grids[i] g_2d = grids[0][0] g_1d_1 = grids[1][0] g_1d_2 = grids[1][1] g_0d = grids[2][0] f_nodes_1 = [4, 5, 6] f_nodes_2 = [1, 5, 9] f_nodes_0 = [5] glob_1 = np.sort(g_1d_1.global_point_ind) glob_2 = np.sort(g_1d_2.global_point_ind) glob_0 = np.sort(np.atleast_1d(g_0d.global_point_ind)) assert np.all(f_nodes_1 == glob_1) assert np.all(f_nodes_2 == glob_2) assert np.all(f_nodes_0 == glob_0)
def cart_grid(fracs, nx, **kwargs): """ Creates a cartesian fractured GridBucket in 2- or 3-dimensions. Parameters ---------- fracs (list of np.ndarray): One list item for each fracture. Each item consist of a (nd x 3) array describing fracture vertices. The fractures has to be rectangles(3D) or straight lines(2D) that alignes with the axis. The fractures may be intersecting. The fractures will snap to closest grid faces. nx (np.ndarray): Number of cells in each direction. Should be 2D or 3D **kwargs: physdims (np.ndarray): Physical dimensions in each direction. Defaults to same as nx, that is, cells of unit size. May also contain fracture tags, options for gridding, etc. Returns: ------- GridBucket: A complete bucket where all fractures are represented as lower dim grids. The higher dim fracture faces are split in two, and on the edges of the GridBucket graph the mapping from lower dim cells to higher dim faces are stored as 'face_cells'. Each face is given boolean tags depending on the type: domain_boundary_faces: All faces that lie on the domain boundary (i.e. should be given a boundary condition). fracture_faces: All faces that are split (i.e. has a connection to a lower dim grid). tip_faces: A boundary face that is not on the domain boundary, nor coupled to a lower domentional domain. The union of the above three is the tag boundary_faces. Examples -------- frac1 = np.array([[1,4],[2,2]]) frac2 = np.array([[2,2],[4,1]]) fracs = [frac1, frac2] gb = cart_grid(fracs, [5,5]) """ ndim = np.asarray(nx).size physdims = kwargs.get('physdims', None) if physdims is None: physdims = nx elif np.asarray(physdims).size != ndim: raise ValueError('Physical dimension must equal grid dimension') # Call relevant method, depending on grid dimensions if ndim == 2: grids = structured.cart_grid_2d(fracs, nx, physdims=physdims) elif ndim == 3: grids = structured.cart_grid_3d(fracs, nx, physdims=physdims) else: raise ValueError('Only support for 2 and 3 dimensions') return grid_list_to_grid_bucket(grids, **kwargs)