OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::Array< T, D > Class Template Reference

Public Member Functions

 Array (const std::array< int, D > &dimensions, const std::array< int, D > &offsets={0})
 Constructs an Array object with the specified dimensions and offsets.
 
 Array (const Decomposition &decomp)
 Constructs an Array object from Decomposition object. Array dimension and offset depends from the type T of array. If the type of array is double, i.e. T = double, then inbox_size and inbox_offset is used. If the type of array is complex, i.e. T = std::complex<double>, then outbox_size and oubox_offset is used.
 
std::vector< T >::iterator begin ()
 
std::vector< T >::iterator end ()
 
std::vector< T >::const_iterator begin () const
 
std::vector< T >::const_iterator end () const
 
const MultiIndex< D > & get_index () const
 Get the index object.
 
std::vector< T > & get_data ()
 Get the data object.
 
T & operator[] (const std::array< int, D > &indices)
 
T & operator[] (int idx)
 
T & operator() (const std::array< int, D > &indices)
 
std::array< int, D > get_size () const
 Get the size object.
 
std::array< int, D > get_offset () const
 Get the offset object.
 
bool inbounds (const std::array< int, D > &indices)
 Checks if the specified indices are in bounds.
 
template<typename Func >
void apply (Func &&func)
 Applies the specified function to each element of the array.
 
 operator std::vector< T > & ()
 Convert Array<T, D> to std::vector<T>.
 
void set_data (const std::vector< T > &new_data)
 

Friends

std::ostream & operator<< (std::ostream &os, const Array< T, D > &array)
 Outputs the array to the specified output stream.
 

Constructor & Destructor Documentation

◆ Array() [1/2]

template<typename T , size_t D>
pfc::Array< T, D >::Array ( const std::array< int, D > &  dimensions,
const std::array< int, D > &  offsets = {0} 
)
inline

Constructs an Array object with the specified dimensions and offsets.

Parameters
dimensionsThe dimensions of the array.
offsetsThe offsets of the array.

◆ Array() [2/2]

template<typename T , size_t D>
pfc::Array< T, D >::Array ( const Decomposition decomp)
inline

Constructs an Array object from Decomposition object. Array dimension and offset depends from the type T of array. If the type of array is double, i.e. T = double, then inbox_size and inbox_offset is used. If the type of array is complex, i.e. T = std::complex<double>, then outbox_size and oubox_offset is used.

Parameters
decompThe Decomposition object.

Member Function Documentation

◆ apply()

template<typename T , size_t D>
template<typename Func >
void pfc::Array< T, D >::apply ( Func &&  func)
inline

Applies the specified function to each element of the array.

Template Parameters
Func
Parameters
funcA function that takes std::array<int, D> as an argument and returns a type convertible to T.
Here is the call graph for this function:

◆ get_data()

template<typename T , size_t D>
std::vector< T > & pfc::Array< T, D >::get_data ( )
inline

Get the data object.

Returns
std::vector<T>&
Here is the caller graph for this function:

◆ get_index()

template<typename T , size_t D>
const MultiIndex< D > & pfc::Array< T, D >::get_index ( ) const
inline

Get the index object.

Returns
const MultiIndex<D>&

◆ get_offset()

template<typename T , size_t D>
std::array< int, D > pfc::Array< T, D >::get_offset ( ) const
inline

Get the offset object.

Returns
std::array<int, D>

◆ get_size()

template<typename T , size_t D>
std::array< int, D > pfc::Array< T, D >::get_size ( ) const
inline

Get the size object.

Returns
std::array<int, D>

◆ inbounds()

template<typename T , size_t D>
bool pfc::Array< T, D >::inbounds ( const std::array< int, D > &  indices)
inline

Checks if the specified indices are in bounds.

Parameters
indicesThe indices to check.
Returns
true
false

◆ operator std::vector< T > &()

template<typename T , size_t D>
pfc::Array< T, D >::operator std::vector< T > & ( )
inline

Convert Array<T, D> to std::vector<T>.

Returns
A reference to underlying data.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T , size_t D>
std::ostream & operator<< ( std::ostream &  os,
const Array< T, D > &  array 
)
friend

Outputs the array to the specified output stream.

Parameters
osThe output stream.
arrayThe array to output.
Returns
Reference to the output stream.

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