ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
List of all members
ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable > Class Template Reference

#include <source/multicomponent_vector.h>

Public Types

Typedefs and constexpr constants
using ScalarVector = dealii::LinearAlgebra::distributed::Vector< Number, MemorySpace >
 

Public Member Functions

Constructor and initialization
 MultiComponentVectorView ()=default
 
 MultiComponentVectorView (MultiComponentVector< Number, n_comp, simd_length > &multi_component_vector)
 
 MultiComponentVectorView (const MultiComponentVector< Number, n_comp, simd_length > &multi_component_vector)
 
template<bool other_writable>
requires (!writable && other_writable)
DEAL_II_HOST_DEVICE MultiComponentVectorView (const MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, other_writable > &other)
 
template<typename MultiComponentVector >
requires (writable != std::is_const_v<MultiComponentVector>)
void reinit (MultiComponentVector &multi_component_vector)
 
Extracting and inserting components, scaled addition
template<typename Functor = std::identity>
void extract_component (ScalarVector &scalar_vector, unsigned int component, const Functor &functor=std::identity{}) const
 
template<typename Functor = std::identity>
requires writable
void insert_component (const ScalarVector &scalar_vector, unsigned int component, const Functor &functor=std::identity{}) const
 
template<typename Functor = std::identity>
requires writable
void insert_component (const dealii::Vector< Number > &scalar_vector, unsigned int component, const Functor &functor=std::identity{}) const
 
void sadd (const Number s, const Number a, const MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, false > &v) const
 
Access to scalar or tensor-valued entries from various

contexts (scalar, SIMD, GPU):

template<typename Number2 = Number>
DEAL_II_HOST_DEVICE Number2 read_entry (const unsigned int i) const
 
template<typename Number2 = Number>
DEAL_II_HOST_DEVICE Number2 read_entry (const unsigned int *js) const
 
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
DEAL_II_HOST_DEVICE Tensor read_tensor (const unsigned int i) const
 
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
DEAL_II_HOST_DEVICE Tensor read_tensor (const unsigned int *js) const
 
template<typename Number2 = Number>
requires writable
DEAL_II_HOST_DEVICE void write_entry (const Number2 &entry, const unsigned int i) const
 
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
requires writable
DEAL_II_HOST_DEVICE void write_tensor (const Tensor &tensor, const unsigned int i) const
 
template<typename Number2 = Number>
requires writable
DEAL_II_HOST_DEVICE void add_entry (const Number2 &entry, const unsigned int i) const
 
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
requires writable
DEAL_II_HOST_DEVICE void add_tensor (const Tensor &tensor, const unsigned int i) const
 
MPI synchronization
void zero_out_ghost_values () const
 
void update_ghost_values () const
 
void compress (dealii::VectorOperation::values operation) const
 

Internal fields

template<typename , int , int , typename , bool >
class MultiComponentVectorView
 

Detailed Description

template<typename Number, int n_comp, int simd_length, typename MemorySpace, bool writable>
class ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >

A "view" of a MultiComponentVector that lives in the host or device memory space. It provides a number of methods for reading and writing scalar and tensor-valued entries.

Note
This class is designed to be captured by value in computation loops with access to either the host or device memory space. As such we do not store a reference to the underlying MultiComponentVector but rather raw pointers into the corresponding memory. The view is only valid as long as the underlying MultiComponentVector object is not modified.

Definition at line 253 of file multicomponent_vector.h.

Member Typedef Documentation

◆ ScalarVector

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
using ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::ScalarVector = dealii::LinearAlgebra::distributed::Vector<Number, MemorySpace>

Shorthand typedef for the underlying scalar dealii::LinearAlgebra::distributed::Vector<Number, MemorySpace> used to insert and extract a single component of the MultiComponentVector.

Definition at line 304 of file multicomponent_vector.h.

Constructor & Destructor Documentation

◆ MultiComponentVectorView() [1/4]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::MultiComponentVectorView ( )
default

◆ MultiComponentVectorView() [2/4]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::MultiComponentVectorView ( MultiComponentVector< Number, n_comp, simd_length > &  multi_component_vector)

◆ MultiComponentVectorView() [3/4]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::MultiComponentVectorView ( const MultiComponentVector< Number, n_comp, simd_length > &  multi_component_vector)

◆ MultiComponentVectorView() [4/4]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<bool other_writable>
requires (!writable && other_writable)
DEAL_II_HOST_DEVICE ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::MultiComponentVectorView ( const MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, other_writable > &  other)

Converting constructor creating a read only view from a writable view (mirroring the conversion from T * to const T *).

Note
We need to make this a templated constructor, otherwise the writable-converting constructor here would suppress the default copy constructor.

Member Function Documentation

◆ reinit()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename MultiComponentVector >
requires (writable != std::is_const_v<MultiComponentVector>)
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::reinit ( MultiComponentVector multi_component_vector)

◆ extract_component()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Functor = std::identity>
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::extract_component ( ScalarVector scalar_vector,
unsigned int  component,
const Functor &  functor = std::identity{} 
) const

Extracts a single component out of the MultiComponentVector and stores it in scalar_vector. The destination vector must have a compatible corresponding (scalar) MPI partitioner, i.e., the "local size", the number of locally owned elements, has to match.

The function calls scalar_vector.update_ghost_values() before returning.

Optionally, a third argument functor can be supplied that is applied to each (scalar) value individually before stored in scalar_vector.

Note
This function is used in the VTUOutput module to unpack a single component out of our custom MultiComponentVector in order to call deal.II specific functions (that can only operate on scalar vectors).

◆ insert_component() [1/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Functor = std::identity>
requires writable
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::insert_component ( const ScalarVector scalar_vector,
unsigned int  component,
const Functor &  functor = std::identity{} 
) const

Inserts a single component into a MultiComponentVector. The source vector must have a compatible corresponding (scalar) MPI partitioner, i.e., the "local size", the number of locally owned elements, has to match.

The function does not call update_ghost_values() automatically. This has to be done by the user once all components are updated.

Optionally, a third argument functor can be supplied that is applied to each (scalar) value individually before stored in the corresponding component.

Note
This function is used in InitialValues to populate all components of the initial state that are returned component wise as single scalar vectors by deal.II interpolation functions.

◆ insert_component() [2/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Functor = std::identity>
requires writable
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::insert_component ( const dealii::Vector< Number > &  scalar_vector,
unsigned int  component,
const Functor &  functor = std::identity{} 
) const

Variant of the method above that reads values out of a dealii::Vector in (rank-) local numbering.

◆ sadd()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::sadd ( const Number  s,
const Number  a,
const MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, false > &  v 
) const

Scaled addition of the given vector $U$ and the argument vector $V$: $U\leftarrow s\,U+a\,V$.

◆ read_entry() [1/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number>
DEAL_II_HOST_DEVICE Number2 ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::read_entry ( const unsigned int  i) const

Return the entry indexed by i.

If the template parameter Number2 is a VectorizedArray then the function returns a SIMD vectorized dealii::Tensor populated with entries from the n_comp component vectors stored at indices i, i+1, ..., i+simd_length-1.

Note
This function is only available if n_comp is equal to 1.

◆ read_entry() [2/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number>
DEAL_II_HOST_DEVICE Number2 ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::read_entry ( const unsigned int *  js) const

Variant of above function.

Returns a SIMD vectorized dealii::Tensor populated with entries from the n_comp component vectors stored at indices *(js), *(js+1), ..., *(js+simd_length-1), i.e., js has to point to an array of size simd_length containing all indices.

Note
This function is only available if n_comp is equal to 1.

◆ read_tensor() [1/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
DEAL_II_HOST_DEVICE Tensor ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::read_tensor ( const unsigned int  i) const

Return the tensor-valued entry indexed by i.

If the template parameter Number2 is a VectorizedArray then the function returns a SIMD vectorized dealii::Tensor populated with entries from the n_compontens component vectors stored at indices i, i+1, ..., i+simd_length-1.

◆ read_tensor() [2/2]

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
DEAL_II_HOST_DEVICE Tensor ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::read_tensor ( const unsigned int *  js) const

Variant of above function.

Returns a SIMD vectorized dealii::Tensor populated with entries from the n_comp component vectors stored at indices *(js), *(js+1), ..., *(js+simd_length-1), i.e., js has to point to an array of size simd_length containing all indices.

◆ write_entry()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number>
requires writable
DEAL_II_HOST_DEVICE void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::write_entry ( const Number2 &  entry,
const unsigned int  i 
) const

Write a (scalar valued) entry to the vector at position by i.

If the template parameter Number2 is a VectorizedArray then the function takes a SIMD vectorized tensor as argument instead and updates the values of the n_comp component vectors at indices i, i+1, ..., i+simd_length_1. with the values supplied by tensor.

Note
This function is only available if n_comp is equal to 1.

◆ write_tensor()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
requires writable
DEAL_II_HOST_DEVICE void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::write_tensor ( const Tensor &  tensor,
const unsigned int  i 
) const

Update the values of the n_comp component vector at index i with the values supplied by tensor.

If the template parameter Number2 is a VectorizedArray then the function takes a SIMD vectorized tensor as argument instead and updates the values of the n_comp component vectors at indices i, i+1, ..., i+simd_length_1. with the values supplied by tensor.

Note
tensor can be an arbitrary indexable container, such as dealii::Tensor or std::array, that has an operator[]() returning a Number, and has a type trait value_type.

◆ add_entry()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number>
requires writable
DEAL_II_HOST_DEVICE void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::add_entry ( const Number2 &  entry,
const unsigned int  i 
) const

Add a (scalar valued) entry to the vector at position i. Update the values of the n_comp component vector at index i by adding the values supplied by tensor.

If the template parameter Number2 is a VectorizedArray then the function takes a SIMD vectorized tensor as argument instead and updates the values of the n_comp component vectors at indices i, i+1, ..., i+simd_length_1. with the values supplied by tensor.

Note
This function is only available if n_comp is equal to 1.

◆ add_tensor()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename Number2 = Number, typename Tensor = dealii::Tensor<1, n_comp, Number2>>
requires writable
DEAL_II_HOST_DEVICE void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::add_tensor ( const Tensor &  tensor,
const unsigned int  i 
) const

Update the values of the n_comp component vector at index i by adding the values supplied by tensor.

If the template parameter Number2 is a VectorizedArray then the function takes a SIMD vectorized tensor as argument instead and updates the values of the n_comp component vectors at indices i, i+1, ..., i+simd_length_1. with the values supplied by tensor.

Note
tensor can be an arbitrary indexable container, such as dealii::Tensor or std::array, that has an operator[]() returning a Number, and has a type trait value_type.

◆ zero_out_ghost_values()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::zero_out_ghost_values ( ) const

MPI synchronization: Zero out all ghost values stored in the vector.

◆ update_ghost_values()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::update_ghost_values ( ) const

MPI synchronization: Import all ghost values from neighboring MPI ranks on the templated memory space.

◆ compress()

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
void ryujin::Vectors::MultiComponentVectorView< Number, n_comp, simd_length, MemorySpace, writable >::compress ( dealii::VectorOperation::values  operation) const

MPI synchronization: Copy the data that has accumulated in the ghost range to the owning processor. This function operates on the templated memory space.

Friends And Related Symbol Documentation

◆ MultiComponentVectorView

template<typename Number , int n_comp, int simd_length, typename MemorySpace , bool writable>
template<typename , int , int , typename , bool >
friend class MultiComponentVectorView
friend

Definition at line 556 of file multicomponent_vector.h.


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