Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::AlgVector< T, Allocator > Class Template Reference

Distributed dense vector that mirrors the layout of an AlgPartition. More...

#include <AMReX_AlgVector.H>

Public Types

using value_type = T
 
using allocator_type = Allocator
 
using Vec = PODVector< T, Allocator >
 

Public Member Functions

 AlgVector ()=default
 Create an empty vector; call define() before use.
 
 AlgVector (Long global_size)
 Allocate and partition global_size rows across MPI ranks.
 
 AlgVector (AlgPartition partition)
 Adopt an explicit partition that describes the data layout.
 
 AlgVector (AlgVector< T, Allocator > const &)=delete
 
AlgVectoroperator= (AlgVector< T, Allocator > const &)=delete
 
 AlgVector (AlgVector< T, Allocator > &&) noexcept=default
 
AlgVectoroperator= (AlgVector< T, Allocator > &&) noexcept=default
 
 ~AlgVector ()=default
 
void define (Long global_size)
 Resize/repartition the vector to span global_size rows.
 
void define (AlgPartition partition)
 Replace the current partition and storage with partition.
 
bool empty () const
 True if the local storage holds zero entries.
 
AlgPartition const & partition () const
 Partition describing the global layout of the vector.
 
Long numLocalRows () const
 Number of entries stored on this rank.
 
Long numGlobalRows () const
 Global number of rows.
 
Long globalBegin () const
 Inclusive global index begin.
 
Long globalEnd () const
 Exclusive global index end.
 
T const * data () const
 
T * data ()
 
Table1D< T const, Longview () const
 
Table1D< T const, Longconst_view () const
 
Table1D< T, Longview ()
 
void setVal (T val)
 
void setValAsync (T val)
 
void copy (AlgVector< T, Allocator > const &rhs)
 
void copyAsync (AlgVector< T, Allocator > const &rhs)
 
void plus (AlgVector< T, Allocator > const &rhs)
 
void plusAsync (AlgVector< T, Allocator > const &rhs)
 
void scale (T scale_factor)
 
void scaleAsync (T scale_factor)
 
sum (bool local=false) const
 Return the sum of elements.
 
norminf (bool local=false) const
 Return the infinity norm.
 
norm1 (bool local=false) const
 Return the 1-norm.
 
norm2 (bool local=false) const
 Return the 2-norm.
 
std::pair< T, T > norm1and2 (bool local=false) const
 Return the 1-norm and 2-norm as a pair.
 
template<typename FAB , std::enable_if_t< amrex::IsBaseFab< FAB >::value &&std::is_same_v< T, typename FAB::value_type >, int > = 0>
void copyFrom (FabArray< FAB > const &fa)
 Flatten a cell-centered FabArray into this vector's storage.
 
template<typename FAB , std::enable_if_t< amrex::IsBaseFab< FAB >::value &&std::is_same_v< T, typename FAB::value_type >, int > = 0>
void copyTo (FabArray< FAB > &fa) const
 Scatter this vector back into a cell-centered FabArray.
 
void printToFile (std::string const &file) const
 

Detailed Description

template<typename T, typename Allocator = DefaultAllocator<T>>
class amrex::AlgVector< T, Allocator >

Distributed dense vector that mirrors the layout of an AlgPartition.

Member Typedef Documentation

◆ allocator_type

template<typename T , typename Allocator = DefaultAllocator<T>>
using amrex::AlgVector< T, Allocator >::allocator_type = Allocator

◆ value_type

template<typename T , typename Allocator = DefaultAllocator<T>>
using amrex::AlgVector< T, Allocator >::value_type = T

◆ Vec

template<typename T , typename Allocator = DefaultAllocator<T>>
using amrex::AlgVector< T, Allocator >::Vec = PODVector<T,Allocator>

Constructor & Destructor Documentation

◆ AlgVector() [1/5]

template<typename T , typename Allocator = DefaultAllocator<T>>
amrex::AlgVector< T, Allocator >::AlgVector ( )
default

Create an empty vector; call define() before use.

◆ AlgVector() [2/5]

template<typename T , typename Allocator >
amrex::AlgVector< T, Allocator >::AlgVector ( Long  global_size)
explicit

Allocate and partition global_size rows across MPI ranks.

◆ AlgVector() [3/5]

template<typename T , typename Allocator >
amrex::AlgVector< T, Allocator >::AlgVector ( AlgPartition  partition)
explicit

Adopt an explicit partition that describes the data layout.

◆ AlgVector() [4/5]

template<typename T , typename Allocator = DefaultAllocator<T>>
amrex::AlgVector< T, Allocator >::AlgVector ( AlgVector< T, Allocator > const &  )
delete

◆ AlgVector() [5/5]

template<typename T , typename Allocator = DefaultAllocator<T>>
amrex::AlgVector< T, Allocator >::AlgVector ( AlgVector< T, Allocator > &&  )
defaultnoexcept

◆ ~AlgVector()

template<typename T , typename Allocator = DefaultAllocator<T>>
amrex::AlgVector< T, Allocator >::~AlgVector ( )
default

Member Function Documentation

◆ const_view()

template<typename T , typename Allocator = DefaultAllocator<T>>
Table1D< T const, Long > amrex::AlgVector< T, Allocator >::const_view ( ) const
inline

Return a Table1D view of the data. Unlike data(), indexing starts at the global row index. Use the global row index when accessing the data.

◆ copy()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::copy ( AlgVector< T, Allocator > const &  rhs)

Copy values from rhs into this vector. For GPU builds, this function synchronizes with the hostr before returning.

◆ copyAsync()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::copyAsync ( AlgVector< T, Allocator > const &  rhs)

Copy values from rhs into this vector. For GPU guilds, this function is asynchronous with respect to the host.

◆ copyFrom()

template<typename T , typename Allocator >
template<typename FAB , std::enable_if_t< amrex::IsBaseFab< FAB >::value &&std::is_same_v< T, typename FAB::value_type >, int > >
void amrex::AlgVector< T, Allocator >::copyFrom ( FabArray< FAB > const &  fa)

Flatten a cell-centered FabArray into this vector's storage.

Parameters
faSource data; each valid box is copied in IndexType order.

◆ copyTo()

template<typename T , typename Allocator >
template<typename FAB , std::enable_if_t< amrex::IsBaseFab< FAB >::value &&std::is_same_v< T, typename FAB::value_type >, int > >
void amrex::AlgVector< T, Allocator >::copyTo ( FabArray< FAB > &  fa) const

Scatter this vector back into a cell-centered FabArray.

Parameters
faDestination data that receives entries owned by this rank.

◆ data() [1/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
T * amrex::AlgVector< T, Allocator >::data ( )
inline

Return raw data pointer. Unlike view(), the starting index is zero. Use the local row index when accessing the data.

◆ data() [2/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
T const * amrex::AlgVector< T, Allocator >::data ( ) const
inline

Return raw data pointer. Unlike view(), the starting index is zero. Use the local row index when accessing the data.

◆ define() [1/2]

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::define ( AlgPartition  partition)

Replace the current partition and storage with partition.

Parameters
partitionPartition describing the global layout to adopt.

◆ define() [2/2]

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::define ( Long  global_size)

Resize/repartition the vector to span global_size rows.

Existing contents are discarded; rows are divided evenly across participating ranks.

Parameters
global_sizeTotal number of entries in the vector.

◆ empty()

template<typename T , typename Allocator = DefaultAllocator<T>>
bool amrex::AlgVector< T, Allocator >::empty ( ) const
inline

True if the local storage holds zero entries.

◆ globalBegin()

template<typename T , typename Allocator = DefaultAllocator<T>>
Long amrex::AlgVector< T, Allocator >::globalBegin ( ) const
inline

Inclusive global index begin.

◆ globalEnd()

template<typename T , typename Allocator = DefaultAllocator<T>>
Long amrex::AlgVector< T, Allocator >::globalEnd ( ) const
inline

Exclusive global index end.

◆ norm1()

template<typename T , typename Allocator >
T amrex::AlgVector< T, Allocator >::norm1 ( bool  local = false) const

Return the 1-norm.

By default, this returns the global norm over all MPI ranks. If local is true, it returns the norm over the locally stored entries only.

Parameters
localIf true, compute the norm over local entries only.
Returns
The 1-norm.

◆ norm1and2()

template<typename T , typename Allocator >
std::pair< T, T > amrex::AlgVector< T, Allocator >::norm1and2 ( bool  local = false) const

Return the 1-norm and 2-norm as a pair.

By default, this returns the global norms over all MPI ranks. If local is true, it returns the norms over the locally stored entries only.

Parameters
localIf true, compute the norms over local entries only.
Returns
The 1-norm and 2-norm as a pair.

◆ norm2()

template<typename T , typename Allocator >
T amrex::AlgVector< T, Allocator >::norm2 ( bool  local = false) const

Return the 2-norm.

By default, this returns the global norm over all MPI ranks. If local is true, it returns the norm over the locally stored entries only.

Parameters
localIf true, compute the norm over local entries only.
Returns
The 2-norm.

◆ norminf()

template<typename T , typename Allocator >
T amrex::AlgVector< T, Allocator >::norminf ( bool  local = false) const

Return the infinity norm.

By default, this returns the global norm over all MPI ranks. If local is true, it returns the norm over the locally stored entries only.

Parameters
localIf true, compute the norm over local entries only.
Returns
The infinity norm.

◆ numGlobalRows()

template<typename T , typename Allocator = DefaultAllocator<T>>
Long amrex::AlgVector< T, Allocator >::numGlobalRows ( ) const
inline

Global number of rows.

◆ numLocalRows()

template<typename T , typename Allocator = DefaultAllocator<T>>
Long amrex::AlgVector< T, Allocator >::numLocalRows ( ) const
inline

Number of entries stored on this rank.

◆ operator=() [1/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
AlgVector & amrex::AlgVector< T, Allocator >::operator= ( AlgVector< T, Allocator > &&  )
defaultnoexcept

◆ operator=() [2/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
AlgVector & amrex::AlgVector< T, Allocator >::operator= ( AlgVector< T, Allocator > const &  )
delete

◆ partition()

template<typename T , typename Allocator = DefaultAllocator<T>>
AlgPartition const & amrex::AlgVector< T, Allocator >::partition ( ) const
inline

Partition describing the global layout of the vector.

◆ plus()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::plus ( AlgVector< T, Allocator > const &  rhs)

Add rhs to this vector in-place. For GPU builds, this function synchronizes with the hostr before returning.

◆ plusAsync()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::plusAsync ( AlgVector< T, Allocator > const &  rhs)

Add rhs to this vector in-place. For GPU guilds, this function is asynchronous with respect to the host.

◆ printToFile()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::printToFile ( std::string const &  file) const

◆ scale()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::scale ( scale_factor)

Scale this vector by scale_factor in-place. For GPU builds, this function synchronizes with the hostr before returning.

◆ scaleAsync()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::scaleAsync ( scale_factor)

Scale this vector by scale_factor in-place. For GPU guilds, this function is asynchronous with respect to the host.

◆ setVal()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::setVal ( val)

Set every element to val. For GPU builds, this function synchronizes with the host before returning.

◆ setValAsync()

template<typename T , typename Allocator >
void amrex::AlgVector< T, Allocator >::setValAsync ( val)

Set every element to val. For GPU builds, this function is asynchronous with respect to the host.

◆ sum()

template<typename T , typename Allocator >
T amrex::AlgVector< T, Allocator >::sum ( bool  local = false) const

Return the sum of elements.

By default, this returns the global sum over all MPI ranks. If local is true, it returns the sum over the locally stored entries only.

Parameters
localIf true, compute the sum over local entries only.
Returns
The sum of elements.

◆ view() [1/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
Table1D< T, Long > amrex::AlgVector< T, Allocator >::view ( )
inline

Return a Table1D view of the data. Unlike data(), indexing starts at the global row index. Use the global row index when accessing the data.

◆ view() [2/2]

template<typename T , typename Allocator = DefaultAllocator<T>>
Table1D< T const, Long > amrex::AlgVector< T, Allocator >::view ( ) const
inline

Return a Table1D view of the data. Unlike data(), indexing starts at the global row index. Use the global row index when accessing the data.


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