summaryrefslogtreecommitdiff
path: root/c++/macroscopic.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-04-18 16:25:30 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-04-18 16:25:30 +0200
commitae8711ba90ac2a47ea7654dc873927fb2783ff91 (patch)
tree04f15d1223fec76a02f1c5261256ce4bdd71eeab /c++/macroscopic.hpp
parent80f35c35295eb07f2b9b61d1fb1bd01c37717caa (diff)
wip rendering in terminal and extracting example code to files
Diffstat (limited to 'c++/macroscopic.hpp')
-rw-r--r--c++/macroscopic.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/c++/macroscopic.hpp b/c++/macroscopic.hpp
new file mode 100644
index 0000000..608b89e
--- /dev/null
+++ b/c++/macroscopic.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+/**
+ * Calculate the macroscopic variables rho and u in Lattice Units.
+ */
+template<typename Desc>
+void compute_rho_u (
+ const saw::data<sch::DfCell<Desc>>& dfs,
+ typename saw::native_data_type<sch::T>::type& rho,
+ std::array<typename saw::native_data_type<sch::T>::type, 2>& vel
+ )
+{
+ using dfi = df_info<sch::T, Desc>;
+
+ rho = 0;
+ std::fill(vel.begin(), vel.end(), 0);
+
+ for(size_t j = 0; j < Desc::Q; ++j){
+ rho += dfs(j).get();
+ for(size_t i = 0; i < Desc::D; ++i){
+ vel[i] += dfi::directions[j][i] * dfs(j).get();
+ }
+ }
+
+ for(size_t i = 0; i < Desc::D; ++i){
+ vel[i] /= rho;
+ }
+}
+}
+}