From 18346ca25b838908b21c29a3e29f89e7a55a1474 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 16 Jul 2026 14:34:19 +0200 Subject: Adding meta as dims name --- modules/core/c++/hlbm.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'modules/core/c++') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index eccc2cd..a749035 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -103,16 +103,13 @@ public: template class component final { private: +/* template void apply_i(const saw::data& field, const saw::data& macros, const saw::data& part_groups, saw::data> index, saw::data time_step) const { // if constexpr ( i < ) - } + } +*/ public: - /* - template - void apply_i() - */ - template void apply(const saw::data& field, const saw::data& macros, const saw::data& part_group, saw::data> index, saw::data time_step) const { /// Figure out how to access the particle list @@ -125,7 +122,7 @@ public: auto& mvel = macros.template get<"velocity">(); { auto& parts = part_spheroid_group.template get<"particles">(); - auto parts_size = parts.dims().at({0u}); + auto parts_size = parts.meta().at({0u}); auto& pi = parts.at(index); auto& pirb = pi.template get<"rigid_body">(); @@ -134,7 +131,12 @@ public: saw::data> start; saw::data> stop; - auto aabb = particle_aabb::calculate(part_spheroid_group,index,mvel.meta()); + auto eo_aabb = particle_aabb::calculate(part_spheroid_group,index,mvel.meta()); + if(eo_aabb.is_error()){ + return; + } + auto& aabb = eo_aabb.get_value(); + /// Ok, I iterate over the space which covers our particle? So lower bounds to upper bounds start = aabb.template get<"a">(); stop = aabb.template get<"b">(); -- cgit v1.2.3 From 9383579d43f834519d5061527f749acf8dca59c6 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 16 Jul 2026 15:10:27 +0200 Subject: Prepping for abstract data in lbm --- modules/core/c++/abstract/alloc.hpp | 9 ++++ modules/core/c++/abstract/data.hpp | 53 +++++----------------- modules/core/c++/abstract/encode.hpp | 9 ++++ modules/core/c++/abstract/schema.hpp | 60 +++++++++++++++++++++++++ modules/core/c++/abstract/string_literal.hpp | 61 ++++++++++++++++++++++++++ modules/core/c++/abstract/stringify_schema.hpp | 51 +++++++++++++++++++++ 6 files changed, 200 insertions(+), 43 deletions(-) create mode 100644 modules/core/c++/abstract/alloc.hpp create mode 100644 modules/core/c++/abstract/encode.hpp create mode 100644 modules/core/c++/abstract/schema.hpp create mode 100644 modules/core/c++/abstract/string_literal.hpp create mode 100644 modules/core/c++/abstract/stringify_schema.hpp (limited to 'modules/core/c++') diff --git a/modules/core/c++/abstract/alloc.hpp b/modules/core/c++/abstract/alloc.hpp new file mode 100644 index 0000000..b15e737 --- /dev/null +++ b/modules/core/c++/abstract/alloc.hpp @@ -0,0 +1,9 @@ +#pragma once + +namespace kel { +namespace lbm { +namespace all { +struct Native {}; +} +} +} diff --git a/modules/core/c++/abstract/data.hpp b/modules/core/c++/abstract/data.hpp index ed23268..f1ae5a7 100644 --- a/modules/core/c++/abstract/data.hpp +++ b/modules/core/c++/abstract/data.hpp @@ -1,52 +1,19 @@ #pragma once -#include "templates.hpp" +#include "schema.hpp" +#include "encode.hpp" namespace kel { -namespace sch { -struct Void {}; - -struct UnsignedInteger {}; -struct SignedInteger {}; -struct FloatingPoint {}; - -template -struct MixedPrecision { - using Meta = Void; - using StorageType = StorageT; - using InterfaceType = InterfaceT; -}; - -template -struct Primitive { - using Meta = Void; - using Type = PrimType; - static constexpr uint64_t Bytes = N; -}; - -template -struct FixedArray { - using Meta = Void; - using Inner = T; - static constexpr std::array Dimensions{Dims...}; +namespace lbm { +template +class data final {}; + +template +class data,Encode> final { +private: +public: }; -template -struct Array { - using Meta = FixedArray; - using Inner = T; - static constexpr std::array Dimensions{Dims}; -}; - -template -struct Tuple { -}; } - -template -struct schema { - using Type = Sch; -}; - } diff --git a/modules/core/c++/abstract/encode.hpp b/modules/core/c++/abstract/encode.hpp new file mode 100644 index 0000000..64aef4a --- /dev/null +++ b/modules/core/c++/abstract/encode.hpp @@ -0,0 +1,9 @@ +#pragma once + +namespace kel { +namespace lbm { +namespace enc { +struct Native {}; +} +} +} diff --git a/modules/core/c++/abstract/schema.hpp b/modules/core/c++/abstract/schema.hpp new file mode 100644 index 0000000..8305005 --- /dev/null +++ b/modules/core/c++/abstract/schema.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include "string_literal.hpp" +#include "templates.hpp" + +namespace kel { +namespace sch { +struct Void {}; + +struct UnsignedInteger {}; +struct SignedInteger {}; +struct FloatingPoint {}; + +template +struct MixedPrecision { + using Meta = Void; + using StorageType = StorageT; + using InterfaceType = InterfaceT; +}; + +template +struct Primitive { + using Meta = Void; + using StorageType = PrimType; + using InterfaceType = PrimType; + static constexpr uint64_t Bytes = N; +}; + +template +struct FixedArray { + using Meta = Void; + using Inner = T; + static constexpr std::array Dimensions{Dims...}; +}; + +template +struct Array { + using Meta = FixedArray; + using Inner = T; + static constexpr std::array Dimensions{Dims}; +}; + +template +struct Tuple { +}; + +template +struct Member {}; + +template +struct Struct {}; + +} + +template +struct schema { + using Type = Sch; +}; + +} diff --git a/modules/core/c++/abstract/string_literal.hpp b/modules/core/c++/abstract/string_literal.hpp new file mode 100644 index 0000000..51e58c8 --- /dev/null +++ b/modules/core/c++/abstract/string_literal.hpp @@ -0,0 +1,61 @@ +#pragma once + +#include +#include + +namespace kel { +namespace lbm { +/** + * Helper object which creates a templated string from the provided string + * literal. It guarantees compile time uniqueness and thus allows using strings + * in template parameters. + */ +template class string_literal { +public: + static_assert(N > 0, "string_literal needs a null terminator"); + + constexpr string_literal(const CharT (&input)[N]) noexcept { + for (size_t i = 0; i < N; ++i) { + data[i] = input[i]; + } + } + + std::array data{}; + + constexpr std::string_view view() const noexcept { + return std::string_view{data.data()}; + } + + constexpr bool + operator==(const string_literal &) const noexcept = default; + + template + constexpr bool + operator==(const string_literal &) const noexcept { + return false; + } + + template + constexpr string_literal operator+(const string_literal& rhs) const noexcept { + CharT sum[N+NR-1]; + + // The weird i+1 happens due to needing to skip the '\0' terminator + for(size_t i = 0; (i+1) < N; ++i){ + sum[i] = data[i]; + } + for(size_t i = 0; i < NR; ++i){ + sum[i+N-1] = rhs.data[i]; + } + + return string_literal{sum}; + } + + +}; + +template +constexpr string_literal operator""_sl() { + return string_literal{{Chars..., '\0'}}; +} +} +} diff --git a/modules/core/c++/abstract/stringify_schema.hpp b/modules/core/c++/abstract/stringify_schema.hpp new file mode 100644 index 0000000..866bc7e --- /dev/null +++ b/modules/core/c++/abstract/stringify_schema.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "schema.hpp" + +namespace kel { +namespace lbm { +namespace impl { +template +struct schema_to_string_helper { + static_assert(always_false, "schema_to_string_helper specialization not handled."); + + static constexpr string_literal apply(){ + return {}; + } +}; + +template<> +struct schema_to_string_helper final { + static constexpr string_literal apply(){ + return "SignedInteger"; + } +}; + +template<> +struct schema_to_string_helper final { + static constexpr string_literal apply(){ + return "UnsignedInteger"; + } +}; + +template<> +struct schema_to_string_helper final { + static constexpr string_literal apply(){ + return "FloatingPoint"; + } +}; + +template +struct schema_to_string_helper> final { + static constexpr string_literal apply(){ + return "Primitive<"+schema_to_string_helper::apply()+","+N+">"; + } +}; +} + +template +struct schema_to_string{ + static constexpr std::string_view value = impl::schema_to_string_helper::apply().view(); +}; +} +} -- cgit v1.2.3 From bd9f266756849a7381d7a4ff575d5f1ccc6e28bb Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 16 Jul 2026 17:23:22 +0200 Subject: Dangling --- modules/core/c++/hlbm.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/core/c++') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index a749035..1c625bb 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -133,6 +133,8 @@ public: auto eo_aabb = particle_aabb::calculate(part_spheroid_group,index,mvel.meta()); if(eo_aabb.is_error()){ + std::cerr<<"Prepping error"<