Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending the coarsening generic functionality #2

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions src/pycopm/core/pycopm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pycopm():
"""Main function"""
start_time = time.monotonic()
parser = argparse.ArgumentParser(
description="Main script to coarser the geological model and run "
description="Main script to coarse the geological model and run "
"simulations using OPM Flow."
)
parser.add_argument(
Expand Down Expand Up @@ -48,21 +48,71 @@ def pycopm():
default="2,2,2",
help="Level of coarsening in the x, y, and z dir ('2,2,2' by default)",
)
parser.add_argument(
"-a",
"--approach",
default="max",
help="Use min, max, or mode to scale the actnum ('min' by default)",
)
parser.add_argument(
"-j",
"--jump",
default=2.0,
help="Tunning parameter to avoid creation of nnc on the structural faults "
"('2.' by default)",
)
parser.add_argument(
"-x",
"--xcoar",
default="",
help="Vector of x-coarsing ('' by default)",
)
parser.add_argument(
"-y",
"--ycoar",
default="",
help="Vector of y-coarsing ('' by default)",
)
parser.add_argument(
"-z",
"--zcoar",
default="",
help="Vector of z-coarsing ('' by default)",
)
parser.add_argument(
"-e",
"--encoding",
default="ISO-8859-1",
help="Use 'utf8' or 'geometric' encoding to read the deck ('ISO-8859-1' by default)",
)

cmdargs = vars(parser.parse_known_args()[0])
file = cmdargs["input"].strip() # Name of the input file
dic = {"fol": cmdargs["output"]} # Name for the output folder
dic["pat"] = os.path.dirname(__file__)[:-5] # Path to the pycopm folder
dic["exe"] = os.getcwd() # Path to the folder of the input.txt file
dic["flow"] = cmdargs["flow"].strip() # Path to flow
dic["cijk"] = np.genfromtxt(
StringIO(cmdargs["coarsening"]), delimiter=",", dtype=int
) # Coarsening level
dic["how"] = cmdargs["approach"].strip() # Max, min, or mode
dic["jump"] = float(cmdargs["jump"]) # Tunning parameter
dic["encoding"] = cmdargs["encoding"].strip()
dic["cijk"] = "yes"
for i in ["x", "y", "z"]:
dic[f"{i}coar"] = []
if cmdargs[f"{i}coar"]:
dic[f"{i}coar"] = list(
np.genfromtxt(StringIO(cmdargs[f"{i}coar"]), delimiter=",", dtype=int)
)
dic["cijk"] = "no"
if dic["cijk"] != "no":
dic["cijk"] = np.genfromtxt(
StringIO(cmdargs["coarsening"]), delimiter=",", dtype=int
) # Coarsening level

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

# When an deck is given, then we only generate the coarser files
# When a deck is given, then we only generate the coarser files
if "DATA" in file:
dic["deck"] = file.upper()[:-5]
create_deck(dic)
Expand Down
Loading
Loading