00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035 namespace Intrepid {
00036
00037 template <class Scalar, class ArrayType>
00038 CubaturePolylib<Scalar,ArrayType>::CubaturePolylib(int degree, EIntrepidPLPoly poly_type, Scalar alpha, Scalar beta) {
00039 TEST_FOR_EXCEPTION((degree < 0),
00040 std::out_of_range,
00041 ">>> ERROR (CubaturePolylib): No cubature rule implemented for the desired polynomial degree.");
00042 degree_ = degree;
00043 dimension_ = 1;
00044 poly_type_ = poly_type;
00045 alpha_ = alpha;
00046 beta_ = beta;
00047 }
00048
00049
00050
00051 template <class Scalar, class ArrayType>
00052 const char* CubaturePolylib<Scalar,ArrayType>::getName() const {
00053 return cubature_name_;
00054 }
00055
00056
00057
00058 template <class Scalar, class ArrayType>
00059 int CubaturePolylib<Scalar,ArrayType>::getDimension() const {
00060 return dimension_;
00061 }
00062
00063
00064
00065 template <class Scalar, class ArrayType>
00066 int CubaturePolylib<Scalar,ArrayType>::getNumPoints() const {
00067 int np = 0;
00068 switch (poly_type_) {
00069 case PL_GAUSS:
00070 np = (degree_+(int)2)/(int)2;
00071 break;
00072 case PL_GAUSS_RADAU_LEFT:
00073 case PL_GAUSS_RADAU_RIGHT:
00074 if (degree_ == 0)
00075 np = 2;
00076 else
00077 np = (degree_+(int)3)/(int)2;
00078 break;
00079 case PL_GAUSS_LOBATTO:
00080 np = (degree_+(int)4)/(int)2;
00081 break;
00082 default:
00083 TEST_FOR_EXCEPTION((1),
00084 std::invalid_argument,
00085 ">>> ERROR (CubaturePolylib): Unknown point type argument.");
00086 }
00087 return np;
00088 }
00089
00090
00091
00092 template <class Scalar, class ArrayType>
00093 void CubaturePolylib<Scalar,ArrayType>::getAccuracy(std::vector<int> & accuracy) const {
00094 accuracy.assign(1, degree_);
00095 }
00096
00097
00098
00099 template <class Scalar, class ArrayType>
00100 const char* CubaturePolylib<Scalar,ArrayType>::cubature_name_ = "INTREPID_CUBATURE_POLYLIB";
00101
00102
00103
00104 template <class Scalar, class ArrayType>
00105 void CubaturePolylib<Scalar,ArrayType>::getCubature(ArrayType & cubPoints, ArrayType & cubWeights) const {
00106 int numCubPoints = getNumPoints();
00107 int cellDim = getDimension();
00108
00109 TEST_FOR_EXCEPTION( ( ( (int)cubPoints.size() < numCubPoints*cellDim ) || ( (int)cubWeights.size() < numCubPoints ) ),
00110 std::out_of_range,
00111 ">>> ERROR (CubatureDirect): Insufficient space allocated for cubature points or weights.");
00112
00113
00114 FieldContainer<Scalar> z(numCubPoints);
00115 FieldContainer<Scalar> w(numCubPoints);
00116
00117
00118 switch (poly_type_) {
00119 case PL_GAUSS:
00120 IntrepidPolylib::zwgj(&z[0], &w[0], numCubPoints, alpha_, beta_);
00121 break;
00122 case PL_GAUSS_RADAU_LEFT:
00123 IntrepidPolylib::zwgrjm(&z[0], &w[0], numCubPoints, alpha_, beta_);
00124 break;
00125 case PL_GAUSS_RADAU_RIGHT:
00126 IntrepidPolylib::zwgrjp(&z[0], &w[0], numCubPoints, alpha_, beta_);
00127 break;
00128 case PL_GAUSS_LOBATTO:
00129 IntrepidPolylib::zwglj(&z[0], &w[0], numCubPoints, alpha_, beta_);
00130 break;
00131 default:
00132 TEST_FOR_EXCEPTION((1),
00133 std::invalid_argument,
00134 ">>> ERROR (CubaturePolylib): Unknown point type argument.");
00135 }
00136
00137
00138 for (int pointId = 0; pointId < numCubPoints; pointId++) {
00139 for (int dim = 0; dim < cellDim; dim++) {
00140 cubPoints(pointId,dim) = z[pointId];
00141 }
00142 cubWeights(pointId) = w[pointId];
00143 }
00144 }
00145
00146
00147 }