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 
55 namespace Intrepid2 {
56 
57 namespace Experimental {
58 
80 ordinal_type
81 KOKKOS_INLINE_FUNCTION
82 range_size(const Kokkos::pair<ordinal_type, ordinal_type>& range) {
83  return range.second - range.first;
84 }
85 
86 template<typename SpT, typename ValueType>
88 public:
89 
90  enum EvalPointsType {BASIS, TARGET};
91 
92  typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
93  typedef typename Kokkos::Impl::is_space<SpT>::host_mirror_space::execution_space host_space_type;
94  typedef Kokkos::DynRankView<ValueType,host_space_type> view_type;
95  typedef Kokkos::View<range_type**,host_space_type> 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**,host_space_type> key_tag;
103 
106  ordinal_type getNumBasisEvalPoints() {
107  return numBasisEvalPoints;
108  }
109 
112  ordinal_type getNumBasisDerivEvalPoints() {
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 
416  template<typename BasisPtrType>
417  void createHGradProjectionStruct(const BasisPtrType cellBasis,
418  const ordinal_type targetCubDegree,
419  const ordinal_type targetGradCubDegre);
420 
421 
427  template<typename BasisPtrType>
428  void createHCurlProjectionStruct(const BasisPtrType cellBasis,
429  const ordinal_type targetCubDegree,
430  const ordinal_type targetCurlCubDegre);
431 
432 
438  template<typename BasisPtrType>
439  void createHDivProjectionStruct(const BasisPtrType cellBasis,
440  const ordinal_type targetCubDegree,
441  const ordinal_type targetDivCubDegre);
442 
447  template<typename BasisPtrType>
448  void createHVolProjectionStruct(const BasisPtrType cellBasis,
449  const ordinal_type targetCubDegree);
450 
451  key_tag subCellTopologyKey;
452  range_tag basisPointsRange;
453  range_tag basisDerivPointsRange;
454  range_tag targetPointsRange;
455  range_tag targetDerivPointsRange;
456  view_tag basisCubPoints;
457  view_tag basisCubWeights;
458  view_tag basisDerivCubPoints;
459  view_tag basisDerivCubWeights;
460  view_tag targetCubPoints;
461  view_tag targetCubWeights;
462  view_tag targetDerivCubPoints;
463  view_tag targetDerivCubWeights;
464  ordinal_type numBasisEvalPoints;
465  ordinal_type numBasisDerivEvalPoints;
466  ordinal_type numTargetEvalPoints;
467  ordinal_type numTargetDerivEvalPoints;
468  ordinal_type maxNumBasisEvalPoints;
469  ordinal_type maxNumTargetEvalPoints;
470  ordinal_type maxNumBasisDerivEvalPoints;
471  ordinal_type maxNumTargetDerivEvalPoints;
472 };
473 
474 }
475 }
477 #endif
478 
479 
480 
481 
482 
void createL2ProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree)
Initialize the ProjectionStruct for L2 projections.
void createHDivProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetDivCubDegre)
Initialize the ProjectionStruct for HDIV projections.
const range_tag getPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target evaluation points in subcells.
const range_tag getDerivPointsRange(const EvalPointsType type) const
Returns the range tag of the basis/target derivative evaluation points on subcells.
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 getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function evaluation weights on a subcell.
ordinal_type getMaxNumEvalPoints(const EvalPointsType type) const
Returns the maximum number of evaluation points across all the subcells.
view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function derivatives evaluation weights on a subcell.
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.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
view_type getBasisEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation points on a subcell.
const range_tag getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
ordinal_type getNumTargetDerivEvalPoints()
Returns number of points where to evaluate the derivatives of the target function.
Contains definitions of custom data types in Intrepid2.
ordinal_type getMaxNumDerivPoints(const EvalPointsType type) const
Returns the maximum number of derivative evaluation points across all the subcells.
const range_tag getBasisDerivPointsRange() const
Returns the range tag of the derivative evaluation points on subcell.
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.
void createHCurlProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetCurlCubDegre)
Initialize the ProjectionStruct for HCURL projections.
void createHGradProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetGradCubDegre)
Initialize the ProjectionStruct for HGRAD projections.
view_type getBasisDerivEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the evaluation points for basis derivatives on a subcell.
ordinal_type getNumBasisEvalPoints()
Returns number of basis evaluation points.
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.
An helper class to compute the evaluation points and weights needed for performing projections...
ordinal_type getNumTargetEvalPoints()
Returns number of points where to evaluate the target function.
const key_tag getTopologyKey() const
Returns the key tag for subcells.
view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation weights on a subcell.
view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const
Returns the basis/target evaluation points on a subcell.
const range_tag getTargetDerivPointsRange() const
Returns the range tag of the target function derivative evaluation points on subcells.
Header file for the Intrepid2::Experimental::ProjectionStruct containing definitions.