|
Intrepid
|
00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Intrepid Package 00005 // Copyright (2007) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Pavel Bochev (pbboche@sandia.gov) or 00025 // Denis Ridzal (dridzal@sandia.gov). 00026 // 00027 // ************************************************************************ 00028 // @HEADER 00029 00035 namespace Intrepid { 00036 00037 template <class Scalar, class ArrayPoint, class ArrayWeight> 00038 CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::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 } // end constructor 00048 00049 00050 00051 template <class Scalar, class ArrayPoint, class ArrayWeight> 00052 const char* CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::getName() const { 00053 return cubature_name_; 00054 } // end getName 00055 00056 00057 00058 template <class Scalar, class ArrayPoint, class ArrayWeight> 00059 int CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::getDimension() const { 00060 return dimension_; 00061 } // end dimension 00062 00063 00064 00065 template <class Scalar, class ArrayPoint, class ArrayWeight> 00066 int CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::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 } // end getNumPoints 00089 00090 00091 00092 template <class Scalar, class ArrayPoint, class ArrayWeight> 00093 void CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::getAccuracy(std::vector<int> & accuracy) const { 00094 accuracy.assign(1, degree_); 00095 } // end getAccuracy 00096 00097 00098 00099 template <class Scalar, class ArrayPoint, class ArrayWeight> 00100 const char* CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::cubature_name_ = "INTREPID_CUBATURE_POLYLIB"; 00101 00102 00103 00104 template <class Scalar, class ArrayPoint, class ArrayWeight> 00105 void CubaturePolylib<Scalar,ArrayPoint,ArrayWeight>::getCubature(ArrayPoint & cubPoints, ArrayWeight & cubWeights) const { 00106 int numCubPoints = getNumPoints(); 00107 int cellDim = getDimension(); 00108 // check size of cubPoints and cubWeights 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 // temporary storage 00114 FieldContainer<Scalar> z(numCubPoints); 00115 FieldContainer<Scalar> w(numCubPoints); 00116 00117 // run Polylib routines 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 // fill input arrays 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 } // end getCubature 00145 00146 00147 } // end namespace Intrepid
1.7.4