예제 #1
0
    def test_two_lines_no_snap(self):
        p = np.array([[0, 1, 0.5, 0.5], [0, 0, 1e-3, 1]])
        e = np.array([[0, 2], [1, 3]])
        tol = 1e-4

        p_new = cg.snap_points_to_segments(p, e, tol)
        assert np.allclose(p_new, p)
예제 #2
0
    def test_snapping_3d(self):
        p = np.array([[0, 1, 0.5, 0.5], [0, 0, 1e-3, 1], [0, 1, 0.5, 1]])
        e = np.array([[0, 2], [1, 3]])
        tol = 1e-2

        p_new = cg.snap_points_to_segments(p, e, tol)
        p_known = np.array([[0, 1, 0.5, 0.5], [0, 0, 0, 1], [0, 1, 0.5, 1]])
        assert np.allclose(p_new, p_known)
예제 #3
0
    def test_single_point_no_snap(self):
        p = np.array([[0, 1], [0, 0]])
        e = np.array([[0], [1]])
        tol = 1e-4
        p_snap = np.array([[0.5], [1e-3]])

        p_new = cg.snap_points_to_segments(p, e, tol, p_snap)
        assert np.allclose(p_snap, p_new)
예제 #4
0
    def test_vertex_snaps(self):
        p = np.array([[0, 1, 0., 0.], [0, 0, 1e-3, 1]])
        e = np.array([[0, 2], [1, 3]])
        tol = 1e-2

        p_new = cg.snap_points_to_segments(p, e, tol)
        p_known = np.array([[0, 1, 0., 0.], [0, 0, 0, 1]])
        self.assertTrue(np.allclose(p_new, p_known))
예제 #5
0
def create(conforming, tol=1e-4):

    csv_folder = "./"
    csv_file = "example_4_outcrop.csv"
    pts, edges = importer.lines_from_csv(csv_folder + csv_file)

    # A tolerance of 1 seems to be sufficient to recover the T-intersections, but
    # I might have missed some, though, so take a look at the network and modify
    # if necessary.
    snap_pts = cg.snap_points_to_segments(pts, edges, tol=1)

    extrusion_kwargs = {}
    extrusion_kwargs["tol"] = tol
    extrusion_kwargs["exposure_angle"] = np.pi / 4.0 * np.ones(edges.shape[1])
    # Added an option not to include the points on the exposed surface. This
    # reduces cell refinement somewhat, but setting it True should also be okay
    extrusion_kwargs["outcrop_consistent"] = True

    fractures = extrusion.fractures_from_outcrop(snap_pts, edges,
                                                 **extrusion_kwargs)
    network = FractureNetwork(fractures, tol=tol)
    # network.to_vtk(folder_export+"network.vtu")
    bounding_box = {
        "xmin": -800,
        "xmax": 600,
        "ymin": 100,
        "ymax": 1500,
        "zmin": -100,
        "zmax": 1000,
    }
    network.impose_external_boundary(bounding_box,
                                     truncate_fractures=True,
                                     keep_box=False)

    mesh_kwargs = {}
    h = 30
    mesh_kwargs["mesh_size"] = {
        "mode": "weighted",  # 'distance'
        "value": h,
        "bound_value": h,
        "tol": tol,
    }

    if conforming:
        # Change h_ideal and h_min at will here, but I ran into trouble with h_min < 1.
        gb = meshing.dfn(network, conforming=True, h_ideal=100, h_min=5)
    else:
        # Switch conforming=True to get conforming meshes
        gb = meshing.dfn(network,
                         conforming=False,
                         **mesh_kwargs,
                         keep_geo=True)

    gb.remove_nodes(lambda g: g.dim == 0)
    gb.compute_geometry()
    gb.assign_node_ordering()

    return gb
예제 #6
0
    def test_single_point_snap(self):
        p = np.array([[0, 1], [0, 0]])
        e = np.array([[0], [1]])
        tol = 1e-4
        p_snap = np.array([[0.5], [1e-5]])

        p_new = cg.snap_points_to_segments(p, e, tol, p_snap)
        p_known = np.array([[0.5], [0]])
        self.assertTrue(np.allclose(p_known, p_new, rtol=1e-8))