diff --git a/olaflow/processing/olaflow.py b/olaflow/processing/olaflow.py index 9556a84..520289b 100644 --- a/olaflow/processing/olaflow.py +++ b/olaflow/processing/olaflow.py @@ -1,10 +1,15 @@ import re +from fluidfoam import readof + class OFModel: def __init__(self, root): self._root = root + def read_mesh(self): + self._x, self._y, self._z = readof.readmesh(str(self._root)) + def write_field(self, field, values): with open(self._root.joinpath("0", field), "r") as aw_file: aw_raw = aw_file.read() @@ -19,3 +24,15 @@ class OFModel: flags=re.S, ) ) + + @property + def x(self): + return self._x + + @property + def y(self): + return self._y + + @property + def z(self): + return self._z diff --git a/olaflow/processing/sws_ola.py b/olaflow/processing/sws_ola.py index 97940ec..7b416be 100644 --- a/olaflow/processing/sws_ola.py +++ b/olaflow/processing/sws_ola.py @@ -6,7 +6,6 @@ import re import matplotlib.pyplot as plt import numpy as np -from fluidfoam import readof from scipy import interpolate from .olaflow import OFModel @@ -30,11 +29,10 @@ sws = np.load(sws_out.joinpath("sws.npz")) x, t = sws["x"], sws["t"] olaflow_root = pathlib.Path(config.get("olaflow", "root")) -of_x, of_y, of_z = mesh = readof.readmesh(str(olaflow_root)) +model = OFModel(olaflow_root) +model.read_mesh() watl = interpolate.interp1d(x, sws["watl"][680]) +alpha_water = np.where(model.z < watl(model.x), 1, 0) -alpha_water = np.where(of_z < watl(of_x), 1, 0) - -model = OFModel(olaflow_root) model.write_field("alpha.water", alpha_water)