Intrepid2
Intrepid2_ProjectionStruct.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
47#ifndef __INTREPID2_PROJECTIONSTRUCT_HPP__
48#define __INTREPID2_PROJECTIONSTRUCT_HPP__
49
50#include "Intrepid2_ConfigDefs.hpp"
51#include "Intrepid2_Types.hpp"
52
53#include <array>
54
55namespace Intrepid2 {
56
57namespace Experimental {
58
80ordinal_type
81KOKKOS_INLINE_FUNCTION
82range_size(const Kokkos::pair<ordinal_type, ordinal_type>& range) {
83 return range.second - range.first;
84}
85
86template<typename DeviceType, typename ValueType>
88public:
89
90 enum EvalPointsType {BASIS, TARGET};
91
92 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
93 typedef typename Kokkos::Impl::is_space<DeviceType>::host_mirror_space::execution_space HostSpaceType;
94 typedef Kokkos::DynRankView<ValueType,HostSpaceType> view_type;
95 typedef Kokkos::View<range_type**,HostSpaceType> range_tag;
96 static constexpr int numberSubCellDims = 4; //{0 for vertex, 1 for edges, 2 for faces, 3 for volumes}
97 //max of numVertices, numEdges, numFaces for a reference cell.
98 //12 is the number of edges in a Hexahderon.
99 //We'll need to change this if we consider generic polyhedra
100 static constexpr int maxSubCellsCount = 12;
101 typedef std::array<std::array<view_type, maxSubCellsCount>, numberSubCellDims> view_tag;
102 typedef Kokkos::View<unsigned**,HostSpaceType> key_tag;
103
106 ordinal_type getNumBasisEvalPoints() {
107 return numBasisEvalPoints;
108 }
109
113 return numBasisDerivEvalPoints;
114 }
115
118 ordinal_type getNumTargetEvalPoints() {
119 return numTargetEvalPoints;
120 }
121
125 return numTargetDerivEvalPoints;
126 }
127
134 ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const {
135 if(type == BASIS)
136 return maxNumBasisDerivEvalPoints;
137 else
138 return maxNumTargetDerivEvalPoints;
139 }
140
147 ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const {
148 if(type == BASIS)
149 return maxNumBasisEvalPoints;
150 else
151 return maxNumTargetEvalPoints;
152 }
153
166 view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
167 return basisCubPoints[subCellDim][subCellId];
168 }
169
170
183 view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
184 return basisDerivCubPoints[subCellDim][subCellId];
185 }
186
187
200 view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
201 return targetCubPoints[subCellDim][subCellId];
202 }
203
204
217 view_type getTargetDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
218 return targetDerivCubPoints[subCellDim][subCellId];
219 }
220
221
236 view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
237 if(type == BASIS)
238 return basisCubPoints[subCellDim][subCellId];
239 else
240 return targetCubPoints[subCellDim][subCellId];
241 }
242
257 view_type getDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
258 if(type == BASIS)
259 return basisDerivCubPoints[subCellDim][subCellId];
260 else
261 return targetDerivCubPoints[subCellDim][subCellId];
262 }
263
264
265
277 view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
278 return basisCubWeights[subCellDim][subCellId];
279 }
280
281
293 view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
294 return basisDerivCubWeights[subCellDim][subCellId];
295 }
296
297
309 view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
310 return targetCubWeights[subCellDim][subCellId];
311 }
312
313
325 view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
326 return targetDerivCubWeights[subCellDim][subCellId];
327 }
328
329
334 const range_tag getBasisPointsRange() const {
335 return basisPointsRange;
336 }
337
338
344 const range_tag getPointsRange(const EvalPointsType type) const {
345 if(type == BASIS)
346 return basisPointsRange;
347 else
348 return targetPointsRange;
349 }
350
351
356 const range_tag getBasisDerivPointsRange() const {
357 return basisDerivPointsRange;
358 }
359
366 const range_tag getDerivPointsRange(const EvalPointsType type) const {
367 if(type == BASIS)
368 return basisDerivPointsRange;
369 else
370 return targetDerivPointsRange;
371 }
372
373
378 const range_tag getTargetPointsRange() const {
379 return targetPointsRange;
380 }
381
382
387 const range_tag getTargetDerivPointsRange() const {
388 return targetDerivPointsRange;
389 }
390
395 const key_tag getTopologyKey() const {
396 return subCellTopologyKey;
397 }
398
399
400
401
406 template<typename BasisPtrType>
407 void createL2ProjectionStruct(const BasisPtrType cellBasis,
408 const ordinal_type targetCubDegree);
409
410
415 template<typename BasisPtrType>
416 void createL2DGProjectionStruct(const BasisPtrType cellBasis,
417 const ordinal_type targetCubDegree) {
418 createHVolProjectionStruct(cellBasis, targetCubDegree);
419 }
420
421
427 template<typename BasisPtrType>
428 void createHGradProjectionStruct(const BasisPtrType cellBasis,
429 const ordinal_type targetCubDegree,
430 const ordinal_type targetGradCubDegre);
431
432
438 template<typename BasisPtrType>
439 void createHCurlProjectionStruct(const BasisPtrType cellBasis,
440 const ordinal_type targetCubDegree,
441 const ordinal_type targetCurlCubDegre);
442
443
449 template<typename BasisPtrType>
450 void createHDivProjectionStruct(const BasisPtrType cellBasis,
451 const ordinal_type targetCubDegree,
452 const ordinal_type targetDivCubDegre);
453
458 template<typename BasisPtrType>
459 void createHVolProjectionStruct(const BasisPtrType cellBasis,
460 const ordinal_type targetCubDegree);
461
462 key_tag subCellTopologyKey;
463 range_tag basisPointsRange;
464 range_tag basisDerivPointsRange;
465 range_tag targetPointsRange;
466 range_tag targetDerivPointsRange;
467 view_tag basisCubPoints;
468 view_tag basisCubWeights;
469 view_tag basisDerivCubPoints;
470 view_tag basisDerivCubWeights;
471 view_tag targetCubPoints;
472 view_tag targetCubWeights;
473 view_tag targetDerivCubPoints;
474 view_tag targetDerivCubWeights;
475 ordinal_type numBasisEvalPoints;
476 ordinal_type numBasisDerivEvalPoints;
477 ordinal_type numTargetEvalPoints;
478 ordinal_type numTargetDerivEvalPoints;
479 ordinal_type maxNumBasisEvalPoints;
480 ordinal_type maxNumTargetEvalPoints;
481 ordinal_type maxNumBasisDerivEvalPoints;
482 ordinal_type maxNumTargetDerivEvalPoints;
483};
484
485}
486}
488#endif
489
490
491
492
493
Header file for the Intrepid2::Experimental::ProjectionStruct containing definitions.
Contains definitions of custom data types in Intrepid2.
An helper class to compute the evaluation points and weights needed for performing projections.
ordinal_type getNumBasisEvalPoints()
Returns number of basis evaluation points.
ordinal_type getNumTargetEvalPoints()
Returns number of points where to evaluate the target function.
view_type getDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const
Returns the evaluation points for basis/target derivatives on a subcell.
void createHCurlProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetCurlCubDegre)
Initialize the ProjectionStruct for HCURL projections.
const range_tag getDerivPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target derivative evaluation points on subcells.
ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const
Returns the maximum number of derivative evaluation points across all the subcells.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
const range_tag getBasisDerivPointsRange() const
Returns the range tag of the derivative evaluation points on subcell.
view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the evaluation points for basis derivatives on a subcell.
const range_tag getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
void createHDivProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetDivCubDegre)
Initialize the ProjectionStruct for HDIV projections.
view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation points on a subcell.
ordinal_type getNumTargetDerivEvalPoints()
Returns number of points where to evaluate the derivatives of the target function.
void createL2ProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for L2 projections.
view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const
Returns the basis/target evaluation points on a subcell.
const key_tag getTopologyKey() const
Returns the key tag for subcells.
view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function derivatives evaluation weights on a subcell.
view_type getTargetDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the points where to evaluate the derivatives of the target function on a subcell.
view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation weights on a subcell.
const range_tag getTargetDerivPointsRange() const
Returns the range tag of the target function derivative evaluation points on subcells.
ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const
Returns the maximum number of evaluation points across all the subcells.
void createL2DGProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for (discontinuous local-L2) projection.
void createHVolProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for HVOL (local-L2) projection.
ordinal_type getNumBasisDerivEvalPoints()
Returns number of evaluation points for basis derivatives.
view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function evaluation weights on a subcell.
void createHGradProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetGradCubDegre)
Initialize the ProjectionStruct for HGRAD projections.
view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis derivatives evaluation weights on a subcell.
view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the points where to evaluate the target function on a subcell.
const range_tag getPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target evaluation points in subcells.