Ejemplo n.º 1
0
def main(kf, description, mesh_size):
    mesh_kwargs = {}
    mesh_kwargs["mesh_size"] = {
        "mode": "constant",
        "value": mesh_size,
        "bound_value": mesh_size,
    }

    domain = {"xmin": 0, "xmax": 1, "ymin": 0, "ymax": 1}
    if_coarse = True

    folder = "example_5_1_1_" + description

    file_name = "network_geiger.csv"
    write_network(file_name)
    gb = importer.from_csv(file_name, mesh_kwargs, domain)
    gb.compute_geometry()

    g_fine = gb.get_grids(lambda g: g.dim == gb.dim_max())[0].copy()

    if if_coarse:
        partition = co.create_aggregations(gb)
        partition = co.reorder_partition(partition)
        co.generate_coarse_grid(gb, partition)

    gb.assign_node_ordering()

    # Assign parameters
    add_data(gb, domain, kf)

    # Choose and define the solvers and coupler
    solver = dual.DualVEMMixDim("flow")
    A, b = solver.matrix_rhs(gb)

    up = sps.linalg.spsolve(A, b)
    solver.split(gb, "up", up)

    gb.add_node_props(["discharge", "pressure", "P0u"])
    solver.extract_u(gb, "up", "discharge")
    solver.extract_p(gb, "up", "pressure")
    solver.project_u(gb, "discharge", "P0u")

    exporter.export_vtk(gb, "vem", ["pressure", "P0u"], folder=folder, binary=False)

    if if_coarse:
        partition = partition[gb.grids_of_dimension(gb.dim_max())[0]]
        p = np.array([d["pressure"] for g, d in gb if g.dim == gb.dim_max()]).ravel()
        data = {"partition": partition, "pressure": p[partition]}
        exporter.export_vtk(g_fine, "sub_grid", data, binary=False, folder=folder)

    print("diam", gb.diameter(lambda g: g.dim == gb.dim_max()))
    print("num_cells 2d", gb.num_cells(lambda g: g.dim == 2))
    print("num_cells 1d", gb.num_cells(lambda g: g.dim == 1))
Ejemplo n.º 2
0
# ------------------------------------------------------------------------------#
# ------------------------------------------------------------------------------#

tol = 1e-4
export_folder = "example_5_2_2"

T = 40 * np.pi * 1e7
Nt = 20  # 10 20 40 80 160 320 640 1280 2560 5120 - 100000
deltaT = T / Nt
export_every = 1
if_coarse = True

mesh_kwargs = {"mesh_size_frac": 500, "mesh_size_min": 20}
domain = {"xmin": 0, "xmax": 700, "ymin": 0, "ymax": 600}
gb = importer.from_csv("network.csv", mesh_kwargs, domain)
gb.compute_geometry()
if if_coarse:
    co.coarsen(gb, "by_volume")
gb.assign_node_ordering()

# Choose and define the solvers and coupler
darcy = dual.DualVEMMixDim("flow")

# Assign parameters
add_data_darcy(gb, domain, tol)

A, b = darcy.matrix_rhs(gb)

up = sps.linalg.spsolve(A, b)
darcy.split(gb, "up", up)
Ejemplo n.º 3
0
#------------------------------------------------------------------------------#

folder = os.path.dirname(os.path.realpath(__file__)) + "/"
export_folder = folder + 'heat'
tol = 1e-3
a = 1e-2

mesh_kwargs = {}
mesh_kwargs['mesh_size'] = {
    'mode': 'constant',
    'value': 0.045,
    'bound_value': 0.025
}

domain = {'xmin': -0.2, 'xmax': 1.2, 'ymin': -0.2, 'ymax': 1.2}
gb = importer.from_csv(folder + 'network.csv', mesh_kwargs, domain)
gb.compute_geometry()
#co.coarsen(gb, 'by_volume')
gb.assign_node_ordering()

# Choose and define the solvers and coupler
darcy = dual.DualVEMMixDim("flow")

# Assign parameters
add_data_darcy(gb, domain, tol, a)

A, b = darcy.matrix_rhs(gb)

up = sps.linalg.spsolve(A, b)
darcy.split(gb, "up", up)
Ejemplo n.º 4
0
def main(kf, description, mesh_size):
    mesh_kwargs = {}
    mesh_kwargs['mesh_size'] = {
        'mode': 'constant',
        'value': mesh_size,
        'bound_value': mesh_size
    }

    domain = {'xmin': 0, 'xmax': 1, 'ymin': 0, 'ymax': 1}
    if_coarse = True

    folder = 'example_5_1_1_' + description

    file_name = 'network_geiger.csv'
    write_network(file_name)
    gb = importer.from_csv(file_name, mesh_kwargs, domain)
    gb.compute_geometry()

    g_fine = gb.get_grids(lambda g: g.dim == gb.dim_max())[0].copy()

    if if_coarse:
        partition = co.create_aggregations(gb)
        partition = co.reorder_partition(partition)
        co.generate_coarse_grid(gb, partition)

    gb.assign_node_ordering()

    internal_flag = FaceTag.FRACTURE
    [g.remove_face_tag_if_tag(FaceTag.BOUNDARY, internal_flag) for g, _ in gb]

    # Assign parameters
    add_data(gb, domain, kf)

    # Choose and define the solvers and coupler
    solver = dual.DualVEMMixDim('flow')
    A, b = solver.matrix_rhs(gb)

    up = sps.linalg.spsolve(A, b)
    solver.split(gb, "up", up)

    gb.add_node_props(["discharge", 'pressure', "P0u"])
    solver.extract_u(gb, "up", "discharge")
    solver.extract_p(gb, "up", 'pressure')
    solver.project_u(gb, "discharge", "P0u")

    exporter.export_vtk(gb,
                        'vem', ['pressure', "P0u"],
                        folder=folder,
                        binary=False)

    if if_coarse:
        partition = partition[gb.grids_of_dimension(gb.dim_max())[0]]
        p = np.array([d['pressure'] for g, d in gb
                      if g.dim == gb.dim_max()]).ravel()
        data = {'partition': partition, 'pressure': p[partition]}
        exporter.export_vtk(g_fine,
                            'sub_grid',
                            data,
                            binary=False,
                            folder=folder)

    print("diam", gb.diameter(lambda g: g.dim == gb.dim_max()))
    print("num_cells 2d", gb.num_cells(lambda g: g.dim == 2))
    print("num_cells 1d", gb.num_cells(lambda g: g.dim == 1))