Intrepid2
Intrepid2_RealSpaceTools.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_REALSPACETOOLS_HPP__
50 #define __INTREPID2_REALSPACETOOLS_HPP__
51 
52 #include "Intrepid2_ConfigDefs.hpp"
53 
54 #include "Intrepid2_Types.hpp"
55 #include "Intrepid2_Utils.hpp"
56 
57 #include "Kokkos_Core.hpp"
58 
59 namespace Intrepid2 {
60 
78  template<typename DeviceType = void>
80  public:
81 
82  struct Serial {
92  template<typename inVecValueType, class ...inVecProperties>
93  KOKKOS_INLINE_FUNCTION
94  static inVecValueType
95  vectorNorm( const Kokkos::DynRankView<inVecValueType,inVecProperties...> inVec,
96  const ENorm normType );
97 
107  template<class MatrixViewType>
108  KOKKOS_INLINE_FUNCTION
109  static typename MatrixViewType::value_type
110  det( const MatrixViewType inMat );
111 
122  template<typename inVec1ValueType, class ...inVec1Properties,
123  typename inVec2ValueType, class ...inVec2Properties>
124  KOKKOS_INLINE_FUNCTION
125  static inVec1ValueType
126  dot( const Kokkos::DynRankView<inVec1ValueType,inVec1Properties...> inVec1,
127  const Kokkos::DynRankView<inVec2ValueType,inVec2Properties...> inVec2 );
128 
129  };
130 
137  template<typename outputValueType, class ...outputProperties,
138  typename inputValueType, class ...inputProperties>
139  static void
140  extractScalarValues( Kokkos::DynRankView<outputValueType,outputProperties...> output,
141  const Kokkos::DynRankView<inputValueType, inputProperties...> input );
142 
153  template<typename outputValueType, class ...outputProperties,
154  typename inputValueType, class ...inputProperties>
155  static void
156  clone( Kokkos::DynRankView<outputValueType,outputProperties...> output,
157  const Kokkos::DynRankView<inputValueType,inputProperties...> input );
158 
168  template<typename absArrayValueType, class ...absArrayProperties,
169  typename inArrayValueType, class ...inArrayProperties>
170  static void
171  absval( Kokkos::DynRankView<absArrayValueType,absArrayProperties...> absArray,
172  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
173 
174 
179  template<typename inoutArrayValueType, class ...inoutArrayProperties>
180  static void
181  absval( Kokkos::DynRankView<inoutArrayValueType,inoutArrayProperties...> inoutArray );
182 
183 
197  template<typename normArrayValueType, class ...normArrayProperties,
198  typename inVecValueType, class ...inVecProperties>
199  static void
200  vectorNorm( Kokkos::DynRankView<normArrayValueType,normArrayProperties...> normArray,
201  const Kokkos::DynRankView<inVecValueType, inVecProperties...> inVecs,
202  const ENorm normType );
203 
218  template<typename transposeMatValueType, class ...transposeMatProperties,
219  typename inMatValueType, class ...inMatProperties>
220  static void
221  transpose( Kokkos::DynRankView<transposeMatValueType,transposeMatProperties...> transposeMats,
222  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats );
223 
239  template<class InverseMatrixViewType, class MatrixViewType>
240  static void
241  inverse( InverseMatrixViewType inverseMats, MatrixViewType inMats );
242 
257  template<class DeterminantArrayViewType, class MatrixViewType>
258  static void
259  det( DeterminantArrayViewType detArray, const MatrixViewType inMats );
260 
272  template<typename sumArrayValueType, class ...sumArrayProperties,
273  typename inArray1ValueType, class ...inArray1Properties,
274  typename inArray2ValueType, class ...inArray2Properties>
275  static void
276  add( Kokkos::DynRankView<sumArrayValueType,sumArrayProperties...> sumArray,
277  const Kokkos::DynRankView<inArray1ValueType,inArray1Properties...> inArray1,
278  const Kokkos::DynRankView<inArray2ValueType,inArray2Properties...> inArray2 );
279 
290  template<typename inoutSumArrayValueType, class ...inoutSumArrayProperties,
291  typename inArrayValueType, class ...inArrayProperties>
292  static void
293  add( Kokkos::DynRankView<inoutSumArrayValueType,inoutSumArrayProperties...> inoutSumArray,
294  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
295 
307  template<typename diffArrayValueType, class ...diffArrayProperties,
308  typename inArray1ValueType, class ...inArray1Properties,
309  typename inArray2ValueType, class ...inArray2Properties>
310  static void
311  subtract( Kokkos::DynRankView<diffArrayValueType,diffArrayProperties...> diffArray,
312  const Kokkos::DynRankView<inArray1ValueType, inArray1Properties...> inArray1,
313  const Kokkos::DynRankView<inArray2ValueType, inArray2Properties...> inArray2 );
314 
325  template<typename inoutDiffArrayValueType, class ...inoutDiffArrayProperties,
326  typename inArrayValueType, class ...inArrayProperties>
327  static void
328  subtract( Kokkos::DynRankView<inoutDiffArrayValueType,inoutDiffArrayProperties...> diffArray,
329  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
330 
342  template<typename ValueType,
343  typename scaledArrayValueType, class ...scaledArrayProperties,
344  typename inArrayValueType, class ...inArrayProperties>
345  static void
346  scale( Kokkos::DynRankView<scaledArrayValueType,scaledArrayProperties...> scaledArray,
347  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray,
348  const ValueType alpha );
349 
356  template<typename ValueType,
357  typename inoutScaledArrayValueType, class ...inoutScaledArrayProperties>
358  static void
359  scale( Kokkos::DynRankView<inoutScaledArrayValueType,inoutScaledArrayProperties...> inoutScaledArray,
360  const ValueType alpha );
361 
362 
376  template<typename dotArrayValueType, class ...dotArrayProperties,
377  typename inVec1ValueType, class ...inVec1Properties,
378  typename inVec2ValueType, class ...inVec2Properties>
379  static void
380  dot( Kokkos::DynRankView<dotArrayValueType,dotArrayProperties...> dotArray,
381  const Kokkos::DynRankView<inVec1ValueType, inVec1Properties...> inVecs1,
382  const Kokkos::DynRankView<inVec2ValueType, inVec2Properties...> inVecs2 );
383 
402  template<typename matVecValueType, class ...matVecProperties,
403  typename inMatValueType, class ...inMatProperties,
404  typename inVecValueType, class ...inVecProperties>
405  static void
406  matvec( Kokkos::DynRankView<matVecValueType,matVecProperties...> matVecs,
407  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats,
408  const Kokkos::DynRankView<inVecValueType, inVecProperties...> inVecs );
409 
423  template<typename vecProdValueType, class ...vecProdProperties,
424  typename inLeftValueType, class ...inLeftProperties,
425  typename inRightValueType, class ...inRightProperties>
426  static void
427  vecprod( Kokkos::DynRankView<vecProdValueType,vecProdProperties...> vecProd,
428  const Kokkos::DynRankView<inLeftValueType, inLeftProperties...> inLeft,
429  const Kokkos::DynRankView<inRightValueType,inRightProperties...> inRight );
430 
431  }; // class RealSpaceTools
432 
433 } // end namespace Intrepid2
434 
435 // include templated definitions
437 
438 #endif
Definition file for utility classes providing basic linear algebra functionality.
Contains definitions of custom data types in Intrepid2.
Header function for Intrepid2::Util class and other utility functions.
Implementation of basic linear algebra functionality in Euclidean space.
static void extractScalarValues(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input)
Extract scalar type values from Sacado-based array.
static void add(Kokkos::DynRankView< sumArrayValueType, sumArrayProperties... > sumArray, const Kokkos::DynRankView< inArray1ValueType, inArray1Properties... > inArray1, const Kokkos::DynRankView< inArray2ValueType, inArray2Properties... > inArray2)
Adds arrays inArray1 and inArray2: sumArray = inArray1 + inArray2.
static void vectorNorm(Kokkos::DynRankView< normArrayValueType, normArrayProperties... > normArray, const Kokkos::DynRankView< inVecValueType, inVecProperties... > inVecs, const ENorm normType)
Computes norms (1, 2, infinity) of vectors stored in a array of total rank 2 (array of vectors),...
static void inverse(InverseMatrixViewType inverseMats, MatrixViewType inMats)
Computes inverses of nonsingular matrices stored in an array of total rank 2 (single matrix),...
static void matvec(Kokkos::DynRankView< matVecValueType, matVecProperties... > matVecs, const Kokkos::DynRankView< inMatValueType, inMatProperties... > inMats, const Kokkos::DynRankView< inVecValueType, inVecProperties... > inVecs)
Matrix-vector left multiply using multidimensional arrays: matVec = inMat * inVec.
static void absval(Kokkos::DynRankView< absArrayValueType, absArrayProperties... > absArray, const Kokkos::DynRankView< inArrayValueType, inArrayProperties... > inArray)
Computes absolute value of an array.
static void vecprod(Kokkos::DynRankView< vecProdValueType, vecProdProperties... > vecProd, const Kokkos::DynRankView< inLeftValueType, inLeftProperties... > inLeft, const Kokkos::DynRankView< inRightValueType, inRightProperties... > inRight)
Vector product using multidimensional arrays: vecProd = inVecLeft x inVecRight
static void subtract(Kokkos::DynRankView< diffArrayValueType, diffArrayProperties... > diffArray, const Kokkos::DynRankView< inArray1ValueType, inArray1Properties... > inArray1, const Kokkos::DynRankView< inArray2ValueType, inArray2Properties... > inArray2)
Subtracts inArray2 from inArray1: diffArray = inArray1 - inArray2.
static void scale(Kokkos::DynRankView< scaledArrayValueType, scaledArrayProperties... > scaledArray, const Kokkos::DynRankView< inArrayValueType, inArrayProperties... > inArray, const ValueType alpha)
Multiplies array inArray by the scalar scalar (componentwise): scaledArray = scalar * inArray.
static void dot(Kokkos::DynRankView< dotArrayValueType, dotArrayProperties... > dotArray, const Kokkos::DynRankView< inVec1ValueType, inVec1Properties... > inVecs1, const Kokkos::DynRankView< inVec2ValueType, inVec2Properties... > inVecs2)
Computes dot product of vectors stored in an array of total rank 2 (array of vectors),...
static void det(DeterminantArrayViewType detArray, const MatrixViewType inMats)
Computes determinants of matrices stored in an array of total rank 3 (array of matrices),...
static void absval(Kokkos::DynRankView< inoutArrayValueType, inoutArrayProperties... > inoutArray)
Computes, in place, absolute value of an array.
static void transpose(Kokkos::DynRankView< transposeMatValueType, transposeMatProperties... > transposeMats, const Kokkos::DynRankView< inMatValueType, inMatProperties... > inMats)
Computes transposes of square matrices stored in an array of total rank 2 (single matrix),...
static void clone(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input)
Clone input array.
static KOKKOS_INLINE_FUNCTION MatrixViewType::value_type det(const MatrixViewType inMat)
Computes determinant of a single square matrix stored in an array of rank 2.
static KOKKOS_INLINE_FUNCTION inVecValueType vectorNorm(const Kokkos::DynRankView< inVecValueType, inVecProperties... > inVec, const ENorm normType)
Computes norm (1, 2, infinity) of a single vector stored in an array of rank 1.
static KOKKOS_INLINE_FUNCTION inVec1ValueType dot(const Kokkos::DynRankView< inVec1ValueType, inVec1Properties... > inVec1, const Kokkos::DynRankView< inVec2ValueType, inVec2Properties... > inVec2)
Computes dot product of two vectors stored in arrays of rank 1.