Intrepid2
Intrepid2_CubaturePolylibDef.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
16namespace Intrepid2 {
17
18 template <typename DT, typename PT, typename WT>
19 CubaturePolylib<DT,PT,WT>::
20 CubaturePolylib(const ordinal_type degree,
21 const EPolyType polytype,
22 const double alpha,
23 const double beta)
24 : CubatureDirect<DT,PT,WT>(degree, 1) {
25
26 INTREPID2_TEST_FOR_EXCEPTION( degree < 0 ||
27 degree > static_cast<ordinal_type>(Parameters::MaxCubatureDegreeEdge), std::out_of_range,
28 ">>> ERROR (CubaturePolylib): No cubature rule implemented for the desired polynomial degree.");
29 INTREPID2_TEST_FOR_EXCEPTION( !isValidPolyType(polytype), std::invalid_argument,
30 ">>> ERROR (CubaturePolylib): Invalid poly type.");
31
32 ordinal_type npts = 0;
33 switch (polytype) {
34 case POLYTYPE_GAUSS: npts = (degree+2)/2; break;
35 case POLYTYPE_GAUSS_RADAU_LEFT:
36 case POLYTYPE_GAUSS_RADAU_RIGHT: npts = (degree == 0 ? 2 : (degree+3)/2); break;
37 case POLYTYPE_GAUSS_LOBATTO: npts = (degree+4)/2; break;
38 case POLYTYPE_MAX: break;
39 }
40 this->cubatureData_.numPoints_ = npts;
41
42 auto points = Kokkos::DynRankView<PT,Kokkos::HostSpace>("CubaturePolylib::points", npts);
43 auto weights = Kokkos::DynRankView<WT,Kokkos::HostSpace>("CubaturePolylib::weights", npts);
44
45 Polylib::Serial::getCubature( points,
46 weights,
47 npts,
48 alpha,
49 beta,
50 polytype );
51
52 this->cubatureData_.points_ = Kokkos::DynRankView<PT,DT>("CubaturePolylib::cubatureData_::points_", npts, 1);
53 this->cubatureData_.weights_ = Kokkos::DynRankView<WT,DT>("CubaturePolylib::cubatureData_::weights_", npts);
54
55 Kokkos::deep_copy(Kokkos::subdynrankview(this->cubatureData_.points_, Kokkos::ALL(), 0), points );
56 Kokkos::deep_copy(this->cubatureData_.weights_, weights );
57 }
58
59
60}
61
KOKKOS_FORCEINLINE_FUNCTION bool isValidPolyType(const EPolyType polytype)
Verifies validity of a PolyType enum.