1
Fork 0
internship/olaflow/processing/pickle.py

45 lines
1.2 KiB
Python
Raw Normal View History

2022-04-13 14:08:55 +02:00
import argparse
2022-04-14 12:37:42 +02:00
import gzip
2022-04-13 14:08:55 +02:00
import configparser
import logging
import pathlib
import pickle
2022-04-14 12:37:42 +02:00
from time import time
2022-04-13 14:08:55 +02:00
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
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)
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)
2022-04-14 12:37:42 +02:00
out = pathlib.Path(config.get("post", "out"))
out.mkdir(parents=True, exist_ok=True)
2022-04-13 14:08:55 +02:00
olaflow_root = args.output
model = OFModel(olaflow_root)
model.read_mesh()
model.read_time()
2022-04-13 14:08:55 +02:00
model.read_field_all("alpha.water")
model.read_field_all("porosity")
model.read_field_all("p")
model.read_field_all("p_rgh")
model.read_field_all("U")
model.read_post("graphUniform", "alpha.water")
2022-04-14 12:37:42 +02:00
with gzip.open(out.joinpath("pickle.gz"), "wb") as f:
2022-04-13 14:08:55 +02:00
pickle.dump(model, f)