diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-06 01:37:34 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-06 01:37:34 +0200 |
| commit | af4b3f8f9bf7b19c169d9fbd0a2b49668af8ad10 (patch) | |
| tree | 3e98fff4bad333affa55e082de0da759bad57229 /modules/core/c++/momentum_gather.hpp | |
| parent | 52326efc80dfeae6e830527df2e7803ecf61b00a (diff) | |
| parent | 015e941a91552ce6ea4cde4507ec9451c3708e77 (diff) | |
| download | libs-lbm-af4b3f8f9bf7b19c169d9fbd0a2b49668af8ad10.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'modules/core/c++/momentum_gather.hpp')
| -rw-r--r-- | modules/core/c++/momentum_gather.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/core/c++/momentum_gather.hpp b/modules/core/c++/momentum_gather.hpp new file mode 100644 index 0000000..7b1fc96 --- /dev/null +++ b/modules/core/c++/momentum_gather.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "common.hpp" +#include "macroscopic.hpp" +#include "component.hpp" +#include "equilibrium.hpp" + +namespace kel { +namespace lbm { +namespace cmpt { +// Gather the force, Luke! +struct ForceGather {}; +} + +template<typename T, typename Descriptor, typename Encode> +class component<T,Descriptor,cmpt::ForceGather, Encode> { +private: +public: + template<typename CellFieldSchema, typename MacroFieldSchema> + void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, + saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, saw::data<sch::UInt64> time_step) const { + + using dfi = df_info<T,Descriptor>; + bool is_even = ((time_step.get() % 2) == 0); + + auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + + auto& porous_f = macros.template get<"porosity">(); + auto& porous = porous_f.at(index); + + auto& force_f = macros.template get<"force">(); + auto& force = force_f.at(index); + + for(uint64_t k{0u}; k < Descriptor::D; ++k){ + force.at({{k}}).set(0); + } + + auto& dfs = dfs_old_f.at(index); + for(uint64_t i{0u}; i < Descriptor::Q; ++i){ + uint64_t i_opp = dfi::opposite_index[i]; + auto dfs_diff = dfs.at({i}) - dfs.at({i_opp}); + for(uint64_t k{0u}; k < Descriptor::D; ++k){ + force.at({{k}}) = force.at({{k}}) + dfs_diff * saw::data<T>{dfi::directions[i][k]}; + } + } + + saw::data<sch::Scalar<T>> one; + one.at({}) = 1.0; + auto flip_porous = one - porous; + force = force * flip_porous; + } +}; +} +} |
