Intrepid2
Intrepid2_OrientationTools.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 
48 #ifndef __INTREPID2_ORIENTATIONTOOLS_HPP__
49 #define __INTREPID2_ORIENTATIONTOOLS_HPP__
50 
51 #include "Intrepid2_ConfigDefs.hpp"
52 #include "Intrepid2_Types.hpp"
53 #include "Intrepid2_Utils.hpp"
54 
55 #include "Shards_CellTopology.hpp"
56 #include "Shards_BasicTopologies.hpp"
57 
58 #include "Intrepid2_PointTools.hpp"
59 
60 #include "Intrepid2_Basis.hpp"
61 
62 // -- HGRAD family
66 
69 
70 // -- HCURL family
73 
77 
78 // -- HDIV family
81 
85 
86 // -- Lower order family
89 
92 
96 
100 
101 #include "Teuchos_LAPACK.hpp"
102 
103 
104 namespace Intrepid2 {
105 
106  namespace Impl {
107 
112  public:
113 
114  // -----------------------------------------------------------------------------
115  // Point modification
116  //
117  //
118 
125  template<typename ValueType>
126  KOKKOS_INLINE_FUNCTION
127  static void
128  getModifiedLinePoint(ValueType &ot,
129  const ValueType pt,
130  const ordinal_type ort);
131 
140  template<typename ValueType>
141  KOKKOS_INLINE_FUNCTION
142  static void
143  getModifiedTrianglePoint(ValueType &ot0,
144  ValueType &ot1,
145  const ValueType pt0,
146  const ValueType pt1,
147  const ordinal_type ort);
148 
157  template<typename ValueType>
158  KOKKOS_INLINE_FUNCTION
159  static void
160  getModifiedQuadrilateralPoint(ValueType &ot0,
161  ValueType &ot1,
162  const ValueType pt0,
163  const ValueType pt1,
164  const ordinal_type ort);
165 
173  template<typename outPointViewType,
174  typename refPointViewType>
175  inline
176  static void
177  mapToModifiedReference(outPointViewType outPoints,
178  const refPointViewType refPoints,
179  const shards::CellTopology cellTopo,
180  const ordinal_type cellOrt = 0);
181 
189  template<typename outPointViewType,
190  typename refPointViewType>
191  inline
192  static void
193  mapToModifiedReference(outPointViewType outPoints,
194  const refPointViewType refPoints,
195  const unsigned cellTopoKey,
196  const ordinal_type cellOrt = 0);
197 
198 
204  template<typename JacobianViewType>
205  KOKKOS_INLINE_FUNCTION
206  static void
207  getLineJacobian(JacobianViewType jacobian, const ordinal_type ort);
208 
214  template<typename JacobianViewType>
215  KOKKOS_INLINE_FUNCTION
216  static void
217  getTriangleJacobian(JacobianViewType jacobian, const ordinal_type ort);
218 
224  template<typename JacobianViewType>
225  KOKKOS_INLINE_FUNCTION
226  static void
227  getQuadrilateralJacobian(JacobianViewType jacobian, const ordinal_type ort);
228 
229 
236  template<typename JacobianViewType>
237  inline
238  static void
239  getJacobianOfOrientationMap(JacobianViewType jacobian,
240  const shards::CellTopology cellTopo,
241  const ordinal_type cellOrt);
242 
249  template<typename JacobianViewType>
250  inline
251  static void
252  getJacobianOfOrientationMap(JacobianViewType jacobian,
253  const unsigned cellTopoKey,
254  const ordinal_type cellOrt);
255 
256  // -----------------------------------------------------------------------------
257  // Coefficient Matrix
258  //
259  //
260 
270  template<typename outputViewType,
271  typename subcellBasisType,
272  typename cellBasisType>
273  inline
274  static void
275  getCoeffMatrix_HGRAD(outputViewType &output,
276  const subcellBasisType subcellBasis,
277  const cellBasisType cellBasis,
278  const ordinal_type subcellId,
279  const ordinal_type subcellOrt);
280 
290  template<typename outputViewType,
291  typename subcellBasisType,
292  typename cellBasisType>
293  inline
294  static void
295  getCoeffMatrix_HCURL(outputViewType &output,
296  const subcellBasisType subcellBasis,
297  const cellBasisType cellBasis,
298  const ordinal_type subcellId,
299  const ordinal_type subcellOrt);
300 
310  template<typename outputViewType,
311  typename subcellBasisType,
312  typename cellBasisType>
313  inline
314  static void
315  getCoeffMatrix_HDIV(outputViewType &output,
316  const subcellBasisType subcellBasis,
317  const cellBasisType cellBasis,
318  const ordinal_type subcellId,
319  const ordinal_type subcellOrt);
320  };
321  }
322 
326  template<typename ExecSpaceType>
328  public:
331  typedef Kokkos::View<double****,ExecSpaceType> CoeffMatrixDataViewType;
332 
333  //
336  static std::map<std::pair<std::string,ordinal_type>,CoeffMatrixDataViewType> ortCoeffData;
337 
338  private:
339 
340  template<typename BasisPtrType>
341  inline
342  static CoeffMatrixDataViewType createCoeffMatrixInternal(BasisPtrType basis);
343 
344  //
345  // High order elements transformation matrices for HGRAD
346  //
347 
348  inline
349  static void init_HGRAD_QUAD_Cn_FEM(CoeffMatrixDataViewType matData,
350  const ordinal_type order);
351 
352  inline
353  static void init_HGRAD_HEX_Cn_FEM(CoeffMatrixDataViewType matData,
354  const ordinal_type order);
355 
356  inline
357  static void init_HGRAD_TRI_Cn_FEM(CoeffMatrixDataViewType matData,
358  const ordinal_type order);
359 
360  inline
361  static void init_HGRAD_TET_Cn_FEM(CoeffMatrixDataViewType matData,
362  const ordinal_type order);
363 
364  //
365  // High order elements transformation matrices for HCURL
366  //
367 
368  inline
369  static void init_HCURL_QUAD_In_FEM(CoeffMatrixDataViewType matData,
370  const ordinal_type order);
371 
372  inline
373  static void init_HCURL_HEX_In_FEM(CoeffMatrixDataViewType matData,
374  const ordinal_type order);
375 
376  inline
377  static void init_HCURL_TRI_In_FEM(CoeffMatrixDataViewType matData,
378  const ordinal_type order);
379 
380  inline
381  static void init_HCURL_TET_In_FEM(CoeffMatrixDataViewType matData,
382  const ordinal_type order);
383 
384  //
385  // High order elements transformation matrices for HDIV
386  //
387 
388  inline
389  static void init_HDIV_QUAD_In_FEM(CoeffMatrixDataViewType matData,
390  const ordinal_type order);
391 
392  inline
393  static void init_HDIV_HEX_In_FEM(CoeffMatrixDataViewType matData,
394  const ordinal_type order);
395 
396  inline
397  static void init_HDIV_TRI_In_FEM(CoeffMatrixDataViewType matData,
398  const ordinal_type order);
399 
400  inline
401  static void init_HDIV_TET_In_FEM(CoeffMatrixDataViewType matData,
402  const ordinal_type order);
403 
404  //
405  // I1 element specialization
406  //
407 
408  inline
409  static void init_EDGE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
410  const ordinal_type edgeId);
411 
412  inline
413  static void init_TRI_FACE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
414  const ordinal_type faceId);
415 
416  inline
417  static void init_QUAD_FACE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
418  const ordinal_type faceId);
419 
420  public:
421 
425  template<typename BasisPtrType>
426  inline
427  static CoeffMatrixDataViewType createCoeffMatrix(BasisPtrType basis);
428 
431  inline
432  static void clearCoeffMatrix();
433 
437  template<typename ptViewType>
438  KOKKOS_INLINE_FUNCTION
439  static bool
440  isLeftHandedCell(const ptViewType pts);
441 
447  template<typename elemOrtValueType, class ...elemOrtProperties,
448  typename elemNodeValueType, class ...elemNodeProperties>
449  inline
450  static void
451  getOrientation( Kokkos::DynRankView<elemOrtValueType,elemOrtProperties...> elemOrts,
452  const Kokkos::DynRankView<elemNodeValueType,elemNodeProperties...> elemNodes,
453  const shards::CellTopology cellTopo);
454 
461  template<typename outputValueType, class ...outputProperties,
462  typename inputValueType, class ...inputProperties,
463  typename ortValueType, class ...ortProperties,
464  typename BasisPtrType>
465  inline
466  static void
467  modifyBasisByOrientation( Kokkos::DynRankView<outputValueType,outputProperties...> output,
468  const Kokkos::DynRankView<inputValueType, inputProperties...> input,
469  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
470  const BasisPtrType basis);
471 
472  template<typename ExecutionSpaceType, typename dofCoordsValueType,
473  typename dofCoeffsValueType, typename BasisType>
474  inline
475  static void
476  getSubCellBases(
479  const BasisType& basis,
480  EPointType pointType = POINTTYPE_EQUISPACED);
481 
482  template<typename dofCoordsValueType, class ...dofCoordsProperties,
483  typename dofCoeffsValueType, class ...dofCoeffsProperties,
484  typename ortValueType, class ...ortProperties,
485  typename BasisType>
486  inline
487  static void
488  getModifiedDofs( Kokkos::DynRankView<dofCoordsValueType,dofCoordsProperties...> orientedDofCoords,
489  Kokkos::DynRankView<dofCoeffsValueType,dofCoeffsProperties...> orientedDofCoeffs,
490  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
491  const BasisType& basis,
492  EPointType pointType = POINTTYPE_EQUISPACED);
493 
494  };
495 
496  template<typename T>
497  std::map<std::pair<std::string,ordinal_type>, typename OrientationTools<T>::CoeffMatrixDataViewType>
499 }
500 
501 // include templated function definitions
508 
509 #endif
510 
511 
512 
513 
514 
515  // class CoeffMatrix {
516  // private:
517  // ordinal_type _m, _n;
518 
519  // Kokkos::View<size_type*,ExecSpaceType> _ap; //!< pointers to column index and values
520  // Kokkos::View<ordinal_type*,ExecSpaceType> _aj; //!< column index compressed format
521  // Kokkos::View<double*,ExecSpaceType> _ax; //!< values
522 
523  // inline
524  // void createInternalArrays(const ordinal_type m,
525  // const ordinal_type n,
526  // const size_type nnz) {
527  // _m = m;
528  // _n = n;
529 
530  // _ap = Kokkos::View<size_type*, SpT>("OrientationTools::CoeffMatrix::RowPtrArray", m+1);
531  // _aj = Kokkos::View<ordinal_type*,SpT>("OrientationTools::CoeffMatrix::ColsArray", nnz);
532  // _ax = Kokkos::View<double*, SpT>("OrientationTools::CoeffMAtrix::ValuesArray", nnz);
533  // }
534 
535  // public:
536  // KOKKOS_INLINE_FUNCTION
537  // CoeffMatrix()
538  // : _m(0), _n(0), _ap(), _aj(), _ax() { }
539 
540  // KOKKOS_INLINE_FUNCTION
541  // CoeffMatrix(const CoeffMatrix &b) = default;
542 
543  // KOKKOS_INLINE_FUNCTION
544  // ordinal_type NumRows() const {
545  // return _m;
546  // }
547 
548  // KOKKOS_INLINE_FUNCTION
549  // ordinal_type NumCols() const {
550  // return _n;
551  // }
552 
553  // KOKKOS_INLINE_FUNCTION
554  // size_type RowPtr(const ordinal_type i) const {
555  // return _ap(i);
556  // }
557 
558  // KOKKOS_INLINE_FUNCTION
559  // Kokkos::View<ordinal_type*,ExecSpaceType> ColsInRow(const ordinal_type i) const {
560  // return Kokkos::subview(_aj, Kokkos::pair<ordinal_type,ordinal_type>(_ap(i), _ap(i+1)));
561  // }
562 
563  // KOKKOS_INLINE_FUNCTION
564  // Kokkos::View<double*,ExecSpaceType> ValuesInRow(const ordinal_type i) const {
565  // return Kokkos::subview(_ax, Kokkos::pair<ordinal_type,ordinal_type>(_ap(i), _ap(i+1)));
566  // }
567 
568  // KOKKOS_INLINE_FUNCTION
569  // ordinal_type NumNonZerosInRow(const ordinal_type i) const {
570  // return (_ap(i+1) - _ap(i));
571  // }
572  // };
573 
static KOKKOS_INLINE_FUNCTION void getModifiedLinePoint(ValueType &ot, const ValueType pt, const ordinal_type ort)
Computes modified point for line segment.
Header file for the Intrepid2::Basis_HGRAD_LINE_Cn_FEM class.
Header file for the Intrepid2::Basis_HDIV_TET_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_HEX_In_FEM class.
static KOKKOS_INLINE_FUNCTION void getModifiedQuadrilateralPoint(ValueType &ot0, ValueType &ot1, const ValueType pt0, const ValueType pt1, const ordinal_type ort)
Computes modified point for quadrilateral.
Header file for the Intrepid2::Basis_HDIV_HEX_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_WEDGE_I1_FEM class.
static void getCoeffMatrix_HGRAD(outputViewType &output, const subcellBasisType subcellBasis, const cellBasisType cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt)
Compute coefficient matrix for HGRAD by collocating point values.
Definition file for the Intrepid2::OrientationTools class.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
static std::map< std::pair< std::string, ordinal_type >, CoeffMatrixDataViewType > ortCoeffData
key :: basis name, order, value :: matrix data view type
static void getJacobianOfOrientationMap(JacobianViewType jacobian, const shards::CellTopology cellTopo, const ordinal_type cellOrt)
Computes jacobian of the parameterization maps of 1- and 2-subcells with orientation.
Header file for the Intrepid2::Basis_HDIV_HEX_In_FEM class.
static void getCoeffMatrix_HCURL(outputViewType &output, const subcellBasisType subcellBasis, const cellBasisType cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt)
Compute coefficient matrix for HCURL by collocating point values.
static KOKKOS_INLINE_FUNCTION bool isLeftHandedCell(const ptViewType pts)
Check if left-handed. If an element is alinged left, it is an error.
static void modifyBasisByOrientation(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input, const Kokkos::DynRankView< ortValueType, ortProperties...> orts, const BasisPtrType basis)
Modify basis due to orientation.
Kokkos::View< double ****, ExecSpaceType > CoeffMatrixDataViewType
subcell ordinal, orientation, matrix m x n
Creation of orientation matrix A of a face or edge for HDIV elements.
static void getCoeffMatrix_HDIV(outputViewType &output, const subcellBasisType subcellBasis, const cellBasisType cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt)
Compute coefficient matrix for HDIV by collocating point values.
Header function for Intrepid2::Util class and other utility functions.
static void clearCoeffMatrix()
Clear coefficient matrix.
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM class.
Header file for the Intrepid2::Basis_HVOL_LINE_Cn_FEM class.
Header file for the Intrepid2::Basis_HDIV_QUAD_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_TET_In_FEM class.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM class.
static void getOrientation(Kokkos::DynRankView< elemOrtValueType, elemOrtProperties...> elemOrts, const Kokkos::DynRankView< elemNodeValueType, elemNodeProperties...> elemNodes, const shards::CellTopology cellTopo)
Compute orientations of cells in a workset.
Header file for the Intrepid2::Basis_HDIV_TRI_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_QUAD_In_FEM class.
Header file for the Intrepid2::Basis_HCURL_QUAD_In_FEM class.
static KOKKOS_INLINE_FUNCTION void getModifiedTrianglePoint(ValueType &ot0, ValueType &ot1, const ValueType pt0, const ValueType pt1, const ordinal_type ort)
Computes modified point for triangle.
Creation of orientation matrix A of a face or edge for HCURL elements.
static KOKKOS_INLINE_FUNCTION void getTriangleJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for triangle.
static KOKKOS_INLINE_FUNCTION void getLineJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for line segment.
Header file for the Intrepid2::Basis_HDIV_TRI_In_FEM class.
Contains definitions of custom data types in Intrepid2.
Header file for the Intrepid2::Basis_HGRAD_QUAD_Cn_FEM class.
Creation of orientation matrix A of a face or edge for HGRAD elements.
Header file for the Intrepid2::Basis_HDIV_TET_In_FEM class.
Definition file for functions that modify points due to orientation in the Intrepid2::Impl::Orientati...
Header file for the Intrepid2::Basis_HCURL_QUAD_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_WEDGE_I1_FEM class.
Tools to compute orientations for degrees-of-freedom.
Header file for the Intrepid2::Basis_HCURL_TET_I1_FEM class.
static KOKKOS_INLINE_FUNCTION void getQuadrilateralJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for quadrilateral.
Header file for the Intrepid2::Basis_HCURL_HEX_I1_FEM class.
static void mapToModifiedReference(outPointViewType outPoints, const refPointViewType refPoints, const shards::CellTopology cellTopo, const ordinal_type cellOrt=0)
Computes modified parameterization maps of 1- and 2-subcells with orientation.
Definition file for matrix data in the Intrepid2::OrientationTools class.
Header file for the Intrepid2::Basis_HCURL_TRI_I1_FEM class.
Header file for the Intrepid2::Basis_HVOL_TRI_Cn_FEM class.
static CoeffMatrixDataViewType createCoeffMatrix(BasisPtrType basis)
Create coefficient matrix.
Header file for the abstract base class Intrepid2::Basis.
Header file for the Intrepid2::Basis_HCURL_TRI_In_FEM class.
Header file for Intrepid2::PointTools class to provide utilities for barycentric coordinates, equispaced lattices, and warp-blend point distrubtions.
Tools to compute orientations for degrees-of-freedom.
Header file for the Intrepid2::Basis_HGRAD_HEX_Cn_FEM class.