summaryrefslogtreecommitdiff
path: root/modules/core/c++/descriptor
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-08-07 15:42:42 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-08-07 15:42:42 +0200
commit1f797c2f9716c5b604dc6eee8335d9149d4a0b77 (patch)
treeb037b9473c454f3fa581650d24188d80553ce100 /modules/core/c++/descriptor
parent7d094fe719923db5eb6b30edcc4fa01c6ce2cc2e (diff)
downloadlibs-lbm-1f797c2f9716c5b604dc6eee8335d9149d4a0b77.tar.gz
Cleanup
Diffstat (limited to 'modules/core/c++/descriptor')
-rw-r--r--modules/core/c++/descriptor/common.hpp13
-rw-r--r--modules/core/c++/descriptor/d2q9.hpp54
-rw-r--r--modules/core/c++/descriptor/d3q27.hpp93
3 files changed, 160 insertions, 0 deletions
diff --git a/modules/core/c++/descriptor/common.hpp b/modules/core/c++/descriptor/common.hpp
index f821510..a20e2ef 100644
--- a/modules/core/c++/descriptor/common.hpp
+++ b/modules/core/c++/descriptor/common.hpp
@@ -4,6 +4,19 @@
namespace kel {
namespace lbm {
+namespace sch {
+using namespace saw::schema;
+
+template<uint64_t DV, uint64_t QV>
+struct Descriptor {
+ static constexpr uint64_t D = DV;
+ static constexpr uint64_t Q = QV;
+};
+
+}
+
+template<typename T, typename Desc>
+class df_info{};
}
}
diff --git a/modules/core/c++/descriptor/d2q9.hpp b/modules/core/c++/descriptor/d2q9.hpp
index f675a99..44c6e28 100644
--- a/modules/core/c++/descriptor/d2q9.hpp
+++ b/modules/core/c++/descriptor/d2q9.hpp
@@ -1,7 +1,61 @@
#pragma once
+#include "common.hpp"
+
namespace kel {
namespace lbm {
+namespace sch {
+using D2Q9 = Descriptor<2u,9u>;
+}
+
+template<typename T>
+class df_info<T,sch::Descriptor<2, 9>> {
+public:
+ using Descriptor = sch::Descriptor<2,9>;
+
+ static constexpr uint64_t D = 2u;
+ static constexpr uint64_t Q = 9u;
+
+ static constexpr std::array<std::array<int32_t, D>, Q> directions = {{
+ { 0, 0}, // 0
+ {-1, 0}, // 1
+ { 1, 0}, // 2
+ { 0,-1}, // 3
+ { 0, 1}, // 4
+ {-1,-1}, // 5
+ { 1, 1}, // 6
+ {-1, 1}, // 7
+ { 1,-1} // 8
+ }};
+
+ static constexpr std::array<typename saw::native_data_type<T>::type,Q> weights = {
+ 4./9.,
+ 1./9.,
+ 1./9.,
+ 1./9.,
+ 1./9.,
+ 1./36.,
+ 1./36.,
+ 1./36.,
+ 1./36.
+ };
+
+ static constexpr std::array<uint64_t,Q> opposite_index = {
+ 0,
+ 2,
+ 1,
+ 4,
+ 3,
+ 6,
+ 5,
+ 8,
+ 7
+ };
+
+ 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.;
+};
+
}
}
diff --git a/modules/core/c++/descriptor/d3q27.hpp b/modules/core/c++/descriptor/d3q27.hpp
new file mode 100644
index 0000000..7b3c84f
--- /dev/null
+++ b/modules/core/c++/descriptor/d3q27.hpp
@@ -0,0 +1,93 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+namespace sch {
+using D3Q27 = Descriptor<3u,27u>;
+}
+
+template<typename T>
+class df_info<T,sch::Descriptor<3, 27>> {
+public:
+ using Descriptor = sch::Descriptor<3,27>;
+
+ static constexpr uint64_t D = 3u;
+ static constexpr uint64_t Q = 27u;
+
+ static constexpr std::array<std::array<int32_t, D>, Q> directions = {{
+ { 0, 0, 0}, // 0
+ // Into 1D
+ {-1, 0, 0}, // 1
+ { 1, 0, 0}, // 2
+ // Expand into 2D
+ { 0, -1, 0}, // 3
+ {-1, -1, 0}, // 4
+ { 1, -1, 0}, // 5
+ { 0, 1, 0}, // 6
+ {-1, 1, 0}, // 7
+ { 1, 1, 0}, // 8
+ // Expand into 3D
+ { 0, 0, -1}, // 9
+ {-1, 0, -1}, // 10
+ { 1, 0, -1}, // 11
+ { 0, -1, -1},// 12
+ {-1, -1, -1},// 13
+ { 1, -1, -1},// 14
+ { 0, 1, -1}, // 15
+ {-1, 1, -1}, // 16
+ { 1, 1, -1}, // 17
+ { 0, 0, 1}, // 18
+ {-1, 0, 1}, // 19
+ { 1, 0, 1}, // 20
+ { 0, -1, 1}, // 21
+ {-1, -1, 1}, // 22
+ { 1, -1, 1}, // 23
+ { 0, 1, 1}, // 24
+ {-1, 1, 1}, // 25
+ { 1, 1, 1} // 26
+ }};
+
+ static constexpr std::array<typename saw::native_data_type<T>::type,Q> weights = {
+ 8./27.,
+ // 1D
+ 1./36.,
+ 1./36.,
+ // 2D
+ 1./36.,
+ 1./54.,
+ 1./54.,
+ 1./36.,
+ 1./54.,
+ 1./54.,
+ // 3D
+ 1./36.,
+ 1./54.,
+ 1./54.,
+ 1./54.,
+ 1./216.,
+ 1./216.,
+ 1./54.,
+ 1./216.,
+ 1./216.,
+ 1./36.,
+ 1./54.,
+ 1./54.,
+ 1./54.,
+ 1./216.,
+ 1./216.,
+ 1./54.,
+ 1./216.,
+ 1./216.
+ };
+
+ static constexpr std::array<uint64_t,Q> opposite_index = {
+ 0,2,1,
+ 6,8,7,3,5,4,
+ 18,20,19,24,26,25,21,23,22,9,11,10,15,17,16,12,14,13
+ };
+
+ 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.;
+};
+}
+}