IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::FieldLayout< Dim > Class Template Reference
+ Inheritance diagram for ippl::FieldLayout< Dim >:
+ Collaboration diagram for ippl::FieldLayout< Dim >:

Classes

struct  bound_type
 

Public Types

using NDIndex_t = NDIndex< Dim >
 
using view_type = typename detail::ViewType< NDIndex_t, 1 >::view_type
 
using host_mirror_type = typename view_type::host_mirror_type
 
using rank_list = std::vector< int >
 
using bounds_list = std::vector< bound_type >
 
using neighbor_list = std::array< rank_list, detail::countHypercubes(Dim) - 1 >
 
using neighbor_range_list = std::array< bounds_list, detail::countHypercubes(Dim) - 1 >
 

Public Member Functions

 FieldLayout (const mpi::Communicator &=MPI_COMM_WORLD)
 
 FieldLayout (mpi::Communicator, const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 
void initialize (const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 
const NDIndex< Dim > & getDomain () const
 
template<unsigned Dim2>
bool operator== (const FieldLayout< Dim2 > &x) const
 
bool operator== (const FieldLayout< Dim > &x) const
 
bool getDistribution (unsigned int d) const
 
std::array< bool, Dim > isParallel () const
 
const NDIndex_tgetLocalNDIndex () const
 
const NDIndex_tgetLocalNDIndex (int rank) const
 
const host_mirror_type getHostLocalDomains () const
 
const view_type getDeviceLocalDomains () const
 
const neighbor_list & getNeighbors () const
 
const neighbor_range_list & getNeighborsSendRange () const
 
const neighbor_range_list & getNeighborsRecvRange () 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)
 
void findNeighbors (int nghost=1)
 
void addNeighbors (const NDIndex_t &gnd, const NDIndex_t &nd, const NDIndex_t &ndNeighbor, const NDIndex_t &intersect, int nghost, int rank)
 
void write (std::ostream &=std::cout) const
 
void updateLayout (const std::vector< NDIndex_t > &domains)
 

Static Public Member Functions

static int getMatchingIndex (int index)
 

Public Attributes

bool isAllPeriodic_m
 
mpi::Communicator comm
 

Protected Member Functions

void calcWidths ()
 

Protected Attributes

NDIndex_t gDomain_m
 Global domain.
 
view_type dLocalDomains_m
 Local domains (device view)
 
host_mirror_type hLocalDomains_m
 Local domains (host mirror view)
 
std::array< bool, Dim > isParallelDim_m
 
unsigned int minWidth_m [Dim]
 

Constructor & Destructor Documentation

◆ FieldLayout()

template<unsigned Dim>
ippl::FieldLayout< Dim >::FieldLayout ( const mpi::Communicator communicator = MPI_COMM_WORLD)

Default constructor, which should only be used if you are going to call 'initialize' soon after (before using in any context)

Member Function Documentation

◆ addNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::addNeighbors ( const NDIndex_t gnd,
const NDIndex_t nd,
const NDIndex_t ndNeighbor,
const NDIndex_t intersect,
int  nghost,
int  rank 
)

Adds a neighbor to the neighbor list

Parameters
gndthe local domain, including ghost cells
ndthe local domain
ndNeighborthe neighbor rank's domain
intersectthe intersection of the domains
nghostnumber of ghost cells
rankthe neighbor's rank

◆ findNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::findNeighbors ( int  nghost = 1)

Finds all neighboring ranks based on the field layout

Parameters
nghostnumber of ghost cells (default 1)

◆ findPeriodicNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::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 
)

Recursively finds neighbor ranks for layouts with all periodic boundary conditions

Parameters
nghostnumber of ghost cells
localDomainthe rank's local domain
grownthe local domain, grown by the number of ghost cells
neighborDomaina candidate neighbor rank's domain
rankthe candidate neighbor's rank
offsetsa dictionary containing offsets along different dimensions
d0the dimension from which to start checking (default 0)
codimthe codimension of overlapping regions to check (default 0)

◆ getMatchingIndex()

template<unsigned Dim>
int ippl::FieldLayout< Dim >::getMatchingIndex ( int  index)
static

Given the index of a hypercube, find the index of the opposite hypercube, i.e. the component with the same codimension belonging to a neighboring domain that touches the hypercube with the given index, as determined by the ternary encoding for hypercubes.

For neighbor communication, the opposite component is the one that receives sent data or sends us data to receive for a given component.

The matching index is given by swapping alls 1s for 0s and vice versa in the ternary encoding, while keeping the 2s unchanged. This can be understood from the fact that if the local component is on the upper boundary of the local domain, the neighbor component must be on the lower boundary of its local domain, and vice versa. The 2s are unchanged because both the local component and the neighbor component must be parallel to the same axes, otherwise their intersection would have lower or higher dimension than the components themselves.

Parameters
indexindex of the known component
Returns
Index of the matching component

◆ getNeighbors()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_list & ippl::FieldLayout< Dim >::getNeighbors ( ) const

Get a list of all the neighbors, arranged by ternary encoding of the hypercubes

Returns
List of list of neighbor ranks touching each boundary component

◆ getNeighborsRecvRange()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_range_list & ippl::FieldLayout< Dim >::getNeighborsRecvRange ( ) const

Get the domain ranges corresponding to regions that should be received from neighbor ranks

Returns
Ranges to receive

◆ getNeighborsSendRange()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_range_list & ippl::FieldLayout< Dim >::getNeighborsSendRange ( ) const

Get the domain ranges corresponding to regions that should be sent to neighbor ranks

Returns
Ranges to send

The documentation for this class was generated from the following files: