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 Mauro Perego (mperego@sandia.gov), or
38// Nate Roberts (nvrober@sandia.gov)
39//
40//
41// ************************************************************************
42// @HEADER
43
48#ifndef __INTREPID2_PROJECTIONSTRUCT_HPP__
49#define __INTREPID2_PROJECTIONSTRUCT_HPP__
50
51#include "Intrepid2_ConfigDefs.hpp"
52#include "Intrepid2_Types.hpp"
53
55
56#include <array>
57
58namespace Intrepid2 {
59
60namespace Experimental {
61
82
83ordinal_type
84KOKKOS_INLINE_FUNCTION
85range_size(const Kokkos::pair<ordinal_type, ordinal_type>& range) {
86 return range.second - range.first;
87}
88
89template<typename DeviceType, typename ValueType>
91public:
92
93 enum EvalPointsType {BASIS, TARGET};
94
95 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
97 typedef Kokkos::DefaultHostExecutionSpace HostExecutionSpaceType;
98 typedef Kokkos::HostSpace HostMemorySpaceType;
99 typedef Kokkos::Device<HostExecutionSpaceType,HostMemorySpaceType> HostDeviceType;
100 typedef Kokkos::DynRankView<ValueType,HostDeviceType > view_type;
101 typedef Kokkos::View<range_type**,HostDeviceType> range_tag;
102 static constexpr int numberSubCellDims = 4; //{0 for vertex, 1 for edges, 2 for faces, 3 for volumes}
103 //max of numVertices, numEdges, numFaces for a reference cell.
104 //12 is the number of edges in a Hexahderon.
105 //We'll need to change this if we consider generic polyhedra
106 static constexpr int maxSubCellsCount = 12;
107 typedef std::array<std::array<view_type, maxSubCellsCount>, numberSubCellDims> view_tag;
108 typedef Kokkos::View<unsigned**,HostDeviceType > key_tag;
109
112 ordinal_type getNumBasisEvalPoints() {
113 return numBasisEvalPoints;
114 }
115
119 return numBasisDerivEvalPoints;
120 }
121
124 ordinal_type getNumTargetEvalPoints() {
125 return numTargetEvalPoints;
126 }
127
131 return numTargetDerivEvalPoints;
132 }
133
140 ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const {
141 if(type == BASIS)
142 return maxNumBasisDerivEvalPoints;
143 else
144 return maxNumTargetDerivEvalPoints;
145 }
146
153 ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const {
154 if(type == BASIS)
155 return maxNumBasisEvalPoints;
156 else
157 return maxNumTargetEvalPoints;
158 }
159
172 view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
173 return basisCubPoints[subCellDim][subCellId];
174 }
175
176
189 view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
190 return basisDerivCubPoints[subCellDim][subCellId];
191 }
192
193
206 view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
207 return targetCubPoints[subCellDim][subCellId];
208 }
209
210
223 view_type getTargetDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
224 return targetDerivCubPoints[subCellDim][subCellId];
225 }
226
227
242 view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
243 if(type == BASIS)
244 return basisCubPoints[subCellDim][subCellId];
245 else
246 return targetCubPoints[subCellDim][subCellId];
247 }
248
263 view_type getDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
264 if(type == BASIS)
265 return basisDerivCubPoints[subCellDim][subCellId];
266 else
267 return targetDerivCubPoints[subCellDim][subCellId];
268 }
269
270
271
283 view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
284 return basisCubWeights[subCellDim][subCellId];
285 }
286
287
299 view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
300 return basisDerivCubWeights[subCellDim][subCellId];
301 }
302
303
315 view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
316 return targetCubWeights[subCellDim][subCellId];
317 }
318
319
331 view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
332 return targetDerivCubWeights[subCellDim][subCellId];
333 }
334
335
340 const range_tag getBasisPointsRange() const {
341 return basisPointsRange;
342 }
343
344
350 const range_tag getPointsRange(const EvalPointsType type) const {
351 if(type == BASIS)
352 return basisPointsRange;
353 else
354 return targetPointsRange;
355 }
356
357
362 const range_tag getBasisDerivPointsRange() const {
363 return basisDerivPointsRange;
364 }
365
372 const range_tag getDerivPointsRange(const EvalPointsType type) const {
373 if(type == BASIS)
374 return basisDerivPointsRange;
375 else
376 return targetDerivPointsRange;
377 }
378
379
384 const range_tag getTargetPointsRange() const {
385 return targetPointsRange;
386 }
387
388
393 const range_tag getTargetDerivPointsRange() const {
394 return targetDerivPointsRange;
395 }
396
401 const key_tag getTopologyKey() const {
402 return subCellTopologyKey;
403 }
404
405
406
407
412 template<typename BasisPtrType>
413 void createL2ProjectionStruct(const BasisPtrType cellBasis,
414 const ordinal_type targetCubDegree);
415
416
421 template<typename BasisPtrType>
422 void createL2DGProjectionStruct(const BasisPtrType cellBasis,
423 const ordinal_type targetCubDegree) {
424 createHVolProjectionStruct(cellBasis, targetCubDegree);
425 }
426
427
433 template<typename BasisPtrType>
434 void createHGradProjectionStruct(const BasisPtrType cellBasis,
435 const ordinal_type targetCubDegree,
436 const ordinal_type targetGradCubDegre);
437
438
444 template<typename BasisPtrType>
445 void createHCurlProjectionStruct(const BasisPtrType cellBasis,
446 const ordinal_type targetCubDegree,
447 const ordinal_type targetCurlCubDegre);
448
449
455 template<typename BasisPtrType>
456 void createHDivProjectionStruct(const BasisPtrType cellBasis,
457 const ordinal_type targetCubDegree,
458 const ordinal_type targetDivCubDegre);
459
464 template<typename BasisPtrType>
465 void createHVolProjectionStruct(const BasisPtrType cellBasis,
466 const ordinal_type targetCubDegree);
467
468 key_tag subCellTopologyKey;
469 range_tag basisPointsRange;
470 range_tag basisDerivPointsRange;
471 range_tag targetPointsRange;
472 range_tag targetDerivPointsRange;
473 view_tag basisCubPoints;
474 view_tag basisCubWeights;
475 view_tag basisDerivCubPoints;
476 view_tag basisDerivCubWeights;
477 view_tag targetCubPoints;
478 view_tag targetCubWeights;
479 view_tag targetDerivCubPoints;
480 view_tag targetDerivCubWeights;
481 ordinal_type numBasisEvalPoints;
482 ordinal_type numBasisDerivEvalPoints;
483 ordinal_type numTargetEvalPoints;
484 ordinal_type numTargetDerivEvalPoints;
485 ordinal_type maxNumBasisEvalPoints;
486 ordinal_type maxNumTargetEvalPoints;
487 ordinal_type maxNumBasisDerivEvalPoints;
488 ordinal_type maxNumTargetDerivEvalPoints;
489};
490
491}
492}
494#endif
495
496
497
498
499
Stateless class that acts as a factory for a family of nodal bases (hypercube topologies only at this...
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.