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 
58 namespace Intrepid2 {
59 
81 ordinal_type
82 KOKKOS_INLINE_FUNCTION
83 range_size(const Kokkos::pair<ordinal_type, ordinal_type>& range) {
84  return range.second - range.first;
85 }
86 
87 template<typename DeviceType, typename ValueType>
89 public:
90 
91  enum EvalPointsType {BASIS, TARGET};
92 
93  using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
94  using HostExecutionSpaceType = Kokkos::DefaultHostExecutionSpace;
95  using HostMemorySpaceType = Kokkos::HostSpace;
96  using MemSpaceType = typename DeviceType::memory_space;
97  using HostDeviceType = Kokkos::Device<HostExecutionSpaceType,HostMemorySpaceType>;
98  using view_type = Kokkos::DynRankView<ValueType,DeviceType >;
99  using host_view_type = Kokkos::DynRankView<ValueType,HostDeviceType >;
100  using range_tag = Kokkos::View<range_type**,HostDeviceType>;
101  static constexpr int numberSubCellDims = 4; //{0 for vertex, 1 for edges, 2 for faces, 3 for volumes}
102  //max of numVertices, numEdges, numFaces for a reference cell.
103  //12 is the number of edges in a Hexahderon.
104  //We'll need to change this if we consider generic polyhedra
105  static constexpr int maxSubCellsCount = 12;
106  using view_tag = std::array<std::array<host_view_type, maxSubCellsCount>, numberSubCellDims>;
107  using key_tag = Kokkos::View<unsigned**,HostDeviceType >;
108 
109 
112  ordinal_type getNumBasisEvalPoints() {
113  return numBasisEvalPoints;
114  }
115 
118  ordinal_type getNumBasisDerivEvalPoints() {
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  host_view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
173  return basisCubPoints[subCellDim][subCellId];
174  }
175 
176 
189  host_view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
190  return basisDerivCubPoints[subCellDim][subCellId];
191  }
192 
193 
206  host_view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
207  return targetCubPoints[subCellDim][subCellId];
208  }
209 
210 
223  host_view_type getTargetDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId) {
224  return targetDerivCubPoints[subCellDim][subCellId];
225  }
226 
227 
242  host_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 
261  view_type getAllEvalPoints(EvalPointsType type = TARGET) const{
262  if(type == BASIS)
263  return allBasisEPoints;
264  else
265  return allTargetEPoints;
266  }
267 
282  host_view_type getDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const{
283  if(type == BASIS)
284  return basisDerivCubPoints[subCellDim][subCellId];
285  else
286  return targetDerivCubPoints[subCellDim][subCellId];
287  }
288 
301  view_type getAllDerivEvalPoints(EvalPointsType type = TARGET) const{
302  if(type == BASIS)
303  return allBasisDerivEPoints;
304  else
305  return allTargetDerivEPoints;
306  }
307 
308 
320  host_view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
321  return basisCubWeights[subCellDim][subCellId];
322  }
323 
324 
336  host_view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
337  return basisDerivCubWeights[subCellDim][subCellId];
338  }
339 
340 
352  host_view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
353  return targetCubWeights[subCellDim][subCellId];
354  }
355 
356 
368  host_view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId) {
369  return targetDerivCubWeights[subCellDim][subCellId];
370  }
371 
372 
377  const range_tag getBasisPointsRange() const {
378  return basisPointsRange;
379  }
380 
381 
387  const range_tag getPointsRange(const EvalPointsType type) const {
388  if(type == BASIS)
389  return basisPointsRange;
390  else
391  return targetPointsRange;
392  }
393 
394 
399  const range_tag getBasisDerivPointsRange() const {
400  return basisDerivPointsRange;
401  }
402 
409  const range_tag getDerivPointsRange(const EvalPointsType type) const {
410  if(type == BASIS)
411  return basisDerivPointsRange;
412  else
413  return targetDerivPointsRange;
414  }
415 
416 
421  const range_tag getTargetPointsRange() const {
422  return targetPointsRange;
423  }
424 
425 
430  const range_tag getTargetDerivPointsRange() const {
431  return targetDerivPointsRange;
432  }
433 
438  const key_tag getTopologyKey() const {
439  return subCellTopologyKey;
440  }
441 
446  template<typename BasisPtrType>
447  void createL2ProjectionStruct(const BasisPtrType cellBasis,
448  const ordinal_type targetCubDegree);
449 
450 
455  template<typename BasisPtrType>
456  void createL2DGProjectionStruct(const BasisPtrType cellBasis,
457  const ordinal_type targetCubDegree) {
458  createHVolProjectionStruct(cellBasis, targetCubDegree);
459  }
460 
461 
467  template<typename BasisPtrType>
468  void createHGradProjectionStruct(const BasisPtrType cellBasis,
469  const ordinal_type targetCubDegree,
470  const ordinal_type targetGradCubDegre);
471 
472 
478  template<typename BasisPtrType>
479  void createHCurlProjectionStruct(const BasisPtrType cellBasis,
480  const ordinal_type targetCubDegree,
481  const ordinal_type targetCurlCubDegre);
482 
483 
489  template<typename BasisPtrType>
490  void createHDivProjectionStruct(const BasisPtrType cellBasis,
491  const ordinal_type targetCubDegree,
492  const ordinal_type targetDivCubDegre);
493 
498  template<typename BasisPtrType>
499  void createHVolProjectionStruct(const BasisPtrType cellBasis,
500  const ordinal_type targetCubDegree);
501 
502  key_tag subCellTopologyKey;
503  range_tag basisPointsRange;
504  range_tag basisDerivPointsRange;
505  range_tag targetPointsRange;
506  range_tag targetDerivPointsRange;
507  view_tag basisCubPoints;
508  view_tag basisCubWeights;
509  view_tag basisDerivCubPoints;
510  view_tag basisDerivCubWeights;
511  view_tag targetCubPoints;
512  view_tag targetCubWeights;
513  view_tag targetDerivCubPoints;
514  view_tag targetDerivCubWeights;
515  view_type allBasisEPoints;
516  view_type allBasisDerivEPoints;
517  view_type allTargetEPoints;
518  view_type allTargetDerivEPoints;
519  ordinal_type numBasisEvalPoints;
520  ordinal_type numBasisDerivEvalPoints;
521  ordinal_type numTargetEvalPoints;
522  ordinal_type numTargetDerivEvalPoints;
523  ordinal_type maxNumBasisEvalPoints;
524  ordinal_type maxNumTargetEvalPoints;
525  ordinal_type maxNumBasisDerivEvalPoints;
526  ordinal_type maxNumTargetDerivEvalPoints;
527 };
528 
529 } // Intrepid2 namespace
531 #endif
532 
533 
534 
535 
536 
ordinal_type getNumBasisDerivEvalPoints()
Returns number of evaluation points for basis derivatives.
void createHVolProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for HVOL (local-L2) projection.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const
Returns the maximum number of derivative evaluation points across all the subcells.
const range_tag getTargetDerivPointsRange() const
Returns the range tag of the target function derivative evaluation points on subcells.
host_view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function derivatives evaluation weights on a subcell.
host_view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const
Returns the basis/target evaluation points on a subcell.
host_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 createHDivProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetDivCubDegre)
Initialize the ProjectionStruct for HDIV projections.
ordinal_type getNumBasisEvalPoints()
Returns number of basis evaluation points.
ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const
Returns the maximum number of evaluation points across all the subcells.
const range_tag getDerivPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target derivative evaluation points on subcells.
host_view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation points on a subcell.
view_type getAllDerivEvalPoints(EvalPointsType type=TARGET) const
Returns all the evaluation points for basis/target derivatives in the cell.
const key_tag getTopologyKey() const
Returns the key tag for subcells.
view_type getAllEvalPoints(EvalPointsType type=TARGET) const
Returns the basis/target evaluation points in the cell.
const range_tag getPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target evaluation points in subcells.
host_view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation weights on a subcell.
Contains definitions of custom data types in Intrepid2.
host_view_type getTargetEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the points where to evaluate the target function on a subcell.
ordinal_type getNumTargetEvalPoints()
Returns number of points where to evaluate the target function.
const range_tag getBasisDerivPointsRange() const
Returns the range tag of the derivative evaluation points on subcell.
void createHCurlProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetCurlCubDegre)
Initialize the ProjectionStruct for HCURL projections.
const range_tag getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
host_view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis derivatives evaluation weights on a subcell.
void createL2ProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for L2 projections.
ordinal_type getNumTargetDerivEvalPoints()
Returns number of points where to evaluate the derivatives of the target function.
host_view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function evaluation weights on a subcell.
void createL2DGProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for (discontinuous local-L2) projection.
void createHGradProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetGradCubDegre)
Initialize the ProjectionStruct for HGRAD projections.
host_view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the evaluation points for basis derivatives on a subcell.
host_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.
An helper class to compute the evaluation points and weights needed for performing projections...
Stateless class that acts as a factory for a family of nodal bases (hypercube topologies only at this...
Header file for the Intrepid2::ProjectionStruct containing definitions.