LCOV - code coverage report
Current view: top level - include/kokkos/base - KokkosTypes.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 176 186 94.6 %
Date: 2026-08-03 21:12:22 Functions: 48 51 94.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #include "KokkosThread.h"
      13             : #include "KokkosScalar.h"
      14             : #include "KokkosJaggedArray.h"
      15             : 
      16             : #ifdef MOOSE_KOKKOS_SCOPE
      17             : #include "KokkosADReal.h"
      18             : #endif
      19             : 
      20             : #include "MooseError.h"
      21             : #include "MooseUtils.h"
      22             : 
      23             : #include "libmesh/tensor_tools.h"
      24             : #include "libmesh/tensor_value.h"
      25             : 
      26             : namespace Moose::Kokkos
      27             : {
      28             : 
      29             : template <typename T>
      30             : struct Vector3;
      31             : 
      32             : using Real3 = Vector3<Real>;
      33             : using ADReal3 = Vector3<ADReal>;
      34             : 
      35             : struct Real33;
      36             : 
      37             : template <typename T>
      38             : struct Vector3
      39             : {
      40             :   T v[3];
      41             : 
      42             : #ifdef MOOSE_KOKKOS_SCOPE
      43             :   Vector3(const libMesh::TypeVector<T> & vector);
      44    87000678 :   KOKKOS_INLINE_FUNCTION Vector3() { *this = T{}; }
      45    73131886 :   KOKKOS_INLINE_FUNCTION Vector3(const T & scalar) { *this = scalar; }
      46             :   KOKKOS_INLINE_FUNCTION Vector3(const Vector3<T> & vector) = default;
      47             :   KOKKOS_INLINE_FUNCTION Vector3(const T & x, const T & y, const T & z);
      48             : 
      49             :   KOKKOS_INLINE_FUNCTION Vector3<T> operator-() const;
      50      366376 :   KOKKOS_INLINE_FUNCTION T & operator()(unsigned int i) { return v[i]; }
      51    72356462 :   KOKKOS_INLINE_FUNCTION const T & operator()(unsigned int i) const { return v[i]; }
      52             : 
      53             :   Vector3<T> & operator=(const libMesh::TypeVector<T> & vector);
      54             : 
      55             :   template <typename U>
      56             :   KOKKOS_INLINE_FUNCTION Vector3<T> & operator=(const Vector3<U> & vector);
      57             :   KOKKOS_INLINE_FUNCTION Vector3<T> & operator=(const Vector3<T> & vector);
      58             :   KOKKOS_INLINE_FUNCTION Vector3<T> & operator=(const T & scalar);
      59             : 
      60             :   template <typename U>
      61             :   KOKKOS_INLINE_FUNCTION void operator+=(const Vector3<U> & vector);
      62             :   KOKKOS_INLINE_FUNCTION void operator+=(const T & scalar);
      63             :   template <typename U>
      64             :   KOKKOS_INLINE_FUNCTION void operator-=(const Vector3<U> & vector);
      65             :   KOKKOS_INLINE_FUNCTION void operator-=(const T & scalar);
      66             :   KOKKOS_INLINE_FUNCTION void operator*=(const T & scalar);
      67             : 
      68             :   KOKKOS_INLINE_FUNCTION Real norm() const;
      69             :   KOKKOS_INLINE_FUNCTION Real dot_product(const Real3 vector) const;
      70             :   KOKKOS_INLINE_FUNCTION Real3 cross_product(const Real3 vector) const;
      71             :   KOKKOS_INLINE_FUNCTION Real33 cartesian_product(const Real3 vector) const;
      72             : #endif
      73             : };
      74             : 
      75             : struct Real33
      76             : {
      77             :   Real a[3][3];
      78             : 
      79             : #ifdef MOOSE_KOKKOS_SCOPE
      80    46623680 :   KOKKOS_INLINE_FUNCTION Real33() { *this = 0; }
      81     4183822 :   KOKKOS_INLINE_FUNCTION Real33(const Real scalar) { *this = scalar; }
      82             :   KOKKOS_INLINE_FUNCTION Real33(const Real33 & tensor) = default;
      83             :   Real33(const libMesh::TypeTensor<Real> & tensor) { *this = tensor; }
      84             : 
      85   580349546 :   KOKKOS_INLINE_FUNCTION Real & operator()(unsigned int i, unsigned int j) { return a[i][j]; }
      86  2361129148 :   KOKKOS_INLINE_FUNCTION Real operator()(unsigned int i, unsigned int j) const { return a[i][j]; }
      87             : 
      88             :   Real33 & operator=(const libMesh::TypeTensor<Real> & tensor);
      89             :   KOKKOS_INLINE_FUNCTION Real33 & operator=(const Real33 & tensor);
      90             :   KOKKOS_INLINE_FUNCTION Real33 & operator=(const Real scalar);
      91             :   KOKKOS_INLINE_FUNCTION void operator+=(const Real33 tensor);
      92             :   KOKKOS_INLINE_FUNCTION void operator*=(const Real scalar);
      93             : 
      94             :   KOKKOS_INLINE_FUNCTION Real contract(const Real33 tensor) const;
      95             :   KOKKOS_INLINE_FUNCTION void identity(const unsigned int dim = 3);
      96             :   KOKKOS_INLINE_FUNCTION Real determinant(const unsigned int dim = 3) const;
      97             :   KOKKOS_INLINE_FUNCTION Real33 inverse(const unsigned int dim = 3) const;
      98             :   KOKKOS_INLINE_FUNCTION Real33 transpose() const;
      99             :   KOKKOS_INLINE_FUNCTION Real3 row(const unsigned int i) const;
     100             :   KOKKOS_INLINE_FUNCTION Real3 col(const unsigned int j) const;
     101             : #endif
     102             : };
     103             : 
     104             : #ifdef MOOSE_KOKKOS_SCOPE
     105             : 
     106             : template <typename T>
     107       78874 : Vector3<T>::Vector3(const libMesh::TypeVector<T> & vector)
     108             : {
     109       78874 :   v[0] = vector(0);
     110       78874 :   v[1] = vector(1);
     111       78874 :   v[2] = vector(2);
     112       78874 : }
     113             : 
     114             : template <typename T>
     115             : KOKKOS_INLINE_FUNCTION
     116   610757947 : Vector3<T>::Vector3(const T & x, const T & y, const T & z)
     117             : {
     118   579732907 :   v[0] = x;
     119   579732907 :   v[1] = y;
     120   579732907 :   v[2] = z;
     121   579732907 : }
     122             : 
     123             : template <typename T>
     124             : Vector3<T> &
     125     1440219 : Vector3<T>::operator=(const libMesh::TypeVector<T> & vector)
     126             : {
     127     1440219 :   v[0] = vector(0);
     128     1440219 :   v[1] = vector(1);
     129     1440219 :   v[2] = vector(2);
     130             : 
     131     1440219 :   return *this;
     132             : }
     133             : 
     134             : template <typename T>
     135             : KOKKOS_INLINE_FUNCTION Vector3<T>
     136        2824 : Vector3<T>::operator-() const
     137             : {
     138        2824 :   Vector3<T> vector(*this);
     139        2824 :   vector *= -1;
     140             : 
     141        2824 :   return vector;
     142             : }
     143             : 
     144             : template <typename T>
     145             : KOKKOS_INLINE_FUNCTION Vector3<T> &
     146   235254648 : Vector3<T>::operator=(const Vector3<T> & vector)
     147             : {
     148   235254648 :   v[0] = vector.v[0];
     149   235254648 :   v[1] = vector.v[1];
     150   235254648 :   v[2] = vector.v[2];
     151             : 
     152   235254648 :   return *this;
     153             : }
     154             : 
     155             : template <typename T>
     156             : template <typename U>
     157             : KOKKOS_INLINE_FUNCTION Vector3<T> &
     158      275920 : Vector3<T>::operator=(const Vector3<U> & vector)
     159             : {
     160      275920 :   v[0] = vector.v[0];
     161      275920 :   v[1] = vector.v[1];
     162      275920 :   v[2] = vector.v[2];
     163             : 
     164      275920 :   return *this;
     165             : }
     166             : 
     167             : template <typename T>
     168             : KOKKOS_INLINE_FUNCTION Vector3<T> &
     169   145920340 : Vector3<T>::operator=(const T & scalar)
     170             : {
     171   145920340 :   v[0] = scalar;
     172   145920340 :   v[1] = scalar;
     173   145920340 :   v[2] = scalar;
     174             : 
     175   145920340 :   return *this;
     176             : }
     177             : 
     178             : template <typename T>
     179             : template <typename U>
     180             : KOKKOS_INLINE_FUNCTION void
     181   349683968 : Vector3<T>::operator+=(const Vector3<U> & vector)
     182             : {
     183   349683968 :   v[0] += vector.v[0];
     184   349683968 :   v[1] += vector.v[1];
     185   349683968 :   v[2] += vector.v[2];
     186   349683968 : }
     187             : 
     188             : template <typename T>
     189             : KOKKOS_INLINE_FUNCTION void
     190             : Vector3<T>::operator+=(const T & scalar)
     191             : {
     192             :   v[0] += scalar;
     193             :   v[1] += scalar;
     194             :   v[2] += scalar;
     195             : }
     196             : 
     197             : template <typename T>
     198             : template <typename U>
     199             : KOKKOS_INLINE_FUNCTION void
     200             : Vector3<T>::operator-=(const Vector3<U> & vector)
     201             : {
     202             :   v[0] -= vector.v[0];
     203             :   v[1] -= vector.v[1];
     204             :   v[2] -= vector.v[2];
     205             : }
     206             : 
     207             : template <typename T>
     208             : KOKKOS_INLINE_FUNCTION void
     209             : Vector3<T>::operator-=(const T & scalar)
     210             : {
     211             :   v[0] -= scalar;
     212             :   v[1] -= scalar;
     213             :   v[2] -= scalar;
     214             : }
     215             : 
     216             : template <typename T>
     217             : KOKKOS_INLINE_FUNCTION void
     218     1161837 : Vector3<T>::operator*=(const T & scalar)
     219             : {
     220     1161837 :   v[0] *= scalar;
     221     1161837 :   v[1] *= scalar;
     222     1161837 :   v[2] *= scalar;
     223     1161837 : }
     224             : 
     225             : template <typename T>
     226             : KOKKOS_INLINE_FUNCTION Vector3<T>
     227             : operator+(const T & left, const Vector3<T> & right)
     228             : {
     229             :   return {left + right.v[0], left + right.v[1], left + right.v[2]};
     230             : }
     231             : 
     232             : template <typename T>
     233             : KOKKOS_INLINE_FUNCTION Vector3<T>
     234             : operator+(const Vector3<T> & left, const T & right)
     235             : {
     236             :   return {left.v[0] + right, left.v[1] + right, left.v[2] + right};
     237             : }
     238             : 
     239             : template <typename T>
     240             : KOKKOS_INLINE_FUNCTION Vector3<T>
     241             : operator+(const Vector3<T> & left, const Vector3<T> & right)
     242             : {
     243             :   return {left.v[0] + right.v[0], left.v[1] + right.v[1], left.v[2] + right.v[2]};
     244             : }
     245             : 
     246             : template <typename T>
     247             : KOKKOS_INLINE_FUNCTION Vector3<T>
     248             : operator-(const T & left, const Vector3<T> & right)
     249             : {
     250             :   return {left - right.v[0], left - right.v[1], left - right.v[2]};
     251             : }
     252             : 
     253             : template <typename T>
     254             : KOKKOS_INLINE_FUNCTION Vector3<T>
     255             : operator-(const Vector3<T> & left, const T & right)
     256             : {
     257             :   return {left.v[0] - right, left.v[1] - right, left.v[2] - right};
     258             : }
     259             : 
     260             : template <typename T>
     261             : KOKKOS_INLINE_FUNCTION Vector3<T>
     262      107880 : operator-(const Vector3<T> & left, const Vector3<T> & right)
     263             : {
     264      107880 :   return {left.v[0] - right.v[0], left.v[1] - right.v[1], left.v[2] - right.v[2]};
     265             : }
     266             : 
     267             : template <typename T>
     268             : KOKKOS_INLINE_FUNCTION Vector3<T>
     269             : operator*(const T & left, const Vector3<T> & right)
     270             : {
     271             :   return {left * right.v[0], left * right.v[1], left * right.v[2]};
     272             : }
     273             : 
     274             : template <typename T>
     275             : KOKKOS_INLINE_FUNCTION Vector3<T>
     276             : operator*(const Vector3<T> & left, const T & right)
     277             : {
     278             :   return {left.v[0] * right, left.v[1] * right, left.v[2] * right};
     279             : }
     280             : 
     281             : template <typename T>
     282             : KOKKOS_INLINE_FUNCTION T
     283    98783204 : operator*(const Vector3<T> & left, const Vector3<T> & right)
     284             : {
     285    98783204 :   return left.v[0] * right.v[0] + left.v[1] * right.v[1] + left.v[2] * right.v[2];
     286             : }
     287             : 
     288             : template <>
     289             : KOKKOS_INLINE_FUNCTION Real
     290      435494 : Vector3<Real>::norm() const
     291             : {
     292      435494 :   return ::Kokkos::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
     293             : }
     294             : 
     295             : template <>
     296             : KOKKOS_INLINE_FUNCTION Real
     297             : Vector3<Real>::dot_product(const Real3 vector) const
     298             : {
     299             :   return v[0] * vector.v[0] + v[1] * vector.v[1] + v[2] * vector.v[2];
     300             : }
     301             : 
     302             : template <>
     303             : KOKKOS_INLINE_FUNCTION Real3
     304     1310424 : Vector3<Real>::cross_product(const Real3 vector) const
     305             : {
     306     1310424 :   Real3 cross;
     307             : 
     308     1310424 :   cross.v[0] = v[1] * vector.v[2] - v[2] * vector.v[1];
     309     1310424 :   cross.v[1] = v[2] * vector.v[0] - v[0] * vector.v[2];
     310     1310424 :   cross.v[2] = v[0] * vector.v[1] - v[1] * vector.v[0];
     311             : 
     312     1310424 :   return cross;
     313             : }
     314             : 
     315             : template <>
     316             : KOKKOS_INLINE_FUNCTION Real33
     317     5377776 : Vector3<Real>::cartesian_product(const Real3 vector) const
     318             : {
     319     5377776 :   Real33 tensor;
     320             : 
     321    21511104 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     322    64533312 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     323    48399984 :       tensor(i, j) = v[i] * vector.v[j];
     324             : 
     325     5377776 :   return tensor;
     326             : }
     327             : 
     328             : inline Real33 &
     329       16461 : Real33::operator=(const libMesh::TypeTensor<Real> & tensor)
     330             : {
     331       65844 :   for (const auto i : make_range(Moose::dim))
     332      197532 :     for (const auto j : make_range(Moose::dim))
     333      148149 :       a[i][j] = tensor(i, j);
     334             : 
     335       16461 :   return *this;
     336             : }
     337             : 
     338             : KOKKOS_INLINE_FUNCTION Real33 &
     339    51492649 : Real33::operator=(const Real33 & tensor)
     340             : {
     341   205970596 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     342   617911788 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     343   463433841 :       a[i][j] = tensor.a[i][j];
     344             : 
     345    51492649 :   return *this;
     346             : }
     347             : 
     348             : KOKKOS_INLINE_FUNCTION Real33 &
     349    51165434 : Real33::operator=(const Real scalar)
     350             : {
     351   204661736 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     352   613985208 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     353   460488906 :       a[i][j] = scalar;
     354             : 
     355    51165434 :   return *this;
     356             : }
     357             : 
     358             : KOKKOS_INLINE_FUNCTION void
     359    33746336 : Real33::operator+=(const Real33 tensor)
     360             : {
     361   134985344 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     362   404956032 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     363   303717024 :       a[i][j] += tensor.a[i][j];
     364    33746336 : }
     365             : 
     366             : KOKKOS_INLINE_FUNCTION void
     367    31200433 : Real33::operator*=(const Real scalar)
     368             : {
     369   124801732 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     370   374405196 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     371   280803897 :       a[i][j] *= scalar;
     372    31200433 : }
     373             : 
     374             : KOKKOS_INLINE_FUNCTION Real
     375    36533064 : Real33::contract(const Real33 tensor) const
     376             : {
     377    36533064 :   Real value = 0;
     378             : 
     379   146132256 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     380   438396768 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     381   328797576 :       value += a[i][j] * tensor.a[i][j];
     382             : 
     383    36533064 :   return value;
     384             : }
     385             : 
     386             : KOKKOS_INLINE_FUNCTION void
     387           0 : Real33::identity(const unsigned int dim)
     388             : {
     389           0 :   *this = 0;
     390             : 
     391           0 :   for (unsigned int i = 0; i < dim; ++i)
     392           0 :     a[i][i] = 1;
     393           0 : }
     394             : 
     395             : KOKKOS_INLINE_FUNCTION Real
     396     2048692 : Real33::determinant(const unsigned int dim) const
     397             : {
     398     2048692 :   Real det = 0;
     399             : 
     400     2048692 :   if (dim == 0)
     401        1016 :     det = 1;
     402     2047676 :   else if (dim == 1)
     403      371178 :     det = a[0][0];
     404     1676498 :   else if (dim == 2)
     405     1644482 :     det = a[0][0] * a[1][1] - a[0][1] * a[1][0];
     406       32016 :   else if (dim == 3)
     407       32016 :     det = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
     408       32016 :           a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
     409       32016 :           a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
     410             : 
     411     2048692 :   return det;
     412             : }
     413             : 
     414             : KOKKOS_INLINE_FUNCTION Real33
     415     1024346 : Real33::inverse(const unsigned int dim) const
     416             : {
     417     1024346 :   Real inv_det = 1.0 / determinant(dim);
     418     1024346 :   Real33 inv_mat;
     419             : 
     420     1024346 :   if (dim == 1)
     421             :   {
     422        8863 :     inv_mat(0, 0) = inv_det;
     423             :   }
     424     1015483 :   else if (dim == 2)
     425             :   {
     426      998251 :     inv_mat(0, 0) = a[1][1] * inv_det;
     427      998251 :     inv_mat(0, 1) = -a[0][1] * inv_det;
     428      998251 :     inv_mat(1, 0) = -a[1][0] * inv_det;
     429      998251 :     inv_mat(1, 1) = a[0][0] * inv_det;
     430             :   }
     431       17232 :   else if (dim == 3)
     432             :   {
     433       17232 :     inv_mat(0, 0) = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) * inv_det;
     434       17232 :     inv_mat(0, 1) = (a[0][2] * a[2][1] - a[0][1] * a[2][2]) * inv_det;
     435       17232 :     inv_mat(0, 2) = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) * inv_det;
     436       17232 :     inv_mat(1, 0) = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) * inv_det;
     437       17232 :     inv_mat(1, 1) = (a[0][0] * a[2][2] - a[0][2] * a[2][0]) * inv_det;
     438       17232 :     inv_mat(1, 2) = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) * inv_det;
     439       17232 :     inv_mat(2, 0) = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) * inv_det;
     440       17232 :     inv_mat(2, 1) = (a[0][1] * a[2][0] - a[0][0] * a[2][1]) * inv_det;
     441       17232 :     inv_mat(2, 2) = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) * inv_det;
     442             :   }
     443             : 
     444     1024346 :   return inv_mat;
     445             : }
     446             : 
     447             : KOKKOS_INLINE_FUNCTION Real33
     448    12537577 : Real33::transpose() const
     449             : {
     450    12537577 :   Real33 tr_mat;
     451             : 
     452    50150308 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     453   150450924 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     454   112838193 :       tr_mat(i, j) = a[j][i];
     455             : 
     456    12537577 :   return tr_mat;
     457             : }
     458             : 
     459             : KOKKOS_INLINE_FUNCTION Real3
     460      359364 : Real33::row(const unsigned int i) const
     461             : {
     462      359364 :   return Real3(a[i][0], a[i][1], a[i][2]);
     463             : }
     464             : 
     465             : KOKKOS_INLINE_FUNCTION Real3
     466             : Real33::col(const unsigned int j) const
     467             : {
     468             :   return Real3(a[0][j], a[1][j], a[2][j]);
     469             : }
     470             : 
     471             : KOKKOS_INLINE_FUNCTION Real3
     472   166271234 : operator*(const Real33 left, const Real3 right)
     473             : {
     474   166271234 :   return {left(0, 0) * right.v[0] + left(0, 1) * right.v[1] + left(0, 2) * right.v[2],
     475   166271234 :           left(1, 0) * right.v[0] + left(1, 1) * right.v[1] + left(1, 2) * right.v[2],
     476   166271234 :           left(2, 0) * right.v[0] + left(2, 1) * right.v[1] + left(2, 2) * right.v[2]};
     477             : }
     478             : 
     479             : KOKKOS_INLINE_FUNCTION ADReal3
     480     2092784 : operator*(const Real33 left, const ADReal3 & right)
     481             : {
     482     4185568 :   return {left(0, 0) * right(0) + left(0, 1) * right(1) + left(0, 2) * right(2),
     483     4185568 :           left(1, 0) * right(0) + left(1, 1) * right(1) + left(1, 2) * right(2),
     484     4185568 :           left(2, 0) * right(0) + left(2, 1) * right(1) + left(2, 2) * right(2)};
     485             : }
     486             : 
     487             : KOKKOS_INLINE_FUNCTION ADReal3
     488             : operator*(const ADReal3 & left, const Real33 right)
     489             : {
     490             :   return {left(0) * right(0, 0) + left(1) * right(1, 0) + left(2) * right(2, 0),
     491             :           left(0) * right(0, 1) + left(1) * right(1, 1) + left(2) * right(2, 1),
     492             :           left(0) * right(0, 2) + left(1) * right(1, 2) + left(2) * right(2, 2)};
     493             : }
     494             : 
     495             : KOKKOS_INLINE_FUNCTION Real33
     496    15368682 : operator*(const Real33 left, const Real33 right)
     497             : {
     498    15368682 :   Real33 mul;
     499             : 
     500    61474728 :   for (unsigned int i = 0; i < Moose::dim; ++i)
     501   184424184 :     for (unsigned int j = 0; j < Moose::dim; ++j)
     502   553272552 :       for (unsigned int k = 0; k < Moose::dim; ++k)
     503   414954414 :         mul(i, j) += left(i, k) * right(k, j);
     504             : 
     505    15368682 :   return mul;
     506             : }
     507             : 
     508             : KOKKOS_INLINE_FUNCTION Real33
     509    31200433 : operator*(const Real left, Real33 right)
     510             : {
     511    31200433 :   right *= left;
     512             : 
     513    31200433 :   return right;
     514             : }
     515             : 
     516             : KOKKOS_INLINE_FUNCTION Real33
     517             : operator*(Real33 left, const Real right)
     518             : {
     519             :   left *= right;
     520             : 
     521             :   return left;
     522             : }
     523             : 
     524             : KOKKOS_INLINE_FUNCTION Real3
     525             : operator+(const Real left, const Real3 right)
     526             : {
     527             :   return {left + right.v[0], left + right.v[1], left + right.v[2]};
     528             : }
     529             : 
     530             : KOKKOS_INLINE_FUNCTION Real3
     531             : operator+(const Real3 left, const Real right)
     532             : {
     533             :   return {left.v[0] + right, left.v[1] + right, left.v[2] + right};
     534             : }
     535             : 
     536             : KOKKOS_INLINE_FUNCTION Real3
     537             : operator-(const Real left, const Real3 right)
     538             : {
     539             :   return {left - right.v[0], left - right.v[1], left - right.v[2]};
     540             : }
     541             : 
     542             : KOKKOS_INLINE_FUNCTION Real3
     543             : operator-(const Real3 left, const Real right)
     544             : {
     545             :   return {left.v[0] - right, left.v[1] - right, left.v[2] - right};
     546             : }
     547             : 
     548             : KOKKOS_INLINE_FUNCTION Real3
     549   392447881 : operator*(const Real left, const Real3 right)
     550             : {
     551   392447881 :   return {left * right.v[0], left * right.v[1], left * right.v[2]};
     552             : }
     553             : 
     554             : KOKKOS_INLINE_FUNCTION Real3
     555      786688 : operator*(const Real3 left, const Real right)
     556             : {
     557      786688 :   return {left.v[0] * right, left.v[1] * right, left.v[2] * right};
     558             : }
     559             : 
     560             : template <typename T,
     561             :           typename = typename std::enable_if<
     562             :               std::is_same<typename std::decay<T>::type, ADReal>::value>::type>
     563             : KOKKOS_INLINE_FUNCTION ADReal3
     564             : operator*(const Real3 left, const T & right)
     565             : {
     566             :   return {left(0) * right, left(1) * right, left(2) * right};
     567             : }
     568             : 
     569             : template <typename T,
     570             :           typename = typename std::enable_if<
     571             :               std::is_same<typename std::decay<T>::type, ADReal>::value>::type>
     572             : KOKKOS_INLINE_FUNCTION ADReal3
     573     8248896 : operator*(const T & left, const Real3 right)
     574             : {
     575     8248896 :   return {left * right(0), left * right(1), left * right(2)};
     576             : }
     577             : 
     578             : KOKKOS_INLINE_FUNCTION ADReal
     579             : operator*(const Real3 left, const ADReal3 & right)
     580             : {
     581             :   return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
     582             : }
     583             : 
     584             : KOKKOS_INLINE_FUNCTION ADReal
     585     2368704 : operator*(const ADReal3 & left, const Real3 right)
     586             : {
     587     2368704 :   return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
     588             : }
     589             : 
     590             : KOKKOS_INLINE_FUNCTION Real3
     591     7973861 : curlFromVectorGradient(const Real33 grad, const unsigned int dim)
     592             : {
     593     7973861 :   if (dim < 2)
     594        1782 :     return 0;
     595     7972079 :   else if (dim == 2)
     596     7972079 :     return Real3(0, 0, grad(1, 0) - grad(0, 1));
     597             :   else
     598           0 :     return Real3(grad(2, 1) - grad(1, 2), grad(0, 2) - grad(2, 0), grad(1, 0) - grad(0, 1));
     599             : }
     600             : 
     601             : #endif
     602             : 
     603             : template <typename T1, typename T2>
     604             : struct Pair
     605             : {
     606             :   T1 first;
     607             :   T2 second;
     608             : 
     609             :   template <typename T3, typename T4>
     610           0 :   auto & operator=(const std::pair<T3, T4> pair)
     611             :   {
     612           0 :     first = pair.first;
     613           0 :     second = pair.second;
     614             : 
     615           0 :     return *this;
     616             :   }
     617             : };
     618             : 
     619             : template <typename T1, typename T2>
     620             : bool
     621     2621224 : operator<(const Pair<T1, T2> & left, const Pair<T1, T2> & right)
     622             : {
     623     2621224 :   return std::make_pair(left.first, left.second) < std::make_pair(right.first, right.second);
     624             : }
     625             : 
     626             : } // namespace Moose::Kokkos

Generated by: LCOV version 1.14