Intrepid2
Intrepid2_Cubature.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 
49 #ifndef __INTREPID2_CUBATURE_HPP__
50 #define __INTREPID2_CUBATURE_HPP__
51 
52 #include "Intrepid2_ConfigDefs.hpp"
53 #include "Intrepid2_Types.hpp"
54 #include "Intrepid2_Utils.hpp"
55 
56 namespace Intrepid2 {
57 
58  /* \struct Intrepid2::CubatureTemplate
59  \brief Template for the cubature rules used by Intrepid. Cubature template consists of
60  cubature points and cubature weights. Intrepid provides a collection of cubature
61  templates for most standard cell topologies. The templates are defined in reference
62  coordinates using a standard reference cell for each canonical cell type. Cubature
63  points are always specified by a triple of (X,Y,Z) coordinates even if the cell
64  dimension is less than 3. The unused dimensions should be padded by zeroes.
65 
66  For example, a set of Gauss rules on [-1,1] looks as the following array of CubatureTemplate structs:
67 
68  \verbatim
69  cubature_rule[4] =
70  { // Collection of Gauss rules on [-1,1]
71  {
72  1, ----> number of points in the rule
73  {{0.0,0.0,0.0}}, ----> X,Y,Z coordinates of the cubature points
74  {0.5} ----> the cubature weight
75  },
76  {
77  2,
78  {{-sqrt(1.0/3.0),0.0,0.0},
79  {+sqrt(1.0/3.0),0.0,0.0}},
80  {1.0,1.0}
81  },
82  {
83  3,
84  {{-sqrt(3.0/5.0),0.0,0.0},
85  {0.0,0.0,0.0},
86  {+sqrt(3.0/5.0),0.0,0.0}},
87  {5.0/9.0, 8.0/9.0,5.0/9.0}
88  },
89  {
90  4,
91  {{-sqrt((3.0+4.0*sqrt(0.3))/7.0),0.0,0.0},
92  {-sqrt((3.0-4.0*sqrt(0.3))/7.0),0.0,0.0},
93  {+sqrt((3.0-4.0*sqrt(0.3))/7.0),0.0,0.0},
94  {+sqrt((3.0+4.0*sqrt(0.3))/7.0),0.0,0.0}},
95  //
96  {0.5-sqrt(10.0/3.0)/12.0,
97  0.5+sqrt(10.0/3.0)/12.0,
98  0.5+sqrt(10.0/3.0)/12.0,
99  0.5-sqrt(10.0/3.0)/12.0}
100  }
101  }; // end Gauss
102  \endverbatim
103 
104  Also see data member documentation.
105  */
106 
107 
119  template<typename ExecSpaceType = void,
120  typename pointValueType = double,
121  typename weightValueType = double>
122  class Cubature {
123  public:
124 
125  typedef Kokkos::DynRankView<pointValueType,Kokkos::LayoutStride,ExecSpaceType> pointViewType;
126  typedef Kokkos::DynRankView<weightValueType,Kokkos::LayoutStride,ExecSpaceType> weightViewType;
127 
134  virtual
135  void
136  getCubature( pointViewType /* cubPoints */,
137  weightViewType /* cubWeights */ ) const {
138  INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
139  ">>> ERROR (Cubature::getCubature): this method should be over-riden by derived classes.");
140  }
141 
149  virtual
150  void
151  getCubature( pointViewType /* cubPoints */,
152  weightViewType /* cubWeights */,
153  pointViewType /* cellVertices */) const {
154  INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
155  ">>> ERROR (Cubature::getCubature): this method should be over-riden by derived classes.");
156  }
157 
160  virtual
161  ordinal_type
162  getNumPoints() const {
163  INTREPID2_TEST_FOR_WARNING( true,
164  ">>> ERROR (Cubature::getNumPoints): this method should be over-riden by derived classes.");
165  return 0;
166  }
167 
168 
171  virtual
172  ordinal_type
173  getDimension() const {
174  INTREPID2_TEST_FOR_WARNING( true,
175  ">>> ERROR (Cubature::getDimension): this method should be over-riden by derived classes.");
176  return 0;
177  }
178 
181  virtual
182  ordinal_type
183  getAccuracy() const {
184  INTREPID2_TEST_FOR_WARNING( true,
185  ">>> ERROR (Cubature::getDimension): this method should be over-riden by derived classes.");
186  return 0;
187  }
188 
191  virtual
192  const char*
193  getName() const {
194  return "Cubature";
195  }
196 
197  Cubature() = default;
198  virtual ~Cubature() {}
199 
200  };
201 
202 }// end namespace Intrepid2
203 
204 
335 #endif
virtual const char * getName() const
Returns cubature name.
Defines the base class for cubature (integration) rules in Intrepid.
virtual ordinal_type getAccuracy() const
Returns dimension of the integration domain.
virtual void getCubature(pointViewType, weightViewType) const
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
virtual void getCubature(pointViewType, weightViewType, pointViewType) const
Returns cubature points and weights on physical cells (return arrays must be pre-sized/pre-allocated)...
virtual ordinal_type getNumPoints() const
Returns the number of cubature points.
Header function for Intrepid2::Util class and other utility functions.
virtual ordinal_type getDimension() const
Returns dimension of the integration domain.
Contains definitions of custom data types in Intrepid2.