From 4de463d6c8fe74abb9782ed2a027b19c2032afbf Mon Sep 17 00:00:00 2001 From: MaNyh <nyhuis@tfd.uni-hannover.de> Date: Tue, 24 May 2022 11:26:00 +0200 Subject: [PATCH] default names for massflow_plane variables --- ntrfc/utils/pyvista_utils/plane.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ntrfc/utils/pyvista_utils/plane.py b/ntrfc/utils/pyvista_utils/plane.py index 505bfb56..71ac0472 100644 --- a/ntrfc/utils/pyvista_utils/plane.py +++ b/ntrfc/utils/pyvista_utils/plane.py @@ -3,34 +3,35 @@ import numpy as np from ntrfc.utils.math.vectorcalc import vecAbs, vecProjection -def massflow_plane(mesh): +def massflow_plane(mesh, rhoname="rho", velocityname="U"): if not "Normals" in mesh.array_names: mesh = mesh.compute_normals() if not "Area" in mesh.array_names: mesh = mesh.compute_cell_sizes() mesh = mesh.point_data_to_cell_data() normals = mesh.cell_normals - rhos = mesh["rho"] + rhos = mesh[rhoname] areas = mesh["Area"] - velocities = mesh["U"] + velocities = mesh[velocityname] massflow = np.array( [vecAbs(vecProjection(velocities[i], normals[i])) for i in range(mesh.number_of_cells)]) ** 2 * rhos * areas return massflow -def massflowave_plane(mesh,valname): - massflow = massflow_plane(mesh) - mass_ave = np.sum(mesh[valname]*massflow)/np.sum(massflow) +def massflowave_plane(mesh, valname, rhoname="rho", velocityname="U"): + massflow = massflow_plane(mesh, rhoname=rhoname, velocityname=velocityname) + + mass_ave = np.sum(mesh[valname] * massflow) / np.sum(massflow) return mass_ave def areaave_plane(mesh, valname): - array=mesh[valname] + array = mesh[valname] if not "Area" in mesh.array_names: mesh = mesh.compute_cell_sizes() areas = mesh["Area"] - area_ave = np.sum((array.T*areas).T)/np.sum(areas) + area_ave = np.sum((array.T * areas).T) / np.sum(areas) return area_ave -- GitLab