summaryrefslogtreecommitdiff
path: root/lib/core/c++/psm.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-02-20 10:53:05 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-02-20 10:53:05 +0100
commitdc1c481df599550fd5717790d908a3879f62960a (patch)
tree097812a0ef10074cfa746ab5a47b71fe37cc3540 /lib/core/c++/psm.hpp
parentabd0dbdca5735a8281e5df27181cc08ec51dae54 (diff)
downloadlibs-lbm-dc1c481df599550fd5717790d908a3879f62960a.tar.gz
Fixing Guo forcing problems
Diffstat (limited to 'lib/core/c++/psm.hpp')
-rw-r--r--lib/core/c++/psm.hpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/core/c++/psm.hpp b/lib/core/c++/psm.hpp
index 8e151c3..94d5ccd 100644
--- a/lib/core/c++/psm.hpp
+++ b/lib/core/c++/psm.hpp
@@ -11,23 +11,54 @@ struct PSM {};
}
/**
- * HLBM collision operator for LBM
+ * PSM collision operator for LBM
*/
template<typename T, typename Descriptor, typename Encode>
class component<T, Descriptor, cmpt::PSM> {
private:
+ saw::data<sch::Scalar<T>> relaxation_;
+ saw::data<sch::Scalar<T>> frequency_;
public:
- component() = default;
+ component(
+ saw::data<sch::Scalar<T>> relaxation__
+ ):
+ relaxation_{relaxation__}
+ {
+ saw::data<sch::Scalar<T>> one;
+ frequency_ = one / relaxation_;
+ }
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 = field.template get<"porosity">();
-
+ auto& rho_f = macros.template get<"density">();
+ auto& vel_f = macros.template get<"velocity">();
+
+ saw::data<sch::Scalar<T>>& rho = rho_f.at(index);
+ saw::data<sch::Vector<T,Descriptor::D>>& vel = vel_f.at(index);
+
+ compute_rho_u<T,Descriptor>(dfs_old_f.at(index),rho,vel);
+
+ auto eq = equilibrium<T,Descriptor>(rho,vel);
+
+ saw::data<sch::Scalar<T>> one;
+ one.at({}) = 1.0;
+ auto flip_porous = one - porous;
+
+ auto& dfs = dfs_old_f.at(index);
+
+ auto dfs_cpy = dfs;
+
+ for(uint64_t i = 0u; i < Descriptor::Q; ++i){
+ uint64_t i_opp = dfi::opposite_index[i];
+ dfs.at({i}) = dfs_cpy.at({i}) + frequency_ * (eq.at(i) - dfs_cpy.at({i})) * flip_porous + (dfs_cpy.at({i_opp}) - dfs_cpy.at({i}) ) * porous;
+ }
}
};