Skip to content

Commit 18fadb3

Browse files
authored
Merge pull request #2 from daavid00/developing
Extending the coarsening generic functionality
2 parents e5ef7b5 + 3f31577 commit 18fadb3

File tree

2 files changed

+372
-82
lines changed

2 files changed

+372
-82
lines changed

src/pycopm/core/pycopm.py

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def pycopm():
2020
"""Main function"""
2121
start_time = time.monotonic()
2222
parser = argparse.ArgumentParser(
23-
description="Main script to coarser the geological model and run "
23+
description="Main script to coarse the geological model and run "
2424
"simulations using OPM Flow."
2525
)
2626
parser.add_argument(
@@ -48,21 +48,71 @@ def pycopm():
4848
default="2,2,2",
4949
help="Level of coarsening in the x, y, and z dir ('2,2,2' by default)",
5050
)
51+
parser.add_argument(
52+
"-a",
53+
"--approach",
54+
default="max",
55+
help="Use min, max, or mode to scale the actnum ('min' by default)",
56+
)
57+
parser.add_argument(
58+
"-j",
59+
"--jump",
60+
default=2.0,
61+
help="Tunning parameter to avoid creation of nnc on the structural faults "
62+
"('2.' by default)",
63+
)
64+
parser.add_argument(
65+
"-x",
66+
"--xcoar",
67+
default="",
68+
help="Vector of x-coarsing ('' by default)",
69+
)
70+
parser.add_argument(
71+
"-y",
72+
"--ycoar",
73+
default="",
74+
help="Vector of y-coarsing ('' by default)",
75+
)
76+
parser.add_argument(
77+
"-z",
78+
"--zcoar",
79+
default="",
80+
help="Vector of z-coarsing ('' by default)",
81+
)
82+
parser.add_argument(
83+
"-e",
84+
"--encoding",
85+
default="ISO-8859-1",
86+
help="Use 'utf8' or 'geometric' encoding to read the deck ('ISO-8859-1' by default)",
87+
)
88+
5189
cmdargs = vars(parser.parse_known_args()[0])
5290
file = cmdargs["input"].strip() # Name of the input file
5391
dic = {"fol": cmdargs["output"]} # Name for the output folder
5492
dic["pat"] = os.path.dirname(__file__)[:-5] # Path to the pycopm folder
5593
dic["exe"] = os.getcwd() # Path to the folder of the input.txt file
5694
dic["flow"] = cmdargs["flow"].strip() # Path to flow
57-
dic["cijk"] = np.genfromtxt(
58-
StringIO(cmdargs["coarsening"]), delimiter=",", dtype=int
59-
) # Coarsening level
95+
dic["how"] = cmdargs["approach"].strip() # Max, min, or mode
96+
dic["jump"] = float(cmdargs["jump"]) # Tunning parameter
97+
dic["encoding"] = cmdargs["encoding"].strip()
98+
dic["cijk"] = "yes"
99+
for i in ["x", "y", "z"]:
100+
dic[f"{i}coar"] = []
101+
if cmdargs[f"{i}coar"]:
102+
dic[f"{i}coar"] = list(
103+
np.genfromtxt(StringIO(cmdargs[f"{i}coar"]), delimiter=",", dtype=int)
104+
)
105+
dic["cijk"] = "no"
106+
if dic["cijk"] != "no":
107+
dic["cijk"] = np.genfromtxt(
108+
StringIO(cmdargs["coarsening"]), delimiter=",", dtype=int
109+
) # Coarsening level
60110

61111
# Make the output folder
62112
if not os.path.exists(f"{dic['exe']}/{dic['fol']}"):
63113
os.system(f"mkdir {dic['exe']}/{dic['fol']}")
64114

65-
# When an deck is given, then we only generate the coarser files
115+
# When a deck is given, then we only generate the coarser files
66116
if "DATA" in file:
67117
dic["deck"] = file.upper()[:-5]
68118
create_deck(dic)

0 commit comments

Comments
 (0)