From c0549d71b2109f10c1238db8b22362e7826ba61b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Jul 2026 15:59:23 +0200 Subject: Just rename from lib to modules --- modules/core/c++/chunk.hpp | 103 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 modules/core/c++/chunk.hpp (limited to 'modules/core/c++/chunk.hpp') diff --git a/modules/core/c++/chunk.hpp b/modules/core/c++/chunk.hpp new file mode 100644 index 0000000..635af91 --- /dev/null +++ b/modules/core/c++/chunk.hpp @@ -0,0 +1,103 @@ +#pragma once + +#include "common.hpp" +#include "flatten.hpp" + +namespace kel { +namespace lbm { +namespace sch { +namespace impl { +template> +struct chunk_schema_type_helper; + +template +struct chunk_schema_type_helper, saw::tmpl_value_group> final { + using Schema = typename chunk_schema_type_helper, saw::tmpl_value_group>::Schema; +}; + +template +struct chunk_schema_type_helper, saw::tmpl_value_group> final { + using Schema = FixedArray; +}; +} + + +template +struct Chunk { + using InnerSchema = typename impl::chunk_schema_type_helper>::Schema; + using StoredValueSchema = Sch; +}; + +// Not needed for now +template +using SuperChunk = Array; +} +} +} + +namespace saw { + +template +class data,Encode> final { +public: + using Schema = kel::lbm::sch::Chunk; +private: + using InnerSchema = typename Schema::InnerSchema; + using ValueSchema = typename InnerSchema::ValueType; + + data values_; +public: + data& ghost_at(const data>& index){ + return values_.at(index); + } + + const data& ghost_at(const data>& index) const { + return values_.at(index); + } + + static constexpr auto get_ghost_dims() { + return data::get_dims(); + } + + static constexpr auto to_ghost_index(const data>& index){ + std::decay_t ind; + for(uint64_t i = 0u; i < sizeof...(Sides); ++i){ + ind.at({i}) = index.at({i}) + Ghost; + } + return ind; + } + + data& at(const data>& index){ + std::decay_t ind = to_ghost_index(index); + return values_.at(ind); + } + + const data& at(const data>& index) const { + std::decay_t ind = to_ghost_index(index); + return values_.at(ind); + } + + /* + const data& neighbour_at(const data>& index) const { + } + */ + + static constexpr auto get_dims(){ + return data,Encode>{{Sides...}}; + } + + auto flat_data(){ + return values_.flat_data(); + } + + static constexpr auto flat_size() { + return data::flat_dims(); + } +}; + +template +struct meta_schema> { + using MetaSchema = typename meta_schema::MetaSchema; +}; + +} -- cgit v1.2.3