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 
182 
188  template<typename JacobianViewType>
189  KOKKOS_INLINE_FUNCTION
190  static void
191  getLineJacobian(JacobianViewType jacobian, const ordinal_type ort);
192 
198  template<typename JacobianViewType>
199  KOKKOS_INLINE_FUNCTION
200  static void
201  getTriangleJacobian(JacobianViewType jacobian, const ordinal_type ort);
202 
208  template<typename JacobianViewType>
209  KOKKOS_INLINE_FUNCTION
210  static void
211  getQuadrilateralJacobian(JacobianViewType jacobian, const ordinal_type ort);
212 
213 
220  template<typename JacobianViewType>
221  inline
222  static void
223  getJacobianOfOrientationMap(JacobianViewType jacobian,
224  const shards::CellTopology cellTopo,
225  const ordinal_type cellOrt);
226 
227  // -----------------------------------------------------------------------------
228  // Coefficient Matrix
229  //
230  //
231 
241  template<typename outputViewType,
242  typename subcellBasisType,
243  typename cellBasisType>
244  inline
245  static void
246  getCoeffMatrix_HGRAD(outputViewType &output,
247  const subcellBasisType subcellBasis,
248  const cellBasisType cellBasis,
249  const ordinal_type subcellId,
250  const ordinal_type subcellOrt);
251 
261  template<typename outputViewType,
262  typename subcellBasisType,
263  typename cellBasisType>
264  inline
265  static void
266  getCoeffMatrix_HCURL(outputViewType &output,
267  const subcellBasisType subcellBasis,
268  const cellBasisType cellBasis,
269  const ordinal_type subcellId,
270  const ordinal_type subcellOrt);
271 
281  template<typename outputViewType,
282  typename subcellBasisType,
283  typename cellBasisType>
284  inline
285  static void
286  getCoeffMatrix_HDIV(outputViewType &output,
287  const subcellBasisType subcellBasis,
288  const cellBasisType cellBasis,
289  const ordinal_type subcellId,
290  const ordinal_type subcellOrt);
291  };
292  }
293 
297  template<typename ExecSpaceType>
299  public:
302  typedef Kokkos::View<double****,ExecSpaceType> CoeffMatrixDataViewType;
303 
304  //
307  static std::map<std::pair<std::string,ordinal_type>,CoeffMatrixDataViewType> ortCoeffData;
308 
309  private:
310 
311  template<typename BasisPtrType>
312  inline
313  static CoeffMatrixDataViewType createCoeffMatrixInternal(BasisPtrType basis);
314 
315  //
316  // High order elements transformation matrices for HGRAD
317  //
318 
319  inline
320  static void init_HGRAD_QUAD_Cn_FEM(CoeffMatrixDataViewType matData,
321  const ordinal_type order);
322 
323  inline
324  static void init_HGRAD_HEX_Cn_FEM(CoeffMatrixDataViewType matData,
325  const ordinal_type order);
326 
327  inline
328  static void init_HGRAD_TRI_Cn_FEM(CoeffMatrixDataViewType matData,
329  const ordinal_type order);
330 
331  inline
332  static void init_HGRAD_TET_Cn_FEM(CoeffMatrixDataViewType matData,
333  const ordinal_type order);
334 
335  //
336  // High order elements transformation matrices for HCURL
337  //
338 
339  inline
340  static void init_HCURL_QUAD_In_FEM(CoeffMatrixDataViewType matData,
341  const ordinal_type order);
342 
343  inline
344  static void init_HCURL_HEX_In_FEM(CoeffMatrixDataViewType matData,
345  const ordinal_type order);
346 
347  inline
348  static void init_HCURL_TRI_In_FEM(CoeffMatrixDataViewType matData,
349  const ordinal_type order);
350 
351  inline
352  static void init_HCURL_TET_In_FEM(CoeffMatrixDataViewType matData,
353  const ordinal_type order);
354 
355  //
356  // High order elements transformation matrices for HDIV
357  //
358 
359  inline
360  static void init_HDIV_QUAD_In_FEM(CoeffMatrixDataViewType matData,
361  const ordinal_type order);
362 
363  inline
364  static void init_HDIV_HEX_In_FEM(CoeffMatrixDataViewType matData,
365  const ordinal_type order);
366 
367  inline
368  static void init_HDIV_TRI_In_FEM(CoeffMatrixDataViewType matData,
369  const ordinal_type order);
370 
371  inline
372  static void init_HDIV_TET_In_FEM(CoeffMatrixDataViewType matData,
373  const ordinal_type order);
374 
375  //
376  // I1 element specialization
377  //
378 
379  inline
380  static void init_EDGE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
381  const ordinal_type edgeId);
382 
383  inline
384  static void init_TRI_FACE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
385  const ordinal_type faceId);
386 
387  inline
388  static void init_QUAD_FACE_ELEMENT_I1_FEM(CoeffMatrixDataViewType matData,
389  const ordinal_type faceId);
390 
391  public:
392 
396  template<typename BasisPtrType>
397  inline
398  static CoeffMatrixDataViewType createCoeffMatrix(BasisPtrType basis);
399 
402  inline
403  static void clearCoeffMatrix();
404 
408  template<typename ptViewType>
409  KOKKOS_INLINE_FUNCTION
410  static bool
411  isLeftHandedCell(const ptViewType pts);
412 
418  template<typename elemOrtValueType, class ...elemOrtProperties,
419  typename elemNodeValueType, class ...elemNodeProperties>
420  inline
421  static void
422  getOrientation( Kokkos::DynRankView<elemOrtValueType,elemOrtProperties...> elemOrts,
423  const Kokkos::DynRankView<elemNodeValueType,elemNodeProperties...> elemNodes,
424  const shards::CellTopology cellTopo);
425 
432  template<typename outputValueType, class ...outputProperties,
433  typename inputValueType, class ...inputProperties,
434  typename ortValueType, class ...ortProperties,
435  typename BasisPtrType>
436  inline
437  static void
438  modifyBasisByOrientation( Kokkos::DynRankView<outputValueType,outputProperties...> output,
439  const Kokkos::DynRankView<inputValueType, inputProperties...> input,
440  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
441  const BasisPtrType basis);
442  };
443 
444  template<typename T>
445  std::map<std::pair<std::string,ordinal_type>, typename OrientationTools<T>::CoeffMatrixDataViewType>
447 }
448 
449 // include templated function definitions
455 
457 
458 #endif
459 
460 
461 
462 
463 
464  // class CoeffMatrix {
465  // private:
466  // ordinal_type _m, _n;
467 
468  // Kokkos::View<size_type*,ExecSpaceType> _ap; //!< pointers to column index and values
469  // Kokkos::View<ordinal_type*,ExecSpaceType> _aj; //!< column index compressed format
470  // Kokkos::View<double*,ExecSpaceType> _ax; //!< values
471 
472  // inline
473  // void createInternalArrays(const ordinal_type m,
474  // const ordinal_type n,
475  // const size_type nnz) {
476  // _m = m;
477  // _n = n;
478 
479  // _ap = Kokkos::View<size_type*, SpT>("OrientationTools::CoeffMatrix::RowPtrArray", m+1);
480  // _aj = Kokkos::View<ordinal_type*,SpT>("OrientationTools::CoeffMatrix::ColsArray", nnz);
481  // _ax = Kokkos::View<double*, SpT>("OrientationTools::CoeffMAtrix::ValuesArray", nnz);
482  // }
483 
484  // public:
485  // KOKKOS_INLINE_FUNCTION
486  // CoeffMatrix()
487  // : _m(0), _n(0), _ap(), _aj(), _ax() { }
488 
489  // KOKKOS_INLINE_FUNCTION
490  // CoeffMatrix(const CoeffMatrix &b) = default;
491 
492  // KOKKOS_INLINE_FUNCTION
493  // ordinal_type NumRows() const {
494  // return _m;
495  // }
496 
497  // KOKKOS_INLINE_FUNCTION
498  // ordinal_type NumCols() const {
499  // return _n;
500  // }
501 
502  // KOKKOS_INLINE_FUNCTION
503  // size_type RowPtr(const ordinal_type i) const {
504  // return _ap(i);
505  // }
506 
507  // KOKKOS_INLINE_FUNCTION
508  // Kokkos::View<ordinal_type*,ExecSpaceType> ColsInRow(const ordinal_type i) const {
509  // return Kokkos::subview(_aj, Kokkos::pair<ordinal_type,ordinal_type>(_ap(i), _ap(i+1)));
510  // }
511 
512  // KOKKOS_INLINE_FUNCTION
513  // Kokkos::View<double*,ExecSpaceType> ValuesInRow(const ordinal_type i) const {
514  // return Kokkos::subview(_ax, Kokkos::pair<ordinal_type,ordinal_type>(_ap(i), _ap(i+1)));
515  // }
516 
517  // KOKKOS_INLINE_FUNCTION
518  // ordinal_type NumNonZerosInRow(const ordinal_type i) const {
519  // return (_ap(i+1) - _ap(i));
520  // }
521  // };
522 
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.
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.
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 getOrientation(Kokkos::DynRankView< elemOrtValueType, elemOrtProperties... > elemOrts, const Kokkos::DynRankView< elemNodeValueType, elemNodeProperties... > elemNodes, const shards::CellTopology cellTopo)
Compute orientations of cells in a workset.
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 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.
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 CoeffMatrixDataViewType createCoeffMatrix(BasisPtrType basis)
Create coefficient matrix.
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.
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.