NeoN
A framework for CFD software
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
NeoN::Array< ValueType > Class Template Reference

A class to contain the data and executors for a field and define some basic operations. More...

#include <array.hpp>

Public Types

using ArrayValueType = ValueType
 

Public Member Functions

 Array (const Executor &exec, localIdx size)
 Create an uninitialized Array with a given size on an executor.
 
 Array (const Executor &exec, const ValueType *in, localIdx size, Executor hostExec=SerialExecutor())
 Create a Array with a given size from existing memory on an executor.
 
 Array (const Executor &exec, localIdx size, ValueType value)
 Create a Array with a given size on an executor and uniform value.
 
 Array (const Executor &exec, std::vector< ValueType > in)
 Create a Array from a given Array of values on an executor.
 
 Array (const Executor &exec, const Array< ValueType > &in)
 Create a Array as a copy of a Array on a specified executor.
 
 Array (const Array< ValueType > &rhs)
 Copy constructor, creates a new field with the same size and data as the parsed field.
 
 Array (Array< ValueType > &&rhs) noexcept
 Move constructor, moves the data from the parsed field to the new field.
 
 ~Array ()
 Destroy the Array object.
 
template<typename func >
void apply (func f)
 applies a functor, transformation, to the field
 
Array< ValueType > copyToExecutor (Executor dstExec) const
 Copies the data to a new field on a specific executor.
 
Array< ValueType > copyToHost () const
 Returns a copy of the field back to the host.
 
void copyToHost (Array< ValueType > &result)
 Copies the data (from anywhere) to a parsed host field.
 
Arrayoperator[] (const localIdx i)=delete
 
const Arrayoperator[] (const localIdx i) const =delete
 
void operator= (const ValueType &rhs)
 Assignment operator, Sets the field values to that of the passed value.
 
void operator= (const Array< ValueType > &rhs)
 Assignment operator, Sets the field values to that of the parsed field.
 
void resize (const localIdx size)
 Resizes the field to a new size.
 
ValueType * data ()
 Direct access to the underlying field data.
 
const ValueType * data () const
 Direct access to the underlying field data.
 
const Executorexec () const
 Gets the executor associated with the field.
 
localIdx size () const
 Gets the size of the field.
 
label ssize () const
 Gets the size of the field.
 
bool empty () const
 Checks if the field is empty.
 
View< ValueType > view () &&=delete
 
View< const ValueType > view () const &&=delete
 
View< ValueType > view () &
 Gets the field as a view.
 
View< const ValueType > view () const &
 Gets the field as a view.
 
View< ValueType > view (std::pair< localIdx, localIdx > range) &&=delete
 
View< const ValueType > view (std::pair< localIdx, localIdx > range) const &&=delete
 
View< ValueType > view (std::pair< localIdx, localIdx > range) &
 Gets a sub view of the field as a view.
 
View< const ValueType > view (std::pair< localIdx, localIdx > range) const &
 Gets a sub view of the field as a view.
 
std::pair< localIdx, localIdxrange () const
 Gets the range of the field.
 

Detailed Description

template<typename ValueType>
class NeoN::Array< ValueType >

A class to contain the data and executors for a field and define some basic operations.

Definition at line 28 of file array.hpp.

Member Typedef Documentation

◆ ArrayValueType

template<typename ValueType >
using NeoN::Array< ValueType >::ArrayValueType = ValueType

Definition at line 33 of file array.hpp.

Constructor & Destructor Documentation

◆ Array() [1/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Executor exec,
localIdx  size 
)
inline

Create an uninitialized Array with a given size on an executor.

Parameters
execExecutor associated to the field
sizesize of the field

Definition at line 40 of file array.hpp.

◆ Array() [2/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Executor exec,
const ValueType *  in,
localIdx  size,
Executor  hostExec = SerialExecutor() 
)
inline

Create a Array with a given size from existing memory on an executor.

Parameters
execExecutor associated to the field
inPointer to existing data
sizesize of the field
hostExecExecutor where the original data is located

Definition at line 58 of file array.hpp.

◆ Array() [3/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Executor exec,
localIdx  size,
ValueType  value 
)
inline

Create a Array with a given size on an executor and uniform value.

Parameters
execExecutor associated to the field
sizesize of the field
valuethe default value

Definition at line 83 of file array.hpp.

◆ Array() [4/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Executor exec,
std::vector< ValueType >  in 
)
inline

Create a Array from a given Array of values on an executor.

Parameters
execExecutor associated to the field
ina Array of elements to copy over

Definition at line 101 of file array.hpp.

◆ Array() [5/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Executor exec,
const Array< ValueType > &  in 
)
inline

Create a Array as a copy of a Array on a specified executor.

Parameters
execExecutor associated to the field
ina Array of elements to copy over

Definition at line 111 of file array.hpp.

◆ Array() [6/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( const Array< ValueType > &  rhs)
inline

Copy constructor, creates a new field with the same size and data as the parsed field.

Parameters
rhsThe field to copy from.

Definition at line 119 of file array.hpp.

◆ Array() [7/7]

template<typename ValueType >
NeoN::Array< ValueType >::Array ( Array< ValueType > &&  rhs)
inlinenoexcept

Move constructor, moves the data from the parsed field to the new field.

Parameters
rhsThe field to move from.

Definition at line 126 of file array.hpp.

◆ ~Array()

template<typename ValueType >
NeoN::Array< ValueType >::~Array ( )
inline

Destroy the Array object.

Definition at line 135 of file array.hpp.

Member Function Documentation

◆ apply()

template<typename ValueType >
template<typename func >
void NeoN::Array< ValueType >::apply ( func  f)
inline

applies a functor, transformation, to the field

Parameters
fThe functor to map over the field.
Note
Ideally the f should be a KOKKOS_LAMBA

Definition at line 147 of file array.hpp.

◆ copyToExecutor()

template<typename ValueType >
Array< ValueType > NeoN::Array< ValueType >::copyToExecutor ( Executor  dstExec) const
inline

Copies the data to a new field on a specific executor.

Parameters
dstExecThe executor on which the data should be copied.
Returns
A copy of the field on the host.

Definition at line 157 of file array.hpp.

◆ copyToHost() [1/2]

template<typename ValueType >
Array< ValueType > NeoN::Array< ValueType >::copyToHost ( ) const
inline

Returns a copy of the field back to the host.

Returns
A copy of the field on the host.

Definition at line 171 of file array.hpp.

◆ copyToHost() [2/2]

template<typename ValueType >
void NeoN::Array< ValueType >::copyToHost ( Array< ValueType > &  result)
inline

Copies the data (from anywhere) to a parsed host field.

Parameters
resultThe field into which the data must be copied. Must be sized.
Warning
exits if the size of the result field is not the same as the source field.

Definition at line 181 of file array.hpp.

◆ data() [1/2]

template<typename ValueType >
ValueType * NeoN::Array< ValueType >::data ( )
inline

Direct access to the underlying field data.

Returns
Pointer to the first cell data in the field.

Definition at line 252 of file array.hpp.

◆ data() [2/2]

template<typename ValueType >
const ValueType * NeoN::Array< ValueType >::data ( ) const
inline

Direct access to the underlying field data.

Returns
Pointer to the first cell data in the field.

Definition at line 258 of file array.hpp.

◆ empty()

template<typename ValueType >
bool NeoN::Array< ValueType >::empty ( ) const
inline

Checks if the field is empty.

Returns
True if the field is empty, false otherwise.

Definition at line 282 of file array.hpp.

◆ exec()

template<typename ValueType >
const Executor & NeoN::Array< ValueType >::exec ( ) const
inline

Gets the executor associated with the field.

Returns
Reference to the executor.

Definition at line 264 of file array.hpp.

◆ operator=() [1/2]

template<typename ValueType >
void NeoN::Array< ValueType >::operator= ( const Array< ValueType > &  rhs)
inline

Assignment operator, Sets the field values to that of the parsed field.

Parameters
rhsThe field to copy from.
Warning
This field will be sized to the size of the parsed field.

Definition at line 211 of file array.hpp.

◆ operator=() [2/2]

template<typename ValueType >
void NeoN::Array< ValueType >::operator= ( const ValueType &  rhs)
inline

Assignment operator, Sets the field values to that of the passed value.

Parameters
rhsThe value to set the field to.

Definition at line 199 of file array.hpp.

◆ operator[]() [1/2]

template<typename ValueType >
const Array & NeoN::Array< ValueType >::operator[] ( const localIdx  i) const
delete

◆ operator[]() [2/2]

template<typename ValueType >
Array & NeoN::Array< ValueType >::operator[] ( const localIdx  i)
delete

◆ range()

template<typename ValueType >
std::pair< localIdx, localIdx > NeoN::Array< ValueType >::range ( ) const
inline

Gets the range of the field.

Returns
The range of the field {0, size()}.

Definition at line 340 of file array.hpp.

◆ resize()

template<typename ValueType >
void NeoN::Array< ValueType >::resize ( const localIdx  size)
inline

Resizes the field to a new size.

Parameters
sizeThe new size to set the field to.

Definition at line 225 of file array.hpp.

◆ size()

template<typename ValueType >
localIdx NeoN::Array< ValueType >::size ( ) const
inline

Gets the size of the field.

Returns
The size of the field.

Definition at line 270 of file array.hpp.

◆ ssize()

template<typename ValueType >
label NeoN::Array< ValueType >::ssize ( ) const
inline

Gets the size of the field.

Returns
The size of the field.

Definition at line 276 of file array.hpp.

◆ view() [1/8]

template<typename ValueType >
View< ValueType > NeoN::Array< ValueType >::view ( ) &
inline

Gets the field as a view.

Returns
View of the field.

Definition at line 294 of file array.hpp.

◆ view() [2/8]

template<typename ValueType >
View< ValueType > NeoN::Array< ValueType >::view ( ) &&
delete

◆ view() [3/8]

template<typename ValueType >
View< const ValueType > NeoN::Array< ValueType >::view ( ) const &
inline

Gets the field as a view.

Returns
View of the field.

Definition at line 303 of file array.hpp.

◆ view() [4/8]

template<typename ValueType >
View< const ValueType > NeoN::Array< ValueType >::view ( ) const &&
delete

◆ view() [5/8]

template<typename ValueType >
View< ValueType > NeoN::Array< ValueType >::view ( std::pair< localIdx, localIdx range) &
inline

Gets a sub view of the field as a view.

Returns
View of the field.

Definition at line 318 of file array.hpp.

◆ view() [6/8]

template<typename ValueType >
View< ValueType > NeoN::Array< ValueType >::view ( std::pair< localIdx, localIdx range) &&
delete

◆ view() [7/8]

template<typename ValueType >
View< const ValueType > NeoN::Array< ValueType >::view ( std::pair< localIdx, localIdx range) const &
inline

Gets a sub view of the field as a view.

Returns
View of the field.

Definition at line 329 of file array.hpp.

◆ view() [8/8]

template<typename ValueType >
View< const ValueType > NeoN::Array< ValueType >::view ( std::pair< localIdx, localIdx range) const &&
delete

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