summaryrefslogtreecommitdiff
path: root/lib/core/c++/momentum_gather.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-06-30 23:52:02 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-06-30 23:52:02 +0200
commit2bae8b93faf614b1acb5df7269087b4f3786da5a (patch)
treea6db1328ed035c6130b6b29110e0891f6c78c7e4 /lib/core/c++/momentum_gather.hpp
parentb88d59477a7973bdee102aaf0e26c13c9059048b (diff)
downloadlibs-lbm-2bae8b93faf614b1acb5df7269087b4f3786da5a.tar.gz
Final run
Diffstat (limited to 'lib/core/c++/momentum_gather.hpp')
-rw-r--r--lib/core/c++/momentum_gather.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/core/c++/momentum_gather.hpp b/lib/core/c++/momentum_gather.hpp
new file mode 100644
index 0000000..7b1fc96
--- /dev/null
+++ b/lib/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;
+ }
+};
+}
+}