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 #ifndef INTREPID_CUBATURE_SPARSE_HPP
00036 #define INTREPID_CUBATURE_SPARSE_HPP
00037
00038 #include "Intrepid_ConfigDefs.hpp"
00039 #include "Intrepid_Cubature.hpp"
00040 #include "Intrepid_CubatureDirectLineGauss.hpp"
00041 #include "Intrepid_CubatureSparseHelper.hpp"
00042 #include "Teuchos_TestForException.hpp"
00043
00044
00049 #define INTREPID_CUBATURE_SPARSE2D_GAUSS_MAX 59
00050
00055 #define INTREPID_CUBATURE_SPARSE3D_GAUSS_MAX 57
00056
00057
00058 namespace Intrepid{
00059
00060 template<class Scalar, int dimension_, class ArrayType = FieldContainer<Scalar> >
00061 class CubatureSparse : public Intrepid::Cubature<Scalar,ArrayType> {
00062 private:
00063
00064 int level_;
00065
00066 int numPoints_;
00067
00068 const int degree_;
00069
00070
00071 public:
00072
00073 ~CubatureSparse() {}
00074
00075
00076 CubatureSparse(const int degree);
00077
00084 virtual void getCubature(ArrayType & cubPoints,
00085 ArrayType & cubWeights) const;
00086
00089 virtual int getNumPoints() const;
00090
00093 virtual int getDimension() const;
00094
00098 virtual void getAccuracy(std::vector<int> & accuracy) const;
00099
00100 };
00101
00102
00103
00104 template<class Scalar, int DIM>
00105 void iterateThroughDimensions(int level,
00106 int dims_left,
00107 SGNodes<Scalar,DIM> & cubPointsND,
00108 Teuchos::Array<Scalar> & partial_node,
00109 Scalar partial_weight);
00110
00111 inline int factorial(int num)
00112 {
00113 int answer = 1;
00114 if(num >= 1)
00115 {
00116 while(num > 0)
00117 {
00118 answer = answer*num;
00119 num--;
00120 }
00121 }
00122 else if(num == 0)
00123 answer = 1;
00124 else
00125 answer = -1;
00126
00127 return answer;
00128 }
00129
00130 inline double combination(int top, int bot)
00131 {
00132 double answer = factorial(top)/(factorial(bot) * factorial(top-bot));
00133 return answer;
00134 }
00135
00136 inline int iterateThroughDimensionsForNumCalc(int dims_left,
00137 int level,
00138 int levels_left,
00139 int level_so_far,
00140 Teuchos::Array<int> & nodes,
00141 int product,
00142 bool no_uni_quad)
00143 {
00144 int numNodes = 0;
00145 for(int j = 1; j <= levels_left; j++)
00146 {
00147 bool temp_bool = no_uni_quad;
00148 int temp_knots = nodes[j-1]*product;
00149 int temp_lsf = level_so_far + j;
00150
00151 if(j==1)
00152 temp_bool = false;
00153
00154 if(dims_left == 1)
00155 {
00156 if(temp_lsf < level && temp_bool == true)
00157 numNodes += 0;
00158 else
00159 {
00160 numNodes += temp_knots;
00161 }
00162 }
00163 else
00164 {
00165 numNodes += iterateThroughDimensionsForNumCalc(dims_left-1,level, levels_left-j+1, temp_lsf, nodes, temp_knots, temp_bool);
00166 }
00167 }
00168 return numNodes;
00169 }
00170
00171 inline int calculateNumPoints(int dim, int level)
00172 {
00173
00174 Teuchos::Array<int> uninum(level);
00175 uninum[0] = 1;
00176 for(int i = 1; i <= level-1; i++)
00177 {
00178 uninum[i] = 2*i;
00179 }
00180
00181 int numOfNodes = iterateThroughDimensionsForNumCalc(dim, level, level, 0, uninum, 1, true);
00182 return numOfNodes;
00183 }
00184
00185
00186 }
00187
00188
00189
00190 #include <Intrepid_CubatureSparseDef.hpp>
00191
00192 #endif