Skip to content
Snippets Groups Projects
Commit 15d266b8 authored by Malte Nyhuis's avatar Malte Nyhuis
Browse files

Merge branch 'fix'

parents 1e3909bc 61739d0d
No related branches found
No related tags found
No related merge requests found
......@@ -243,18 +243,20 @@ def extractSidePolys(ind_hk, ind_vk, sortedPoly):
y_ps = ys[ind_vk:] + ys[:ind_hk + 1]
x_ps = xs[ind_vk:] + xs[:ind_hk + 1]
psl_helper = polyline_from_points(np.stack((x_ps, y_ps, np.zeros(len(x_ps)))).T)
ssl_helper = polyline_from_points(np.stack((x_ss, y_ss, np.zeros(len(x_ss)))).T)
side_one = polyline_from_points(np.stack((x_ps, y_ps, np.zeros(len(x_ps)))).T)
side_two = polyline_from_points(np.stack((x_ss, y_ss, np.zeros(len(x_ss)))).T)
if psl_helper.length > ssl_helper.length:
if side_one.length > side_two.length:
psPoly = pv.PolyData(ssl_helper.points)
ssPoly = pv.PolyData(psl_helper.points)
psPoly = pv.PolyData(side_two.points)
ssPoly = pv.PolyData(side_one.points)
else:
psPoly = pv.PolyData(psl_helper.points)
ssPoly = pv.PolyData(ssl_helper.points)
psPoly = pv.PolyData(side_one.points)
ssPoly = pv.PolyData(side_two.points)
ssPoly=ssPoly.sample(sortedPoly)
psPoly=psPoly.sample(sortedPoly)
return ssPoly, psPoly
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment