예제 #1
0
def dfn_3d_from_fab(file_name,
                    file_inters=None,
                    conforming=True,
                    tol=None,
                    vtk_name=None,
                    **kwargs):
    """ Read the fractures and (possible) intersection from files.
    The fractures are in a .fab file, as specified by FracMan.
    The intersection are specified in the function intersection_dfn_3d.

    Parameters:
        file_name (str): Path to .fab file.
        file_intersections (str): Optional path to intersection file.
        conforming (boolean): If True, the mesh will be conforming along 1d
            intersections.
        vtk_name (str): Gives the possibility to export the network in a vtu
            file. Consider the suffix of the file as ".vtu".
        **kwargs: Parameters passed to gmsh.

    Returns:
        gb (GridBucket): The grid bucket.

    """
    network = network_3d_from_fab(file_name, return_all=False, tol=tol)

    if vtk_name is not None:
        network.to_vtk(vtk_name)

    if file_inters is None:
        return meshing.dfn(network, conforming, **kwargs)
    else:
        inters = intersection_dfn_3d(file_inters, fractures)
        return meshing.dfn(network, conforming, inters, **kwargs)
예제 #2
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
예제 #3
0
def test_conforming_two_fractures():
    f_1 = Fracture(
        np.array([[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]]).T)
    f_2 = Fracture(
        np.array([[-1, 0, -1], [1, 0, -1], [1, 0, 1], [-1, 0, 1]]).T)
    network = FractureNetwork([f_1, f_2])
    gb = meshing.dfn(network, conforming=True)
예제 #4
0
def test_non_conforming_three_fractures():
    f_1 = Fracture(
        np.array([[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]]).T)
    f_2 = Fracture(
        np.array([[-1, 0, -1], [1, 0, -1], [1, 0, 1], [-1, 0, 1]]).T)
    f_3 = Fracture(
        np.array([[0, -1, -1], [0, 1, -1], [0, 1, 1], [0, -1, 1]]).T)
    network = FractureNetwork([f_1, f_2, f_3])
    gb = meshing.dfn(network, conforming=False)
예제 #5
0
# import the dfm and generate the grids
gb, domain = importer.dfm_3d_from_csv(file_dfm, tol, h_ideal=0.2, h_min=0.2)
gb.compute_geometry()

for _, d in gb.edges_props():
    mg = d["mortar_grid"]
    # print(mg.high_to_mortar.shape[0])

dom_min = 0
dom_max = 1

if True:
    frac_list, network, domain = importer.network_3d_from_csv("geiger_3d.csv")
    # Conforming=False would have been cool here, but that does not split the 1d grids
    gb_new = meshing.dfn(frac_list, conforming=True, h_ideal=0.07, h_min=0.05)

    gmap = {}
    for go in gb.grids_of_dimension(2):
        for gn in gb_new.grids_of_dimension(2):
            if gn.frac_num == go.frac_num:
                gmap[go] = gn
                xf = gn.face_centers
                hit = np.logical_or(
                    np.any(np.abs(xf - dom_min) < tol, axis=0),
                    np.any(np.abs(xf - dom_max) < tol, axis=0),
                )
                domain_tag = FaceTag.DOMAIN_BOUNDARY
                gn.remove_face_tag_if_tag(domain_tag, domain_tag)
                gn.add_face_tag(np.where(hit)[0], domain_tag)