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;
94 typedef Kokkos::DefaultHostExecutionSpace HostExecutionSpaceType;
95 typedef Kokkos::HostSpace HostMemorySpaceType;
96 typedef Kokkos::Device<HostExecutionSpaceType,HostMemorySpaceType> HostDeviceType;
97 typedef Kokkos::DynRankView<ValueType,HostDeviceType > view_type;
98 typedef Kokkos::View<range_type**,HostDeviceType> range_tag;
99 static constexpr int numberSubCellDims = 4; //{0 for vertex, 1 for edges, 2 for faces, 3 for volumes}
100 //max of numVertices, numEdges, numFaces for a reference cell.
101 //12 is the number of edges in a Hexahderon.
102 //We'll need to change this if we consider generic polyhedra
103 static constexpr int maxSubCellsCount = 12;
104 typedef std::array<std::array<view_type, maxSubCellsCount>, numberSubCellDims> view_tag;
105 typedef Kokkos::View<unsigned**,HostDeviceType > key_tag;
106
109 ordinal_type getNumBasisEvalPoints() {
110 return numBasisEvalPoints;
111 }
112
116 return numBasisDerivEvalPoints;
117 }
118
121 ordinal_type getNumTargetEvalPoints() {
122 return numTargetEvalPoints;
123 }
124
128 return numTargetDerivEvalPoints;
129 }
130
137 ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const {
138 if(type == BASIS)
139 return maxNumBasisDerivEvalPoints;
140 else
141 return maxNumTargetDerivEvalPoints;
142 }
143
150 ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const {
151 if(type == BASIS)
152 return maxNumBasisEvalPoints;
153 else
154 return maxNumTargetEvalPoints;
155 }
156
169 view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
170 return basisCubPoints[subCellDim][subCellId];
171 }
172
173
186 view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
187 return basisDerivCubPoints[subCellDim][subCellId];
188 }
189
190
203 view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
204 return targetCubPoints[subCellDim][subCellId];
205 }
206
207
220 view_type getTargetDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
221 return targetDerivCubPoints[subCellDim][subCellId];
222 }
223
224
239 view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
240 if(type == BASIS)
241 return basisCubPoints[subCellDim][subCellId];
242 else
243 return targetCubPoints[subCellDim][subCellId];
244 }
245
260 view_type getDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
261 if(type == BASIS)
262 return basisDerivCubPoints[subCellDim][subCellId];
263 else
264 return targetDerivCubPoints[subCellDim][subCellId];
265 }
266
267
268
280 view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
281 return basisCubWeights[subCellDim][subCellId];
282 }
283
284
296 view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
297 return basisDerivCubWeights[subCellDim][subCellId];
298 }
299
300
312 view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
313 return targetCubWeights[subCellDim][subCellId];
314 }
315
316
328 view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
329 return targetDerivCubWeights[subCellDim][subCellId];
330 }
331
332
337 const range_tag getBasisPointsRange() const {
338 return basisPointsRange;
339 }
340
341
347 const range_tag getPointsRange(const EvalPointsType type) const {
348 if(type == BASIS)
349 return basisPointsRange;
350 else
351 return targetPointsRange;
352 }
353
354
359 const range_tag getBasisDerivPointsRange() const {
360 return basisDerivPointsRange;
361 }
362
369 const range_tag getDerivPointsRange(const EvalPointsType type) const {
370 if(type == BASIS)
371 return basisDerivPointsRange;
372 else
373 return targetDerivPointsRange;
374 }
375
376
381 const range_tag getTargetPointsRange() const {
382 return targetPointsRange;
383 }
384
385
390 const range_tag getTargetDerivPointsRange() const {
391 return targetDerivPointsRange;
392 }
393
398 const key_tag getTopologyKey() const {
399 return subCellTopologyKey;
400 }
401
402
403
404
409 template<typename BasisPtrType>
410 void createL2ProjectionStruct(const BasisPtrType cellBasis,
411 const ordinal_type targetCubDegree);
412
413
418 template<typename BasisPtrType>
419 void createL2DGProjectionStruct(const BasisPtrType cellBasis,
420 const ordinal_type targetCubDegree) {
421 createHVolProjectionStruct(cellBasis, targetCubDegree);
422 }
423
424
430 template<typename BasisPtrType>
431 void createHGradProjectionStruct(const BasisPtrType cellBasis,
432 const ordinal_type targetCubDegree,
433 const ordinal_type targetGradCubDegre);
434
435
441 template<typename BasisPtrType>
442 void createHCurlProjectionStruct(const BasisPtrType cellBasis,
443 const ordinal_type targetCubDegree,
444 const ordinal_type targetCurlCubDegre);
445
446
452 template<typename BasisPtrType>
453 void createHDivProjectionStruct(const BasisPtrType cellBasis,
454 const ordinal_type targetCubDegree,
455 const ordinal_type targetDivCubDegre);
456
461 template<typename BasisPtrType>
462 void createHVolProjectionStruct(const BasisPtrType cellBasis,
463 const ordinal_type targetCubDegree);
464
465 key_tag subCellTopologyKey;
466 range_tag basisPointsRange;
467 range_tag basisDerivPointsRange;
468 range_tag targetPointsRange;
469 range_tag targetDerivPointsRange;
470 view_tag basisCubPoints;
471 view_tag basisCubWeights;
472 view_tag basisDerivCubPoints;
473 view_tag basisDerivCubWeights;
474 view_tag targetCubPoints;
475 view_tag targetCubWeights;
476 view_tag targetDerivCubPoints;
477 view_tag targetDerivCubWeights;
478 ordinal_type numBasisEvalPoints;
479 ordinal_type numBasisDerivEvalPoints;
480 ordinal_type numTargetEvalPoints;
481 ordinal_type numTargetDerivEvalPoints;
482 ordinal_type maxNumBasisEvalPoints;
483 ordinal_type maxNumTargetEvalPoints;
484 ordinal_type maxNumBasisDerivEvalPoints;
485 ordinal_type maxNumTargetDerivEvalPoints;
486};
487
488}
489}
491#endif
492
493
494
495
496
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.
Kokkos::DefaultHostExecutionSpace HostExecutionSpaceType
KK : do we really need this complication instead of using default host exec space ?...
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.