Intrepid2
Intrepid2_OrientationTools.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
15#ifndef __INTREPID2_ORIENTATIONTOOLS_HPP__
16#define __INTREPID2_ORIENTATIONTOOLS_HPP__
17
18#include "Intrepid2_ConfigDefs.hpp"
19#include "Intrepid2_Types.hpp"
20#include "Intrepid2_Utils.hpp"
21
22#include "Shards_CellTopology.hpp"
23#include "Shards_BasicTopologies.hpp"
24
27
28#include "Intrepid2_Basis.hpp"
29
30// -- HGRAD family
34
37
38// -- HCURL family
41
45
46// -- HDIV family
49
53
54// -- Lower order family
57
60
64
68
71
72#include "Teuchos_LAPACK.hpp"
73
74
75namespace Intrepid2 {
76
77 namespace Impl {
78
83 public:
84
85 // -----------------------------------------------------------------------------
86 // Point modification
87 //
88 //
89
96 template<typename ValueType>
97 KOKKOS_INLINE_FUNCTION
98 static void
99 getModifiedLinePoint(ValueType &ot,
100 const ValueType pt,
101 const ordinal_type ort);
102
111 template<typename ValueType>
112 KOKKOS_INLINE_FUNCTION
113 static void
115 ValueType &ot1,
116 const ValueType pt0,
117 const ValueType pt1,
118 const ordinal_type ort);
119
128 template<typename ValueType>
129 KOKKOS_INLINE_FUNCTION
130 static void
132 ValueType &ot1,
133 const ValueType pt0,
134 const ValueType pt1,
135 const ordinal_type ort);
136
144 template<typename outPointViewType,
145 typename refPointViewType>
146 inline
147 static void
148 mapToModifiedReference(outPointViewType outPoints,
149 const refPointViewType refPoints,
150 const shards::CellTopology cellTopo,
151 const ordinal_type cellOrt = 0);
152
160 template<typename outPointViewType,
161 typename refPointViewType>
162 KOKKOS_INLINE_FUNCTION
163 static void
164 mapToModifiedReference(outPointViewType outPoints,
165 const refPointViewType refPoints,
166 const unsigned cellTopoKey,
167 const ordinal_type cellOrt = 0);
168
169
175 template<typename JacobianViewType>
176 KOKKOS_INLINE_FUNCTION
177 static void
178 getLineJacobian(JacobianViewType jacobian, const ordinal_type ort);
179
185 template<typename JacobianViewType>
186 KOKKOS_INLINE_FUNCTION
187 static void
188 getTriangleJacobian(JacobianViewType jacobian, const ordinal_type ort);
189
195 template<typename JacobianViewType>
196 KOKKOS_INLINE_FUNCTION
197 static void
198 getQuadrilateralJacobian(JacobianViewType jacobian, const ordinal_type ort);
199
200
207 template<typename JacobianViewType>
208 inline
209 static void
210 getJacobianOfOrientationMap(JacobianViewType jacobian,
211 const shards::CellTopology cellTopo,
212 const ordinal_type cellOrt);
213
220 template<typename JacobianViewType>
221 KOKKOS_INLINE_FUNCTION
222 static void
223 getJacobianOfOrientationMap(JacobianViewType jacobian,
224 const unsigned cellTopoKey,
225 const ordinal_type cellOrt);
226
227
235 template<typename TanViewType, typename ParamViewType>
236 KOKKOS_INLINE_FUNCTION
237 static void getRefSubcellTangents(TanViewType tangents,
238 const ParamViewType subCellParametrization,
239 const unsigned subcellTopoKey,
240 const ordinal_type subCellOrd,
241 const ordinal_type ort);
242
243
254 template<typename TanNormViewType, typename ParamViewType>
255 KOKKOS_INLINE_FUNCTION
256 static void getRefSideTangentsAndNormal(TanNormViewType tangentsAndNormal,
257 const ParamViewType subCellParametrization,
258 const unsigned subcellTopoKey,
259 const ordinal_type subCellOrd,
260 const ordinal_type ort);
261
262
272 template<typename coordsViewType, typename subcellCoordsViewType, typename ParamViewType>
273 KOKKOS_INLINE_FUNCTION
274 static void mapSubcellCoordsToRefCell(coordsViewType cellCoords,
275 const subcellCoordsViewType subCellCoords,
276 const ParamViewType subcellParametrization,
277 const unsigned subcellTopoKey,
278 const ordinal_type subCellOrd,
279 const ordinal_type ort);
280
281 // -----------------------------------------------------------------------------
282 // Coefficient Matrix
283 //
284 //
285
297 template<typename OutputViewType,
298 typename subcellBasisHostType,
299 typename cellBasisHostType>
300 inline
301 static void
302 getCoeffMatrix_HGRAD(OutputViewType &output,
303 const subcellBasisHostType& subcellBasis,
304 const cellBasisHostType& cellBasis,
305 const ordinal_type subcellId,
306 const ordinal_type subcellOrt,
307 const bool inverse = false);
308
319 template<typename OutputViewType,
320 typename subcellBasisHostType,
321 typename cellBasisHostType>
322 inline
323 static void
324 getCoeffMatrix_HCURL(OutputViewType &output,
325 const subcellBasisHostType& subcellBasis,
326 const cellBasisHostType& cellBasis,
327 const ordinal_type subcellId,
328 const ordinal_type subcellOrt,
329 const bool inverse = false);
330
331
342 template<typename OutputViewType,
343 typename subcellBasisHostType,
344 typename cellBasisHostType>
345 inline
346 static void
347 getCoeffMatrix_HDIV(OutputViewType &output,
348 const subcellBasisHostType& subcellBasis,
349 const cellBasisHostType& cellBasis,
350 const ordinal_type subcellId,
351 const ordinal_type subcellOrt,
352 const bool inverse = false);
353
354
363 template<typename OutputViewType,
364 typename cellBasisHostType>
365 inline
366 static void
367 getCoeffMatrix_HVOL(OutputViewType &output,
368 const cellBasisHostType& cellBasis,
369 const ordinal_type cellOrt,
370 const bool inverse = false);
371
372 };
373 }
374
378 template<typename DeviceType>
380 public:
381
384 using CoeffMatrixDataViewType = Kokkos::View<double****,DeviceType>;
385
388 using OperatorViewType = Kokkos::View<OrientationOperator<DeviceType>***,DeviceType>;
389
390 //
393 using KeyType = std::pair<const std::string,ordinal_type>;
394 using OrtCoeffDataType = std::map<KeyType,Kokkos::View<double****,DeviceType> >;
395
396 static OrtCoeffDataType ortCoeffData;
397 static OrtCoeffDataType ortInvCoeffData;
398
399 //
402 using OrtOperatorDataType = std::map<std::pair<std::string,ordinal_type>,Kokkos::View<OrientationOperator<DeviceType>***,DeviceType> >;
403
404 static OrtOperatorDataType edgeOperatorData;
405 static OrtOperatorDataType invEdgeOperatorData;
406 static OrtOperatorDataType faceOperatorData;
407 static OrtOperatorDataType invFaceOperatorData;
408
409 using OrtStaticDoubleAllocationType = std::vector< Kokkos::View<double*,DeviceType> >;
410 using OrtStaticOrdinalAllocationType = std::vector< Kokkos::View<ordinal_type*,DeviceType> >;
411
412 static OrtStaticDoubleAllocationType doubleViewAllocations;
413 static OrtStaticOrdinalAllocationType ordinalViewAllocations;
414
415 private:
416
417 template<typename BasisHostType>
418 inline
419 static CoeffMatrixDataViewType createCoeffMatrixInternal(const BasisHostType* basis, const bool invTrans = false);
420
421 template<typename BasisHostType>
422 inline
423 static OperatorViewType createEdgeOperatorsInternal(const BasisHostType* basis, CoeffMatrixDataViewType matData);
424
425 template<typename BasisHostType>
426 inline
427 static OperatorViewType createFaceOperatorsInternal(const BasisHostType* basis, CoeffMatrixDataViewType matData);
428
430 static OrientationOperator<DeviceType> constructOrientationOperatorInternal(const std::vector<ordinal_type> &nonIdentityDofs,
431 const std::vector<ordinal_type> &rowOffsets, // within the column storage
432 const std::vector<ordinal_type> &colIDs,
433 const std::vector<double> &weights,
434 const bool transpose);
435
438 template<typename BasisHostType>
439 inline
441 BasisHostType const *cellBasis,
442 const bool inverse = false);
443
446 template<typename BasisHostType>
447 inline
449 BasisHostType const *cellBasis,
450 const bool inverse = false);
451
454 template<typename BasisHostType>
455 inline
457 BasisHostType const *cellBasis,
458 const bool inverse = false);
459
462 template<typename BasisHostType>
463 inline
465 BasisHostType const *cellBasis,
466 const bool inverse = false);
467
468 public:
469
473 template<typename BasisType>
474 inline
475 static CoeffMatrixDataViewType createCoeffMatrix(const BasisType* basis);
476
480 template<typename BasisType>
481 inline
482 static CoeffMatrixDataViewType createInvCoeffMatrix(const BasisType* basis);
483
486 inline
487 static void clearCoeffMatrix();
488
492 template<typename BasisType>
493 inline
494 static std::tuple<OperatorViewType, OperatorViewType> createOperators(const BasisType* basis);
495
499 template<typename BasisType>
500 inline
501 static std::tuple<OperatorViewType, OperatorViewType> createInvOperators(const BasisType* basis);
502
505 inline
506 static void clearOperators();
507
514 template<typename elemOrtValueType, class ...elemOrtProperties,
515 typename elemNodeValueType, class ...elemNodeProperties>
516 inline
517 static void
518 getOrientation(Kokkos::DynRankView<elemOrtValueType,elemOrtProperties...> elemOrts,
519 const Kokkos::DynRankView<elemNodeValueType,elemNodeProperties...> elemNodes,
520 const shards::CellTopology cellTopo,
521 bool isSide = false);
522
523
531 template<typename outputValueType, class ...outputProperties,
532 typename inputValueType, class ...inputProperties,
533 typename OrientationViewType,
534 typename BasisType>
535 inline
536 static void
537 modifyBasisByOrientation(Kokkos::DynRankView<outputValueType,outputProperties...> output,
538 const Kokkos::DynRankView<inputValueType, inputProperties...> input,
539 const OrientationViewType orts,
540 const BasisType * basis,
541 const bool transpose = false);
542
549 template<typename outputValueType, class ...outputProperties,
550 typename inputValueType, class ...inputProperties,
551 typename OrientationViewType,
552 typename BasisType>
553 inline
554 static void
555 modifyBasisByOrientationTranspose(Kokkos::DynRankView<outputValueType,outputProperties...> output,
556 const Kokkos::DynRankView<inputValueType, inputProperties...> input,
557 const OrientationViewType orts,
558 const BasisType * basis);
559
560
568 template<typename outputValueType, class ...outputProperties,
569 typename inputValueType, class ...inputProperties,
570 typename OrientationViewType,
571 typename BasisType>
572 inline
573 static void
574 modifyBasisByOrientationInverse(Kokkos::DynRankView<outputValueType,outputProperties...> output,
575 const Kokkos::DynRankView<inputValueType, inputProperties...> input,
576 const OrientationViewType orts,
577 const BasisType * basis,
578 const bool transpose = false);
579
580
588 template<typename outputValueType, class ...outputProperties,
589 typename inputValueType, class ...inputProperties,
590 typename OrientationViewType,
591 typename BasisTypeLeft,
592 typename BasisTypeRight>
593 inline
594 static void
595 modifyMatrixByOrientation(Kokkos::DynRankView<outputValueType,outputProperties...> output,
596 const Kokkos::DynRankView<inputValueType, inputProperties...> input,
597 const OrientationViewType orts,
598 const BasisTypeLeft* basisLeft,
599 const BasisTypeRight* basisRight);
600 };
601
602 //Definition of static members
603 template<typename T>
604 typename OrientationTools<T>::OrtCoeffDataType OrientationTools<T>::ortCoeffData;
605
606 template<typename T>
607 typename OrientationTools<T>::OrtCoeffDataType OrientationTools<T>::ortInvCoeffData;
608
609 //Definition of static members
610 template<typename T>
612
613 template<typename T>
615
616 template<typename T>
618
619 template<typename T>
621
622 template<typename T>
623 typename OrientationTools<T>::OrtStaticDoubleAllocationType OrientationTools<T>::doubleViewAllocations;
624
625 template<typename T>
626 typename OrientationTools<T>::OrtStaticOrdinalAllocationType OrientationTools<T>::ordinalViewAllocations;
627
628}
629
630// include templated function definitions
633#include "Intrepid2_OrientationToolsDefCoeffMatrix_HCURL.hpp"
638
639#endif
Header file for the abstract base class Intrepid2::Basis.
Header file for the Intrepid2::Basis_HCURL_HEX_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_HEX_In_FEM class.
Header file for the Intrepid2::Basis_HCURL_QUAD_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_QUAD_In_FEM class.
Header file for the Intrepid2::Basis_HCURL_TET_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_TET_In_FEM class.
Header file for the Intrepid2::Basis_HCURL_TRI_I1_FEM class.
Header file for the Intrepid2::Basis_HCURL_TRI_In_FEM class.
Header file for the Intrepid2::Basis_HCURL_WEDGE_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_HEX_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_HEX_In_FEM class.
Header file for the Intrepid2::Basis_HDIV_QUAD_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_QUAD_In_FEM class.
Header file for the Intrepid2::Basis_HDIV_TET_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_TET_In_FEM class.
Header file for the Intrepid2::Basis_HDIV_TRI_I1_FEM class.
Header file for the Intrepid2::Basis_HDIV_TRI_In_FEM class.
Header file for the Intrepid2::Basis_HDIV_WEDGE_I1_FEM class.
Header file for the Intrepid2::Basis_HGRAD_HEX_Cn_FEM class.
Header file for the Intrepid2::Basis_HGRAD_LINE_Cn_FEM class.
Header file for the Intrepid2::Basis_HGRAD_QUAD_Cn_FEM class.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM class.
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_HVOL_TRI_Cn_FEM class.
Stateless classes that act as factories for two families of hierarchical bases. HierarchicalBasisFami...
Stateless class that acts as a factory for a family of nodal bases (hypercube topologies only at this...
Header file for the Intrepid2::OrientationOperator class.
Creation of orientation matrix A of a face or edge for HDIV elements.
Creation of orientation matrix A of a face or edge for HGRAD elements.
Creation of orientation matrix A of a face or edge for HGRAD elements.
Definition file for matrix data in the Intrepid2::OrientationTools class.
Definition file for the Intrepid2::OrientationTools class.
Definition file for functions that modify points due to orientation in the Intrepid2::Impl::Orientati...
Header file for Intrepid2::PointTools class to provide utilities for barycentric coordinates,...
Contains definitions of custom data types in Intrepid2.
Header function for Intrepid2::Util class and other utility functions.
Tools to compute orientations for degrees-of-freedom.
static void getCoeffMatrix_HGRAD(OutputViewType &output, const subcellBasisHostType &subcellBasis, const cellBasisHostType &cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt, const bool inverse=false)
Compute orientation matrix for HGRAD basis for a given subcell and its reference basis.
static KOKKOS_INLINE_FUNCTION void getJacobianOfOrientationMap(JacobianViewType jacobian, const unsigned cellTopoKey, const ordinal_type cellOrt)
Computes jacobian of the parameterization maps of 1- and 2-subcells with orientation.
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.
static void getCoeffMatrix_HDIV(OutputViewType &output, const subcellBasisHostType &subcellBasis, const cellBasisHostType &cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt, const bool inverse=false)
Compute orientation matrix for HDIV basis for a given subcell and its reference basis.
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.
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.
static KOKKOS_INLINE_FUNCTION void getRefSubcellTangents(TanViewType tangents, const ParamViewType subCellParametrization, const unsigned subcellTopoKey, const ordinal_type subCellOrd, const ordinal_type ort)
Computes the (oriented) subCell tangents.
static KOKKOS_INLINE_FUNCTION void getQuadrilateralJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for quadrilateral.
static KOKKOS_INLINE_FUNCTION void getLineJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for line segment.
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.
static void getCoeffMatrix_HVOL(OutputViewType &output, const cellBasisHostType &cellBasis, const ordinal_type cellOrt, const bool inverse=false)
Compute orientation matrix for HVOL basis for a given (2D or 1D) cell and its reference basis....
static void getCoeffMatrix_HCURL(OutputViewType &output, const subcellBasisHostType &subcellBasis, const cellBasisHostType &cellBasis, const ordinal_type subcellId, const ordinal_type subcellOrt, const bool inverse=false)
Compute orientation matrix for HCURL basis for a given subcell and its reference basis.
static KOKKOS_INLINE_FUNCTION void getRefSideTangentsAndNormal(TanNormViewType tangentsAndNormal, const ParamViewType subCellParametrization, const unsigned subcellTopoKey, const ordinal_type subCellOrd, const ordinal_type ort)
Computes the (oriented) tangents and normal of the side subCell The normals are only defined for side...
static KOKKOS_INLINE_FUNCTION void mapSubcellCoordsToRefCell(coordsViewType cellCoords, const subcellCoordsViewType subCellCoords, const ParamViewType subcellParametrization, const unsigned subcellTopoKey, const ordinal_type subCellOrd, const ordinal_type ort)
Maps points defined on the subCell manifold into the parent Cell accounting for orientation.
static KOKKOS_INLINE_FUNCTION void getModifiedLinePoint(ValueType &ot, const ValueType pt, const ordinal_type ort)
Computes modified point for line segment.
static KOKKOS_INLINE_FUNCTION void getTriangleJacobian(JacobianViewType jacobian, const ordinal_type ort)
Computes Jacobian of orientation map for triangle.
Tools to compute orientations for degrees-of-freedom.
static void init_HVOL(CoeffMatrixDataViewType matData, BasisHostType const *cellBasis, const bool inverse=false)
Compute orientation matrix for HVOL basis.
static CoeffMatrixDataViewType createCoeffMatrix(const BasisType *basis)
Create coefficient matrix.
static void clearOperators()
Clear coefficient matrix.
std::pair< const std::string, ordinal_type > KeyType
key :: basis name, order, value :: matrix data view type
static void modifyBasisByOrientationInverse(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input, const OrientationViewType orts, const BasisType *basis, const bool transpose=false)
Modify basis due to orientation, applying the inverse of the operator applied in modifyBasisByOrienta...
static std::tuple< OperatorViewType, OperatorViewType > createInvOperators(const BasisType *basis)
Create inverse orientation operators.
static OrientationOperator< DeviceType > constructOrientationOperatorInternal(const std::vector< ordinal_type > &nonIdentityDofs, const std::vector< ordinal_type > &rowOffsets, const std::vector< ordinal_type > &colIDs, const std::vector< double > &weights, const bool transpose)
allocates managed static storage in doubleViewAllocations and ordinalViewAllocations; constructs Orie...
static void init_HCURL(CoeffMatrixDataViewType matData, BasisHostType const *cellBasis, const bool inverse=false)
Compute orientation matrix for HCURL basis.
static CoeffMatrixDataViewType createInvCoeffMatrix(const BasisType *basis)
Create inverse of coefficient matrix.
static void clearCoeffMatrix()
Clear coefficient matrix.
static std::tuple< OperatorViewType, OperatorViewType > createOperators(const BasisType *basis)
Create orientation operators.
static void modifyBasisByOrientation(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input, const OrientationViewType orts, const BasisType *basis, const bool transpose=false)
Modify basis due to orientation.
Kokkos::View< double ****, DeviceType > CoeffMatrixDataViewType
subcell ordinal, orientation, matrix m x n
static void init_HDIV(CoeffMatrixDataViewType matData, BasisHostType const *cellBasis, const bool inverse=false)
Compute orientation matrix for HDIV basis.
static void modifyMatrixByOrientation(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input, const OrientationViewType orts, const BasisTypeLeft *basisLeft, const BasisTypeRight *basisRight)
Modify an assembled (C,F1,F2) matrix according to orientation of the cells.
std::map< std::pair< std::string, ordinal_type >, Kokkos::View< OrientationOperator< DeviceType > ***, DeviceType > > OrtOperatorDataType
key :: basis name, order, value :: matrix data view type, transpose (0 for no transpose,...
static void getOrientation(Kokkos::DynRankView< elemOrtValueType, elemOrtProperties... > elemOrts, const Kokkos::DynRankView< elemNodeValueType, elemNodeProperties... > elemNodes, const shards::CellTopology cellTopo, bool isSide=false)
Compute orientations of cells in a workset.
static void init_HGRAD(CoeffMatrixDataViewType matData, BasisHostType const *cellBasis, const bool inverse=false)
Compute orientation matrix for HGRAD basis.
Kokkos::View< OrientationOperator< DeviceType > ***, DeviceType > OperatorViewType
subcell ordinal, orientation, transpose (0 or 1)
static void modifyBasisByOrientationTranspose(Kokkos::DynRankView< outputValueType, outputProperties... > output, const Kokkos::DynRankView< inputValueType, inputProperties... > input, const OrientationViewType orts, const BasisType *basis)
Modify basis due to orientation, applying the transpose of the operator applied in modifyBasisByOrien...