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

moved problems to library

parent 6ad6754c
#include "StochasticEllipticProblem.hpp"
class StochasticLaplace1D : public IStochasticEllipticProblem {
CirculantEmbedding1D tensorGenerator;
public:
explicit StochasticLaplace1D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
tensorGenerator(CirculantEmbedding1D(meshes)) {};
void DrawSample(const SampleID &id) override {
tensorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return 1 - x[0];
}
VectorField Flux(const Point &x) const override {
return VectorField(1.0, 0.0);
}
Scalar Load(const Point &x) const override {
return 0.0;
}
Tensor Permeability(const cell &c) const override {
return this->tensorGenerator.EvalSample(c);
}
string Name() const override { return "StochasticLaplace1D"; }
};
class Laplace1D : public IStochasticEllipticProblem {
public:
explicit Laplace1D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes) {};
void DrawSample(const SampleID &id) override {}
Scalar Solution(const Point &x) const override {
return 1 - x[0];
}
VectorField Flux(const Point &x) const override {
return VectorField(-1.0, 0.0);
}
Scalar Load(const Point &x) const override {
return 0.0;
}
Tensor Permeability(const cell &c) const override {
return One;
}
string Name() const override { return "Laplace1D"; }
};
class StochasticLaplace2D : public IStochasticEllipticProblem {
CirculantEmbedding2D tensorGenerator;
public:
explicit StochasticLaplace2D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
tensorGenerator(CirculantEmbedding2D(meshes)) {}
void DrawSample(const SampleID &id) override {
tensorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
return this->tensorGenerator.EvalSample(c);
}
string Name() const override { return "StochasticLaplace2D"; }
};
class StochasticLaplace2DTest : public IStochasticEllipticProblem {
UniformDistributionRVector rVectorGenerator;
public:
explicit StochasticLaplace2DTest(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
rVectorGenerator(UniformDistributionRVector(meshes, 2, -1.0, 1.0)) {}
void DrawSample(const SampleID &id) override {
rVectorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
if (c()[1] > 0.125 && c()[1] < 0.375) {
if (c()[0] > 0.125 && c()[0] < 0.375)
return (1 + 0.9 * this->rVectorGenerator.EvalSample()[0]) * One;
if (c()[0] > 0.625 && c()[0] < 0.875)
return (1 + 0.9 * this->rVectorGenerator.EvalSample()[1]) * One;
}
return One;
}
string Name() const override { return "StochasticLaplace2DTest"; }
};
class Laplace2D : public IStochasticEllipticProblem {
public:
explicit Laplace2D(const Meshes &meshes) : IStochasticEllipticProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
return One;
}
string Name() const override { return "Laplace2D"; }
};
IStochasticEllipticProblem *
CreateStochasticEllipticProblem(const string &problemName, const Meshes &meshes) {
if (problemName == "StochasticLaplace1D")
......
......@@ -23,147 +23,6 @@ public:
}
};
class StochasticLaplace1D : public IStochasticEllipticProblem {
CirculantEmbedding1D tensorGenerator;
public:
explicit StochasticLaplace1D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
tensorGenerator(CirculantEmbedding1D(meshes)) {};
void DrawSample(const SampleID &id) override {
tensorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return 1 - x[0];
}
VectorField Flux(const Point &x) const override {
return VectorField(1.0, 0.0);
}
Scalar Load(const Point &x) const override {
return 0.0;
}
Tensor Permeability(const cell &c) const override {
return this->tensorGenerator.EvalSample(c);
}
string Name() const override { return "StochasticLaplace1D"; }
};
class Laplace1D : public IStochasticEllipticProblem {
public:
explicit Laplace1D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes) {};
void DrawSample(const SampleID &id) override {}
Scalar Solution(const Point &x) const override {
return 1 - x[0];
}
VectorField Flux(const Point &x) const override {
return VectorField(-1.0, 0.0);
}
Scalar Load(const Point &x) const override {
return 0.0;
}
Tensor Permeability(const cell &c) const override {
return One;
}
string Name() const override { return "Laplace1D"; }
};
class StochasticLaplace2D : public IStochasticEllipticProblem {
CirculantEmbedding2D tensorGenerator;
public:
explicit StochasticLaplace2D(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
tensorGenerator(CirculantEmbedding2D(meshes)) {}
void DrawSample(const SampleID &id) override {
tensorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
return this->tensorGenerator.EvalSample(c);
}
string Name() const override { return "StochasticLaplace2D"; }
};
class StochasticLaplace2DTest : public IStochasticEllipticProblem {
UniformDistributionRVector rVectorGenerator;
public:
explicit StochasticLaplace2DTest(const Meshes &meshes) :
IStochasticEllipticProblem(meshes),
rVectorGenerator(UniformDistributionRVector(meshes, 2, -1.0, 1.0)) {}
void DrawSample(const SampleID &id) override {
rVectorGenerator.DrawSample(id);
}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
if (c()[1] > 0.125 && c()[1] < 0.375) {
if (c()[0] > 0.125 && c()[0] < 0.375)
return (1 + 0.9 * this->rVectorGenerator.EvalSample()[0]) * One;
if (c()[0] > 0.625 && c()[0] < 0.875)
return (1 + 0.9 * this->rVectorGenerator.EvalSample()[1]) * One;
}
return One;
}
string Name() const override { return "StochasticLaplace2DTest"; }
};
class Laplace2D : public IStochasticEllipticProblem {
public:
explicit Laplace2D(const Meshes &meshes) : IStochasticEllipticProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
Scalar Solution(const Point &x) const override {
return -x[1];
}
VectorField Flux(const Point &x) const override {
return VectorField(0.0, -1.0);
}
Scalar Load(const Point &x) const override { return 0.0; }
Tensor Permeability(const cell &c) const override {
return One;
}
string Name() const override { return "Laplace2D"; }
};
IStochasticEllipticProblem *
CreateStochasticEllipticProblem(const string &problemName, const Meshes &meshes);
......
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