IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::SubFieldLayout< Dim > Class Template Reference

SubFieldLayout provides a layout for a sub-region of a larger field. More...

#include <SubFieldLayout.h>

+ Inheritance diagram for ippl::SubFieldLayout< Dim >:
+ Collaboration diagram for ippl::SubFieldLayout< Dim >:

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
 
- Public Types inherited from ippl::FieldLayout< Dim >
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

 SubFieldLayout (const mpi::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)
 
 SubFieldLayout (mpi::Communicator, const NDIndex< Dim > &domain, const NDIndex< Dim > &subDomain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 Constructor that creates a SubFieldLayout for a sub-region of a larger domain.
 
 SubFieldLayout (mpi::Communicator, const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 Constructor for full-domain layout.
 
virtual ~SubFieldLayout ()=default
 Destructor: Everything deletes itself automatically.
 
void initialize (const NDIndex< Dim > &domain, const NDIndex< Dim > &subDomain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 Initializes a SubFieldLayout with the sub-domain partitioned in the same way as the original FieldLayout partitiones the full domain.
 
void initialize (const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
 Initializes a SubFieldLayout using the domain as both the full domain and sub-domain.
 
const NDIndex< Dim > & getOriginDomain () const
 Return the original domain before sub-region extraction.
 
template<unsigned Dim2>
bool operator== (const SubFieldLayout< Dim2 > &x) const
 Compare SubFieldLayouts to see if they represent the same domain.
 
template<unsigned Dim2>
bool operator== (const FieldLayout< Dim2 > &x) const
 Compare SubFieldLayout to a FieldLayout to see if they represent the same domain.
 
- Public Member Functions inherited from ippl::FieldLayout< Dim >
 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)
 

Additional Inherited Members

- Static Public Member Functions inherited from ippl::FieldLayout< Dim >
static int getMatchingIndex (int index)
 
- Public Attributes inherited from ippl::FieldLayout< Dim >
bool isAllPeriodic_m
 
mpi::Communicator comm
 
- Protected Member Functions inherited from ippl::FieldLayout< Dim >
void calcWidths ()
 
- Protected Attributes inherited from ippl::FieldLayout< Dim >
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]
 

Detailed Description

template<unsigned Dim>
class ippl::SubFieldLayout< Dim >

SubFieldLayout provides a layout for a sub-region of a larger field.

SubFieldLayout extends FieldLayout to handle sub-regions of a larger computational domain. It ensures that the sub-region is partitioned in the same way as the original FieldLayout, maintaining consistent parallel decomposition and neighbor relationships within the sub-region.

Important Constraint:
SubFieldLayout only allows for sub-layouts that do NOT leave local domains empty. All MPI ranks must have at least some portion of the sub-domain assigned to them. If a sub-domain would result in empty local domains for some ranks, an exception will be thrown during initialization.
Template Parameters
DimNumber of spatial dimensions

Constructor & Destructor Documentation

◆ SubFieldLayout() [1/3]

template<unsigned Dim>
ippl::SubFieldLayout< Dim >::SubFieldLayout ( 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)

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

Parameters
communicatorMPI communicator to use (defaults to MPI_COMM_WORLD)
Parameters
communicatorMPI communicator to use (defaults to MPI_COMM_WORLD)

Creates a SubFieldLayout without specifying domains. The layout must be initialized later using the initialize() methods. This constructor is useful when you need to defer the layout configuration until more information is available.

Creates a SubFieldLayout without specifying domains. The layout must be initialized later using the initialize() methods. This constructor is useful when you need to defer the layout configuration until more information is available.

◆ SubFieldLayout() [2/3]

template<unsigned Dim>
ippl::SubFieldLayout< Dim >::SubFieldLayout ( mpi::Communicator  communicator,
const NDIndex< Dim > &  domain,
const NDIndex< Dim > &  subDomain,
std::array< bool, Dim >  isParallel,
bool  isAllPeriodic = false 
)

Constructor that creates a SubFieldLayout for a sub-region of a larger domain.

Constructor that creates a SubFieldLayout for a sub-region of a larger domain.

Parameters
communicatorMPI communicator to use
domainThe full domain that defines the partitioning
subDomainThe sub-region within the full domain, which is partitioned in the same way as the fullomain
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions
Parameters
communicatorMPI communicator to use
domainThe full domain that defines the partitioning
subDomainThe sub-region within the full domain, which is partitioned in the same way as the fullomain
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions

Implementation details: Initializes both the full domain decomposition and the sub-domain layout. The sub-domain must be contained within the full domain. All MPI ranks must have non-empty local domains after intersection with the sub-domain, otherwise an exception will be thrown.

This constructor sets up the parallel decomposition based on the full domain, then restricts the full domain to the specified sub-region while maintaining the same partitioning structure.

Implementation details: Initializes both the full domain decomposition and the sub-domain layout. The sub-domain must be contained within the full domain. All MPI ranks must have non-empty local domains after intersection with the sub-domain, otherwise an exception will be thrown.

This constructor sets up the parallel decomposition based on the full domain, then restricts the full domain to the specified sub-region while maintaining the same partitioning structure.

◆ SubFieldLayout() [3/3]

template<unsigned Dim>
ippl::SubFieldLayout< Dim >::SubFieldLayout ( mpi::Communicator  communicator,
const NDIndex< Dim > &  domain,
std::array< bool, Dim >  isParallel,
bool  isAllPeriodic = false 
)

Constructor for full-domain layout.

Constructor for full-domain layout.

Parameters
communicatorMPI communicator to use
domainThe full domain that defines the partitioning and is used as the sub-domain simultaneously
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions
Parameters
communicatorMPI communicator to use
domainThe full domain that defines the partitioning and is used as the sub-domain simultaneously
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions

Implementation details: Creates a SubFieldLayout where the sub-domain is the same as the full domain, making it functionally equivalent to a regular FieldLayout.

Implementation details: Creates a SubFieldLayout where the sub-domain is the same as the full domain, making it functionally equivalent to a regular FieldLayout.

Member Function Documentation

◆ getOriginDomain()

template<unsigned Dim>
const NDIndex< Dim > & ippl::SubFieldLayout< Dim >::getOriginDomain ( ) const
inline

Return the original domain before sub-region extraction.

Returns
Reference to the original full domain

◆ initialize() [1/2]

template<unsigned Dim>
void ippl::SubFieldLayout< Dim >::initialize ( const NDIndex< Dim > &  domain,
const NDIndex< Dim > &  subDomain,
std::array< bool, Dim >  isParallel,
bool  isAllPeriodic = false 
)

Initializes a SubFieldLayout with the sub-domain partitioned in the same way as the original FieldLayout partitiones the full domain.

Initializes a SubFieldLayout with the sub-domain partitioned in the same way as the original FieldLayout partitiones the full domain.

Parameters
domainThe full domain to be partitioned
subDomainThe sub-region within the full domain
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions
Parameters
domainThe full domain to be partitioned
subDomainThe sub-region within the full domain
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions

Implementation details: This method first partitions the full domain for parallel processing, then restricts each rank's local domain to the specified sub-domain.

The sub-domain must be contained within the full domain, and all MPI ranks must have non-empty local domains after intersection with the sub-domain, otherwise an exception will be thrown.

Implementation details: This method first partitions the full domain for parallel processing, then restricts each rank's local domain to the specified sub-domain.

The sub-domain must be contained within the full domain, and all MPI ranks must have non-empty local domains after intersection with the sub-domain, otherwise an exception will be thrown.

◆ initialize() [2/2]

template<unsigned Dim>
void ippl::SubFieldLayout< Dim >::initialize ( const NDIndex< Dim > &  domain,
std::array< bool, Dim >  isParallel,
bool  isAllPeriodic = false 
)

Initializes a SubFieldLayout using the domain as both the full domain and sub-domain.

Initializes a SubFieldLayout using the domain as both the full domain and sub-domain.

Parameters
domainThe domain to be partitioned
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions
Parameters
domainThe domain to be partitioned
decompArray specifying which dimensions should be parallel
isAllPeriodicWhether all dimensions have periodic boundary conditions

Implementation details: This method initializes the layout to use the entire domain as both the full domain and the sub-domain, making it equivalent to a regular FieldLayout.

Implementation details: This method initializes the layout to use the entire domain as both the full domain and the sub-domain, making it equivalent to a regular FieldLayout.

◆ operator==() [1/2]

template<unsigned Dim>
template<unsigned Dim2>
bool ippl::SubFieldLayout< Dim >::operator== ( const FieldLayout< Dim2 > &  x) const
inline

Compare SubFieldLayout to a FieldLayout to see if they represent the same domain.

Template Parameters
Dim2Dimension of the FieldLayout
Parameters
xThe FieldLayout to compare with
Returns
true if the SubFieldLayout's domain equals its original domain and matches the FieldLayout's domain and local domains

◆ operator==() [2/2]

template<unsigned Dim>
template<unsigned Dim2>
bool ippl::SubFieldLayout< Dim >::operator== ( const SubFieldLayout< Dim2 > &  x) const
inline

Compare SubFieldLayouts to see if they represent the same domain.

Template Parameters
Dim2Dimension of the other SubFieldLayout
Parameters
xThe other SubFieldLayout to compare with
Returns
true if both the current domain, origin domain and local domains match

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