From cf3ee2ab8de44160c24da7850955021142f41da8 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 7 Aug 2026 16:14:16 +0200 Subject: Clean up descriptors --- modules/core/c++/descriptor.hpp | 74 ++--------------------------------- modules/core/c++/descriptor/d1q3.hpp | 31 +++++++++++++++ modules/core/c++/descriptor/d2q5.hpp | 49 +++++++++++++++++++++++ modules/core/c++/descriptor/d3q19.hpp | 72 ++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+), 71 deletions(-) create mode 100644 modules/core/c++/descriptor/d2q5.hpp create mode 100644 modules/core/c++/descriptor/d3q19.hpp (limited to 'modules') diff --git a/modules/core/c++/descriptor.hpp b/modules/core/c++/descriptor.hpp index ed64a0f..ac09e7b 100644 --- a/modules/core/c++/descriptor.hpp +++ b/modules/core/c++/descriptor.hpp @@ -4,7 +4,10 @@ #include #include +#include "descriptor/d1q3.hpp" +#include "descriptor/d2q5.hpp" #include "descriptor/d2q9.hpp" +#include "descriptor/d3q19.hpp" #include "descriptor/d3q27.hpp" namespace kel { @@ -12,9 +15,6 @@ namespace lbm { namespace sch { using namespace saw::schema; -//using D2Q5 = Descriptor<2u,5u>; -using D3Q27 = Descriptor<3u,27u>; - template struct Cell { using Descriptor = Desc; @@ -63,74 +63,6 @@ struct df_ct_helper { } */ -template -class df_info> { -public: - using Descriptor = sch::Descriptor<1,3>; - - static constexpr uint64_t D = 1u; - static constexpr uint64_t Q = 3u; - - static constexpr std::array,Q> directions = {{ - { 0}, - {-1}, - { 1} - }}; - - static constexpr std::array::type, Q> weights = { - 2./3., - 1./6., - 1./6. - }; - - static constexpr std::array opposite_index = { - 0,2,1 - }; - - static constexpr typename saw::native_data_type::type inv_cs2 = 3.0; - static constexpr typename saw::native_data_type::type cs2 = 1./3.; -}; - -/** - * D2Q5 Descriptor - */ -template -class df_info> { -public: - using Descriptor = sch::Descriptor<2,5>; - - static constexpr uint64_t D = 2u; - static constexpr uint64_t Q = 5u; - - static constexpr std::array, Q> directions = {{ - { 0, 0}, - {-1, 0}, - { 1, 0}, - { 0,-1}, - { 0, 1}, - }}; - - static constexpr std::array::type,Q> weights = { - 1./3., - 1./6., - 1./6., - 1./6., - 1./6. - }; - - static constexpr std::array opposite_index = { - 0, - 2, - 1, - 4, - 3 - }; - - static constexpr typename saw::native_data_type::type inv_cs2 = 3.0; - static constexpr typename saw::native_data_type::type cs2 = 1./3.; -}; - - template class cell_schema_builder { private: 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 +class df_info> { +public: + using Descriptor = sch::Descriptor<1,3>; + + static constexpr uint64_t D = 1u; + static constexpr uint64_t Q = 3u; + + static constexpr std::array,Q> directions = {{ + { 0}, + {-1}, + { 1} + }}; + + static constexpr std::array::type, Q> weights = { + 2./3., + 1./6., + 1./6. + }; + + static constexpr std::array opposite_index = { + 0,2,1 + }; + + static constexpr typename saw::native_data_type::type inv_cs2 = 3.0; + static constexpr typename saw::native_data_type::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..74f8b96 --- /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 D2Q9 = Descriptor<2u,5u>; +} + +template +class df_info> { +public: + using Descriptor = sch::Descriptor<2,5>; + + static constexpr uint64_t D = 2u; + static constexpr uint64_t Q = 5u; + + static constexpr std::array, Q> directions = {{ + { 0, 0}, // 0 + {-1, 0}, // 1 + { 1, 0}, // 2 + { 0,-1}, // 3 + { 0, 1} // 4 + }}; + + static constexpr std::array::type,Q> weights = { + 1./3., + 1./6., + 1./6., + 1./6., + 1./6. + }; + + static constexpr std::array opposite_index = { + 0, + 2, + 1, + 4, + 3 + }; + + static constexpr typename saw::native_data_type::type inv_cs2 = 3.0; + static constexpr typename saw::native_data_type::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 +class df_info> { +public: + using Descriptor = sch::Descriptor<3,19>; + + static constexpr uint64_t D = 3u; + static constexpr uint64_t Q = 19u; + + static constexpr std::array,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::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 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::type inv_cs2 = 3.0; + static constexpr typename saw::native_data_type::type cs2 = 1./3.; +}; +} +} -- cgit v1.2.3