summaryrefslogtreecommitdiff
path: root/c++/macroscopic.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-09-17 21:35:41 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-09-17 21:35:41 +0200
commit04940fe64b714bcfad9026d54ee75a2fbdc7fe7b (patch)
tree58ed3cb5dc051e74b1e7a4eef895a88859e29181 /c++/macroscopic.hpp
parent08f2d21521c107fef57abf20d81707020aa3bd47 (diff)
Streamlining and thoughts about changes in particle dynamicsdev
Diffstat (limited to 'c++/macroscopic.hpp')
-rw-r--r--c++/macroscopic.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/c++/macroscopic.hpp b/c++/macroscopic.hpp
index 8a25248..51368e9 100644
--- a/c++/macroscopic.hpp
+++ b/c++/macroscopic.hpp
@@ -59,5 +59,34 @@ void compute_rho_u (
vel().at({i}) = vel().at({i}) / rho();
}
}
+
+/**
+ * Calculate the macroscopic variables rho and u in Lattice Units.
+ */
+template<typename T, typename Desc>
+void compute_rho_u (
+ const saw::data<sch::Cell<T, Desc, 0, 0, 1>>& dfs,
+ saw::ref<saw::data<T>> rho,
+ saw::ref<saw::data<sch::Vector<T,Desc::D>>> vel
+ )
+{
+ using dfi = df_info<T, Desc>;
+
+ rho().set(0);
+ for(uint64_t i = 0; i < Desc::D; ++i){
+ vel().at({{i}}).set(0);
+ }
+
+ for(size_t j = 0; j < Desc::Q; ++j){
+ rho() = rho() + dfs(j);
+ for(size_t i = 0; i < Desc::D; ++i){
+ vel().at({{i}}) = vel().at({{i}}) + saw::data<T>{static_cast<typename saw::native_data_type<T>::type>(dfi::directions[j][i])} * dfs(j);
+ }
+ }
+
+ for(size_t i = 0; i < Desc::D; ++i){
+ vel().at({{i}}) = vel().at({{i}}) / rho();
+ }
+}
}
}