https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
Moose::Kokkos::Utils Namespace Reference

Functions

template<typename T >
KOKKOS_INLINE_FUNCTION T sign (T x)
 Returns the sign of a value.
 
template<typename T >
KOKKOS_INLINE_FUNCTION const T * find (const T &target, const T *const begin, const T *const end)
 Find a value in an array.
 
KOKKOS_INLINE_FUNCTION void choleskySolve (Real *const A, Real *const x, Real *const b, const unsigned int n)
 Perform an in-place linear solve using Cholesky decomposition Matrix and right-hand-side vector are modified after this call.
 

Function Documentation

◆ choleskySolve()

KOKKOS_INLINE_FUNCTION void Moose::Kokkos::Utils::choleskySolve ( Real *const  A,
Real *const  x,
Real *const  b,
const unsigned int  n 
)

Perform an in-place linear solve using Cholesky decomposition Matrix and right-hand-side vector are modified after this call.

Parameters
AThe row-major matrix
xThe solution vector
bThe right-hand-side vector
nThe system size

Definition at line 72 of file KokkosUtils.h.

73{
74 for (unsigned int i = 0; i < n; ++i)
75 {
76 for (unsigned int j = 0; j <= i; ++j)
77 {
78 Real sum = A[j + n * i];
79
80 for (unsigned int k = 0; k < j; ++k)
81 sum -= A[k + n * i] * A[k + n * j];
82
83 if (i == j)
84 A[j + n * i] = ::Kokkos::sqrt(sum);
85 else
86 A[j + n * i] = sum / A[j + n * j];
87 }
88 }
89
90 for (unsigned int i = 0; i < n; ++i)
91 {
92 Real sum = b[i];
93
94 for (unsigned int j = 0; j < i; ++j)
95 sum -= A[j + n * i] * b[j];
96
97 b[i] = sum / A[i + n * i];
98 }
99
100 for (int i = n - 1; i >= 0; --i)
101 {
102 Real sum = b[i];
103
104 for (unsigned int j = i + 1; j < n; ++j)
105 sum -= A[i + n * j] * x[j];
106
107 x[i] = sum / A[i + n * i];
108 }
109}

Referenced by Moose::Kokkos::AuxKernel::computeElementInternal().

◆ find()

template<typename T >
KOKKOS_INLINE_FUNCTION const T * Moose::Kokkos::Utils::find ( const T &  target,
const T *const  begin,
const T *const  end 
)

Find a value in an array.

Parameters
targetThe target value to find
beginThe pointer to the first element of the array
endThe pointer next to the last element of the array
Returns
The pointer to the target element, end if the target element was not found

Definition at line 40 of file KokkosUtils.h.

41{
42 if (begin == end)
43 return end;
44
45 auto left = begin;
46 auto right = end - 1;
47
48 while (left <= right)
49 {
50 auto mid = left + (right - left) / 2;
51
52 if (*mid == target)
53 return mid;
54 else if (*mid < target)
55 left = mid + 1;
56 else
57 right = mid - 1;
58 }
59
60 return end;
61}

Referenced by Moose::Kokkos::Matrix::find(), and Moose::Kokkos::Mesh::isBoundaryNode().

◆ sign()

template<typename T >
KOKKOS_INLINE_FUNCTION T Moose::Kokkos::Utils::sign ( x)

Returns the sign of a value.

Parameters
xThe value
Returns
The sign of the value

Definition at line 26 of file KokkosUtils.h.

27{
28 return x >= 0.0 ? 1.0 : -1.0;
29}

Referenced by KokkosPiecewiseConstant::value().