56 template <
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
57 CubatureGenSparse<Scalar,dimension_,ArrayPoint,ArrayWeight>::CubatureGenSparse(
const int degree) :
60 SGNodes<int, dimension_> list;
61 SGNodes<int,dimension_> bigger_rules;
63 bool continue_making_first_list =
true;
64 bool more_bigger_rules =
true;
66 int poly_exp[dimension_];
67 int level[dimension_];
68 int temp_big_rule[dimension_];
70 for(
int i = 0; i<dimension_; i++){
75 while(continue_making_first_list){
76 for(
int i = 0; i < dimension_; i++)
80 max_exp = std::max(degree_,1) - Sum(poly_exp,1,dimension_-1);
81 else if(i == dimension_ -1)
82 max_exp = std::max(degree_,1) - Sum(poly_exp,0,dimension_-2);
84 max_exp = std::max(degree_,1) - Sum(poly_exp,0,dimension_-1) + poly_exp[i];
86 if(poly_exp[i] < max_exp)
94 continue_making_first_list =
false;
101 if(continue_making_first_list)
103 for(
int j = 0; j < dimension_;j++)
108 level[j] = (int)std::ceil((((Scalar)poly_exp[j])+3.0)/4.0);
114 list.addNode(level,1);
120 while(more_bigger_rules)
122 bigger_rules.addNode(temp_big_rule,1);
124 for(
int i = 0; i < dimension_; i++)
126 if(temp_big_rule[i] == 0){
127 temp_big_rule[i] = 1;
131 if(i == dimension_-1)
132 more_bigger_rules =
false;
134 temp_big_rule[i] = 0;
139 for(
int x = 0; x < list.size(); x++){
140 for(
int y = 0; y < bigger_rules.size(); y++)
142 SGPoint<int, dimension_> next_rule;
143 for(
int t = 0; t < dimension_; t++)
144 next_rule.coords[t] = list.nodes[x].coords[t] + bigger_rules.nodes[y].coords[t];
146 bool is_in_set =
false;
147 for(
int z = 0; z < list.size(); z++)
149 if(next_rule == list.nodes[z]){
157 int big_sum[dimension_];
158 for(
int i = 0; i < dimension_; i++)
159 big_sum[i] = bigger_rules.nodes[y].coords[i];
160 Scalar coeff = std::pow(-1.0, Sum(big_sum, 0, dimension_-1));
162 Scalar point[dimension_];
163 int point_record[dimension_];
165 for(
int j = 0; j<dimension_; j++)
168 bool more_points =
true;
174 for(
int w = 0; w < dimension_; w++){
178 int order1D = 2*list.nodes[x].coords[w]-1;
184 int cubDegree1D = 2*order1D - 1;
185 CubatureDirectLineGauss<Scalar> Cub1D(cubDegree1D);
186 FieldContainer<Scalar> cubPoints1D(order1D, 1);
187 FieldContainer<Scalar> cubWeights1D(order1D);
189 Cub1D.getCubature(cubPoints1D, cubWeights1D);
191 point[w] = cubPoints1D(point_record[w]-1, 0);
192 weight = weight * cubWeights1D(point_record[w]-1);
194 weight = weight*coeff;
195 grid.addNode(point, weight);
197 for(
int v = 0; v < dimension_; v++)
199 if(point_record[v] < 2*list.nodes[x].coords[v]-1){
204 if(v == dimension_-1)
215 numPoints_ = grid.size();
220 template <
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
222 ArrayWeight & cubWeights)
const{
223 grid.copyToArrays(cubPoints, cubWeights);
226 template<
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
228 ArrayWeight& cubWeights,
229 ArrayPoint& cellCoords)
const
231 TEUCHOS_TEST_FOR_EXCEPTION( (
true), std::logic_error,
232 ">>> ERROR (CubatureGenSparse): Cubature defined in reference space calling method for physical space cubature.");
236 template <
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
243 template <
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
250 template <
class Scalar,
int dimension_,
class ArrayPo
int,
class ArrayWeight>
252 accuracy.assign(1, degree_);
virtual int getNumPoints() const
Returns the number of cubature points.
virtual void getCubature(ArrayPoint &cubPoints, ArrayWeight &cubWeights) const
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
virtual void getAccuracy(std::vector< int > &accuracy) const
Returns algebraic accuracy (e.g. max. degree of polynomial that is integrated exactly).
virtual int getDimension() const
Returns dimension of the integration domain.