-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_XX.py
116 lines (81 loc) · 3.25 KB
/
example_XX.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import numpy as np
from porepy.viz import exporter
from porepy.fracs import importer
from porepy.params import tensor
from porepy.params.bc import BoundaryCondition
from porepy.params.data import Parameters
from porepy.grids.grid import FaceTag
from porepy.numerics import elliptic
from porepy.utils import comp_geom as cg
import create_porepy_grid
# ------------------------------------------------------------------------------#
def add_data(gb, domain, kf):
"""
Define the permeability, apertures, boundary conditions
"""
gb.add_node_props(["param"])
tol = 1e-5
a = 1e-3
for g, d in gb:
param = Parameters(g)
# Permeability
kxx = np.ones(g.num_cells) * np.power(kf, g.dim < gb.dim_max())
if g.dim == 2:
perm = tensor.SecondOrder(3, kxx=kxx, kyy=kxx, kzz=1)
else:
perm = tensor.SecondOrder(3, kxx=kxx, kyy=1, kzz=1)
if g.dim == 1:
R = cg.project_line_matrix(g.nodes, reference=[1, 0, 0])
perm.rotate(R)
param.set_tensor("flow", perm)
# Source term
param.set_source("flow", np.zeros(g.num_cells))
# Assign apertures
aperture = np.power(a, gb.dim_max() - g.dim)
param.set_aperture(np.ones(g.num_cells) * aperture)
# Boundaries
bound_faces = g.get_boundary_faces()
if bound_faces.size != 0:
bound_face_centers = g.face_centers[:, bound_faces]
bottom_corner = np.logical_and(
bound_face_centers[0, :] < 0.1, bound_face_centers[1, :] < 0.1
)
top_corner = np.logical_and(
bound_face_centers[0, :] > 0.9, bound_face_centers[1, :] > 0.9
)
labels = np.array(["neu"] * bound_faces.size)
dir_faces = np.logical_or(bottom_corner, top_corner)
labels[dir_faces] = "dir"
bc_val = np.zeros(g.num_faces)
bc_val[bound_faces[bottom_corner]] = 1
bc_val[bound_faces[top_corner]] = -1
param.set_bc("flow", BoundaryCondition(g, bound_faces, labels))
param.set_bc_val("flow", bc_val)
else:
param.set_bc("flow", BoundaryCondition(g, np.empty(0), np.empty(0)))
d["param"] = param
# Assign coupling permeability
gb.add_edge_prop("kn")
for e, d in gb.edges_props():
g = gb.sorted_nodes_of_edge(e)[0]
d["kn"] = kf / gb.node_prop(g, "param").get_aperture()
# ------------------------------------------------------------------------------#
def main():
gb = create_porepy_grid.create(mesh_size=0.01)
internal_flag = FaceTag.FRACTURE
[g.remove_face_tag_if_tag(FaceTag.BOUNDARY, internal_flag) for g, _ in gb]
# Assign parameters
domain = gb.bounding_box(as_dict=True)
kf = 1e-4
add_data(gb, domain, kf)
# Choose and define the solvers and coupler
problem = elliptic.DualElliptic(gb)
problem.solve()
problem.split()
problem.pressure("pressure")
problem.project_discharge("P0u")
problem.save(["pressure", "P0u"])
# ------------------------------------------------------------------------------#
if __name__ == "__main__":
main()
# ------------------------------------------------------------------------------#