8#ifndef IPPL_FIELD_LAYOUT_H
9#define IPPL_FIELD_LAYOUT_H
24 template <
unsigned Dim>
27 template <
unsigned Dim>
46 for (
unsigned int d = 0; d < dim; d++) {
79 template <
unsigned Dim>
92 bool isUpper(
unsigned int face);
109 template <
unsigned Dim>
112 unsigned int axis = index / 2;
129 unsigned Dim,
typename... CubeTags,
130 typename = std::enable_if_t<
sizeof...(CubeTags) ==
Dim - 1>,
131 typename = std::enable_if_t<std::conjunction_v<std::is_same<e_cube_tag, CubeTags>...>>>
133 if constexpr (
Dim == 1) {
143 template <
size_t... Idx>
145 const std::index_sequence<Idx...>&) {
146 return getCube<
sizeof...(Idx)>(args[Idx]...);
156 template <
unsigned Dim>
158 std::array<e_cube_tag, Dim> args;
161 return getFace_impl(args, std::make_index_sequence<Dim>{});
165 template <
unsigned Dim>
174 std::array<long, Dim>
lo;
176 std::array<long, Dim>
hi;
184 for (
unsigned d = 0; d <
Dim; d++) {
185 total *=
hi[d] -
lo[d];
204 bool isAllPeriodic =
false);
216 bool isAllPeriodic =
false);
224 template <
unsigned Dim2>
229 throw std::runtime_error(
"FieldLayout: only FieldLayouts with the same global domain should be compared");
239 throw std::runtime_error(
"FieldLayout: only FieldLayouts with the same global domain should be compared");
242 for (
unsigned int i = 0; i <
Dim; ++i) {
326 const int rank, std::map<unsigned int, int>& offsets,
327 unsigned d0 = 0,
unsigned codim = 0);
345 const NDIndex_t& intersect,
int nghost,
int rank);
347 void write(std::ostream& = std::cout)
const;
349 void updateLayout(
const std::vector<NDIndex_t>& domains);
395 template <
unsigned Dim>
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
std::ostream & operator<<(std::ostream &os, const BConds< Field, Dim > &bc)
constexpr unsigned int factorial(unsigned x)
unsigned int getFaceDim(unsigned int face)
constexpr unsigned int binomialCoefficient(unsigned a, unsigned b)
unsigned int getFace_impl(const std::array< e_cube_tag, sizeof...(Idx)> &args, const std::index_sequence< Idx... > &)
unsigned int getFace(unsigned int axis, e_cube_tag side)
unsigned int indexToFace(unsigned int index)
unsigned int getCube(e_cube_tag tag, CubeTags... tags)
constexpr unsigned int countCubes(unsigned m)
KOKKOS_INLINE_FUNCTION constexpr unsigned int countHypercubes(unsigned int dim)
bool isUpper(unsigned int face)
std::array< bool, Dim > isParallelDim_m
typename view_type::host_mirror_type host_mirror_type
void findNeighbors(int nghost=1)
const neighbor_list & getNeighbors() const
bool operator==(const FieldLayout< Dim2 > &x) const
std::vector< bound_type > bounds_list
const host_mirror_type getHostLocalDomains() const
unsigned int minWidth_m[Dim]
void addNeighbors(const NDIndex_t &gnd, const NDIndex_t &nd, const NDIndex_t &ndNeighbor, const NDIndex_t &intersect, int nghost, int rank)
const view_type getDeviceLocalDomains() const
const NDIndex< Dim > & getDomain() const
neighbor_list neighbors_m
bool getDistribution(unsigned int d) const
neighbor_range_list neighborsSendRange_m
std::array< bool, Dim > isParallel() const
std::array< rank_list, detail::countHypercubes(Dim) - 1 > neighbor_list
typename detail::ViewType< NDIndex_t, 1 >::view_type view_type
void initialize(const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
const NDIndex_t & getLocalNDIndex() const
void findPeriodicNeighbors(const int nghost, const NDIndex< Dim > &localDomain, NDIndex< Dim > &grown, NDIndex< Dim > &neighborDomain, const int rank, std::map< unsigned int, int > &offsets, unsigned d0=0, unsigned codim=0)
int getPeriodicOffset(const NDIndex_t &nd, const unsigned int d, const int k)
neighbor_range_list neighborsRecvRange_m
view_type dLocalDomains_m
Local domains (device view).
FieldLayout(const mpi::Communicator &=MPI_COMM_WORLD)
host_mirror_type hLocalDomains_m
Local domains (host mirror view).
void write(std::ostream &=std::cout) const
virtual ~FieldLayout()=default
std::array< bounds_list, detail::countHypercubes(Dim) - 1 > neighbor_range_list
std::vector< int > rank_list
const neighbor_range_list & getNeighborsSendRange() const
const neighbor_range_list & getNeighborsRecvRange() const
bound_type getBounds(const NDIndex_t &nd1, const NDIndex_t &nd2, const NDIndex_t &offset, int nghost)
NDIndex_t gDomain_m
Global domain.
void updateLayout(const std::vector< NDIndex_t > &domains)
bool operator==(const FieldLayout< Dim > &x) const
static int getMatchingIndex(int index)
std::array< long, Dim > lo
std::array< long, Dim > hi
Kokkos::View< typename NPtr< T, Dim >::type, Properties... > view_type