libMesh
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions | Variables
libMesh::Kokkos Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  is_tensor_like
 Opt-in trait marking the types the generic tensor operations in kokkos_tensor_ops.h accept, all of which expose components as T(i,j): specialized below for the libMesh owning tensor types and tensor_ref. More...
 
struct  is_tensor_like< libMesh::TensorValue< T > >
 
struct  is_tensor_like< libMesh::TypeTensor< T > >
 
struct  is_tensor_like< tensor_ref< ViewType > >
 
struct  is_tensor_ref
 Type trait satisfied only by tensor_ref instantiations; the tensor-ref analogue of is_vector_ref. More...
 
struct  is_tensor_ref< tensor_ref< ViewType > >
 
struct  is_vector_like
 Opt-in trait marking the types the generic vector operations in kokkos_vector_ops.h (and their SFINAE constraints) accept, all of which expose components as v(i): specialized below for the libMesh owning vector types and vector_ref. More...
 
struct  is_vector_like< libMesh::Point >
 
struct  is_vector_like< libMesh::TypeVector< T > >
 
struct  is_vector_like< libMesh::VectorValue< T > >
 
struct  is_vector_like< vector_ref< ViewType > >
 
struct  is_vector_ref
 Type trait satisfied only by vector_ref instantiations. More...
 
struct  is_vector_ref< vector_ref< ViewType > >
 
struct  static_dim_storage_policy
 Storage policy describing Kokkos views that hold runtime-many vectors or tensors whose per-entry dimensions are fixed at LIBMESH_DIM. More...
 
class  tensor_ref
 Non-owning handle to one tensor entry of a Kokkos storage view. More...
 
struct  tensor_traits
 Traits mapping each tensor-like type to its "semantic" owning libMesh type. More...
 
struct  tensor_traits< libMesh::TensorValue< T > >
 
struct  tensor_traits< libMesh::TypeTensor< T > >
 
struct  tensor_traits< tensor_ref< ViewType > >
 
class  vector_ref
 Non-owning handle to one vector entry of a Kokkos storage view. More...
 
struct  vector_traits
 Traits mapping each vector-like type to its "semantic" owning libMesh type - the type an algorithm should return when it needs to materialize a result from that input. More...
 
struct  vector_traits< libMesh::Point >
 
struct  vector_traits< libMesh::TypeVector< T > >
 
struct  vector_traits< libMesh::VectorValue< T > >
 
struct  vector_traits< vector_ref< ViewType > >
 

Typedefs

template<typename T >
using vector_semantic_type_t = typename vector_traits< detail::remove_cvref_t< T > >::semantic_type
 The owning libMesh type a vector-like T materializes to, with any cv/reference qualification on T stripped first.
 
template<typename T >
using tensor_semantic_type_t = typename tensor_traits< detail::remove_cvref_t< T > >::semantic_type
 The owning libMesh type a tensor-like T materializes to, with any cv/reference qualification on T stripped first.
 
using layout_left_storage_policy = static_dim_storage_policy< libMesh::Real, ::Kokkos::LayoutLeft >
 Convenience policies for libMesh's default Real scalar type with the two standard Kokkos layouts, plus the default policy used by the policy-free convenience overloads below.
 
using layout_right_storage_policy = static_dim_storage_policy< libMesh::Real, ::Kokkos::LayoutRight >
 
using default_storage_policy = layout_right_storage_policy
 

Functions

template<typename ViewType >
LIBMESH_DEVICE_INLINE vector_ref< typename std::remove_reference< ViewType >::type > make_vector_ref (ViewType &&view, const unsigned int index)
 
template<typename ViewType >
LIBMESH_DEVICE_INLINE tensor_ref< typename std::remove_reference< ViewType >::type > make_tensor_ref (ViewType &&view, const unsigned int index)
 
template<typename OutputVector , typename VectorLike >
LIBMESH_DEVICE_INLINE OutputVector materialize_vector (const VectorLike &v)
 
template<typename OutputTensor , typename TensorLike >
LIBMESH_DEVICE_INLINE OutputTensor materialize_tensor (const TensorLike &T_in)
 
template<typename VectorType , typename ViewType >
LIBMESH_DEVICE_INLINE VectorType load_vector (const ViewType &view, const unsigned int i)
 
template<typename ViewType , typename VectorType >
LIBMESH_DEVICE_INLINE void store_vector (const ViewType &view, const unsigned int i, const VectorType &v)
 Copies the components of the vector v into entry i of the vector view view, overwriting whatever that entry held.
 
template<typename TensorType , typename ViewType >
LIBMESH_DEVICE_INLINE TensorType load_tensor (const ViewType &view, const unsigned int i)
 
template<typename ViewType , typename TensorType >
LIBMESH_DEVICE_INLINE void store_tensor (const ViewType &view, const unsigned int i, const TensorType &T)
 Copies the components of the tensor T into entry i of the tensor view view, overwriting whatever that entry held.
 
template<typename StoragePolicy >
constexpr const char * storage_policy_name ()
 
template<typename StoragePolicy >
StoragePolicy::vector_view make_vector_storage (const char *label, const std::size_t n)
 
default_storage_policy::vector_view make_vector_storage (const char *label, const std::size_t n)
 
template<typename StoragePolicy >
StoragePolicy::tensor_view make_tensor_storage (const char *label, const std::size_t n)
 
default_storage_policy::tensor_view make_tensor_storage (const char *label, const std::size_t n)
 
template<typename StoragePolicy , typename VectorType >
StoragePolicy::vector_view upload_vector_storage (const std::vector< VectorType > &values, const char *label)
 Allocates a device view sized for values, copies each vector's components into a host mirror, and deep-copies the result to the device.
 
template<typename VectorType >
default_storage_policy::vector_view upload_vector_storage (const std::vector< VectorType > &values, const char *label)
 
template<typename StoragePolicy , typename TensorType >
StoragePolicy::tensor_view upload_tensor_storage (const std::vector< TensorType > &values, const char *label)
 Allocates a device view sized for values, copies each tensor's components into a host mirror, and deep-copies the result to the device.
 
template<typename TensorType >
default_storage_policy::tensor_view upload_tensor_storage (const std::vector< TensorType > &values, const char *label)
 
template<typename ResultTensor >
LIBMESH_DEVICE_INLINE ResultTensor tensor_identity (const unsigned int dim=LIBMESH_DIM)
 
template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto copy_tensor (const TensorLike &T_in) -> std::conditional_t< std::is_void< ResultTensor >::value, tensor_semantic_type_t< TensorLike >, ResultTensor >
 
template<typename LeftTensor , typename RightTensor , typename std::enable_if< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto contract (const LeftTensor &left, const RightTensor &right)
 
template<typename ResultTensor = void, typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto outer_product (const LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector >, std::conditional_t< std::is_void< ResultTensor >::value, libMesh::TypeTensor< typename LeftVector::value_type >, ResultTensor > >
 
template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto transpose (const TensorLike &T_in) -> std::enable_if_t< is_tensor_like_v< TensorLike >, std::conditional_t< std::is_void< ResultTensor >::value, tensor_semantic_type_t< TensorLike >, ResultTensor > >
 
template<typename TensorLike >
LIBMESH_DEVICE_INLINE auto det (const TensorLike &T_in) -> std::enable_if_t< is_tensor_like_v< TensorLike >, decltype(T_in.det())>
 
template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto inverse (const TensorLike &T_in, const unsigned int dim=LIBMESH_DIM) -> std::enable_if_t< is_tensor_like_v< TensorLike >, std::conditional_t< std::is_void< ResultTensor >::value, tensor_semantic_type_t< TensorLike >, ResultTensor > >
 
template<typename ResultVector = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto row (const TensorLike &T_in, const unsigned int i) -> std::enable_if_t< is_tensor_like_v< TensorLike >, std::conditional_t< std::is_void< ResultVector >::value, libMesh::TypeVector< typename TensorLike::value_type >, ResultVector > >
 
template<typename ResultVector = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto column (const TensorLike &T_in, const unsigned int i) -> std::enable_if_t< is_tensor_like_v< TensorLike >, std::conditional_t< std::is_void< ResultVector >::value, libMesh::TypeVector< typename TensorLike::value_type >, ResultVector > >
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator+= (LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), LeftTensor & >
 Adds right to left in place; when left is a ref, the update writes through to the underlying storage.
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator-= (LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), LeftTensor & >
 Subtracts right from left in place.
 
template<typename TensorLike >
LIBMESH_DEVICE_INLINE auto operator- (const TensorLike &T_in) -> std::enable_if_t< is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike >, tensor_semantic_type_t< TensorLike > >
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator+ (const LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), tensor_semantic_type_t< LeftTensor > >
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator- (const LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), tensor_semantic_type_t< LeftTensor > >
 
template<typename Scalar , typename TensorLike , typename std::enable_if<!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar > &&is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const Scalar &alpha, const TensorLike &T_in)
 
template<typename TensorLike , typename Scalar , typename std::enable_if< is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const TensorLike &T_in, const Scalar &alpha)
 
template<typename TensorLike , typename Scalar >
LIBMESH_DEVICE_INLINE auto operator/ (const TensorLike &T_in, const Scalar &alpha) -> std::enable_if_t< is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, tensor_semantic_type_t< TensorLike > >
 
template<typename LeftTensor , typename RightTensor , typename std::enable_if< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const LeftTensor &left, const RightTensor &right)
 
template<typename TensorLike , typename VectorLike , typename std::enable_if< is_tensor_like_v< TensorLike > &&is_vector_like_v< VectorLike > &&(is_tensor_ref_v< TensorLike >||is_vector_ref_v< VectorLike >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const TensorLike &T_in, const VectorLike &v)
 
template<typename VectorLike , typename TensorLike , typename std::enable_if< is_vector_like_v< VectorLike > &&is_tensor_like_v< TensorLike > &&(is_vector_ref_v< VectorLike >||is_tensor_ref_v< TensorLike >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const VectorLike &v, const TensorLike &T_in)
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator== (const LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), bool >
 
template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto operator!= (const LeftTensor &left, const RightTensor &right) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), bool >
 
template<typename LeftTensor , typename Scalar >
LIBMESH_DEVICE_INLINE auto operator*= (LeftTensor &left, const Scalar &alpha) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_ref_v< LeftTensor > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, LeftTensor & >
 Scales left by alpha in place.
 
template<typename LeftTensor , typename Scalar >
LIBMESH_DEVICE_INLINE auto operator/= (LeftTensor &left, const Scalar &alpha) -> std::enable_if_t< is_tensor_like_v< LeftTensor > &&is_tensor_ref_v< LeftTensor > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, LeftTensor & >
 Divides left by alpha in place.
 
template<typename ResultVector = void, typename VectorLike >
LIBMESH_DEVICE_INLINE auto copy_vector (const VectorLike &v) -> std::conditional_t< std::is_void< ResultVector >::value, vector_semantic_type_t< VectorLike >, ResultVector >
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto vector_dot (const LeftVector &left, const RightVector &right)
 
template<typename ResultVector = void, typename VectorLike >
LIBMESH_DEVICE_INLINE auto vector_unit (const VectorLike &v) -> std::conditional_t< std::is_void< ResultVector >::value, vector_semantic_type_t< VectorLike >, ResultVector >
 
template<typename ResultVector = void, typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto vector_cross (const LeftVector &left, const RightVector &right) -> std::conditional_t< std::is_void< ResultVector >::value, vector_semantic_type_t< LeftVector >, ResultVector >
 
template<typename LeftVector , typename MiddleVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto vector_triple_product (const LeftVector &left, const MiddleVector &middle, const RightVector &right)
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto vector_cross_norm_sq (const LeftVector &left, const RightVector &right)
 
template<typename VectorA , typename VectorB , typename VectorC >
LIBMESH_DEVICE_INLINE auto vector_solid_angle (const VectorA &v01, const VectorB &v02, const VectorC &v03)
 
template<typename LeftVector , typename RightVector , typename std::enable_if< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto contract (const LeftVector &left, const RightVector &right)
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator+= (LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), LeftVector & >
 Adds right to left in place; when left is a ref, the update writes through to the underlying storage.
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator-= (LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), LeftVector & >
 Subtracts right from left in place.
 
template<typename VectorLike >
LIBMESH_DEVICE_INLINE auto operator- (const VectorLike &v) -> std::enable_if_t< is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike >, vector_semantic_type_t< VectorLike > >
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator+ (const LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), vector_semantic_type_t< LeftVector > >
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator- (const LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), vector_semantic_type_t< LeftVector > >
 
template<typename LeftVector , typename RightVector , typename std::enable_if< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const LeftVector &left, const RightVector &right)
 
template<typename Scalar , typename VectorLike , typename std::enable_if<!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar > &&is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const Scalar &alpha, const VectorLike &v)
 
template<typename VectorLike , typename Scalar , typename std::enable_if< is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator* (const VectorLike &v, const Scalar &alpha)
 
template<typename VectorLike , typename Scalar , typename std::enable_if< is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto operator/ (const VectorLike &v, const Scalar &alpha)
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator== (const LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), bool >
 
template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto operator!= (const LeftVector &left, const RightVector &right) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), bool >
 
template<typename LeftVector , typename Scalar >
LIBMESH_DEVICE_INLINE auto operator*= (LeftVector &left, const Scalar &alpha) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_ref_v< LeftVector > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, LeftVector & >
 Scales left by alpha in place.
 
template<typename LeftVector , typename Scalar >
LIBMESH_DEVICE_INLINE auto operator/= (LeftVector &left, const Scalar &alpha) -> std::enable_if_t< is_vector_like_v< LeftVector > &&is_vector_ref_v< LeftVector > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, LeftVector & >
 Divides left by alpha in place.
 

Variables

template<typename T >
constexpr bool is_vector_like_v = is_vector_like<detail::remove_cvref_t<T>>::value
 Variable template shorthands for the traits above.
 
template<typename T >
constexpr bool is_tensor_like_v = is_tensor_like<detail::remove_cvref_t<T>>::value
 
template<typename T >
constexpr bool is_vector_ref_v = is_vector_ref<detail::remove_cvref_t<T>>::value
 
template<typename T >
constexpr bool is_tensor_ref_v = is_tensor_ref<detail::remove_cvref_t<T>>::value
 

Typedef Documentation

◆ default_storage_policy

Definition at line 100 of file kokkos_storage_policy.h.

◆ layout_left_storage_policy

Convenience policies for libMesh's default Real scalar type with the two standard Kokkos layouts, plus the default policy used by the policy-free convenience overloads below.

LayoutRight keeps each entry's components contiguous in memory, the natural arrangement when one thread works on one whole entry; LayoutLeft keeps a given component contiguous across entries, the coalescing-friendly arrangement for GPU thread teams. The Kokkos unit tests run under both policies to keep the algebra layout-agnostic.

Definition at line 98 of file kokkos_storage_policy.h.

◆ layout_right_storage_policy

Definition at line 99 of file kokkos_storage_policy.h.

◆ tensor_semantic_type_t

template<typename T >
using libMesh::Kokkos::tensor_semantic_type_t = typedef typename tensor_traits<detail::remove_cvref_t<T> >::semantic_type

The owning libMesh type a tensor-like T materializes to, with any cv/reference qualification on T stripped first.

Definition at line 620 of file kokkos_linalg_base.h.

◆ vector_semantic_type_t

template<typename T >
using libMesh::Kokkos::vector_semantic_type_t = typedef typename vector_traits<detail::remove_cvref_t<T> >::semantic_type

The owning libMesh type a vector-like T materializes to, with any cv/reference qualification on T stripped first.

Definition at line 613 of file kokkos_linalg_base.h.

Function Documentation

◆ column()

template<typename ResultVector = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::column ( const TensorLike &  T_in,
const unsigned int  i 
) -> std::enable_if_t<is_tensor_like_v<TensorLike>, std::conditional_t<std::is_void<ResultVector>::value, libMesh::TypeVector<typename TensorLike::value_type>, ResultVector>>
Returns
Column i of the tensor-like T_in, as an owning vector.

Definition at line 578 of file kokkos_tensor_ops.h.

583{
584 using output_type = std::conditional_t<std::is_void<ResultVector>::value,
586 ResultVector>;
587 return detail::column<output_type>(T_in, i);
588}
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition type_vector.h:64

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::column().

◆ contract() [1/2]

template<typename LeftTensor , typename RightTensor , typename std::enable_if< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::contract ( const LeftTensor &  left,
const RightTensor &  right 
)
Returns
The full contraction of left with right; the tensor overload of the contract() name shared with kokkos_vector_ops.h.

Definition at line 479 of file kokkos_tensor_ops.h.

480{
481 return detail::tensor_contract(left, right);
482}

References libMesh::Kokkos::detail::tensor_contract().

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::contract(), and libMesh::Kokkos::vector_ref< ViewType >::contract().

◆ contract() [2/2]

template<typename LeftVector , typename RightVector , typename std::enable_if< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::contract ( const LeftVector &  left,
const RightVector &  right 
)
Returns
The dot product of left and right; a synonym for vector_dot() matching the TypeVector::contract() name.

Definition at line 370 of file kokkos_vector_ops.h.

371{
372 return vector_dot(left, right);
373}
LIBMESH_DEVICE_INLINE auto vector_dot(const LeftVector &left, const RightVector &right)

References vector_dot().

◆ copy_tensor()

template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::copy_tensor ( const TensorLike &  T_in) -> std::conditional_t<std::is_void<ResultTensor>::value, tensor_semantic_type_t<TensorLike>, ResultTensor>
Returns
An owning copy of the tensor-like T_in: by default a value of T_in 's semantic type, or of ResultTensor if that parameter is given explicitly. This is how a kernel snapshots a storage-backed ref's current value for register-resident work.

Definition at line 84 of file kokkos_tensor_ops.h.

88{
89 using output_type = std::conditional_t<std::is_void<ResultTensor>::value,
91 ResultTensor>;
92 return materialize_tensor<output_type>(T_in);
93}
typename tensor_traits< detail::remove_cvref_t< T > >::semantic_type tensor_semantic_type_t
The owning libMesh type a tensor-like T materializes to, with any cv/reference qualification on T str...

◆ copy_vector()

template<typename ResultVector = void, typename VectorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::copy_vector ( const VectorLike &  v) -> std::conditional_t<std::is_void<ResultVector>::value, vector_semantic_type_t<VectorLike>, ResultVector>
Returns
An owning copy of the vector-like v: by default a value of v 's semantic type, or of ResultVector if that parameter is given explicitly. This is how a kernel snapshots a storage-backed ref's current value for register-resident work.

Definition at line 65 of file kokkos_vector_ops.h.

69{
70 using output_type = std::conditional_t<std::is_void<ResultVector>::value,
72 ResultVector>;
73 return materialize_vector<output_type>(v);
74}
typename vector_traits< detail::remove_cvref_t< T > >::semantic_type vector_semantic_type_t
The owning libMesh type a vector-like T materializes to, with any cv/reference qualification on T str...

◆ det()

template<typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::det ( const TensorLike &  T_in) -> std::enable_if_t<is_tensor_like_v<TensorLike>, decltype(T_in.det())>
Returns
The determinant of the tensor-like T_in, delegating to its det() member so owning types use TypeTensor::det() while refs use tensor_ref::det().

Definition at line 529 of file kokkos_tensor_ops.h.

531{
532 return T_in.det();
533}

Referenced by libMesh::Kokkos::detail::inverse().

◆ inverse()

template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::inverse ( const TensorLike &  T_in,
const unsigned int  dim = LIBMESH_DIM 
) -> std::enable_if_t<is_tensor_like_v<TensorLike>, std::conditional_t<std::is_void<ResultTensor>::value, tensor_semantic_type_t<TensorLike>, ResultTensor>>
Returns
The inverse of the leading dim x dim block of the tensor-like T_in, as an owning tensor.

Definition at line 541 of file kokkos_tensor_ops.h.

546{
547 using output_type = std::conditional_t<std::is_void<ResultTensor>::value,
549 ResultTensor>;
550 return detail::inverse<output_type>(T_in, dim);
551}
unsigned int dim

References dim.

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::inverse(), and libMesh::Kokkos::tensor_ref< ViewType >::solve().

◆ load_tensor()

template<typename TensorType , typename ViewType >
LIBMESH_DEVICE_INLINE TensorType libMesh::Kokkos::load_tensor ( const ViewType &  view,
const unsigned int  i 
)
Returns
Entry i of the tensor view view, materialized as an owning tensor of type TensorType (e.g. a TypeTensor or TensorValue).

The view is expected to have one runtime extent indexing entries followed by LIBMESH_DIM x LIBMESH_DIM extents indexing components, as created by make_tensor_storage().

Definition at line 87 of file kokkos_storage.h.

88{
89 return materialize_tensor<TensorType>(make_tensor_ref(view, i));
90}
LIBMESH_DEVICE_INLINE tensor_ref< typename std::remove_reference< ViewType >::type > make_tensor_ref(ViewType &&view, const unsigned int index)

References make_tensor_ref().

◆ load_vector()

template<typename VectorType , typename ViewType >
LIBMESH_DEVICE_INLINE VectorType libMesh::Kokkos::load_vector ( const ViewType &  view,
const unsigned int  i 
)
Returns
Entry i of the vector view view, materialized as an owning vector of type VectorType (e.g. a TypeVector, VectorValue, or Point).

The view is expected to have one runtime extent indexing entries followed by a LIBMESH_DIM extent indexing components, as created by make_vector_storage().

Definition at line 57 of file kokkos_storage.h.

58{
59 return materialize_vector<VectorType>(make_vector_ref(view, i));
60}
LIBMESH_DEVICE_INLINE vector_ref< typename std::remove_reference< ViewType >::type > make_vector_ref(ViewType &&view, const unsigned int index)

References make_vector_ref().

◆ make_tensor_ref()

template<typename ViewType >
LIBMESH_DEVICE_INLINE tensor_ref< typename std::remove_reference< ViewType >::type > libMesh::Kokkos::make_tensor_ref ( ViewType &&  view,
const unsigned int  index 
)
Returns
A tensor_ref addressing entry index of view; the tensor analogue of make_vector_ref(), with the same by-value view semantics.

Definition at line 646 of file kokkos_linalg_base.h.

647{
648 return tensor_ref<typename std::remove_reference<ViewType>::type>(std::forward<ViewType>(view),
649 index);
650}
Non-owning handle to one tensor entry of a Kokkos storage view.

Referenced by load_tensor(), store_tensor(), libMeshTest::KokkosTensorOracle::test_dim_ops(), libMeshTest::KokkosTensorOracle::test_linalg_foundation_storage_roundtrip(), libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), and libMeshTest::KokkosTensorOracle::test_tensor_ops().

◆ make_tensor_storage() [1/2]

template<typename StoragePolicy >
StoragePolicy::tensor_view libMesh::Kokkos::make_tensor_storage ( const char *  label,
const std::size_t  n 
)
inline
Returns
A newly allocated (zero-initialized) device view holding n tensors, laid out according to StoragePolicy and labeled label for Kokkos profiling/debugging purposes.

Definition at line 144 of file kokkos_storage_policy.h.

145{
146 return typename StoragePolicy::tensor_view(std::string(label), n);
147}

◆ make_tensor_storage() [2/2]

default_storage_policy::tensor_view libMesh::Kokkos::make_tensor_storage ( const char *  label,
const std::size_t  n 
)
inline
Returns
A newly allocated device view holding n tensors, using the default storage policy.

Definition at line 154 of file kokkos_storage_policy.h.

155{
156 return make_tensor_storage<default_storage_policy>(label, n);
157}

◆ make_vector_ref()

template<typename ViewType >
LIBMESH_DEVICE_INLINE vector_ref< typename std::remove_reference< ViewType >::type > libMesh::Kokkos::make_vector_ref ( ViewType &&  view,
const unsigned int  index 
)
Returns
A vector_ref addressing entry index of view, so kernel code need not spell out the vector_ref's template argument. The ref stores the view by value (Kokkos views are cheap reference-counted handles), so the deduced reference qualification on the forwarded view is stripped from the ref's type.

Definition at line 632 of file kokkos_linalg_base.h.

633{
634 return vector_ref<typename std::remove_reference<ViewType>::type>(std::forward<ViewType>(view),
635 index);
636}
Non-owning handle to one vector entry of a Kokkos storage view.

Referenced by load_vector(), store_vector(), libMeshTest::KokkosTensorOracle::test_linalg_foundation_storage_roundtrip(), libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), libMeshTest::KokkosVectorOracle::test_mixed_representation_ops(), libMeshTest::KokkosTensorOracle::test_tensor_ops(), and libMeshTest::KokkosVectorOracle::test_vector_ops_case().

◆ make_vector_storage() [1/2]

template<typename StoragePolicy >
StoragePolicy::vector_view libMesh::Kokkos::make_vector_storage ( const char *  label,
const std::size_t  n 
)
inline
Returns
A newly allocated (zero-initialized) device view holding n vectors, laid out according to StoragePolicy and labeled label for Kokkos profiling/debugging purposes.

Definition at line 122 of file kokkos_storage_policy.h.

123{
124 return typename StoragePolicy::vector_view(std::string(label), n);
125}

◆ make_vector_storage() [2/2]

default_storage_policy::vector_view libMesh::Kokkos::make_vector_storage ( const char *  label,
const std::size_t  n 
)
inline
Returns
A newly allocated device view holding n vectors, using the default storage policy.

Definition at line 132 of file kokkos_storage_policy.h.

133{
134 return make_vector_storage<default_storage_policy>(label, n);
135}

◆ materialize_tensor()

template<typename OutputTensor , typename TensorLike >
LIBMESH_DEVICE_INLINE OutputTensor libMesh::Kokkos::materialize_tensor ( const TensorLike &  T_in)
Returns
An owning tensor of type OutputTensor whose components are copied from the tensor-like T_in.

Definition at line 683 of file kokkos_linalg_base.h.

684{
685 static_assert(is_tensor_like_v<OutputTensor>,
686 "materialize_tensor() requires a tensor-like output type");
687 static_assert(is_tensor_like_v<TensorLike>,
688 "materialize_tensor() requires a tensor-like input type");
689
690 OutputTensor out;
691 out.zero();
692
693 for (unsigned int row = 0; row < LIBMESH_DIM; ++row)
694 for (unsigned int col = 0; col < LIBMESH_DIM; ++col)
695 out(row, col) = T_in(row, col);
696
697 return out;
698}
OStreamProxy out

References libMesh::out, and row().

◆ materialize_vector()

template<typename OutputVector , typename VectorLike >
LIBMESH_DEVICE_INLINE OutputVector libMesh::Kokkos::materialize_vector ( const VectorLike &  v)
Returns
An owning vector of type OutputVector whose components are copied from the vector-like v.

This is the bridge from non-owning refs (or any other vector-like input) to register-resident values a kernel can compute with.

Definition at line 661 of file kokkos_linalg_base.h.

662{
663 static_assert(is_vector_like_v<OutputVector>,
664 "materialize_vector() requires a vector-like output type");
665 static_assert(is_vector_like_v<VectorLike>,
666 "materialize_vector() requires a vector-like input type");
667
668 OutputVector out;
669 out.zero();
670
671 for (unsigned int component = 0; component < LIBMESH_DIM; ++component)
672 out(component) = v(component);
673
674 return out;
675}

References libMesh::out.

◆ operator!=() [1/2]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator!= ( const LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), bool>
Returns
true if left and right differ in any component, false otherwise.

Definition at line 929 of file kokkos_tensor_ops.h.

933{
934 return !(left == right);
935}

◆ operator!=() [2/2]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator!= ( const LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), bool>
Returns
true if left and right differ in any component, false otherwise.

Definition at line 650 of file kokkos_vector_ops.h.

654{
655 return !(left == right);
656}

◆ operator*() [1/8]

template<typename LeftTensor , typename RightTensor , typename std::enable_if< is_tensor_like_v< LeftTensor > &&is_tensor_like_v< RightTensor > &&(is_tensor_ref_v< LeftTensor >||is_tensor_ref_v< RightTensor >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const LeftTensor &  left,
const RightTensor &  right 
)
Returns
The matrix product of left and right, as an owning tensor.

Definition at line 871 of file kokkos_tensor_ops.h.

872{
873 return detail::multiply_tensors<tensor_semantic_type_t<LeftTensor>>(left, right);
874}

◆ operator*() [2/8]

template<typename LeftVector , typename RightVector , typename std::enable_if< is_vector_like_v< LeftVector > &&is_vector_like_v< RightVector > &&(is_vector_ref_v< LeftVector >||is_vector_ref_v< RightVector >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const LeftVector &  left,
const RightVector &  right 
)
Returns
The dot product of left and right, matching the TypeVector convention that vector * vector is a dot product.

Definition at line 578 of file kokkos_vector_ops.h.

579{
580 return vector_dot(left, right);
581}

References vector_dot().

◆ operator*() [3/8]

template<typename Scalar , typename TensorLike , typename std::enable_if<!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar > &&is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const Scalar &  alpha,
const TensorLike &  T_in 
)
Returns
The tensor-like T_in scaled by alpha, as an owning tensor. The scalar may appear on either side of the product.

Definition at line 827 of file kokkos_tensor_ops.h.

828{
829 return T_in * alpha;
830}

◆ operator*() [4/8]

template<typename Scalar , typename VectorLike , typename std::enable_if<!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar > &&is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const Scalar &  alpha,
const VectorLike &  v 
)
Returns
The vector-like v scaled by alpha, as an owning vector. The scalar may appear on either side of the product.

Definition at line 593 of file kokkos_vector_ops.h.

594{
595 return v * alpha;
596}

◆ operator*() [5/8]

template<typename TensorLike , typename Scalar , typename std::enable_if< is_tensor_like_v< TensorLike > &&is_tensor_ref_v< TensorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const TensorLike &  T_in,
const Scalar &  alpha 
)

Definition at line 838 of file kokkos_tensor_ops.h.

839{
840 return detail::transformed_tensor<tensor_semantic_type_t<TensorLike>>(
841 T_in,
843}

◆ operator*() [6/8]

template<typename TensorLike , typename VectorLike , typename std::enable_if< is_tensor_like_v< TensorLike > &&is_vector_like_v< VectorLike > &&(is_tensor_ref_v< TensorLike >||is_vector_ref_v< VectorLike >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const TensorLike &  T_in,
const VectorLike &  v 
)
Returns
The matrix-vector product T_in * v, as an owning vector.

Definition at line 885 of file kokkos_tensor_ops.h.

886{
887 return detail::multiply_tensor_vector<vector_semantic_type_t<VectorLike>>(T_in, v);
888}

◆ operator*() [7/8]

template<typename VectorLike , typename Scalar , typename std::enable_if< is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const VectorLike &  v,
const Scalar &  alpha 
)

Definition at line 604 of file kokkos_vector_ops.h.

605{
606 return detail::transformed_vector<vector_semantic_type_t<VectorLike>>(
607 v,
609}

◆ operator*() [8/8]

template<typename VectorLike , typename TensorLike , typename std::enable_if< is_vector_like_v< VectorLike > &&is_tensor_like_v< TensorLike > &&(is_vector_ref_v< VectorLike >||is_tensor_ref_v< TensorLike >), int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator* ( const VectorLike &  v,
const TensorLike &  T_in 
)
Returns
The vector-matrix product v * T_in (i.e. T_in^T * v), as an owning vector.

Definition at line 900 of file kokkos_tensor_ops.h.

901{
902 return detail::multiply_vector_tensor<vector_semantic_type_t<VectorLike>>(v, T_in);
903}

◆ operator*=() [1/2]

template<typename LeftTensor , typename Scalar >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator*= ( LeftTensor &  left,
const Scalar &  alpha 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_ref_v<LeftTensor> && !is_vector_like_v<Scalar> && !is_tensor_like_v<Scalar>, LeftTensor &>

Scales left by alpha in place.

Definition at line 971 of file kokkos_tensor_ops.h.

975{
976 detail::transform_tensor_components(left, left, detail::scale_value<Scalar>{alpha});
977 return left;
978}

References libMesh::Kokkos::detail::transform_tensor_components().

◆ operator*=() [2/2]

template<typename LeftVector , typename Scalar >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator*= ( LeftVector &  left,
const Scalar &  alpha 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_ref_v<LeftVector> && !is_vector_like_v<Scalar> && !is_tensor_like_v<Scalar>, LeftVector &>

Scales left by alpha in place.

Definition at line 692 of file kokkos_vector_ops.h.

696{
697 detail::transform_vector_components(left, left, detail::scale_value<Scalar>{alpha});
698 return left;
699}

References libMesh::Kokkos::detail::transform_vector_components().

◆ operator+() [1/2]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator+ ( const LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), tensor_semantic_type_t<LeftTensor>>
Returns
The sum of left and right, as an owning tensor.

Definition at line 791 of file kokkos_tensor_ops.h.

795{
796 auto out = copy_tensor<tensor_semantic_type_t<LeftTensor>>(left);
797 out += right;
798 return out;
799}

References libMesh::out.

◆ operator+() [2/2]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator+ ( const LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), vector_semantic_type_t<LeftVector>>
Returns
The sum of left and right, as an owning vector.

Definition at line 543 of file kokkos_vector_ops.h.

547{
548 auto out = copy_vector<vector_semantic_type_t<LeftVector>>(left);
549 out += right;
550 return out;
551}

References libMesh::out.

◆ operator+=() [1/2]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator+= ( LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), LeftTensor &>

Adds right to left in place; when left is a ref, the update writes through to the underlying storage.

Definition at line 943 of file kokkos_tensor_ops.h.

947{
948 detail::update_tensor_components(left, right, 1);
949 return left;
950}

References libMesh::Kokkos::detail::update_tensor_components().

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::add(), and libMesh::Kokkos::vector_ref< ViewType >::add().

◆ operator+=() [2/2]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator+= ( LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), LeftVector &>

Adds right to left in place; when left is a ref, the update writes through to the underlying storage.

Definition at line 664 of file kokkos_vector_ops.h.

668{
669 detail::update_vector_components(left, right, 1);
670 return left;
671}

References libMesh::Kokkos::detail::update_vector_components().

◆ operator-() [1/4]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator- ( const LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), tensor_semantic_type_t<LeftTensor>>
Returns
The difference of left and right, as an owning tensor.

Definition at line 807 of file kokkos_tensor_ops.h.

811{
812 auto out = copy_tensor<tensor_semantic_type_t<LeftTensor>>(left);
813 out -= right;
814 return out;
815}

References libMesh::out.

◆ operator-() [2/4]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator- ( const LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), vector_semantic_type_t<LeftVector>>
Returns
The difference of left and right, as an owning vector.

Definition at line 558 of file kokkos_vector_ops.h.

562{
563 auto out = copy_vector<vector_semantic_type_t<LeftVector>>(left);
564 out -= right;
565 return out;
566}

References libMesh::out.

◆ operator-() [3/4]

template<typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator- ( const TensorLike &  T_in) -> std::enable_if_t<is_tensor_like_v<TensorLike> && is_tensor_ref_v<TensorLike>, tensor_semantic_type_t<TensorLike>>
Returns
The negative of the tensor-like T_in, as an owning tensor.

Definition at line 777 of file kokkos_tensor_ops.h.

780{
781 return detail::transformed_tensor<tensor_semantic_type_t<TensorLike>>(
782 T_in,
784}
Componentwise transform functors, shared by the vector helpers here and the tensor helpers in kokkos_...

◆ operator-() [4/4]

template<typename VectorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator- ( const VectorLike &  v) -> std::enable_if_t<is_vector_like_v<VectorLike> && is_vector_ref_v<VectorLike>, vector_semantic_type_t<VectorLike>>
Returns
The negative of the vector-like v, as an owning vector.

Definition at line 529 of file kokkos_vector_ops.h.

532{
533 return detail::transformed_vector<vector_semantic_type_t<VectorLike>>(
534 v,
536}

◆ operator-=() [1/2]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator-= ( LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), LeftTensor &>

Subtracts right from left in place.

Definition at line 957 of file kokkos_tensor_ops.h.

961{
962 detail::update_tensor_components(left, right, -1);
963 return left;
964}

References libMesh::Kokkos::detail::update_tensor_components().

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::subtract(), and libMesh::Kokkos::vector_ref< ViewType >::subtract().

◆ operator-=() [2/2]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator-= ( LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), LeftVector &>

Subtracts right from left in place.

Definition at line 678 of file kokkos_vector_ops.h.

682{
683 detail::update_vector_components(left, right, -1);
684 return left;
685}

References libMesh::Kokkos::detail::update_vector_components().

◆ operator/() [1/2]

template<typename TensorLike , typename Scalar >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator/ ( const TensorLike &  T_in,
const Scalar &  alpha 
) -> std::enable_if_t<is_tensor_like_v<TensorLike> && is_tensor_ref_v<TensorLike> && !is_vector_like_v<Scalar> && !is_tensor_like_v<Scalar>, tensor_semantic_type_t<TensorLike>>
Returns
The tensor-like T_in divided (componentwise) by the scalar alpha, as an owning tensor.

Definition at line 851 of file kokkos_tensor_ops.h.

855{
856 return detail::transformed_tensor<tensor_semantic_type_t<TensorLike>>(
857 T_in,
859}

◆ operator/() [2/2]

template<typename VectorLike , typename Scalar , typename std::enable_if< is_vector_like_v< VectorLike > &&is_vector_ref_v< VectorLike > &&!is_vector_like_v< Scalar > &&!is_tensor_like_v< Scalar >, int >::type = 0>
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator/ ( const VectorLike &  v,
const Scalar &  alpha 
)
Returns
The vector-like v divided (componentwise) by the scalar alpha, as an owning vector.

Definition at line 621 of file kokkos_vector_ops.h.

622{
623 return detail::transformed_vector<vector_semantic_type_t<VectorLike>>(
624 v,
626}

◆ operator/=() [1/2]

template<typename LeftTensor , typename Scalar >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator/= ( LeftTensor &  left,
const Scalar &  alpha 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_ref_v<LeftTensor> && !is_vector_like_v<Scalar> && !is_tensor_like_v<Scalar>, LeftTensor &>

Divides left by alpha in place.

Definition at line 985 of file kokkos_tensor_ops.h.

989{
990 detail::transform_tensor_components(left, left, detail::divide_value<Scalar>{alpha});
991 return left;
992}

References libMesh::Kokkos::detail::transform_tensor_components().

◆ operator/=() [2/2]

template<typename LeftVector , typename Scalar >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator/= ( LeftVector &  left,
const Scalar &  alpha 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_ref_v<LeftVector> && !is_vector_like_v<Scalar> && !is_tensor_like_v<Scalar>, LeftVector &>

Divides left by alpha in place.

Definition at line 706 of file kokkos_vector_ops.h.

710{
711 detail::transform_vector_components(left, left, detail::divide_value<Scalar>{alpha});
712 return left;
713}

References libMesh::Kokkos::detail::transform_vector_components().

◆ operator==() [1/2]

template<typename LeftTensor , typename RightTensor >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator== ( const LeftTensor &  left,
const RightTensor &  right 
) -> std::enable_if_t<is_tensor_like_v<LeftTensor> && is_tensor_like_v<RightTensor> && (is_tensor_ref_v<LeftTensor> || is_tensor_ref_v<RightTensor>), bool>
Returns
true if left and right agree in every component, false otherwise. Each component is compared with exact operator==.
Note
This is stricter than TypeTensor::operator==, which compares the summed componentwise differences against a component-count multiple of TOLERANCE; two tensors that the host operator calls equal may compare unequal here.

Definition at line 915 of file kokkos_tensor_ops.h.

919{
920 return detail::tensor_equal_impl(left, right);
921}

References libMesh::Kokkos::detail::tensor_equal_impl().

◆ operator==() [2/2]

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::operator== ( const LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector> && (is_vector_ref_v<LeftVector> || is_vector_ref_v<RightVector>), bool>
Returns
true if left and right agree in every component, false otherwise. Each component is compared with exact operator==, matching TypeVector::operator==; this is not a tolerance-based floating-point comparison.

Definition at line 636 of file kokkos_vector_ops.h.

640{
641 return detail::vector_equal_impl(left, right);
642}

References libMesh::Kokkos::detail::vector_equal_impl().

◆ outer_product()

template<typename ResultTensor = void, typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::outer_product ( const LeftVector &  left,
const RightVector &  right 
) -> std::enable_if_t<is_vector_like_v<LeftVector> && is_vector_like_v<RightVector>, std::conditional_t<std::is_void<ResultTensor>::value, libMesh::TypeTensor<typename LeftVector::value_type>, ResultTensor>>
Returns
The outer product left * conj(right)^T of two vector-like inputs, as an owning tensor: by default a TypeTensor of the left operand's component type, or ResultTensor if given explicitly.

Definition at line 492 of file kokkos_tensor_ops.h.

497{
498 using output_type = std::conditional_t<std::is_void<ResultTensor>::value,
500 ResultTensor>;
501 return detail::outer_product<output_type>(left, right);
502}
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
Definition type_tensor.h:54

◆ row()

template<typename ResultVector = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::row ( const TensorLike &  T_in,
const unsigned int  i 
) -> std::enable_if_t<is_tensor_like_v<TensorLike>, std::conditional_t<std::is_void<ResultVector>::value, libMesh::TypeVector<typename TensorLike::value_type>, ResultVector>>
Returns
Row i of the tensor-like T_in, as an owning vector: by default a TypeVector of T_in 's component type, or ResultVector if given explicitly.

Definition at line 560 of file kokkos_tensor_ops.h.

565{
566 using output_type = std::conditional_t<std::is_void<ResultVector>::value,
568 ResultVector>;
569 return detail::row<output_type>(T_in, i);
570}

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::is_zero(), materialize_tensor(), libMesh::Kokkos::tensor_ref< ViewType >::norm_sq(), libMesh::Kokkos::tensor_ref< ViewType >::row(), store_tensor(), and upload_tensor_storage().

◆ storage_policy_name()

template<typename StoragePolicy >
constexpr const char * libMesh::Kokkos::storage_policy_name ( )
constexpr
Returns
The name of StoragePolicy, as reported by its static name() member; a free-function form convenient for labeling per-policy results in generic code such as the Kokkos unit tests.

Definition at line 110 of file kokkos_storage_policy.h.

111{
112 return StoragePolicy::name();
113}

◆ store_tensor()

template<typename ViewType , typename TensorType >
LIBMESH_DEVICE_INLINE void libMesh::Kokkos::store_tensor ( const ViewType &  view,
const unsigned int  i,
const TensorType &  T 
)

Copies the components of the tensor T into entry i of the tensor view view, overwriting whatever that entry held.

Definition at line 98 of file kokkos_storage.h.

99{
100 auto out = make_tensor_ref(view, i);
101
102 for (unsigned int row = 0; row < LIBMESH_DIM; ++row)
103 for (unsigned int col = 0; col < LIBMESH_DIM; ++col)
104 out(row, col) = T(row, col);
105}

References make_tensor_ref(), libMesh::out, and row().

Referenced by libMeshTest::KokkosTensorOracle::test_dim_ops(), libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), and libMeshTest::KokkosTensorOracle::test_tensor_ops().

◆ store_vector()

template<typename ViewType , typename VectorType >
LIBMESH_DEVICE_INLINE void libMesh::Kokkos::store_vector ( const ViewType &  view,
const unsigned int  i,
const VectorType &  v 
)

Copies the components of the vector v into entry i of the vector view view, overwriting whatever that entry held.

Definition at line 68 of file kokkos_storage.h.

69{
70 auto out = make_vector_ref(view, i);
71
72 for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
73 out(d) = v(d);
74}

References make_vector_ref(), and libMesh::out.

Referenced by libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), libMeshTest::KokkosVectorOracle::test_mixed_representation_ops(), libMeshTest::KokkosTensorOracle::test_tensor_ops(), and libMeshTest::KokkosVectorOracle::test_vector_ops_case().

◆ tensor_identity()

template<typename ResultTensor >
LIBMESH_DEVICE_INLINE ResultTensor libMesh::Kokkos::tensor_identity ( const unsigned int  dim = LIBMESH_DIM)
Returns
An owning ResultTensor whose leading dim x dim block is the identity and whose remaining components are zero.

Definition at line 65 of file kokkos_tensor_ops.h.

66{
67 ResultTensor out;
68 out.zero();
69
70 for (unsigned int i = 0; i < dim; ++i)
71 out(i, i) = 1;
72
73 return out;
74}

References dim, and libMesh::out.

◆ transpose()

template<typename ResultTensor = void, typename TensorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::transpose ( const TensorLike &  T_in) -> std::enable_if_t<is_tensor_like_v<TensorLike>, std::conditional_t<std::is_void<ResultTensor>::value, tensor_semantic_type_t<TensorLike>, ResultTensor>>
Returns
The transpose of the tensor-like T_in, as an owning tensor.

Definition at line 510 of file kokkos_tensor_ops.h.

515{
516 using output_type = std::conditional_t<std::is_void<ResultTensor>::value,
518 ResultTensor>;
519 return detail::transpose<output_type>(T_in);
520}

Referenced by libMesh::Kokkos::tensor_ref< ViewType >::transpose().

◆ upload_tensor_storage() [1/2]

template<typename StoragePolicy , typename TensorType >
StoragePolicy::tensor_view libMesh::Kokkos::upload_tensor_storage ( const std::vector< TensorType > &  values,
const char *  label 
)
inline

Allocates a device view sized for values, copies each tensor's components into a host mirror, and deep-copies the result to the device.

Returns
The populated device view.
Note
Host-side setup helper, not something to call from within a kernel. With a device-resident default memory space the deep_copy is a host-to-device transfer; on host-only builds the mirror aliases the view and the copy is a no-op.

Definition at line 211 of file kokkos_storage_policy.h.

212{
213 auto d = make_tensor_storage<StoragePolicy>(label, values.size());
214 auto h = ::Kokkos::create_mirror_view(d);
215
216 for (std::size_t i = 0; i < values.size(); ++i)
217 for (unsigned int row = 0; row < LIBMESH_DIM; ++row)
218 for (unsigned int col = 0; col < LIBMESH_DIM; ++col)
219 h(i, row, col) = values[i](row, col);
220
221 ::Kokkos::deep_copy(d, h);
222 return d;
223}

References row().

◆ upload_tensor_storage() [2/2]

template<typename TensorType >
default_storage_policy::tensor_view libMesh::Kokkos::upload_tensor_storage ( const std::vector< TensorType > &  values,
const char *  label 
)
inline
Returns
A device view populated from values, using the default storage policy.

Definition at line 231 of file kokkos_storage_policy.h.

232{
233 return upload_tensor_storage<default_storage_policy>(values, label);
234}

◆ upload_vector_storage() [1/2]

template<typename StoragePolicy , typename VectorType >
StoragePolicy::vector_view libMesh::Kokkos::upload_vector_storage ( const std::vector< VectorType > &  values,
const char *  label 
)
inline

Allocates a device view sized for values, copies each vector's components into a host mirror, and deep-copies the result to the device.

Returns
The populated device view.
Note
Host-side setup helper, not something to call from within a kernel. With a device-resident default memory space the deep_copy is a host-to-device transfer; on host-only builds the mirror aliases the view and the copy is a no-op.

Definition at line 173 of file kokkos_storage_policy.h.

174{
175 auto d = make_vector_storage<StoragePolicy>(label, values.size());
176 auto h = ::Kokkos::create_mirror_view(d);
177
178 for (std::size_t i = 0; i < values.size(); ++i)
179 for (unsigned int component = 0; component < LIBMESH_DIM; ++component)
180 h(i, component) = values[i](component);
181
182 ::Kokkos::deep_copy(d, h);
183 return d;
184}

◆ upload_vector_storage() [2/2]

template<typename VectorType >
default_storage_policy::vector_view libMesh::Kokkos::upload_vector_storage ( const std::vector< VectorType > &  values,
const char *  label 
)
inline
Returns
A device view populated from values, using the default storage policy.

Definition at line 192 of file kokkos_storage_policy.h.

193{
194 return upload_vector_storage<default_storage_policy>(values, label);
195}

◆ vector_cross()

template<typename ResultVector = void, typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_cross ( const LeftVector &  left,
const RightVector &  right 
) -> std::conditional_t<std::is_void<ResultVector>::value, vector_semantic_type_t<LeftVector>, ResultVector>
Returns
The cross product of left and right, as an owning vector.
Note
The result is only nonzero when LIBMESH_DIM == 3; in lower dimensions the zero vector is returned, without the debug-mode assertion TypeVector::cross() performs.

Definition at line 267 of file kokkos_vector_ops.h.

271{
272 using output_type = std::conditional_t<std::is_void<ResultVector>::value,
274 ResultVector>;
275 output_type out;
276 out.zero();
277
278#if LIBMESH_DIM == 3
279 out(0) = left(1) * right(2) - left(2) * right(1);
280 out(1) = -left(0) * right(2) + left(2) * right(0);
281 out(2) = left(0) * right(1) - left(1) * right(0);
282#else
283 libmesh_ignore(left);
284 libmesh_ignore(right);
285#endif
286
287 return out;
288}
void libmesh_ignore(const Args &...)

References libMesh::libmesh_ignore(), and libMesh::out.

Referenced by libMesh::Kokkos::vector_ref< ViewType >::cross().

◆ vector_cross_norm_sq()

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_cross_norm_sq ( const LeftVector &  left,
const RightVector &  right 
)
Returns
|left x right|^2, computed without the extra temporary a cross().norm_sq() chain would create, mirroring cross_norm_sq() in type_vector.h. In 2D only the out-of-plane component contributes.

Definition at line 320 of file kokkos_vector_ops.h.

321{
322 const auto z = left(0) * right(1) - left(1) * right(0);
323
324#if LIBMESH_DIM == 3
325 const auto x = left(1) * right(2) - left(2) * right(1);
326 const auto y = left(0) * right(2) - left(2) * right(0);
327 return x * x + y * y + z * z;
328#else
329 return z * z;
330#endif
331}

Referenced by libMeshTest::KokkosVectorOracle::test_mixed_representation_ops().

◆ vector_dot()

template<typename LeftVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_dot ( const LeftVector &  left,
const RightVector &  right 
)
Returns
The dot product of left and right, in whatever type their componentwise products sum to.

Definition at line 220 of file kokkos_vector_ops.h.

221{
222 static_assert(is_vector_like_v<LeftVector>, "vector_dot() requires a vector-like left input");
223 static_assert(is_vector_like_v<RightVector>, "vector_dot() requires a vector-like right input");
224
225 using sum_type =
226 detail::remove_cvref_t<decltype(left(0) * right(0))>;
227
228 sum_type sum = sum_type(0);
229 for (unsigned int component = 0; component < LIBMESH_DIM; ++component)
230 sum += left(component) * right(component);
231
232 return sum;
233}
typename std::remove_cv< typename std::remove_reference< T >::type >::type remove_cvref_t
Strips reference and const/volatile qualifiers from T, turning e.g.

Referenced by contract(), operator*(), libMeshTest::KokkosVectorOracle::test_vector_ops_case(), and vector_solid_angle().

◆ vector_solid_angle()

template<typename VectorA , typename VectorB , typename VectorC >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_solid_angle ( const VectorA &  v01,
const VectorB &  v02,
const VectorC &  v03 
)
Returns
The solid angle subtended by a tetrahedral vertex, as defined by the edge vectors v01, v02, v03 - positive if the vectors obey the right-hand rule, negative for a left-hand orientation. Computed by Van Oosterom and Strackee's formula, mirroring the solid_angle() free function in type_vector.h.

Definition at line 342 of file kokkos_vector_ops.h.

343{
344 using std::atan;
345
346 const auto norm01 = v01.norm();
347 const auto norm02 = v02.norm();
348 const auto norm03 = v03.norm();
349 const auto tan_half_angle =
350 vector_triple_product(v01, v02, v03) /
351 (vector_dot(v01, v02) * norm03 +
352 vector_dot(v01, v03) * norm02 +
353 vector_dot(v02, v03) * norm01 +
354 norm01 * norm02 * norm03);
355
356 return Real(2) * atan(tan_half_angle);
357}
LIBMESH_DEVICE_INLINE auto vector_triple_product(const LeftVector &left, const MiddleVector &middle, const RightVector &right)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::Real, vector_dot(), and vector_triple_product().

Referenced by libMeshTest::KokkosVectorOracle::test_mixed_representation_ops(), and libMeshTest::KokkosVectorOracle::test_vector_ops_case().

◆ vector_triple_product()

template<typename LeftVector , typename MiddleVector , typename RightVector >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_triple_product ( const LeftVector &  left,
const MiddleVector &  middle,
const RightVector &  right 
)
Returns
The scalar triple product left . (middle x right), i.e. the signed volume of the parallelepiped the three vectors span (zero unless LIBMESH_DIM == 3).

Definition at line 297 of file kokkos_vector_ops.h.

300{
301#if LIBMESH_DIM == 3
302 return left(0) * (middle(1) * right(2) - middle(2) * right(1)) -
303 left(1) * (middle(0) * right(2) - middle(2) * right(0)) +
304 left(2) * (middle(0) * right(1) - middle(1) * right(0));
305#else
306 libmesh_ignore(left, middle, right);
307 using value_type =
308 detail::remove_cvref_t<decltype(left(0) * middle(0))>;
309 return value_type(0);
310#endif
311}

References libMesh::libmesh_ignore().

Referenced by vector_solid_angle().

◆ vector_unit()

template<typename ResultVector = void, typename VectorLike >
LIBMESH_DEVICE_INLINE auto libMesh::Kokkos::vector_unit ( const VectorLike &  v) -> std::conditional_t<std::is_void<ResultVector>::value, vector_semantic_type_t<VectorLike>, ResultVector>
Returns
An owning unit vector in the direction of v. Asserts (in debug modes) that v is not the zero vector.

Definition at line 242 of file kokkos_vector_ops.h.

246{
247 const auto length = v.norm();
248 libmesh_assert_not_equal_to(length, static_cast<Real>(0.));
249 using output_type = std::conditional_t<std::is_void<ResultVector>::value,
251 ResultVector>;
252 return detail::transformed_vector<output_type>(v, detail::divide_value<decltype(length)>{length});
253}

References libMesh::Real.

Referenced by libMesh::Kokkos::vector_ref< ViewType >::unit().

Variable Documentation

◆ is_tensor_like_v

template<typename T >
constexpr bool libMesh::Kokkos::is_tensor_like_v = is_tensor_like<detail::remove_cvref_t<T>>::value
inlineconstexpr

Definition at line 170 of file kokkos_linalg_base.h.

◆ is_tensor_ref_v

template<typename T >
constexpr bool libMesh::Kokkos::is_tensor_ref_v = is_tensor_ref<detail::remove_cvref_t<T>>::value
inlineconstexpr

Definition at line 176 of file kokkos_linalg_base.h.

◆ is_vector_like_v

template<typename T >
constexpr bool libMesh::Kokkos::is_vector_like_v = is_vector_like<detail::remove_cvref_t<T>>::value
inlineconstexpr

Variable template shorthands for the traits above.

The traits are specialized only for plain (unqualified) types, so each shorthand strips reference and cv-qualifiers before consulting the trait; callers can therefore apply them to qualified types (e.g. is_vector_like_v<const TypeVector<Real> &> is still true) without decaying first.

Definition at line 167 of file kokkos_linalg_base.h.

◆ is_vector_ref_v

template<typename T >
constexpr bool libMesh::Kokkos::is_vector_ref_v = is_vector_ref<detail::remove_cvref_t<T>>::value
inlineconstexpr

Definition at line 173 of file kokkos_linalg_base.h.