Serialize pointer-to-pointer-... array into one 1D array, keeping track of the offsets in few additional 1D arrays.
More...
|
| Index_t * | GetIndices () |
| |
| const Index_t * | GetIndices () const |
| |
| | NdFlattener () |
| | Basic constructor. Afterwards, initialization can be done with initialize_or_refresh.
|
| |
| template<class... ARGS> |
| | NdFlattener (ARGS const &... args) |
| | Constructor which calls initialize_or_refresh.
|
| |
| template<class... ARGS> |
| void | initialize_or_refresh (ARGS const &... args) |
| | Initialize or refresh the NdFlattener.
|
| |
| bool | initialized () |
| | Initialization status of the NdFlattener.
|
| |
| template<class f_type > |
| void | initialize (f_type f) |
| | Initialize from a 'recursive function'.
|
| |
| template<class f_type > |
| void | refresh (f_type f) |
| | Refresh the data according to the 'recursive function'.
|
| |
| template<typename MPI_Environment_type > |
| void | initialize (MPI_Environment_type const &mpi_env, Base const &local_version) |
| | Initialize a flattener with K indices by combining distributed flatteners with (K-1) indices each.
|
| |
| template<typename MPI_Environment_type > |
| void | refresh (MPI_Environment_type const &mpi_env, Base const &local_version) |
| | Refresh the data by MPI collective communication.
|
| |
| Index_t | size () const |
| |
| helpers::IndexAccumulator< K - 1, NdFlattener< K - 1, Data_t, Index_t > > | operator[] (Index_t i0) |
| | Look-up with IndexAccumulator, non-const version.
|
| |
| helpers::IndexAccumulator< K - 1, const NdFlattener< K - 1, Data_t, Index_t > > | operator[] (Index_t i0) const |
| | Look-up with IndexAccumulator, const version.
|
| |
|
| void | toPythonString_fromto (std::ostream &output, Index_t from, Index_t to) const |
| | Write to stream in Python-list style, using the data of the indices array between 'from' (inclusive) and 'to' (exclusive).
|
| |
| void | allocate () |
| | Allocate the indices array after nNodes has been determined.
|
| |
| void | reset_iNode () |
| | Set iNode to 0 in all layers.
|
| |
| template<class f_type > |
| void | count_f (f_type f) |
| | Determine the space required for reading the 'recursive function'.
|
| |
| template<class f_type > |
| void | set_f (f_type f, bool refresh) |
| | Read the 'recursive function' into the allocated arrays.
|
| |
| void | count_g (Nd_MPI_Environment const &mpi_env, su2matrix< Index_t > &Nodes_all, CurrentLayer const &local_version) |
| | Count the distributed flatteners' numbers of nodes, and set nNodes.
|
| |
| void | set_g (Nd_MPI_Environment const &mpi_env, su2matrix< Index_t > const &Nodes_all, CurrentLayer const &local_version) |
| | Gather the distributed flatteners' data and index arrays into the allocated arrays.
|
| |
template<size_t K_, typename Data_t_, typename Index_t_>
class NdFlattener< K_, Data_t_, Index_t_ >
Serialize pointer-to-pointer-... array into one 1D array, keeping track of the offsets in few additional 1D arrays.
The pointer-to-pointer-... array can be provided by a nested lambda function ('recursive function') or by gathering such arrays from MPI processes ('collective communication'). After initializing an NdFlattener with either of these data, it can be refreshed in the same way after the the pointer-to-pointer-... array's values (but not its structure) have changed.
- Template Parameters
-
| K | - number of indices |
| Data_t | - Type of stored array data |
| Index | - Type of index |
template<size_t K_, typename Data_t_ , typename Index_t_ >
template<class f_type >
| void NdFlattener< K_, Data_t_, Index_t_ >::initialize |
( |
f_type |
f | ) |
|
|
inline |
Initialize from a 'recursive function'.
The function should return a pair. Its first entry is the number of children. Its second entry is a function with the same meaning, recursively one layer down.
- Parameters
-
| f | - the 'recursive function' |
template<size_t K_, typename Data_t_ , typename Index_t_ >
template<typename MPI_Environment_type >
| void NdFlattener< K_, Data_t_, Index_t_ >::initialize |
( |
MPI_Environment_type const & |
mpi_env, |
|
|
Base const & |
local_version |
|
) |
| |
|
inline |
Initialize a flattener with K indices by combining distributed flatteners with (K-1) indices each.
The new first index will encode the rank of the process. Data is exchanged in MPI::Allgatherv-style collective communication.
- Parameters
-
| [in] | mpi_env | - The MPI environment used for communication. |
| [in] | local_version | - The local NdFlattener structure with (K-1) indices. |
template<size_t K_, typename Data_t_ , typename Index_t_ >
template<class... ARGS>
| void NdFlattener< K_, Data_t_, Index_t_ >::initialize_or_refresh |
( |
ARGS const &... |
args | ) |
|
|
inline |
Initialize or refresh the NdFlattener.
Either a 'recursive function' or 'collective communication' may be used. When the NdFlattener does not hold data yet, it is initialized, meaning that the data are collected and the indices arrays are allocated and filled. Otherwise it is refreshed, meaning that the data are recollected under the assumption that the indices arrays did not change.
template<size_t K_, typename Data_t_ , typename Index_t_ >
template<class f_type >
| void NdFlattener< K_, Data_t_, Index_t_ >::refresh |
( |
f_type |
f | ) |
|
|
inline |
Refresh the data according to the 'recursive function'.
The NdFlattener must have been constructed with a 'recursive function'. Now refresh the values with another 'recursive function'. The subarray lengths resulting from both 'recursive functions' must coincide, as the indices arrays are not changed.
- Parameters
-
| f | - the 'recursive function' |
- Template Parameters
-
| f_type | - to allow for any type of the 'recursive function' |
template<size_t K_, typename Data_t_ , typename Index_t_ >
template<typename MPI_Environment_type >
| void NdFlattener< K_, Data_t_, Index_t_ >::refresh |
( |
MPI_Environment_type const & |
mpi_env, |
|
|
Base const & |
local_version |
|
) |
| |
|
inline |
Refresh the data by MPI collective communication.
The NdFlattener must have been constructed by MPI collective communication. Now refresh the values with another collective communication. The subarray lengths resulting from both collective communications must coincide, as the indices arrays are not changed.
- Parameters
-
| [in] | mpi_env | - The MPI environment used for communication. |
| [in] | local_version | - The local NdFlattener structure. |
template<size_t K_, typename Data_t_ , typename Index_t_ >
Write to stream in Python-list style, using the data of the indices array between 'from' (inclusive) and 'to' (exclusive).
Like this: [[1, 2], [10, 20, 30]]
- Parameters
-
| [in] | output | - Stream |
| [in] | from | - Beginning of the representation in the indices array. |
| [in] | to | - Ending of the representation in the indices array. |
template<size_t K_, typename Data_t_ , typename Index_t_ >
| std::ostream & operator<< |
( |
std::ostream & |
output, |
|
|
NdFlattener< K_, Data_t_, Index_t_ > const & |
nd |
|
) |
| |
|
friend |
Write in Python-list style.
Like this: [[1, 2], [10, 20, 30]]