18#ifndef LIBMESH_KOKKOS_LINALG_BASE_H
19#define LIBMESH_KOKKOS_LINALG_BASE_H
47#include "libmesh/libmesh_common.h"
48#include "libmesh/libmesh_device.h"
49#include "libmesh/point.h"
50#include "libmesh/tensor_value.h"
51#include "libmesh/type_tensor.h"
52#include "libmesh/type_vector.h"
71 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
81template <
typename ViewType>
90template <
typename ViewType>
192template <
typename ViewType>
203 LIBMESH_DEVICE_INLINE
213 LIBMESH_DEVICE_INLINE
214 decltype(
auto)
operator()(
const unsigned int component)
const
219 LIBMESH_DEVICE_INLINE
220 decltype(
auto)
operator()(
const unsigned int component)
228 template <
typename RightVector>
229 LIBMESH_DEVICE_INLINE
230 void assign(
const RightVector & right);
235 template <
typename RightVector>
236 LIBMESH_DEVICE_INLINE
237 void add(
const RightVector & right);
242 template <
typename RightVector>
243 LIBMESH_DEVICE_INLINE
249 template <
typename RightVector>
250 LIBMESH_DEVICE_INLINE
251 void subtract(
const RightVector & right);
257 template <
typename RightVector>
258 LIBMESH_DEVICE_INLINE
264 LIBMESH_DEVICE_INLINE
270 template <
typename RightVector>
271 LIBMESH_DEVICE_INLINE
272 auto contract(
const RightVector & right)
const;
278 LIBMESH_DEVICE_INLINE
284 LIBMESH_DEVICE_INLINE
291 LIBMESH_DEVICE_INLINE
298 LIBMESH_DEVICE_INLINE
305 LIBMESH_DEVICE_INLINE
312 template <
typename RightVector>
313 LIBMESH_DEVICE_INLINE
314 auto cross(
const RightVector & right)
const;
319 LIBMESH_DEVICE_INLINE
339template <
typename ViewType>
350 LIBMESH_DEVICE_INLINE
358 LIBMESH_DEVICE_INLINE
359 decltype(
auto)
operator()(
const unsigned int row,
const unsigned int col)
const
364 LIBMESH_DEVICE_INLINE
365 decltype(
auto)
operator()(
const unsigned int row,
const unsigned int col)
373 template <
typename RightTensor>
374 LIBMESH_DEVICE_INLINE
375 void assign(
const RightTensor & right);
380 template <
typename RightTensor>
381 LIBMESH_DEVICE_INLINE
382 void add(
const RightTensor & right);
387 template <
typename RightTensor>
388 LIBMESH_DEVICE_INLINE
394 template <
typename RightTensor>
395 LIBMESH_DEVICE_INLINE
396 void subtract(
const RightTensor & right);
402 template <
typename RightTensor>
403 LIBMESH_DEVICE_INLINE
409 LIBMESH_DEVICE_INLINE
416 template <
typename RightTensor>
417 LIBMESH_DEVICE_INLINE
418 auto contract(
const RightTensor & right)
const;
424 LIBMESH_DEVICE_INLINE
430 LIBMESH_DEVICE_INLINE
437 LIBMESH_DEVICE_INLINE
444 LIBMESH_DEVICE_INLINE
451 LIBMESH_DEVICE_INLINE
452 auto det(
const unsigned int dim = LIBMESH_DIM)
const;
457 LIBMESH_DEVICE_INLINE
464 LIBMESH_DEVICE_INLINE
465 auto inverse(
const unsigned int dim = LIBMESH_DIM)
const;
471 template <
typename VectorLike,
typename ResultVector>
472 LIBMESH_DEVICE_INLINE
473 void solve(
const VectorLike &
b, ResultVector & x)
const;
478 LIBMESH_DEVICE_INLINE
479 auto row(
const unsigned int i)
const;
484 LIBMESH_DEVICE_INLINE
485 auto column(
const unsigned int i)
const;
491 template <
typename VectorLike>
492 LIBMESH_DEVICE_INLINE
498 LIBMESH_DEVICE_INLINE
530template <
typename ViewType>
554template <
typename ViewType>
559template <
typename ViewType>
579template <
typename ViewType>
598template <
typename ViewType>
603template <
typename ViewType>
629template <
typename ViewType>
643template <
typename ViewType>
645tensor_ref<typename std::remove_reference<ViewType>::type>
659template <
typename OutputVector,
typename VectorLike>
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");
671 for (
unsigned int component = 0; component < LIBMESH_DIM; ++component)
672 out(component) = v(component);
681template <
typename OutputTensor,
typename TensorLike>
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");
693 for (
unsigned int row = 0;
row < LIBMESH_DIM; ++
row)
694 for (
unsigned int col = 0; col < LIBMESH_DIM; ++col)
Non-owning handle to one tensor entry of a Kokkos storage view.
LIBMESH_DEVICE_INLINE auto left_multiply(const VectorLike &v) const
LIBMESH_DEVICE_INLINE void add(const RightTensor &right)
Adds right to the referenced entry, in place.
LIBMESH_DEVICE_INLINE auto transpose() const
LIBMESH_DEVICE_INLINE tensor_ref(ViewType view, const unsigned int index)
Constructs a reference to entry index of view.
LIBMESH_DEVICE_INLINE unsigned int index() const
LIBMESH_DEVICE_INLINE void zero()
Sets every component of the referenced entry to zero.
LIBMESH_DEVICE_INLINE void subtract_scaled(const RightTensor &right, const value_type &factor)
Subtracts factor times right from the referenced entry, in place.
LIBMESH_DEVICE_INLINE void solve(const VectorLike &b, ResultVector &x) const
Solves the linear system (*this)x = b for x, via the explicit inverse.
LIBMESH_DEVICE_INLINE auto norm() const
LIBMESH_DEVICE_INLINE void add_scaled(const RightTensor &right, const value_type &factor)
Adds factor times right to the referenced entry, in place.
LIBMESH_DEVICE_INLINE auto norm_sq() const
LIBMESH_DEVICE_INLINE void subtract(const RightTensor &right)
Subtracts right from the referenced entry, in place.
LIBMESH_DEVICE_INLINE auto tr() const
LIBMESH_DEVICE_INLINE void assign(const RightTensor &right)
Assigns right 's components to the referenced entry.
LIBMESH_DEVICE_INLINE auto row(const unsigned int i) const
detail::tensor_view_value_t< ViewType > value_type
LIBMESH_DEVICE_INLINE auto contract(const RightTensor &right) const
LIBMESH_DEVICE_INLINE auto inverse(const unsigned int dim=LIBMESH_DIM) const
LIBMESH_DEVICE_INLINE auto det(const unsigned int dim=LIBMESH_DIM) const
LIBMESH_DEVICE_INLINE auto column(const unsigned int i) const
LIBMESH_DEVICE_INLINE bool is_zero() const
Non-owning handle to one vector entry of a Kokkos storage view.
LIBMESH_DEVICE_INLINE auto l1_norm() const
LIBMESH_DEVICE_INLINE auto norm() const
LIBMESH_DEVICE_INLINE vector_ref(ViewType view, const unsigned int index)
Constructs a reference to entry index of view.
LIBMESH_DEVICE_INLINE auto cross(const RightVector &right) const
LIBMESH_DEVICE_INLINE void zero()
Sets every component of the referenced entry to zero.
LIBMESH_DEVICE_INLINE void add_scaled(const RightVector &right, const value_type &factor)
Adds factor times right to the referenced entry, in place.
LIBMESH_DEVICE_INLINE void add(const RightVector &right)
Adds right to the referenced entry, in place.
detail::vector_view_value_t< ViewType > value_type
LIBMESH_DEVICE_INLINE void subtract(const RightVector &right)
Subtracts right from the referenced entry, in place.
LIBMESH_DEVICE_INLINE void subtract_scaled(const RightVector &right, const value_type &factor)
Subtracts factor times right from the referenced entry, in place.
LIBMESH_DEVICE_INLINE auto norm_sq() const
LIBMESH_DEVICE_INLINE auto contract(const RightVector &right) const
LIBMESH_DEVICE_INLINE void assign(const RightVector &right)
Assigns right 's components to the referenced entry.
LIBMESH_DEVICE_INLINE unsigned int index() const
LIBMESH_DEVICE_INLINE auto unit() const
LIBMESH_DEVICE_INLINE bool is_zero() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
This class defines a vector in LIBMESH_DIM dimensional space of type T.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
remove_cvref_t< decltype(std::declval< ViewType & >()(0, 0))> vector_view_value_t
The plain component type stored by a vector view.
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.
remove_cvref_t< decltype(std::declval< ViewType & >()(0, 0, 0))> tensor_view_value_t
The plain component type stored by a tensor view, recovered from an (entry, row, column) indexing exp...
LIBMESH_DEVICE_INLINE OutputTensor materialize_tensor(const TensorLike &T_in)
LIBMESH_DEVICE_INLINE vector_ref< typename std::remove_reference< ViewType >::type > make_vector_ref(ViewType &&view, const unsigned int index)
constexpr bool is_tensor_like_v
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...
LIBMESH_DEVICE_INLINE OutputVector materialize_vector(const VectorLike &v)
constexpr bool is_vector_like_v
Variable template shorthands for the traits above.
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...
constexpr bool is_vector_ref_v
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 > >
constexpr bool is_tensor_ref_v
LIBMESH_DEVICE_INLINE tensor_ref< typename std::remove_reference< ViewType >::type > make_tensor_ref(ViewType &&view, const unsigned int index)
The libMesh namespace provides an interface to certain functionality in the library.
Opt-in trait marking the types the generic tensor operations in kokkos_tensor_ops....
Type trait satisfied only by tensor_ref instantiations; the tensor-ref analogue of is_vector_ref.
Opt-in trait marking the types the generic vector operations in kokkos_vector_ops....
Type trait satisfied only by vector_ref instantiations.
typename tensor_ref< ViewType >::value_type value_type
Traits mapping each tensor-like type to its "semantic" owning libMesh type.
typename vector_ref< ViewType >::value_type value_type
Traits mapping each vector-like type to its "semantic" owning libMesh type - the type an algorithm sh...