Gyselalib++
VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > Class Template Reference

A class which holds multiple (scalar) fields in order to represent a vector field. More...

Inheritance diagram for VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >:
VectorFieldCommon< Field< ElementType, IdxRangeType, MemorySpace, LayoutStridedPolicy >, NDTag >

Public Types

using field_type = Field< ElementType, IdxRangeType, MemorySpace, LayoutStridedPolicy >
 Type describing the object which can be extracted from this VectorField using the get<> function.
 
using element_type = typename base_type::element_type
 The type of an element in one of the Fields comprising the VectorField.
 
using span_type = VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >
 A type which can hold a modifiable reference to a VectorFieldMem. More...
 
using view_type = VectorField< const ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >
 A type which can hold a constant reference to a VectorFieldMem. More...
 
using layout_type = LayoutStridedPolicy
 Type describing the way in which the data is laid out in the Field memory. More...
 
using discrete_domain_type = typename base_type::discrete_domain_type
 The type of the index range on which the field is defined. More...
 
using index_range_type = discrete_domain_type
 The IdxRange on which the fields in this object are defined.
 
using memory_space = typename field_type::memory_space
 The type of the memory space where the field is saved (CPU vs GPU).
 

Public Member Functions

constexpr KOKKOS_DEFAULTED_FUNCTION VectorField ()=default
 Empty VectorField.
 
KOKKOS_DEFAULTED_FUNCTION ~VectorField ()=default
 VectorField destructor.
 
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField (VectorField const &other)=default
 Constructs a new VectorField by copy, yields a new view to the same data. More...
 
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField (VectorField &&other)=default
 Constructs a new VectorField by move. More...
 
template<class OElementType , class Allocator >
constexpr KOKKOS_FUNCTION VectorField (VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > &other) noexcept
 Constructs a new VectorField from a VectorFieldMem, yields a new view to the same data. More...
 
template<class OElementType , class SFINAEElementType = ElementType, class = std::enable_if_t<std::is_const_v<SFINAEElementType>>, class Allocator >
constexpr KOKKOS_FUNCTION VectorField (VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > const &other) noexcept
 Constructs a new VectorField from a VectorFieldMem, yields a new view to the same data. More...
 
template<class OElementType , class Allocator >
 VectorField (VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > &&other)=delete
 
template<class OElementType >
constexpr KOKKOS_FUNCTION VectorField (VectorField< OElementType, index_range_type, NDTag, MemorySpace, LayoutStridedPolicy > const &other) noexcept
 Constructs a new VectorField by copy of a chunk, yields a new view to the same data. More...
 
template<class... OElementType, class = std::enable_if_t< std::conjunction_v<std::is_same<OElementType, ElementType>...>>, class = std::enable_if_t<sizeof...(OElementType) == base_type::NDims>>
KOKKOS_FUNCTION VectorField (index_range_type const &idx_range, OElementType *... ptr)
 Constructs a new VectorField from scratch. More...
 
template<class... FieldType, class = std::enable_if_t<std::conjunction_v<std::is_same<FieldType, field_type>...>>>
constexpr KOKKOS_FUNCTION VectorField (FieldType... fields)
 Constructs a new VectorField containing references to Field. More...
 
constexpr KOKKOS_DEFAULTED_FUNCTION VectorFieldoperator= (VectorField const &other)=default
 Copy-assigns a new value to this VectorField, yields a new view to the same data. More...
 
constexpr KOKKOS_DEFAULTED_FUNCTION VectorFieldoperator= (VectorField &&other)=default
 Move-assigns a new value to this VectorField. More...
 
constexpr view_type span_cview () const
 Get a constant reference to the vector field referred to by this vector field span. More...
 
constexpr span_type span_view () const
 Get a modifiable reference to the vector field referred to by this vector field span. More...
 
template<class... ODDims>
KOKKOS_FUNCTION element_type operator() (Idx< ODDims > const &... delems) const noexcept
 Element access using a list of Idxs. More...
 
template<class... ODDims, class = std::enable_if_t<sizeof...(ODDims) != 1>>
KOKKOS_FUNCTION element_type operator() (Idx< ODDims... > const &delems) const noexcept
 Element access using a multi-dimensional Idx. More...
 
template<class... QueryDDims>
constexpr auto operator[] (Idx< QueryDDims... > const &slice_spec)
 Slice out some dimensions. More...
 
template<class... QueryDDims>
constexpr auto operator[] (IdxRange< QueryDDims... > const &oidx_range)
 Slice out some dimensions. More...
 
template<class QueryTag >
constexpr chunk_span_type get () const noexcept
 Get the Field describing the component in the QueryTag direction. More...
 

Detailed Description

template<class ElementType, class IdxRangeType, class NDTag, class MemorySpace, class LayoutStridedPolicy>
class VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >

A class which holds multiple (scalar) fields in order to represent a vector field.

Pre-declaration of VectorField.

Template Parameters
ElementTypeThe data type of a scalar element of the vector field.
IdxRangeType
NDTagA NDTag describing the dimensions described by the scalar elements of a vector field element.
MemorySpaceThe memory space (CPU/GPU).
LayoutStridedPolicyThe memory layout. See DDC.

Member Typedef Documentation

◆ span_type

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
using VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::span_type = VectorField<ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy>

A type which can hold a modifiable reference to a VectorFieldMem.

A type which can hold a reference to a VectorFieldMem. If this object is modifiable then so is the span type. This is a DDC keyword used to make this class interchangeable with Field.

◆ view_type

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
using VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::view_type = VectorField<const ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy>

A type which can hold a constant reference to a VectorFieldMem.

This is a DDC keyword used to make this class interchangeable with Field.

◆ layout_type

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
using VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::layout_type = LayoutStridedPolicy

Type describing the way in which the data is laid out in the Field memory.

Type describing the way in which the data is laid out in the Field memory. I.e. it describes whether it is contiguous or not.

◆ discrete_domain_type

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
using VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::discrete_domain_type = typename base_type::discrete_domain_type

The type of the index range on which the field is defined.

This is a DDC keyword used to make this class interchangeable with Field. In DDC IdxRange types are referred to as DiscreteDomain types.

Constructor & Destructor Documentation

◆ VectorField() [1/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > const &  other)
constexprdefault

Constructs a new VectorField by copy, yields a new view to the same data.

Parameters
otherthe VectorField to copy

◆ VectorField() [2/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > &&  other)
constexprdefault

Constructs a new VectorField by move.

Parameters
otherthe VectorField to move

◆ VectorField() [3/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class OElementType , class Allocator >
constexpr KOKKOS_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > &  other)
inlineexplicitconstexprnoexcept

Constructs a new VectorField from a VectorFieldMem, yields a new view to the same data.

Parameters
otherthe VectorFieldMem to view

◆ VectorField() [4/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class OElementType , class SFINAEElementType = ElementType, class = std::enable_if_t<std::is_const_v<SFINAEElementType>>, class Allocator >
constexpr KOKKOS_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > const &  other)
inlineexplicitconstexprnoexcept

Constructs a new VectorField from a VectorFieldMem, yields a new view to the same data.

Parameters
otherthe VectorFieldMem to view

◆ VectorField() [5/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class OElementType >
constexpr KOKKOS_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( VectorField< OElementType, index_range_type, NDTag, MemorySpace, LayoutStridedPolicy > const &  other)
inlineconstexprnoexcept

Constructs a new VectorField by copy of a chunk, yields a new view to the same data.

Parameters
otherthe VectorField to move

◆ VectorField() [6/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... OElementType, class = std::enable_if_t< std::conjunction_v<std::is_same<OElementType, ElementType>...>>, class = std::enable_if_t<sizeof...(OElementType) == base_type::NDims>>
KOKKOS_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( index_range_type const &  idx_range,
OElementType *...  ptr 
)
inline

Constructs a new VectorField from scratch.

Parameters
ptrthe allocation pointer to the data
idx_rangethe index range that sustains the view

◆ VectorField() [7/7]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... FieldType, class = std::enable_if_t<std::conjunction_v<std::is_same<FieldType, field_type>...>>>
constexpr KOKKOS_FUNCTION VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::VectorField ( FieldType...  fields)
inlineconstexpr

Constructs a new VectorField containing references to Field.

Parameters
fieldsThe Fields.

Member Function Documentation

◆ operator=() [1/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField& VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator= ( VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > const &  other)
constexprdefault

Copy-assigns a new value to this VectorField, yields a new view to the same data.

Parameters
otherthe VectorField to copy
Returns
*this

◆ operator=() [2/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField& VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator= ( VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > &&  other)
constexprdefault

Move-assigns a new value to this VectorField.

Parameters
otherthe VectorField to move
Returns
*this

◆ span_cview()

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr view_type VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::span_cview ( ) const
inlineconstexpr

Get a constant reference to the vector field referred to by this vector field span.

This function is designed to match the equivalent function in DDC. In Gysela it should not be called directly. Instead the global function get_const_field should be used.

Returns
A constant reference to the vector field.

◆ span_view()

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
constexpr span_type VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::span_view ( ) const
inlineconstexpr

Get a modifiable reference to the vector field referred to by this vector field span.

This function is designed to match the equivalent function in DDC. In Gysela it should not be called directly. Instead the global function get_field should be used.

Returns
A constant reference to the vector field.

◆ operator()() [1/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... ODDims>
KOKKOS_FUNCTION element_type VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator() ( Idx< ODDims > const &...  delems) const
inlinenoexcept

Element access using a list of Idxs.

Parameters
delems1D discrete coordinates
Returns
copy of this element

◆ operator()() [2/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... ODDims, class = std::enable_if_t<sizeof...(ODDims) != 1>>
KOKKOS_FUNCTION element_type VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator() ( Idx< ODDims... > const &  delems) const
inlinenoexcept

Element access using a multi-dimensional Idx.

Parameters
delemsdiscrete coordinates
Returns
copy of this element

◆ operator[]() [1/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... QueryDDims>
constexpr auto VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator[] ( Idx< QueryDDims... > const &  slice_spec)
inlineconstexpr

Slice out some dimensions.

Get the VectorFieldMem on the reduced index range which is obtained by indexing the dimensions QueryDDims at the position slice_spec.

Parameters
[in]slice_specThe slice describing the index range of interest.
Returns
A reference to the vector field on the sliced index range.

◆ operator[]() [2/2]

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class... QueryDDims>
constexpr auto VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::operator[] ( IdxRange< QueryDDims... > const &  oidx_range)
inlineconstexpr

Slice out some dimensions.

Get the VectorFieldMem on the reduced index range passed as an argument.

Parameters
[in]oidx_rangeThe index range of interest.
Returns
A reference to the vector field on the sliced index range.

◆ get()

template<class ElementType , class IdxRangeType , class NDTag , class MemorySpace , class LayoutStridedPolicy >
template<class QueryTag >
constexpr chunk_span_type VectorField< ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy >::get ( ) const
inlineconstexprnoexcept

Get the Field describing the component in the QueryTag direction.

Returns
The field in the specified direction.

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