summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/descriptor.hpp18
-rw-r--r--c++/equilibrium.hpp6
-rw-r--r--c++/macroscopic.hpp32
-rw-r--r--c++/term_renderer.hpp7
4 files changed, 63 insertions, 0 deletions
diff --git a/c++/descriptor.hpp b/c++/descriptor.hpp
index 014327c..aa8c943 100644
--- a/c++/descriptor.hpp
+++ b/c++/descriptor.hpp
@@ -152,6 +152,24 @@ public:
static constexpr typename saw::native_data_type<T>::type inv_cs2 = 3.0;
static constexpr typename saw::native_data_type<T>::type cs2 = 1./3.;
};
+
+template<typename Schema>
+class cell_schema_builder {
+private:
+ saw::schema_factory<Schema> factory_struct_;
+public:
+ cell_schema_builder() = default;
+
+ cell_schema_builder(saw::schema_factory<Schema> inp):
+ factory_struct_{inp}
+ {}
+
+ template<typename TA, saw::string_literal KA>
+ constexpr auto require() const noexcept {
+ return {factory_struct_.add_maybe()};
+ }
+};
+
}
}
diff --git a/c++/equilibrium.hpp b/c++/equilibrium.hpp
index ac36dbc..bb55d00 100644
--- a/c++/equilibrium.hpp
+++ b/c++/equilibrium.hpp
@@ -13,14 +13,20 @@ saw::data<sch::FixedArray<T, Descriptor::Q>> equilibrium(saw::data<T> rho, saw::
// 0.0
// / \
// | |
+ //
+ // Velocity * Velocity meaning || vel ||_2^2 or <vel,vel>_2
saw::data<T> vel_vel{0.0};
for(uint64_t j = 0u; j < Descriptor::D; ++j){
vel_vel = vel_vel + vel.at(j) * vel.at(j);
}
+ /**
+ * Calculate equilibrium
+ */
for(uint64_t i = 0u; i < eq.template get_dim_size<0u>(); ++i){
saw::data<T> vel_c{};
for(uint64_t j = 0u; j < Descriptor::D; ++j){
+ // <vel,c_i>_2
vel_c = vel_c + (vel.at(j) * saw::data<T>{static_cast<saw::native_data_type<T>::type>(dfi::directions[i][j])});
}
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;
+ }
+}
+}
+}
diff --git a/c++/term_renderer.hpp b/c++/term_renderer.hpp
new file mode 100644
index 0000000..f675a99
--- /dev/null
+++ b/c++/term_renderer.hpp
@@ -0,0 +1,7 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+
+}
+}