From 1f993006305952f4cafddd08267731877e808bba Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 8 Sep 2025 17:15:27 +0200 Subject: Dangling changes Fixed ForcedGuo collision --- c++/boundary.hpp | 2 +- c++/collision.hpp | 32 ++++++++++++++++---------------- c++/particle/particle.hpp | 3 ++- c++/statistics.hpp | 11 +++++++++++ c++/write_vtk.hpp | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 c++/statistics.hpp (limited to 'c++') diff --git a/c++/boundary.hpp b/c++/boundary.hpp index 3cf6f3f..bc4859c 100644 --- a/c++/boundary.hpp +++ b/c++/boundary.hpp @@ -51,7 +51,7 @@ public: auto& cell = field(index); auto& dfs_old = (is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); - auto& dfs = (not is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + // auto& dfs = (not is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); using dfi = df_info; diff --git a/c++/collision.hpp b/c++/collision.hpp index df9a734..cd6cf14 100644 --- a/c++/collision.hpp +++ b/c++/collision.hpp @@ -17,11 +17,11 @@ template class component { private: typename saw::native_data_type::type relaxation_; - typename saw::native_data_type::type frequency_; + saw::data frequency_; public: component(typename saw::native_data_type::type relaxation__): relaxation_{relaxation__}, - frequency_{1 / relaxation_} + frequency_{typename saw::native_data_type::type(1) / relaxation_} {} using Component = cmpt::BGK; @@ -57,7 +57,8 @@ public: auto eq = equilibrium(rho,vel); for(uint64_t i = 0u; i < Descriptor::Q; ++i){ - dfs_old({i}).set(dfs_old({i}).get() + (1.0 / relaxation_) * (eq.at(i).get() - dfs_old({i}).get())); + dfs_old({i}) = dfs_old({i}) + frequency_ * (eq.at(i) - dfs_old({i})); + // dfs_old({i}).set(dfs_old({i}).get() + (1.0 / relaxation_) * (eq.at(i).get() - dfs_old({i}).get())); } } }; @@ -66,11 +67,11 @@ template class component { private: typename saw::native_data_type::type relaxation_; - typename saw::native_data_type::type frequency_; + saw::data frequency_; public: component(typename saw::native_data_type::type relaxation__): relaxation_{relaxation__}, - frequency_{1 / relaxation_} + frequency_{typename saw::native_data_type::type(1) / relaxation_} {} using Component = cmpt::BGKGuo; @@ -89,7 +90,7 @@ public: template void apply(saw::data& field, saw::data> index, uint64_t time_step){ - bool is_even = ((time_step & 2) == 0); + bool is_even = ((time_step % 2) == 0); auto& cell = field(index); auto& dfs_old = (is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); @@ -105,22 +106,21 @@ public: auto& force = cell.template get<"force">(); for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + saw::data ci_min_u{0}; saw::data ci_dot_u{0}; - saw::data ci_dot_F{0}; - saw::data u_dot_F{0}; for(uint64_t d = 0u; d < Descriptor::D; ++d){ - ci_dot_u = ci_dot_u + vel.at({d}) * dfi::directions[i][d]; - ci_dot_F = ci_dot_F + force({d}) * dfi::directions[i][d]; - u_dot_F = u_dot_F + vel.at({d}) * force({d}); + ci_dot_u = ci_dot_u + vel.at({d}) * saw::data{static_cast::type>(dfi::directions[i][d])}; } + saw::data F_i{0};// = saw::data{dfi::weights[i]} * (ci_dot_F * dfi::inv_cs2 + ci_dot_u * ci_dot_F * (dfi::inv_cs2 * dfi::inv_cs2)); - // auto df_old = dfs_old({i}); - saw::data F_i = saw::data{dfi::weights[i]} * (ci_dot_F / dfi::cs2 + ci_dot_u * ci_dot_F / (dfi::cs2 * dfi::cs2)); - if(F_i.get() != 0){ - std::cerr<<"AAAH"; + for(uint64_t d = 0u; d < Descriptor::D; ++d){ + F_i = F_i + + saw::data{dfi::weights[i]} * ((saw::data{static_cast::type>(dfi::directions[i][d])} + - vel.at({d}) ) * dfi::inv_cs2 + ci_dot_u * saw::data{static_cast::type>(dfi::directions[i][d])} * dfi::inv_cs2 * dfi::inv_cs2 ) * force({d}); } - dfs_old({i}) = dfs_old({i}) + saw::data{frequency_} * (eq.at(i) - dfs_old({i}) ) - F_i * saw::data{1.0f - 0.5f * frequency_}; + + dfs_old({i}) = dfs_old({i}) + frequency_ * (eq.at(i) - dfs_old({i}) ) + F_i * (saw::data{1} - saw::data{0.5f} * frequency_); } } }; diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp index a55b06e..ae7769a 100644 --- a/c++/particle/particle.hpp +++ b/c++/particle/particle.hpp @@ -27,7 +27,7 @@ using ParticleMask = Struct< template using Particle = Struct< Member, "rigid_body">, - Member, "mask">, + Member, "mask">, Member >; } @@ -84,6 +84,7 @@ public: template void update_particle_border(saw::data& latt){ + (void) latt; for(auto& iter : particles_){ auto& par = iter; diff --git a/c++/statistics.hpp b/c++/statistics.hpp new file mode 100644 index 0000000..c07ccb7 --- /dev/null +++ b/c++/statistics.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace kel { +namespace lbm { +template +class statistics { +private: +public: +}; +} +} diff --git a/c++/write_vtk.hpp b/c++/write_vtk.hpp index eb2545a..c9ecc99 100644 --- a/c++/write_vtk.hpp +++ b/c++/write_vtk.hpp @@ -81,7 +81,7 @@ struct lbm_vtk_writer...> , template static saw::error_or write_i(std::ostream& vtk_file, const saw::data...>,Dim>>& field){ - auto meta = field.get_dims(); + // auto meta = field.get_dims(); saw::data> index; for(saw::data it{0}; it.get() < Dim; ++it){ index.at({0u}).set(0u); -- cgit v1.2.3