diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-10-18 18:01:14 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-10-18 18:01:14 +0200 |
| commit | 24bf28a8fb9cc8c3a90b77de9b60728bece7885d (patch) | |
| tree | dfcbfcb8775bf96847d4a187695158b968902889 /lib/c++/equilibrium.hpp | |
| parent | a980da34513a9ad41e309e66432fcb80ddaf2e31 (diff) | |
| download | libs-lbm-24bf28a8fb9cc8c3a90b77de9b60728bece7885d.tar.gz | |
Moving project structure for more less compilation
Diffstat (limited to 'lib/c++/equilibrium.hpp')
| -rw-r--r-- | lib/c++/equilibrium.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/c++/equilibrium.hpp b/lib/c++/equilibrium.hpp new file mode 100644 index 0000000..bb55d00 --- /dev/null +++ b/lib/c++/equilibrium.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "descriptor.hpp" + +namespace kel { +namespace lbm { +template<typename T, typename Descriptor> +saw::data<sch::FixedArray<T, Descriptor::Q>> equilibrium(saw::data<T> rho, saw::data<sch::FixedArray<T,Descriptor::D>> vel){ + using dfi = df_info<T, Descriptor>; + + saw::data<sch::FixedArray<T,Descriptor::Q>> eq; + // ^ + // 0.0 + // / \ + // | | + // + // Velocity * Velocity meaning || vel ||_2^2 or <vel,vel>_2 + saw::data<T> vel_vel{0.0}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_vel = vel_vel + vel.at(j) * vel.at(j); + } + + /** + * Calculate equilibrium + */ + for(uint64_t i = 0u; i < eq.template get_dim_size<0u>(); ++i){ + saw::data<T> vel_c{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + // <vel,c_i>_2 + vel_c = vel_c + (vel.at(j) * saw::data<T>{static_cast<saw::native_data_type<T>::type>(dfi::directions[i][j])}); + } + + auto vel_c_cs2 = vel_c * saw::data<T>{dfi::inv_cs2}; + + eq.at(i).set( + dfi::weights[i] * rho.get() * + ( + 1.0 + + vel_c_cs2.get() + - dfi::inv_cs2 * 0.5 * vel_vel.get() + + vel_c_cs2.get() * vel_c_cs2.get() * 0.5 + ) + ); + } + + return eq; +} +} +} |
