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

restructured transport problems

parent 9631b614
......@@ -3,7 +3,9 @@
class StochasticPollution1D : public IStochasticTransportProblem {
HybridFaceNormalFluxGenerator scalarGenerator;
HybridCellFluxGenerator vectorFieldGenerator;
public:
explicit StochasticPollution1D(const Meshes &meshes) :
IStochasticTransportProblem(meshes),
......@@ -95,6 +97,37 @@ public:
string Name() const override { return "StochasticPollutionCosHat1D"; }
};
class PollutionCosHat1D : public IStochasticTransportProblem {
double amplitude = 1.00;
double cc = 6.0;
public:
explicit PollutionCosHat1D(const Meshes &meshes) :
IStochasticTransportProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
Scalar Solution(double t, const Point &x) const override {
Point midPoint = Point(0.2, 0.0);
double r = dist(midPoint, x);
if (r < 1 / cc)
return amplitude * pow(cos(cc * Pi * r) + 1.0, 2.0);
return 0.0;
}
VectorField CellFlux(const cell &c, const Point &x) const override {
return VectorField(-1.0, 0.0);
}
Scalar FaceNormalFlux(const cell &c, int face, const VectorField &N,
const Point &x) const override {
return 1.0;
}
string Name() const override { return "PollutionCosHat1D"; }
};
class StochasticPollution2D : public IStochasticTransportProblem {
HybridFaceNormalFluxGenerator scalarGenerator;
......@@ -132,7 +165,6 @@ public:
};
class Pollution2D : public IStochasticTransportProblem {
private:
double d = 1.0 / 16.0;
public:
......@@ -141,8 +173,8 @@ public:
void DrawSample(const SampleID &id) override {}
Scalar Solution(double t, const Point &x) const override {
if ((abs(1 - x[1] - 1.5 * d) < d / 2) && (abs(0.5 - x[0]) < 4 * d))
return 32.0;
if ((abs(1 - x[1] - 1.5 * d) < d / 2) && (abs(0.5 - x[0]) < 3 * d))
return 1.0;
return 0.0;
}
......@@ -167,7 +199,7 @@ class StochasticPollutionCosHat2D : public IStochasticTransportProblem {
HybridCellFluxGenerator vectorFieldGenerator;
double amplitude = 1.00;
double amplitude = 1.0;
double cc = 6.0;
......@@ -203,7 +235,10 @@ public:
};
class PollutionCosHat2D : public IStochasticTransportProblem {
double amplitude = 2.0 / Pi;
double amplitude = 1.0;
double cc = 6.0;
public:
explicit PollutionCosHat2D(const Meshes &meshes)
: IStochasticTransportProblem(meshes) {}
......@@ -211,10 +246,10 @@ public:
void DrawSample(const SampleID &id) override {}
double Solution(double t, const Point &x) const override {
Point midPoint = 0.25 * (Point(cos(2. * Pi * t), sin(2. * Pi * t))
+ Point(1.0, 1.0));
Point midPoint = Point(0.5, 0.8);
double r = dist(midPoint, x);
if (r < 1.0 / (2.0 * Pi)) return amplitude * pow(cos(r / 2.0), 2.0);
if (r < 1 / cc)
return amplitude * pow(cos(cc * Pi * r) + 1.0, 2.0);
return 0.0;
}
......@@ -234,39 +269,6 @@ public:
string Name() const override { return "PollutionCosHat2D"; }
};
class CosHat2D : public IStochasticTransportProblem {
double amplitude = 1.0;
double frequency = 8.0;
public:
explicit CosHat2D(const Meshes &meshes) : IStochasticTransportProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
double Solution(double t, const Point &x) const override {
Point midPoint = 0.25 * (Point(cos(2.0 * Pi * t), sin(2.0 * Pi * t)))
+ Point(0.5, 0.5);
double r = dist(midPoint, x);
if (r < (Pi / 2.0) / frequency)
return amplitude * pow(cos(frequency * r), 2.0);
return 0.0;
}
VectorField CircleVectorField(const Point &x) const {
return 2 * Pi * VectorField(0.5 - x[1], x[0] - 0.5, 0.0);
}
VectorField CellFlux(const cell &c, const Point &x) const override {
return CircleVectorField(x);
};
Scalar FaceNormalFlux(const cell &c, int face, const VectorField &N,
const Point &x) const override {
return CircleVectorField(x) * N;
};
string Name() const override { return "CosHat2D"; }
};
class StochasticGaussHat2D : public IStochasticTransportProblem {
private:
double mu = 0.0;
......@@ -349,6 +351,74 @@ public:
string Name() const override { return "GaussHat2D"; }
};
class StochasticCosHat2D : public IStochasticTransportProblem {
// Todo add generator
double amplitude = 1.0;
double frequency = 8.0;
public:
explicit StochasticCosHat2D(const Meshes &meshes) : IStochasticTransportProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
double Solution(double t, const Point &x) const override {
Point midPoint = 0.25 * (Point(cos(2.0 * Pi * t), sin(2.0 * Pi * t)))
+ Point(0.5, 0.5);
double r = dist(midPoint, x);
if (r < (Pi / 2.0) / frequency)
return amplitude * pow(cos(frequency * r), 2.0);
return 0.0;
}
VectorField CircleVectorField(const Point &x) const {
return 2 * Pi * VectorField(0.5 - x[1], x[0] - 0.5, 0.0);
}
VectorField CellFlux(const cell &c, const Point &x) const override {
return CircleVectorField(x);
};
Scalar FaceNormalFlux(const cell &c, int face, const VectorField &N,
const Point &x) const override {
return CircleVectorField(x) * N;
};
string Name() const override { return "CosHat2D"; }
};
class CosHat2D : public IStochasticTransportProblem {
double amplitude = 1.0;
double frequency = 8.0;
public:
explicit CosHat2D(const Meshes &meshes) : IStochasticTransportProblem(meshes) {}
void DrawSample(const SampleID &id) override {}
double Solution(double t, const Point &x) const override {
Point midPoint = 0.25 * (Point(cos(2.0 * Pi * t), sin(2.0 * Pi * t)))
+ Point(0.5, 0.5);
double r = dist(midPoint, x);
if (r < (Pi / 2.0) / frequency)
return amplitude * pow(cos(frequency * r), 2.0);
return 0.0;
}
VectorField CircleVectorField(const Point &x) const {
return 2 * Pi * VectorField(0.5 - x[1], x[0] - 0.5, 0.0);
}
VectorField CellFlux(const cell &c, const Point &x) const override {
return CircleVectorField(x);
};
Scalar FaceNormalFlux(const cell &c, int face, const VectorField &N,
const Point &x) const override {
return CircleVectorField(x) * N;
};
string Name() const override { return "CosHat2D"; }
};
IStochasticTransportProblem *
CreateStochasticTransportProblem(const string &problemName, const Meshes &meshes) {
if (problemName == "StochasticPollution1D")
......@@ -358,8 +428,8 @@ CreateStochasticTransportProblem(const string &problemName, const Meshes &meshes
if (problemName == "StochasticPollutionCosHat1D")
return new StochasticPollutionCosHat1D(meshes);
// if (problemName == "PollutionCosHat1D")
// return new PollutionCosHat1D(meshes);
if (problemName == "PollutionCosHat1D")
return new PollutionCosHat1D(meshes);
if (problemName == "StochasticPollution2D")
return new StochasticPollution2D(meshes);
......@@ -376,6 +446,8 @@ CreateStochasticTransportProblem(const string &problemName, const Meshes &meshes
if (problemName == "GaussHat2D")
return new GaussHat2D(meshes);
if (problemName == "StochasticCosHat2D")
return new StochasticCosHat2D(meshes);
if (problemName == "CosHat2D")
return new CosHat2D(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