From 2e6ae2ef9bb230930f5213c256e624080b08faca Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 16 Apr 2025 16:49:14 +0200 Subject: Trying to make a cleaner vtk writer --- c++/examples/cavity_2d.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'c++/examples') diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp index 88a7702..0a8e9b1 100644 --- a/c++/examples/cavity_2d.cpp +++ b/c++/examples/cavity_2d.cpp @@ -71,6 +71,9 @@ void compute_rho_u ( vel[1] /= rho; } +/** + * Unsure if feasible. I would have a rho normalization on the dfs and then I would use the const rho_computation + */ template void compute_const_rho_u ( saw::data>& dfs, @@ -80,15 +83,20 @@ void compute_const_rho_u ( { using dfi = df_info; + saw::native_data_type::type real_rho = 0; std::fill(vel.begin(), vel.end(), 0); for(size_t i = 0; i < Desc::Q; ++i){ + real_rho += dfs(i).get(); vel[0] += dfi::directions[i][0] * dfs(i).get(); vel[1] += dfi::directions[i][1] * dfs(i).get(); } + for(size_t i = 0; i < Desc::Q; ++i){ + dfs(i).set(dfs(i).get() * (rho/real_rho)); + } - vel[0] /= rho; - vel[1] /= rho; + vel[0] *= real_rho / (rho*rho) + vel[1] *= real_rho / (rho*rho) } /** -- cgit v1.2.3