Commit 07ffc775 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

moved PDESolverCreator, and refactored TestPDESolver.cpp

parent ec6efe55
#include "HybridFluxGenerator.hpp"
#include "pdesolver/PDESolver.hpp"
#include "pdesolver/PDESolverCreator.hpp"
void HybridFaceNormalFluxGenerator::createPDESolver() {
......
......@@ -7,6 +7,7 @@
#include "montecarlo/datastructure/Errors.hpp"
#include "basics/Utilities.hpp"
#include "mesh/MeshesCreator.hpp"
class MultilevelMonteCarlo {
private:
......
add_library(PDESOLVER STATIC
PDESolver.cpp
PDESolverCreator.cpp
assembling/LagrangeEllipticAssemble.cpp
assembling/MixedEllipticAssemble.cpp
assembling/HybridEllipticAssemble.cpp
......
......@@ -109,50 +109,3 @@ TimeSeries TransportPDESolver::createTimeSeries(SampleSolution &solution) {
double h_max = solution.U.GetMesh().MeshWidth().second;
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")
}
......@@ -121,10 +121,12 @@ protected:
void createOtherMatrixGraphs(Meshes &meshes) override;
public:
EllipticPDESolver(IStochasticEllipticAssemble *assemble) :
EllipticPDESolver(IStochasticEllipticAssemble *assemble,
std::string pc="SuperLU",
std::string linearSolver="GMRES") :
PDESolver(),
assemble(assemble),
solver(Solver(GetPC("SuperLU"), "GMRES")),
solver(Solver(GetPC(pc), linearSolver)),
newton(Newton(solver)) {
}
......@@ -201,40 +203,4 @@ public:
}
};
class PDESolverCreator {
private:
std::string _model;
std::string _problem;
std::string _quantity;
int _degree = 1;
Meshes &meshes;
public:
PDESolverCreator(Meshes &meshes) : meshes(meshes) {}
PDESolverCreator WithModel(const std::string &model) {
_model = model;
return *this;
}
PDESolverCreator WithProblem(const std::string &problem) {
_problem = problem;
return *this;
}
PDESolverCreator WithDegree(int degree) {
_degree = degree;
return *this;
}
PDESolverCreator WithQuantity(const std::string &quantity) {
_quantity = quantity;
return *this;
}
PDESolver *Create();
};
#endif //PDESOLVER_HPP
#include "PDESolverCreator.hpp"
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")
}
\ No newline at end of file
#ifndef PDESOLVERCREATOR_HPP
#define PDESOLVERCREATOR_HPP
#include "PDESolver.hpp"
class PDESolverCreator {
private:
std::string _model;
std::string _problem;
std::string _quantity;
std::string _pc;
std::string _linearSolver;
int _degree = 1;
Meshes &meshes;
public:
PDESolverCreator(Meshes &meshes) : meshes(meshes) {}
PDESolverCreator WithModel(const std::string &model) {
_model = model;
return *this;
}
PDESolverCreator WithProblem(const std::string &problem) {
_problem = problem;
return *this;
}
PDESolverCreator WithDegree(int degree) {
_degree = degree;
return *this;
}
PDESolverCreator WithQuantity(const std::string &quantity) {
_quantity = quantity;
return *this;
}
PDESolver *Create();
};
#endif //PDESOLVERCREATOR_HPP
#include "pdesolver/PDESolver.hpp"
#include "pdesolver/PDESolverCreator.hpp"
#include "TestEnvironment.hpp"
......@@ -21,10 +21,7 @@ protected:
SampleID dummyID;
TestPDESolver(const std::string &meshName) {
dummyID.level = Level(6, 0);
dummyID.coarse = false;
dummyID.number = -1;
TestPDESolver(const std::string &meshName) : dummyID(6, 0, false) {
meshes = createTestMeshes(meshName, dummyID.level.pLevel,
dummyID.level.fine);
......
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