diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-20 14:50:23 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-20 14:50:23 +0100 |
| commit | 952940c3487856447bb80c819b61483b8028d027 (patch) | |
| tree | 6e9c641af6d8f785a3c7c8faf60e351325561ed8 /lib/core/c++ | |
| parent | e8a72234dc585459d2a5dc95ff601e8a212e0b71 (diff) | |
| download | libs-lbm-952940c3487856447bb80c819b61483b8028d027.tar.gz | |
Chunk setup test
Diffstat (limited to 'lib/core/c++')
| -rw-r--r-- | lib/core/c++/chunk.hpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/lib/core/c++/chunk.hpp b/lib/core/c++/chunk.hpp index 1950661..607bec0 100644 --- a/lib/core/c++/chunk.hpp +++ b/lib/core/c++/chunk.hpp @@ -34,12 +34,46 @@ using SuperChunk = Array<ChunkSchema,Dim>; } namespace saw { -template<typename Sch, uint64_t Dim, uint64_t Side, uint64_t Ghost, typename Encode> -class data<kel::lbm::sch::Chunk<Sch,Dim,Side,Ghost>,Encode> final { +template<typename Sch, uint64_t Ghost, uint64_t... Sides, typename Encode> +class data<kel::lbm::sch::Chunk<Sch,Ghost,Sides...>,Encode> final { public: - using Schema = kel::lbm::sch::Chunk<Sch,Dim,Side,Ghost>; + using Schema = kel::lbm::sch::Chunk<Sch,Ghost,Sides...>; private: - data<typename Schema::InnerSchema, Encode> values_; + using InnerSchema = typename Schema::InnerSchema; + using ValueSchema = typename InnerSchema::ValueType; + + data<InnerSchema, Encode> values_; public: + data<ValueSchema, Encode>& ghost_at(const data<schema::FixedArray<schema::UInt64,sizeof...(Sides)>>& index){ + return values_.at(index); + } + + const data<ValueSchema, Encode>& ghost_at(const data<schema::FixedArray<schema::UInt64,sizeof...(Sides)>>& index) const { + return values_.at(index); + } + + static constexpr auto get_ghost_dims() { + return data<InnerSchema,Encode>::get_dims(); + } + + data<ValueSchema, Encode>& at(const data<schema::FixedArray<schema::UInt64,sizeof...(Sides)>>& index){ + std::decay_t<decltype(index)> ind; + for(uint64_t i = 0u; i < sizeof...(Sides); ++i){ + ind.at({i}) = index.at({i}) + Ghost; + } + return values_.at(ind); + } + + const data<ValueSchema, Encode>& at(const data<schema::FixedArray<schema::UInt64,sizeof...(Sides)>>& index) const { + std::decay_t<decltype(index)> ind; + for(uint64_t i = 0u; i < sizeof...(Sides); ++i){ + ind.at({i}) = index.at({i}) + Ghost; + } + return values_.at(ind); + } + + static constexpr auto get_dims(){ + return data<schema::FixedArray<schema::UInt64, sizeof...(Sides)>,Encode>{{Sides...}}; + } }; } |
