1
Fork 0

Moved fluidfoam to olaflow file

This commit is contained in:
Edgar P. Burkhart 2022-03-07 11:30:53 +01:00
parent 62af6a03ed
commit 4869c982bb
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 20 additions and 5 deletions

View file

@ -1,10 +1,15 @@
import re import re
from fluidfoam import readof
class OFModel: class OFModel:
def __init__(self, root): def __init__(self, root):
self._root = 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): def write_field(self, field, values):
with open(self._root.joinpath("0", field), "r") as aw_file: with open(self._root.joinpath("0", field), "r") as aw_file:
aw_raw = aw_file.read() aw_raw = aw_file.read()
@ -19,3 +24,15 @@ class OFModel:
flags=re.S, flags=re.S,
) )
) )
@property
def x(self):
return self._x
@property
def y(self):
return self._y
@property
def z(self):
return self._z

View file

@ -6,7 +6,6 @@ import re
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from fluidfoam import readof
from scipy import interpolate from scipy import interpolate
from .olaflow import OFModel from .olaflow import OFModel
@ -30,11 +29,10 @@ sws = np.load(sws_out.joinpath("sws.npz"))
x, t = sws["x"], sws["t"] x, t = sws["x"], sws["t"]
olaflow_root = pathlib.Path(config.get("olaflow", "root")) 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]) 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) model.write_field("alpha.water", alpha_water)