diff options
Diffstat (limited to 'c++')
-rw-r--r-- | c++/descriptor.h | 12 | ||||
-rw-r--r-- | c++/examples/cavity_2d.cpp | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/c++/descriptor.h b/c++/descriptor.h index 052365d..564a705 100644 --- a/c++/descriptor.h +++ b/c++/descriptor.h @@ -85,7 +85,10 @@ public: data() = default; data<Sch, Encode>& operator()(const data<schema::UInt64>& index){ - return inner_(index); + return inner_.at(index); + } + const data<Sch, Encode>& operator()(const data<schema::UInt64>& index)const{ + return inner_.at(index); } }; @@ -97,6 +100,7 @@ public: private: data<schema::Array<CellT,Desc::D>, Encode> inner_; public: + data() = default; data(const data<schema::FixedArray<schema::UInt64, Desc::D>>& inner_meta__): inner_{inner_meta__} {} @@ -107,8 +111,12 @@ public: return inner_.template get_dim_size<i>(); } + const data<CellT>& operator()(const data<schema::FixedArray<schema::UInt64, Desc::D>, Encode>& index)const{ + return inner_.at(index); + } + data<CellT>& operator()(const data<schema::FixedArray<schema::UInt64, Desc::D>, Encode>& index){ - return inner_(index); + return inner_.at(index); } }; } diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp index 0cd3f9b..f9353e9 100644 --- a/c++/examples/cavity_2d.cpp +++ b/c++/examples/cavity_2d.cpp @@ -131,7 +131,10 @@ template<typename Func> void apply_for_cells(Func&& func, saw::data<kel::lbm::sch::CavityFieldD2Q5>& dat){ for(std::size_t i = 0; i < dat.template get_dim_size<0>().get(); ++i){ for(std::size_t j = 0; j < dat.template get_dim_size<1>().get(); ++j){ - func(dat({i,j}), i, j); + saw::data<saw::schema::UInt64> di{i}; + saw::data<saw::schema::UInt64> dj{j}; + auto& cell_v = dat({{di,dj}}); + func(cell_v, i, j); } } } @@ -180,7 +183,7 @@ int main(){ , saw::encode::Native > lattices; //{dim_x, dim_y}; - auto& df_field = lattices.at(0).template get<"dfs">(); + // auto& df_field = lattices.at(0).template get<"dfs">(); //for(uint64_t i = 0; i < df_field.get_dim_size<0u>(); ++i){ // lattices.at(i) = {dim_x, dim_y}; //} @@ -204,7 +207,7 @@ int main(){ apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ // Not needed (void) i; - std::cout<<static_cast<uint32_t>(cell.template get<"info">().at(0).get()); + std::cout<<static_cast<uint32_t>(cell.template get<"info">()({0}).get()); if( (j+1) < dim_y){ std::cout<<" "; }else{ @@ -216,7 +219,7 @@ int main(){ apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ // Not needed (void) i; - std::cout<<cell.template get<"dfs">().at(0).get(); + std::cout<<cell.template get<"dfs">()({0}).get(); if( (j+1) < dim_y){ std::cout<<" "; }else{ |