Intrepid2
Intrepid2_CubaturePolylibDef.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 namespace Intrepid2 {
50 
51  template <typename SpT, typename PT, typename WT>
52  CubaturePolylib<SpT,PT,WT>::
53  CubaturePolylib(const ordinal_type degree,
54  const EPolyType polytype,
55  const double alpha,
56  const double beta)
57  : CubatureDirect<SpT,PT,WT>(degree, 1) {
58 
59  INTREPID2_TEST_FOR_EXCEPTION( degree < 0 ||
60  degree > static_cast<ordinal_type>(Parameters::MaxCubatureDegreeEdge), std::out_of_range,
61  ">>> ERROR (CubaturePolylib): No cubature rule implemented for the desired polynomial degree.");
62  INTREPID2_TEST_FOR_EXCEPTION( !isValidPolyType(polytype), std::invalid_argument,
63  ">>> ERROR (CubaturePolylib): Invalid poly type.");
64 
65  ordinal_type npts = 0;
66  switch (polytype) {
67  case POLYTYPE_GAUSS: npts = (degree+2)/2; break;
68  case POLYTYPE_GAUSS_RADAU_LEFT:
69  case POLYTYPE_GAUSS_RADAU_RIGHT: npts = (degree == 0 ? 2 : (degree+3)/2); break;
70  case POLYTYPE_GAUSS_LOBATTO: npts = (degree+4)/2; break;
71  case POLYTYPE_MAX: break;
72  }
73  this->cubatureData_.numPoints_ = npts;
74 
75  auto points = Kokkos::DynRankView<PT,Kokkos::HostSpace>("CubaturePolylib::points", npts);
76  auto weights = Kokkos::DynRankView<WT,Kokkos::HostSpace>("CubaturePolylib::weights", npts);
77 
78  Polylib::Serial::getCubature( points,
79  weights,
80  npts,
81  alpha,
82  beta,
83  polytype );
84 
85  this->cubatureData_.points_ = Kokkos::DynRankView<PT,SpT>("CubaturePolylib::cubatureData_::points_", npts, 1);
86  this->cubatureData_.weights_ = Kokkos::DynRankView<WT,SpT>("CubaturePolylib::cubatureData_::weights_", npts);
87 
88  Kokkos::deep_copy(Kokkos::subdynrankview(this->cubatureData_.points_, Kokkos::ALL(), 0), points );
89  Kokkos::deep_copy(this->cubatureData_.weights_, weights );
90  }
91 
92 
93 }
94 
Kokkos::DynRankView< pointValueType, ExecSpaceType > points_
Array with the (X,Y,Z) coordinates of the cubature points.
CubatureData cubatureData_
Cubature data on device.
static constexpr ordinal_type MaxCubatureDegreeEdge
The maximum degree of the polynomial that can be integrated exactly by a direct edge rule...
ordinal_type numPoints_
Number of cubature points stored in the template.
Kokkos::DynRankView< weightValueType, ExecSpaceType > weights_
Array with the associated cubature weights.