1
Fork 0

Updated pickle with input output arguments

This commit is contained in:
Edgar P. Burkhart 2022-05-03 11:13:27 +02:00
parent 56d77d98bc
commit 2fea19158f
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 29 additions and 15 deletions

View file

@ -1,6 +1,5 @@
import argparse
import gzip
import configparser
import logging
import pathlib
import pickle
@ -14,20 +13,29 @@ from .olaflow import OFModel
parser = argparse.ArgumentParser(description="Post-process olaflow results")
parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
parser.add_argument("-o", "--output", type=pathlib.Path)
parser.add_argument(
"-i", "--input", type=pathlib.Path, help="Olaflow output directory", required=True
)
parser.add_argument(
"-o",
"--output",
type=pathlib.Path,
help="Output directory for pickled data",
required=True,
)
parser.add_argument(
"-z", "--compress", action="store_true", help="Enable gzip compression"
)
args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
log = logging.getLogger("ola_post")
log.info("Starting sws -> olaFlow converter")
config = configparser.ConfigParser()
config.read(args.config)
out = pathlib.Path(config.get("post", "out"))
out = args.output
out.mkdir(parents=True, exist_ok=True)
olaflow_root = args.output
olaflow_root = args.input
model = OFModel(olaflow_root)
model.read_mesh()
model.read_time()
@ -40,5 +48,9 @@ model.read_field_all("U")
model.read_post("graphUniform", "alpha.water")
with gzip.open(out.joinpath("pickle.gz"), "wb") as f:
with (
gzip.open(out.joinpath("pickle.gz"), "wb")
if args.compress
else out.joinpath("pickle").open("wb")
) as f:
pickle.dump(model, f)

View file

@ -1,10 +1,12 @@
#!/usr/bin/env sh
echo START
export inp="of"
read -p "Output: " out
read -p "Case: " out
export out_of="out_of_$out"
export out_post="out_post_$out"
cp -r --reflink $inp $out
pushd $out
cp -r --reflink $inp $out_of
pushd $out_of
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
mkdir log
echo Generating mesh
@ -17,10 +19,10 @@ setFields > log/setFields.log
popd
echo Converting swash output to initial condition
python -m processing.sws_ola -o $out
python -m processing.sws_ola -o $out_of
echo Converting swash output to boundary condition
python -m processing.sws_wavedict_paddle -o $out
pushd $out
python -m processing.sws_wavedict_paddle -o $out_of
pushd $out_of
echo Generating parallel cases
decomposePar > log/decomposePar.log
@ -36,6 +38,6 @@ postProcess -func graphUniform > log/postProcess.log
popd
echo Pickling Olaflow output
python -m processing.pickle -o $out
python -m processing.pickle -i $out_of -o $out_post
echo END