summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/SConscript2
-rw-r--r--c++/boundary.hpp59
-rw-r--r--c++/collision.hpp16
3 files changed, 75 insertions, 2 deletions
diff --git a/c++/SConscript b/c++/SConscript
index 57091af..3b79d1a 100644
--- a/c++/SConscript
+++ b/c++/SConscript
@@ -13,7 +13,7 @@ dir_path = Dir('.').abspath
core_env = env.Clone();
core_env.sources = sorted(glob.glob(dir_path + "/*.cpp"));
-core_env.headers = sorted(glob.glob(dir_path + "/*.h"));
+core_env.headers = sorted(glob.glob(dir_path + "/*.hpp"));
env.sources += core_env.sources;
env.headers += core_env.headers;
diff --git a/c++/boundary.hpp b/c++/boundary.hpp
new file mode 100644
index 0000000..77542c5
--- /dev/null
+++ b/c++/boundary.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+#include "component.hpp"
+#include "equilibrium.hpp"
+
+namespace kel {
+namespace lbm {
+namespace cmpt {
+struct BounceBack {};
+}
+
+template<typename T, typename Descriptor>
+class component<T, Descriptor, cmpt::BounceBack> {
+private:
+ typename saw::native_data_type<T>::type relaxation_;
+public:
+ component(typename saw::native_data_type<T>::type relaxation__):
+ relaxation_{relaxation__}
+ {}
+
+ using Component = cmpt::BounceBack;
+
+ /**
+ * Thoughts regarding automating order setup
+ */
+ using access = cmpt::access_tuple<
+ cmpt::access<"dfs", 1, true, true, true>
+ >;
+
+ /**
+ * Thoughts regarding automating order setup
+ */
+ static constexpr saw::string_literal name = "collision";
+ static constexpr saw::string_literal after = "";
+ static constexpr saw::string_literal before = "streaming";
+
+ /**
+ * Raw setup
+ */
+ template<typename CellFieldSchema>
+ void apply(saw::data<CellFieldSchema>& field, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, uint64_t time_step){
+ bool is_even = ((time_step % 2) == 0);
+ auto& cell = field.at(index);
+
+ auto& dfs_old = is_even ? cell.template get<"dfs_old">() : cell.template get<"dfs">();
+ auto& dfs = (!is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">();
+
+ using dfi = df_info<sch::T,Desc>;
+
+ // Technically use .copy()
+ auto df_cpy = dfs;
+
+ for(uint64_t i = 1u; i < Desc::Q; ++i){
+ dfs({i}) = df_cpy({dfi::opposite_index.at(i)});
+ }
+ }
+};
+}
+}
diff --git a/c++/collision.hpp b/c++/collision.hpp
index 9143862..7ca7c9f 100644
--- a/c++/collision.hpp
+++ b/c++/collision.hpp
@@ -11,7 +11,13 @@ struct BGK {};
template<typename T, typename Descriptor>
class component<T, Descriptor, cmpt::BGK> {
+private:
+ typename saw::native_data_type<T>::type relaxation_;
public:
+ component(typename saw::native_data_type<T>::type relaxation__):
+ relaxation_{relaxation__}
+ {}
+
using Component = cmpt::BGK;
/**
@@ -31,14 +37,22 @@ public:
/**
* Raw setup
*/
- void apply(saw::data<sch::CellField>& field, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, uint64_t time_step){
+ template<typename CellFieldSchema>
+ void apply(saw::data<CellFieldSchema>& field, saw::data<sch::FixedArray<sch::UInt64,Descriptor::D>> index, uint64_t time_step){
bool is_even = ((time_step % 2) == 0);
auto& cell = field.at(index);
auto& dfs_old = is_even ? cell.template get<"dfs_old">() : cell.template get<"dfs">();
auto& dfs = (!is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">();
+ typename saw::native_data_type<T>::type rho;
+ std::array<typename saw::native_data_type<T>::type, Descriptor::D> vel;
+ compute_rho_u<T,Descriptor>(dfs,rho,vel);
+ auto eq = equilibrium<Descriptor>(rho,vel);
+ for(uint64_t i = 0u; i < Descriptor::Q; ++i){
+ dfs({i}).set(dfs({i}).get() + (1.0 / relaxation_) * (eq[i] - dfs({i}).get()));
+ }
}