Commit fe8aeb3c authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

first version of SparseGridGenerator

parent 123b006a
......@@ -20,21 +20,32 @@ protected:
RVector sample;
std::vector<double> points;
double weight = 0.0;
std::vector<double> points{};
std::vector<double> weights{};
void drawSample(const SampleID &id) override {
// Todo the parallelization
for (int i = 0; i < dimension; i++) {
sample[i] = points.front();
points.erase(points.begin());
// points.erase(points.begin());
weight = weights.front();
// weights.erase(points.begin());
}
};
public:
SparseGridGenerator(const Meshes &meshes, int dimension, int outputs,
SparseGridGenerator(const Meshes &meshes, int dimension, int outputs, int level,
TasGrid::TypeDepth depth = TasGrid::type_level,
TasGrid::TypeOneDRule rule = TasGrid::rule_clenshawcurtis) :
SampleGenerator(meshes), dimension(dimension), outputs(outputs),
depth(depth), rule(rule), sample(RVector(dimension)) {
grid.makeGlobalGrid(dimension, outputs, level, depth, rule);
points = grid.getPoints();
weights = grid.getQuadratureWeights();
}
void CreateGlobalGrid(int level) {
......@@ -42,11 +53,11 @@ public:
}
std::vector<double> GetPoints() {
return grid.getPoints();
return points;
}
std::vector<double> GetWeights() {
return grid.getQuadratureWeights();
return weights;
}
int GetNumPoints() {
......@@ -57,6 +68,7 @@ public:
return grid.getNumDimensions();
}
// todo move to stochastic collocation class
double Quadrature(double func(double, double)) {
double I = 0.0;
std::vector<double> points = GetPoints();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment