Updated pickle with input output arguments
This commit is contained in:
parent
56d77d98bc
commit
2fea19158f
2 changed files with 29 additions and 15 deletions
|
@ -1,6 +1,5 @@
|
||||||
import argparse
|
import argparse
|
||||||
import gzip
|
import gzip
|
||||||
import configparser
|
|
||||||
import logging
|
import logging
|
||||||
import pathlib
|
import pathlib
|
||||||
import pickle
|
import pickle
|
||||||
|
@ -14,20 +13,29 @@ from .olaflow import OFModel
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Post-process olaflow results")
|
parser = argparse.ArgumentParser(description="Post-process olaflow results")
|
||||||
parser.add_argument("-v", "--verbose", action="count", default=0)
|
parser.add_argument("-v", "--verbose", action="count", default=0)
|
||||||
parser.add_argument("-c", "--config", default="config.ini")
|
parser.add_argument(
|
||||||
parser.add_argument("-o", "--output", type=pathlib.Path)
|
"-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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
|
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
|
||||||
log = logging.getLogger("ola_post")
|
log = logging.getLogger("ola_post")
|
||||||
|
|
||||||
log.info("Starting sws -> olaFlow converter")
|
log.info("Starting sws -> olaFlow converter")
|
||||||
config = configparser.ConfigParser()
|
out = args.output
|
||||||
config.read(args.config)
|
|
||||||
out = pathlib.Path(config.get("post", "out"))
|
|
||||||
out.mkdir(parents=True, exist_ok=True)
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
olaflow_root = args.output
|
olaflow_root = args.input
|
||||||
model = OFModel(olaflow_root)
|
model = OFModel(olaflow_root)
|
||||||
model.read_mesh()
|
model.read_mesh()
|
||||||
model.read_time()
|
model.read_time()
|
||||||
|
@ -40,5 +48,9 @@ model.read_field_all("U")
|
||||||
|
|
||||||
model.read_post("graphUniform", "alpha.water")
|
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)
|
pickle.dump(model, f)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
echo START
|
echo START
|
||||||
export inp="of"
|
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
|
cp -r --reflink $inp $out_of
|
||||||
pushd $out
|
pushd $out_of
|
||||||
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
|
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
|
||||||
mkdir log
|
mkdir log
|
||||||
echo Generating mesh
|
echo Generating mesh
|
||||||
|
@ -17,10 +19,10 @@ setFields > log/setFields.log
|
||||||
|
|
||||||
popd
|
popd
|
||||||
echo Converting swash output to initial condition
|
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
|
echo Converting swash output to boundary condition
|
||||||
python -m processing.sws_wavedict_paddle -o $out
|
python -m processing.sws_wavedict_paddle -o $out_of
|
||||||
pushd $out
|
pushd $out_of
|
||||||
|
|
||||||
echo Generating parallel cases
|
echo Generating parallel cases
|
||||||
decomposePar > log/decomposePar.log
|
decomposePar > log/decomposePar.log
|
||||||
|
@ -36,6 +38,6 @@ postProcess -func graphUniform > log/postProcess.log
|
||||||
|
|
||||||
popd
|
popd
|
||||||
echo Pickling Olaflow output
|
echo Pickling Olaflow output
|
||||||
python -m processing.pickle -o $out
|
python -m processing.pickle -i $out_of -o $out_post
|
||||||
|
|
||||||
echo END
|
echo END
|
||||||
|
|
Loading…
Reference in a new issue