22#define PHARE_CORE_GRID_GridLayout_HPP
33
44
5- #include " core/hybrid/hybrid_quantities .hpp"
5+ #include " core/def .hpp"
66#include " core/utilities/types.hpp"
7- #include " core/data/field/field.hpp"
8- #include " gridlayoutdefs.hpp"
9- #include " core/utilities/algorithm.hpp"
107#include " core/utilities/box/box.hpp"
118#include " core/utilities/constants.hpp"
129#include " core/utilities/index/index.hpp"
1310#include " core/utilities/point/point.hpp"
14- #include " core/def.hpp"
11+ #include " core/hybrid/hybrid_quantities.hpp"
12+
13+ #include " gridlayoutdefs.hpp"
1514
1615#include < array>
17- #include < cmath>
1816#include < tuple>
1917#include < cstddef>
2018#include < functional>
@@ -879,7 +877,6 @@ namespace core
879877 return GridLayoutImpl::centering (hybridQuantity);
880878 }
881879
882-
883880 NO_DISCARD constexpr static std::array<std::array<QtyCentering, dimension>, 6 >
884881 centering (HybridQuantity::Tensor hybridQuantity)
885882 {
@@ -1027,6 +1024,29 @@ namespace core
10271024
10281025
10291026
1027+ /* *
1028+ * @brief BxToMoments return the indexes and associated coef to compute the linear
1029+ * interpolation necessary to project Bx onto moments.
1030+ */
1031+ NO_DISCARD auto static constexpr BxToMoments () { return GridLayoutImpl::BxToMoments (); }
1032+
1033+
1034+ /* *
1035+ * @brief ByToMoments return the indexes and associated coef to compute the linear
1036+ * interpolation necessary to project By onto moments.
1037+ */
1038+ NO_DISCARD auto static constexpr ByToMoments () { return GridLayoutImpl::ByToMoments (); }
1039+
1040+
1041+ /* *
1042+ * @brief BzToMoments return the indexes and associated coef to compute the linear
1043+ * interpolation necessary to project Bz onto moments.
1044+ */
1045+ NO_DISCARD auto static constexpr BzToMoments () { return GridLayoutImpl::BzToMoments (); }
1046+
1047+
1048+
1049+
10301050 /* *
10311051 * @brief ExToMoments return the indexes and associated coef to compute the linear
10321052 * interpolation necessary to project Ex onto moments.
@@ -1157,30 +1177,23 @@ namespace core
11571177
11581178
11591179
1160-
1161- auto AMRGhostBoxFor (auto const & field) const
1180+ auto AMRBoxFor (auto const & field) const
11621181 {
11631182 auto const centerings = centering (field);
1164- auto const growBy = [&]() {
1165- std::array<int , dimension> arr;
1166- for (std::uint8_t i = 0 ; i < dimension; ++i)
1167- arr[i] = nbrGhosts (centerings[i]);
1168- return arr;
1169- }();
1170- auto ghostBox = grow (AMRBox_, growBy);
1183+ auto box = AMRBox_;
11711184 for (std::uint8_t i = 0 ; i < dimension; ++i)
1172- ghostBox .upper [i] += (centerings[i] == QtyCentering::primal) ? 1 : 0 ;
1173- return ghostBox ;
1185+ box .upper [i] += (centerings[i] == QtyCentering::primal) ? 1 : 0 ;
1186+ return box ;
11741187 }
11751188
1176- auto AMRBoxFor (auto const & field) const
1189+ auto AMRGhostBoxFor (auto const & field) const
11771190 {
11781191 auto const centerings = centering (field);
1179- return grow (AMRGhostBoxFor (field), for_N_make_array<dimension>([&](auto i) {
1180- return -1 * nbrGhosts (centerings[i]);
1181- }));
1192+ return grow (AMRBoxFor (field), for_N_make_array<dimension>(
1193+ [&](auto i) { return nbrGhosts (centerings[i]); }));
11821194 }
11831195
1196+
11841197 template <typename Field, typename Fn>
11851198 void evalOnBox (Field& field, Fn&& fn) const
11861199 {
@@ -1203,6 +1216,15 @@ namespace core
12031216
12041217 auto levelNumber () const { return levelNumber_; }
12051218
1219+
1220+ auto amr_lcl_idx (auto const & box) const { return boxes_iterator{box, AMRToLocal (box)}; }
1221+ auto amr_lcl_idx () const { return amr_lcl_idx (AMRBox ()); }
1222+ auto domain_amr_lcl_idx (auto const & field) const { return amr_lcl_idx (AMRBoxFor (field)); }
1223+ auto ghost_amr_lcl_idx (auto const & field) const
1224+ {
1225+ return amr_lcl_idx (AMRGhostBoxFor (field));
1226+ }
1227+
12061228 private:
12071229 template <typename Field, typename IndicesFn, typename Fn>
12081230 static void evalOnBox_ (Field& field, Fn& fn, IndicesFn& startToEnd)
@@ -1515,51 +1537,6 @@ namespace core
15151537 }
15161538
15171539
1518-
1519- struct AMRLocalIndexer //
1520- {
1521- GridLayout const * layout;
1522- Box<int , dimension> amr_box;
1523- Box<std::uint32_t , dimension> lcl_box = layout->AMRToLocal (amr_box);
1524-
1525- struct iterator
1526- {
1527- void operator ++()
1528- {
1529- ++amr_it;
1530- ++lcl_it;
1531- }
1532- auto operator *() { return std::forward_as_tuple (*amr_it, *lcl_it); }
1533- auto operator ==(auto const & that) const
1534- {
1535- return amr_it == that.amr_it and lcl_it == that.lcl_it ;
1536- }
1537- auto operator !=(auto const & that) const
1538- {
1539- return amr_it != that.amr_it or lcl_it != that.lcl_it ;
1540- }
1541-
1542- AMRLocalIndexer const * amr_lcl_indexer;
1543- box_iterator<int , dimension> amr_it;
1544- box_iterator<std::uint32_t , dimension> lcl_it;
1545- };
1546-
1547- auto begin () const { return iterator{this , amr_box.begin (), lcl_box.begin ()}; }
1548- auto end () const { return iterator{this , amr_box.end (), lcl_box.end ()}; }
1549- };
1550-
1551- public:
1552- auto amr_lcl_idx (auto const & box) const { return AMRLocalIndexer{this , box}; }
1553- auto amr_lcl_idx () const { return amr_lcl_idx (AMRBox ()); }
1554- auto domain_amr_lcl_idx (auto const & field) const
1555- {
1556- return AMRLocalIndexer{this , AMRBoxFor (field)};
1557- }
1558- auto ghost_amr_lcl_idx (auto const & field) const
1559- {
1560- return AMRLocalIndexer{this , AMRGhostBoxFor (field)};
1561- }
1562-
15631540 private:
15641541 std::array<double , dimension> meshSize_;
15651542 Point<double , dimension> origin_;
0 commit comments