summaryrefslogtreecommitdiff
path: root/modules/core/c++
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-08-07 18:15:51 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-08-07 18:15:51 +0200
commit9cc16e97489860ef1989c1bb16745a4dc0155b9f (patch)
tree60636c39dad819388e6fd814a2a9c2efac5dded1 /modules/core/c++
parent5d4192c73c72f29debe0f3b6e73889f0204ab74a (diff)
parent15ee0a4a9b398b86001c7a2542e8e98f9dedba70 (diff)
downloadlibs-lbm-9cc16e97489860ef1989c1bb16745a4dc0155b9f.tar.gz
Merge branch 'dev'HEADmaster
Diffstat (limited to 'modules/core/c++')
-rw-r--r--modules/core/c++/SConscript2
-rw-r--r--modules/core/c++/args.hpp27
-rw-r--r--modules/core/c++/descriptor.hpp220
-rw-r--r--modules/core/c++/descriptor/common.hpp13
-rw-r--r--modules/core/c++/descriptor/d1q3.hpp31
-rw-r--r--modules/core/c++/descriptor/d2q5.hpp49
-rw-r--r--modules/core/c++/descriptor/d2q9.hpp54
-rw-r--r--modules/core/c++/descriptor/d3q19.hpp72
-rw-r--r--modules/core/c++/descriptor/d3q27.hpp93
-rw-r--r--modules/core/c++/environment.hpp5
10 files changed, 323 insertions, 243 deletions
diff --git a/modules/core/c++/SConscript b/modules/core/c++/SConscript
index 91f5b3e..f45660c 100644
--- a/modules/core/c++/SConscript
+++ b/modules/core/c++/SConscript
@@ -15,6 +15,7 @@ core_env = env.Clone();
core_env.sources = sorted(glob.glob(dir_path + "/*.cpp"));
core_env.headers = sorted(glob.glob(dir_path + "/*.hpp"));
+core_env.descriptor_headers = sorted(glob.glob(dir_path + "/descriptor/*.hpp"));
core_env.particle_headers = sorted(glob.glob(dir_path + "/particle/*.hpp"));
core_env.particle_geometry_headers = sorted(glob.glob(dir_path + "/particle/geometry/*.hpp"));
@@ -30,6 +31,7 @@ env.library_static = core_env.StaticLibrary('#build/kel-lbm', [objects]);
env.Install('$prefix/lib/', env.library_static);
env.Install('$prefix/include/kel/lbm/', core_env.headers);
+env.Install('$prefix/include/kel/lbm/descriptor/', core_env.descriptor_headers);
env.Install('$prefix/include/kel/lbm/particle/', core_env.particle_headers);
env.Install('$prefix/include/kel/lbm/particle/geometry/', core_env.particle_geometry_headers);
env.Install('$prefix/include/kel/lbm/math/', core_env.math_headers);
diff --git a/modules/core/c++/args.hpp b/modules/core/c++/args.hpp
deleted file mode 100644
index a0aa941..0000000
--- a/modules/core/c++/args.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <forstio/codec/data.hpp>
-#include <forstio/codec/args.hpp>
-
-namespace kel {
-namespace lbm {
-namespace sch {
-using namespace saw::schema;
-}
-
-template<typename ArgSchema>
-saw::error_or<saw::data<ArgSchema>> setup_lbm_env(int argc, char** argv){
- saw::data<ArgSchema,saw::encode::Args> args_data{argc,argv};
-
- saw::codec<ArgSchema,saw::encode::Args> args_codec;
-
- saw::data<ArgSchema> args_decoded;
- auto eov = args_codec.decode(args_data,args_decoded);
- if(eov.is_error()){
- return eov;
- }
-
- return args_decoded;
-}
-}
-}
diff --git a/modules/core/c++/descriptor.hpp b/modules/core/c++/descriptor.hpp
index 9f7399a..ac09e7b 100644
--- a/modules/core/c++/descriptor.hpp
+++ b/modules/core/c++/descriptor.hpp
@@ -4,21 +4,17 @@
#include <forstio/codec/data_math.hpp>
#include <forstio/codec/schema_factory.hpp>
+#include "descriptor/d1q3.hpp"
+#include "descriptor/d2q5.hpp"
+#include "descriptor/d2q9.hpp"
+#include "descriptor/d3q19.hpp"
+#include "descriptor/d3q27.hpp"
+
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;
-};
-
-using D2Q9 = Descriptor<2u,9u>;
-//using D2Q5 = Descriptor<2u,5u>;
-using D3Q27 = Descriptor<3u,27u>;
-
template<typename Sch, typename Desc, uint64_t SC_V, uint64_t DC_V, uint64_t QC_V>
struct Cell {
using Descriptor = Desc;
@@ -51,9 +47,6 @@ struct CellFieldStruct {
}
-template<typename T, typename Desc>
-class df_info{};
-
/*
namespace impl {
template<typename Desc>
@@ -70,207 +63,6 @@ struct df_ct_helper {
}
*/
-template<typename T>
-class df_info<T,sch::Descriptor<1,3>> {
-public:
- using Descriptor = sch::Descriptor<1,3>;
-
- static constexpr uint64_t D = 1u;
- static constexpr uint64_t Q = 3u;
-
- static constexpr std::array<std::array<int32_t,D>,Q> directions = {{
- { 0},
- {-1},
- { 1}
- }};
-
- static constexpr std::array<typename saw::native_data_type<T>::type, Q> weights = {
- 2./3.,
- 1./6.,
- 1./6.
- };
-
- static constexpr std::array<uint64_t,Q> opposite_index = {
- 0,2,1
- };
-
- 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.;
-};
-
-/**
- * D2Q5 Descriptor
- */
-template<typename T>
-class df_info<T,sch::Descriptor<2, 5>> {
-public:
- using Descriptor = sch::Descriptor<2,5>;
-
- static constexpr uint64_t D = 2u;
- static constexpr uint64_t Q = 5u;
-
- static constexpr std::array<std::array<int32_t, D>, Q> directions = {{
- { 0, 0},
- {-1, 0},
- { 1, 0},
- { 0,-1},
- { 0, 1},
- }};
-
- static constexpr std::array<typename saw::native_data_type<T>::type,Q> weights = {
- 1./3.,
- 1./6.,
- 1./6.,
- 1./6.,
- 1./6.
- };
-
- static constexpr std::array<uint64_t,Q> opposite_index = {
- 0,
- 2,
- 1,
- 4,
- 3
- };
-
- 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 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.;
-};
-
-
-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.;
-};
-
-
template<typename Schema>
class cell_schema_builder {
private:
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/d1q3.hpp b/modules/core/c++/descriptor/d1q3.hpp
index 7fc8591..9ea0a35 100644
--- a/modules/core/c++/descriptor/d1q3.hpp
+++ b/modules/core/c++/descriptor/d1q3.hpp
@@ -4,6 +4,37 @@
namespace kel {
namespace lbm {
+namespace sch {
+using D1Q3 = Descriptor<1u,3u>;
+}
+
+template<typename T>
+class df_info<T,sch::Descriptor<1,3>> {
+public:
+ using Descriptor = sch::Descriptor<1,3>;
+
+ static constexpr uint64_t D = 1u;
+ static constexpr uint64_t Q = 3u;
+
+ static constexpr std::array<std::array<int32_t,D>,Q> directions = {{
+ { 0},
+ {-1},
+ { 1}
+ }};
+
+ static constexpr std::array<typename saw::native_data_type<T>::type, Q> weights = {
+ 2./3.,
+ 1./6.,
+ 1./6.
+ };
+
+ static constexpr std::array<uint64_t,Q> opposite_index = {
+ 0,2,1
+ };
+
+ 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/d2q5.hpp b/modules/core/c++/descriptor/d2q5.hpp
new file mode 100644
index 0000000..fef9c40
--- /dev/null
+++ b/modules/core/c++/descriptor/d2q5.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "common.hpp"
+
+namespace kel {
+namespace lbm {
+namespace sch {
+using D2Q5 = Descriptor<2u,5u>;
+}
+
+template<typename T>
+class df_info<T,sch::Descriptor<2, 5>> {
+public:
+ using Descriptor = sch::Descriptor<2,5>;
+
+ static constexpr uint64_t D = 2u;
+ static constexpr uint64_t Q = 5u;
+
+ 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
+ }};
+
+ static constexpr std::array<typename saw::native_data_type<T>::type,Q> weights = {
+ 1./3.,
+ 1./6.,
+ 1./6.,
+ 1./6.,
+ 1./6.
+ };
+
+ static constexpr std::array<uint64_t,Q> opposite_index = {
+ 0,
+ 2,
+ 1,
+ 4,
+ 3
+ };
+
+ 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/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/d3q19.hpp b/modules/core/c++/descriptor/d3q19.hpp
new file mode 100644
index 0000000..bbd1bd1
--- /dev/null
+++ b/modules/core/c++/descriptor/d3q19.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+namespace sch {
+using D3Q19 = Descriptor<3u,19u>;
+}
+
+template<typename T>
+class df_info<T, sch::Descriptor<3,19>> {
+public:
+ using Descriptor = sch::Descriptor<3,19>;
+
+ static constexpr uint64_t D = 3u;
+ static constexpr uint64_t Q = 19u;
+
+ static constexpr std::array<std::array<int32_t,D>,Q> directions = {{
+ { 0, 0, 0}, // 0
+
+ {-1, 0, 0}, // 1
+ { 1, 0, 0}, // 2
+ { 0, -1, 0}, // 3
+ { 0, 1, 0}, // 4
+ { 0, 0, -1}, // 5
+ { 0, 0, 1}, // 6
+
+ {-1, -1, 0}, // 7
+ { 1, -1, 0}, // 8
+ {-1, 1, 0}, // 9
+ { 1, 1, 0}, //10
+
+ {-1, 0, -1}, //11
+ { 1, 0, -1}, //12
+ {-1, 0, 1}, //13
+ { 1, 0, 1}, //14
+
+ { 0, -1, -1}, //15
+ { 0, 1, -1}, //16
+ { 0, -1, 1}, //17
+ { 0, 1, 1} //18
+ }};
+
+ static constexpr std::array<typename saw::native_data_type<T>::type,Q> weights = {
+ 1./3.,
+
+ 1./18., 1./18.,
+ 1./18., 1./18.,
+ 1./18., 1./18.,
+
+ 1./36., 1./36.,
+ 1./36., 1./36.,
+ 1./36., 1./36.,
+ 1./36., 1./36.,
+ 1./36., 1./36.,
+ 1./36., 1./36.
+ };
+
+ static constexpr std::array<uint64_t,Q> opposite_index = {
+ 0,
+ 2,1,
+ 4,3,
+ 6,5,
+ 10,9,8,7,
+ 14,13,12,11,
+ 18,17,16,15
+ };
+
+ 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.;
+};
+}
+}
diff --git a/modules/core/c++/environment.hpp b/modules/core/c++/environment.hpp
index ed9cd40..51092d5 100644
--- a/modules/core/c++/environment.hpp
+++ b/modules/core/c++/environment.hpp
@@ -22,7 +22,7 @@ saw::error_or<environment> init_lbm_env(const saw::data<ArgSch>& args){
namespace fs = std::filesystem;
auto& args_n = args.template get<"args">();
- auto& name = args_n.template get<"name">();
+ auto& arg_name = args_n.template get<"name">();
const char* home_dir = std::getenv("HOME");
if(not home_dir){
@@ -50,7 +50,8 @@ saw::error_or<environment> init_lbm_env(const saw::data<ArgSch>& args){
}
{
- env.name_dir = env.data_dir / name.view();
+ env.name = arg_name.stl_view();
+ env.name_dir = env.data_dir / arg_name.stl_view();
}
return env;