Commit 8a1c9185 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

renaming StochasticProblem file + moved Create from CreatePDESolver

parent 00d00ac1
Pipeline #118011 failed with stages
in 3 minutes and 35 seconds
#include "PDESolver.hpp" #include "PDESolver.hpp"
MatrixGraphs *PDESolver::CreateSolutionMatrixGraphs(Meshes &meshes) {
auto disc = this->GetDisc();
auto discType = typeid(*disc).name();
if (discType == typeid(LagrangeDiscretization).name())
return new MatrixGraphs(meshes, *disc);
if (discType == typeid(RTLagrangeDiscretization).name()) {
auto assemble = this->GetAssemble();
auto assembleType = typeid(*assemble).name();
if (assembleType == typeid(HybridEllipticAssemble).name())
return new MatrixGraphs(meshes, dof(new FaceDoF(1)));
if (assembleType == typeid(MixedEllipticAssemble).name())
return new MatrixGraphs(meshes, *disc);
}
if (discType == typeid(DGDiscretization).name())
return new CellMatrixGraphs(meshes, *disc);
if (discType == typeid(EGDiscretization).name())
return new CellVertexMatrixGraphs(meshes, *disc);
Exit(string(discType) +" not found")
}
void EllipticPDESolver::run(SampleSolution &solution) { void EllipticPDESolver::run(SampleSolution &solution) {
newton(*assemble, solution.U); newton(*assemble, solution.U);
} }
...@@ -29,14 +49,6 @@ void EllipticPDESolver::computeCost(SampleSolution &solution) { ...@@ -29,14 +49,6 @@ void EllipticPDESolver::computeCost(SampleSolution &solution) {
void EllipticPDESolver::plotSolution(SampleSolution &solution) { void EllipticPDESolver::plotSolution(SampleSolution &solution) {
if (!plotting) return; if (!plotting) return;
plotMap.VtkPlot(solution); plotMap.VtkPlot(solution);
// Todo plot flux
// const auto d = dof(new CellDoF(3));
// MatrixGraph *fluxMGraph = new MatrixGraph(d, solution.U.GetMesh());
// SampleSolution fluxSolution(fluxMGraph);
// mout << fluxSolution.U << endl;
// assemble->SetFlux(solution.U, fluxSolution.U);
// plotMap.VtkPlot(fluxSolution, 3, "CellData");
} }
void TransportPDESolver::run(SampleSolution &solution) { void TransportPDESolver::run(SampleSolution &solution) {
...@@ -70,3 +82,50 @@ TimeSeries TransportPDESolver::createTimeSeries(SampleSolution &solution) { ...@@ -70,3 +82,50 @@ TimeSeries TransportPDESolver::createTimeSeries(SampleSolution &solution) {
double h_max = solution.U.GetMesh().MeshWidth().second; double h_max = solution.U.GetMesh().MeshWidth().second;
return TimeSeries(t0, T, CFL * h_max, "UniformTimeSeries"); return TimeSeries(t0, T, CFL * h_max, "UniformTimeSeries");
} }
PDESolver *PDESolverCreator::Create() {
if (_model == "LagrangeElliptic")
return new EllipticPDESolver(
new LagrangeEllipticAssemble(
new LagrangeDiscretization(meshes, _degree),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "MixedElliptic")
return new EllipticPDESolver(
new MixedEllipticAssemble(
new RTLagrangeDiscretization(meshes, 0, 0),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "HybridElliptic")
return new EllipticPDESolver(
new HybridEllipticAssemble(
new RTLagrangeDiscretization(meshes, 0, 0),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "DGElliptic")
return new EllipticPDESolver(
new DGEllipticAssemble(
new DGDiscretization(meshes, _degree),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "DGTransport")
return new TransportPDESolver(
new DGTransportAssemble(
new DGDiscretization(meshes, _degree),
CreateStochasticTransportProblem(_problem, meshes)
)
);
if (_model == "PGTransport")
return nullptr; // Todo open research question
Exit(_model + " not found")
}
...@@ -79,25 +79,7 @@ public: ...@@ -79,25 +79,7 @@ public:
mout.EndBlock(verbose == 0); mout.EndBlock(verbose == 0);
} }
MatrixGraphs *CreateSolutionMatrixGraphs(Meshes &meshes) { MatrixGraphs *CreateSolutionMatrixGraphs(Meshes &meshes);
auto disc = this->GetDisc();
auto discType = typeid(*disc).name();
if (discType == typeid(LagrangeDiscretization).name())
return new MatrixGraphs(meshes, *disc);
if (discType == typeid(RTLagrangeDiscretization).name()) {
auto assemble = this->GetAssemble();
auto assembleType = typeid(*assemble).name();
if (assembleType == typeid(HybridEllipticAssemble).name())
return new MatrixGraphs(meshes, dof(new FaceDoF(1)));
if (assembleType == typeid(MixedEllipticAssemble).name())
return new MatrixGraphs(meshes, *disc);
}
if (discType == typeid(DGDiscretization).name())
return new CellMatrixGraphs(meshes, *disc);
if (discType == typeid(EGDiscretization).name())
return new CellVertexMatrixGraphs(meshes, *disc);
Exit(string(discType) +" not found")
}
void SetQuantity(const std::string &_quantity) { void SetQuantity(const std::string &_quantity) {
this->quantity = _quantity; this->quantity = _quantity;
...@@ -242,52 +224,7 @@ public: ...@@ -242,52 +224,7 @@ public:
return *this; return *this;
} }
PDESolver *Create() { PDESolver *Create();
if (_model == "LagrangeElliptic")
return new EllipticPDESolver(
new LagrangeEllipticAssemble(
new LagrangeDiscretization(meshes, _degree),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "MixedElliptic")
return new EllipticPDESolver(
new MixedEllipticAssemble(
new RTLagrangeDiscretization(meshes, 0, 0),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "HybridElliptic")
return new EllipticPDESolver(
new HybridEllipticAssemble(
new RTLagrangeDiscretization(meshes, 0, 0),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "DGElliptic")
return new EllipticPDESolver(
new DGEllipticAssemble(
new DGDiscretization(meshes, _degree),
CreateStochasticEllipticProblem(_problem, meshes)
)
);
if (_model == "DGTransport")
return new TransportPDESolver(
new DGTransportAssemble(
new DGDiscretization(meshes, _degree),
CreateStochasticTransportProblem(_problem, meshes)
)
);
if (_model == "PGTransport")
return nullptr; // Todo open research question
Exit(_model + " not found")
}
}; };
#endif //PDESOLVER_HPP #endif //PDESOLVER_HPP
#include "StochasticProblem.hpp" #include "IStochasticProblem.hpp"
#include "generators/CirculantEmbedding.hpp" #include "generators/CirculantEmbedding.hpp"
#include "generators/HybridFluxGenerator.hpp" #include "generators/HybridFluxGenerator.hpp"
......
#ifndef STOCHASTICPROBLEM_HPP #ifndef ISTOCHASTICPROBLEM_HPP
#define STOCHASTICPROBLEM_HPP #define ISTOCHASTICPROBLEM_HPP
#include "Algebra.hpp" #include "Algebra.hpp"
#include "montecarlo/Sample.hpp" #include "montecarlo/Sample.hpp"
......
#ifndef STOCHASTICELLIPTICPROBLEM_HPP #ifndef STOCHASTICELLIPTICPROBLEM_HPP
#define STOCHASTICELLIPTICPROBLEM_HPP #define STOCHASTICELLIPTICPROBLEM_HPP
#include "problem/StochasticProblem.hpp" #include "problem/IStochasticProblem.hpp"
class IStochasticEllipticProblem : public IStochasticProblem { class IStochasticEllipticProblem : public IStochasticProblem {
......
#ifndef STOCHASTICREACTIONPROBLEM_HPP #ifndef STOCHASTICREACTIONPROBLEM_HPP
#define STOCHASTICREACTIONPROBLEM_HPP #define STOCHASTICREACTIONPROBLEM_HPP
#include "StochasticProblem.hpp" #include "IStochasticProblem.hpp"
// Todo rmv // Todo rmv
......
#ifndef MLMC_STOCHASTICTRANSPORTPROBLEM_HPP #ifndef MLMC_STOCHASTICTRANSPORTPROBLEM_HPP
#define MLMC_STOCHASTICTRANSPORTPROBLEM_HPP #define MLMC_STOCHASTICTRANSPORTPROBLEM_HPP
#include "problem/StochasticProblem.hpp" #include "problem/IStochasticProblem.hpp"
class IStochasticTransportProblem : public IStochasticProblem { class IStochasticTransportProblem : public IStochasticProblem {
......
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