Commit 336e8bcd authored by chinsp's avatar chinsp
Browse files

added test case for polynomial of total degree 2

parent c7353352
Pipeline #158232 passed with stages
in 11 minutes and 22 seconds
...@@ -23,7 +23,7 @@ CreateStochasticDummyProblem(const std::string &problemName, const Meshes &meshe ...@@ -23,7 +23,7 @@ CreateStochasticDummyProblem(const std::string &problemName, const Meshes &meshe
return new SparseGrid1DGeneratorProblem(meshes); return new SparseGrid1DGeneratorProblem(meshes);
if (problemName == "SparseGrid2DGeneratorProblem") if (problemName == "SparseGrid2DGeneratorProblem")
return new SparseGrid2DGeneratorProblem(meshes); return new SparseGrid2DGeneratorProblem(meshes);
if (problemName == "SparseGrid2DPolynomialDegree2Problem") if (problemName == "SparseGrid2DPolyDeg2Problem")
return new SparseGrid2DPolynomialDegree2Problem(meshes); return new SparseGrid2DPolyDeg2Problem(meshes);
Exit(problemName + " not found") Exit(problemName + " not found")
} }
\ No newline at end of file
...@@ -249,22 +249,22 @@ public: ...@@ -249,22 +249,22 @@ public:
} }
}; };
class SparseGrid2DPolynomialDegree2Problem : public SparseGridGeneratorProblem { class SparseGrid2DPolyDeg2Problem : public SparseGridGeneratorProblem {
public: public:
explicit SparseGrid2DPolynomialDegree2Problem(const Meshes &meshes) : explicit SparseGrid2DPolyDeg2Problem(const Meshes &meshes) :
SparseGridGeneratorProblem(meshes, SparseGridGenerator(meshes, 2, 0, 1)) {} SparseGridGeneratorProblem(meshes, SparseGridGenerator(meshes, 2, 0, 4)) {}
double FunctionEvaluation() override { double FunctionEvaluation() override {
RVector sample = this->generator.EvalSample(); RVector sample = this->generator.EvalSample();
return sample[0] * sample[1]; return 1 + sample[0] + pow(sample[0],2) + sample[1] + pow(sample[1],2) + sample[0] * sample[1];
} }
string Name() const override { string Name() const override {
return "SparseGrid2DPolynomialDegree2Problem"; return "SparseGrid2DPolyDeg2Problem";
} }
}; };
// Todo find more test cases in tasmanina examples and write sparse grid problems // Todo find more test cases in tasmanian examples and write sparse grid problems
StochasticDummyProblem * StochasticDummyProblem *
CreateStochasticDummyProblem(const std::string &problemName, const Meshes &meshes); CreateStochasticDummyProblem(const std::string &problemName, const Meshes &meshes);
......
...@@ -9,8 +9,8 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -9,8 +9,8 @@ INSTANTIATE_TEST_SUITE_P(
TestStochasticCollocation, TestStochasticCollocationWithoutEpsilon, Values( TestStochasticCollocation, TestStochasticCollocationWithoutEpsilon, Values(
TestParams{"SparseGrid2DGeneratorProblem", "FunctionEvaluation", TestParams{"SparseGrid2DGeneratorProblem", "FunctionEvaluation",
"DummyPDESolver", 2.513723354063905}, "DummyPDESolver", 2.513723354063905},
TestParams{"SparseGrid2DPolynomialDegree2Problem", "FunctionEvaluation", TestParams{"SparseGrid2DPolyDeg2Problem", "FunctionEvaluation",
"DummyPDESolver", 0.0} "DummyPDESolver", 6.666666666666667}
// Todo add more test cases // Todo add more test cases
)); ));
......
Markdown is supported
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