File mpicartesianneighbours.h
File List > cartesian > mpicartesianneighbours.h
Go to the documentation of this file
#ifndef TEMPLAT_PARALLEL_MPI_CARTESIAN_MPICARTESIANNEIGHBOURS_H
#define TEMPLAT_PARALLEL_MPI_CARTESIAN_MPICARTESIANNEIGHBOURS_H
/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
Released under the MIT license, see LICENSE.md. */
// File info: Main contributor(s): Wessel Valkenburg, Year: 2019
#include "TempLat/parallel/mpi/cartesian/mpicartesiangroup.h"
#include "TempLat/parallel/mpi/cartesian/mpicartesianneighbourssingledimension.h"
namespace TempLat
{
class MPICartesianNeighbours
{
public:
// Put public methods here. These should change very little over time.
MPICartesianNeighbours(MPICartesianGroup group)
: mCartesianGroup(group), mNDimensions(mCartesianGroup.getNDimensions())
{
for (ptrdiff_t dim = 0; dim < mNDimensions; ++dim) {
allNeighbours.emplace_back(mCartesianGroup, dim);
// sayMPI << allNeighbours.back() << "\n";
}
}
const int &getUpperNeighbour(ptrdiff_t dimension)
{
// sayMPI << "returning neighbour for dimension " << dimension << " upper " <<
// allNeighbours[dimension].getUpper() << "\n";
return allNeighbours[dimension].getUpper();
}
const int &getLowerNeighbour(ptrdiff_t dimension)
{
// sayMPI << "returning neighbour for dimension " << dimension << " lower " <<
// allNeighbours[dimension].getLower() << "\n";
return allNeighbours[dimension].getLower();
}
private:
/* Put all member variables and private methods here. These may change arbitrarily. */
MPICartesianGroup mCartesianGroup;
ptrdiff_t mNDimensions;
std::vector<MPICartesianNeighboursSingleDimension> allNeighbours;
};
} // namespace TempLat
#endif