Exemplo n.º 1
0
    def run_vem(self, gb):
        solver_flow = vem_dual.DualVEMMixedDim("flow")
        A_flow, b_flow = solver_flow.matrix_rhs(gb)

        up = sps.linalg.spsolve(A_flow, b_flow)
        solver_flow.split(gb, "up", up)
        solver_flow.extract_p(gb, "up", "pressure")
Exemplo n.º 2
0
def main(kf, description, is_coarse=False, if_export=False):
    mesh_kwargs = {}
    mesh_kwargs['mesh_size'] = {
        'mode': 'constant',
        'value': 0.045,
        'bound_value': 0.045
    }

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

    file_name = 'network_geiger.csv'
    write_network(file_name)
    gb = importer.dfm_2d_from_csv(file_name, mesh_kwargs, domain)
    gb.compute_geometry()
    if is_coarse:
        co.coarsen(gb, 'by_volume')
    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_flow = vem_dual.DualVEMMixedDim('flow')
    A_flow, b_flow = solver_flow.matrix_rhs(gb)

    solver_source = vem_source.IntegralMixedDim('flow')
    A_source, b_source = solver_source.matrix_rhs(gb)

    up = sps.linalg.spsolve(A_flow + A_source, b_flow + b_source)
    solver_flow.split(gb, "up", up)

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

    if if_export:
        save = Exporter(gb, "vem", folder="vem_" + description)
        save.write_vtk(['pressure', "P0u"])
gb = importer.dfm_2d_from_csv(folder + 'network.csv', mesh_kwargs, domain)
gb.compute_geometry()
gb.assign_node_ordering()

gb.add_node_props(['face_tags'])
for g, d in gb:
    d['face_tags'] = g.face_tags.copy()

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

# Assign parameters
add_data_darcy(gb, domain, tol)

# Choose and define the solvers and coupler
darcy = vem_dual.DualVEMMixedDim('flow')
A_flow, b_flow = darcy.matrix_rhs(gb)

solver_source = vem_source.IntegralMixedDim('flow')
A_source, b_source = solver_source.matrix_rhs(gb)

up = sps.linalg.spsolve(A_flow + A_source, b_flow + b_source)
darcy.split(gb, "up", up)

gb.add_node_props(['pressure', "P0u"])
for g, d in gb:
    discharge = darcy.discr.extract_u(g, d["up"])
    d['discharge'] = discharge
    d['pressure'] = darcy.discr.extract_p(g, d["up"])
    d["P0u"] = darcy.discr.project_u(g, discharge, d)
do_save = False
folder = os.path.dirname(os.path.realpath(__file__)) + "/"
export_folder = folder + "advection_diffusion_coupling"
tol = 1e-3

mesh_kwargs = {"mesh_size_frac": 0.045, "mesh_size_min": 0.01}
domain = {"xmin": -0.2, "xmax": 1.2, "ymin": -0.2, "ymax": 1.2}
gb = importer.dfm_2d_from_csv(folder + "network.csv", mesh_kwargs, domain)
gb.compute_geometry()
gb.assign_node_ordering()

# Assign parameters
add_data_darcy(gb, domain, tol)

# Choose and define the solvers and coupler
darcy = vem_dual.DualVEMMixedDim("flow")
A_flow, b_flow = darcy.matrix_rhs(gb)

solver_source = vem_source.DualSourceMixedDim("flow", coupling=[None])
A_source, b_source = solver_source.matrix_rhs(gb)

up = sps.linalg.spsolve(A_flow + A_source, b_flow + b_source)
darcy.split(gb, "up", up)

gb.add_node_props(["pressure", "P0u"])
for g, d in gb:
    discharge = darcy.discr.extract_u(g, d["up"])
    d["discharge"] = discharge
    d["pressure"] = darcy.discr.extract_p(g, d["up"])
    d["P0u"] = darcy.discr.project_u(g, discharge, d)
Exemplo n.º 5
0
 def flux_disc(self):
     if self.is_GridBucket:
         return vem_dual.DualVEMMixedDim(physics=self.physics)
     else:
         return vem_dual.DualVEM(physics=self.physics)