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

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

#include <vector.hpp>

Public Types

using VectorValueType = ValueType
 

Public Member Functions

 Vector (const Executor &exec, localIdx size)
 Create an uninitialized Vector with a given size on an executor.
 
 Vector (const Executor &exec, const ValueType *in, localIdx size, Executor hostExec=SerialExecutor())
 Create a Vector with a given size from existing memory on an executor.
 
 Vector (const Executor &exec, localIdx size, ValueType value)
 Create a Vector with a given size on an executor and uniform value.
 
 Vector (const Executor &exec, std::vector< ValueType > in)
 Create a Vector from a given vector of values on an executor.
 
 Vector (const Executor &exec, const Vector< ValueType > &in)
 Create a Vector as a copy of a Vector on a specified executor.
 
 Vector (const Vector< ValueType > &rhs)
 Copy constructor, creates a new field with the same size and data as the parsed field.
 
 Vector (Vector< ValueType > &&rhs) noexcept
 Move constructor, moves the data from the parsed field to the new field.
 
 ~Vector ()
 Destroy the Vector object.
 
template<typename func >
void apply (func f)
 applies a functor, transformation, to the field
 
Vector< ValueType > copyToExecutor (Executor dstExec) const
 Copies the data to a new field on a specific executor.
 
Vector< ValueType > copyToHost () const
 Returns a copy of the field back to the host.
 
void copyToHost (Vector< ValueType > &result)
 Copies the data (from anywhere) to a parsed host field.
 
ValueType & operator[] (const localIdx i)=delete
 
const ValueType & operator[] (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 Vector< ValueType > &rhs)
 Assignment operator, Sets the field values to that of the parsed field.
 
Vector< ValueType > & operator+= (const Vector< ValueType > &rhs)
 Arithmetic add operator, addition of a second field.
 
Vector< ValueType > & operator-= (const Vector< ValueType > &rhs)
 Arithmetic subtraction operator, subtraction by a second field.
 
Vector< ValueType > operator* (const Vector< ValueType > &rhs)
 Arithmetic multiply operator, multiply by a second field.
 
Vector< ValueType > operator* (const scalar rhs)
 Arithmetic multiply operator, multiplies every cell in the field by a scalar.
 
Vector< ValueType > & operator*= (const Vector< ValueType > &rhs)
 Assignment multiply operator, multiplies this field by another field element-wise.
 
Vector< ValueType > & operator*= (const scalar rhs)
 Assignment multiply operator, multiplies every cell in the field by a scalar.
 
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::Vector< ValueType >

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

Definition at line 27 of file vector.hpp.

Member Typedef Documentation

◆ VectorValueType

template<typename ValueType >
using NeoN::Vector< ValueType >::VectorValueType = ValueType

Definition at line 32 of file vector.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/7]

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

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

Parameters
execExecutor associated to the field
sizesize of the field

◆ Vector() [2/7]

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

Create a Vector 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

◆ Vector() [3/7]

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

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

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

◆ Vector() [4/7]

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

Create a Vector from a given vector of values on an executor.

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

◆ Vector() [5/7]

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

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

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

◆ Vector() [6/7]

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

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

Parameters
rhsThe field to copy from.

◆ Vector() [7/7]

template<typename ValueType >
NeoN::Vector< ValueType >::Vector ( Vector< ValueType > &&  rhs)
noexcept

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

Parameters
rhsThe field to move from.

◆ ~Vector()

template<typename ValueType >
NeoN::Vector< ValueType >::~Vector ( )

Destroy the Vector object.

Member Function Documentation

◆ apply()

template<typename ValueType >
template<typename func >
void NeoN::Vector< 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 100 of file vector.hpp.

◆ copyToExecutor()

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

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.

◆ copyToHost() [1/2]

template<typename ValueType >
Vector< ValueType > NeoN::Vector< ValueType >::copyToHost ( ) const

Returns a copy of the field back to the host.

Returns
A copy of the field on the host.

◆ copyToHost() [2/2]

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

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.

◆ data() [1/2]

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

Direct access to the underlying field data.

Returns
Pointer to the first cell data in the field.

Definition at line 215 of file vector.hpp.

◆ data() [2/2]

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

Direct access to the underlying field data.

Returns
Pointer to the first cell data in the field.

Definition at line 221 of file vector.hpp.

◆ empty()

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

Checks if the field is empty.

Returns
True if the field is empty, false otherwise.

Definition at line 245 of file vector.hpp.

◆ exec()

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

Gets the executor associated with the field.

Returns
Reference to the executor.

Definition at line 227 of file vector.hpp.

◆ operator*() [1/2]

template<typename ValueType >
Vector< ValueType > NeoN::Vector< ValueType >::operator* ( const scalar  rhs)

Arithmetic multiply operator, multiplies every cell in the field by a scalar.

Parameters
rhsThe scalar to multiply with the field.
Returns
The result of the multiplication.
Note
We exclude types where the multiplication operator is ambiguous, e.g. vec3. See notes regarding concepts https://eel.is/c++draft/expr.prim.req

◆ operator*() [2/2]

template<typename ValueType >
Vector< ValueType > NeoN::Vector< ValueType >::operator* ( const Vector< ValueType > &  rhs)

Arithmetic multiply operator, multiply by a second field.

Parameters
rhsThe field to subtract from this field.
Returns
The result of the multiply.
Note
We exclude types where the multiplication operator is ambiguous, e.g. vec3. See notes regarding concepts https://eel.is/c++draft/expr.prim.req

◆ operator*=() [1/2]

template<typename ValueType >
Vector< ValueType > & NeoN::Vector< ValueType >::operator*= ( const scalar  rhs)

Assignment multiply operator, multiplies every cell in the field by a scalar.

Parameters
rhsThe scalar to multiply with the field.
Note
We exclude types where the multiplication operator is ambiguous, e.g. vec3. See notes regarding concepts https://eel.is/c++draft/expr.prim.req

◆ operator*=() [2/2]

template<typename ValueType >
Vector< ValueType > & NeoN::Vector< ValueType >::operator*= ( const Vector< ValueType > &  rhs)

Assignment multiply operator, multiplies this field by another field element-wise.

Parameters
rhsThe field to multiply with this field.
Returns
The result of the element-wise multiplication.
Note
We exclude types where the multiplication operator is ambiguous, e.g. vec3. See notes regarding concepts https://eel.is/c++draft/expr.prim.req

◆ operator+=()

template<typename ValueType >
Vector< ValueType > & NeoN::Vector< ValueType >::operator+= ( const Vector< ValueType > &  rhs)

Arithmetic add operator, addition of a second field.

Parameters
rhsThe field to add with this field.
Returns
The result of the addition.

◆ operator-=()

template<typename ValueType >
Vector< ValueType > & NeoN::Vector< ValueType >::operator-= ( const Vector< ValueType > &  rhs)

Arithmetic subtraction operator, subtraction by a second field.

Parameters
rhsThe field to subtract from this field.
Returns
The result of the subtraction.

◆ operator=() [1/2]

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

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

Parameters
rhsThe value to set the field to.

◆ operator=() [2/2]

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

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.

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ range()

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

Gets the range of the field.

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

Definition at line 303 of file vector.hpp.

◆ resize()

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

Resizes the field to a new size.

Parameters
sizeThe new size to set the field to.

◆ size()

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

Gets the size of the field.

Returns
The size of the field.

Definition at line 233 of file vector.hpp.

◆ ssize()

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

Gets the size of the field.

Returns
The size of the field.

Definition at line 239 of file vector.hpp.

◆ view() [1/8]

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

Gets the field as a view.

Returns
View of the field.

Definition at line 257 of file vector.hpp.

◆ view() [2/8]

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

◆ view() [3/8]

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

Gets the field as a view.

Returns
View of the field.

Definition at line 266 of file vector.hpp.

◆ view() [4/8]

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

◆ view() [5/8]

template<typename ValueType >
View< ValueType > NeoN::Vector< 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 281 of file vector.hpp.

◆ view() [6/8]

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

◆ view() [7/8]

template<typename ValueType >
View< const ValueType > NeoN::Vector< 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 292 of file vector.hpp.

◆ view() [8/8]

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

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