Commit 4162ac52 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

Adpated to new Discretization and removed smart pointers

parent 63d1b81d
......@@ -3,10 +3,6 @@
using namespace std;
/*
* Public
*/
void MainProgram::Initialize() {
meshes = createMeshes();
disc = createDiscretization();
......@@ -16,8 +12,8 @@ void MainProgram::Initialize() {
plotter = make_shared<MultilevelPlotter>(*meshes);
mlmc = make_unique<MultilevelMonteCarlo>(initLevels, initSampleAmount,
meshes.get(), stochField.get(),
assemble.get());
meshes, stochField,
assemble);
meshes->PrintInfo();
mlmc->PrintInfo();
......@@ -84,46 +80,32 @@ void MainProgram::checkValues() {
"\nLast element of initLevels has to be smaller or equal to maxLevel\n")
}
shared_ptr<Meshes> MainProgram::createMeshes() {
Meshes *MainProgram::createMeshes() {
if (problemName.find("1D") != string::npos)
return make_shared<Meshes>("Line", pLevel, maxLevel);
return new Meshes("Line", pLevel, maxLevel);
if (problemName.find("2D") != string::npos)
return make_shared<Meshes>("UnitSquare", pLevel, maxLevel);
return new Meshes("UnitSquare", pLevel, maxLevel);
if (problemName == "StochasticInitialConditions2D") // Todo Refactor
return make_shared<Meshes>("ComparisonSquare.geo", pLevel, maxLevel);
return new Meshes("ComparisonSquare.geo", pLevel, maxLevel);
Exit("\nMesh not found in " + problemName + "\n")
}
shared_ptr<IDiscretizationT<>> MainProgram::createDiscretization() {
if (modelName == "LagrangeFEM") {
if (degree == 1)
return make_shared<DiscretizationT<>>(*meshes, "P1");
if (degree == 2)
return make_shared<DiscretizationT<>>(*meshes, "P2");
}
if (modelName == "MixedFEM" || modelName == "HybridFEM") {
return make_shared<DiscretizationT<>>(*meshes, "RT0_P0");
}
if (modelName == "DGFEM" || modelName == "DGTransport") {
if (degree == 0)
return make_shared<DGDiscretization>(*meshes, "DG_P0");
if (degree == 1)
return make_shared<DGDiscretization>(*meshes, "DG_P1");
if (degree == 2)
return make_shared<DGDiscretization>(*meshes, "DG_P2");
}
IDiscretization *MainProgram::createDiscretization() {
if (modelName == "LagrangeFEM")
return new LagrangeDiscretization(*meshes, degree);
if (modelName == "MixedFEM" || modelName == "HybridFEM")
return new RTLagrangeDiscretization(*meshes, 0, 0);
if (modelName == "DGFEM" || modelName == "DGTransport")
return new DGDiscretization(*meshes, degree);
Exit("\nDiscretization not found in " + modelName + "\n")
}
shared_ptr<StochasticField> MainProgram::createStochasticField() {
StochasticField *MainProgram::createStochasticField() {
if (problemName.find("Stochastic") != string::npos) {
if (problemName.find("Laplace") != string::npos)
return make_shared<StochasticField>(*(meshes.get()), "CirculantEmbedding");
return new StochasticField(*meshes, "CirculantEmbedding");
if (problemName.find("Pollution") != string::npos)
return make_shared<StochasticField>(*(meshes.get()), "HybridFluxGenerator");
return new StochasticField (*meshes, "HybridFluxGenerator");
if (problemName.find("Initial")) {
return nullptr; // Todo
}
......@@ -131,67 +113,62 @@ shared_ptr<StochasticField> MainProgram::createStochasticField() {
if (problemName.find("Deterministic") != string::npos) {
if (problemName.find("Laplace") != string::npos)
return make_shared<StochasticField>(
*(meshes.get()), "DeterministicPermeabilityGenerator");
return new StochasticField(
*meshes, "DeterministicPermeabilityGenerator");
if (problemName.find("Pollution") != string::npos)
return make_shared<StochasticField>(
*(meshes.get()), "DeterministicHybridFluxGenerator");
return new StochasticField(
*meshes, "DeterministicHybridFluxGenerator");
}
Exit("\nStochastic field not found in " + problemName + "\n")
}
shared_ptr<StochasticProblem> MainProgram::createStochasticProblem() {
StochasticProblem *MainProgram::createStochasticProblem() {
if (problemName.find("StochasticLaplace1D") != string::npos ||
problemName.find("DeterministicLaplace1D") != string::npos)
return make_shared<StochasticLaplace1D>();
return new StochasticLaplace1D();
if (problemName.find("StochasticLaplace2D") != string::npos ||
problemName.find("DeterministicLaplace2D") != string::npos)
return make_shared<StochasticLaplace2D>();
return new StochasticLaplace2D();
if (problemName.find("StochasticPollution1D") != string::npos ||
problemName.find("DeterministicPollution1D") != string::npos)
return make_shared<StochasticPollution1D>();
return new StochasticPollution1D();
if (problemName.find("StochasticPollutionCosHat1D") != string::npos ||
problemName.find("DeterministicPollutionCosHat1D") != string::npos)
return make_shared<StochasticPollutionCosHat1D>();
return new StochasticPollutionCosHat1D();
if (problemName.find("StochasticPollution2D") != string::npos ||
problemName.find("DeterministicPollution2D") != string::npos)
return make_shared<StochasticPollution2D>();
return new StochasticPollution2D();
if (problemName.find("StochasticPollutionCosHat2D") != string::npos ||
problemName.find("DeterministicPollutionCosHat2D") != string::npos)
return make_shared<StochasticPollutionCosHat2D>();
return new StochasticPollutionCosHat2D();
if (problemName.find("StochasticPollutionMollifiedBar2D") != string::npos ||
problemName.find("DeterministicPollutionMollifiedBar2D") != string::npos)
return make_shared<StochasticPollutionMollifiedBar2D>();
return new StochasticPollutionMollifiedBar2D();
if (problemName.find("StochasticInitialConditions2D") != string::npos)
return nullptr;
Exit("\nProblem field not found in " + problemName + "\n")
}
shared_ptr<IAssemble> MainProgram::createAssemble() {
shared_ptr<StochasticEllipticProblem> ellipticProblem =
dynamic_pointer_cast<StochasticEllipticProblem>(problem);
shared_ptr<StochasticTransportProblem> transportProblem =
dynamic_pointer_cast<StochasticTransportProblem>(problem);
IAssemble *MainProgram::createAssemble() {
StochasticEllipticProblem *ellipticProblem =
dynamic_cast<StochasticEllipticProblem * >(problem);
StochasticTransportProblem *transportProblem =
dynamic_cast<StochasticTransportProblem * >(problem);
if (ellipticProblem != nullptr) {
if (modelName == "LagrangeFEM")
return std::make_shared<LagrangeEllipticAssemble>(disc.get(), ellipticProblem.get());
return new LagrangeEllipticAssemble(disc, ellipticProblem);
if (modelName == "MixedFEM")
return std::make_shared<MixedEllipticAssemble>(disc.get(),
ellipticProblem.get());
return new MixedEllipticAssemble(disc, ellipticProblem);
if (modelName == "HybridFEM")
return std::make_shared<HybridEllipticAssemble>(disc.get(),
ellipticProblem.get());
return new HybridEllipticAssemble(disc, ellipticProblem);
if (modelName == "DGFEM")
return std::make_shared<DGEllipticAssemble>(disc.get(),
ellipticProblem.get());
return new DGEllipticAssemble(disc, ellipticProblem);
}
if (transportProblem != nullptr) {
if (modelName == "DGTransport")
return std::make_shared<DGTransportAssemble>(disc.get(),
transportProblem.get(),
nullptr);
return new DGTransportAssemble(disc, transportProblem, nullptr);
if (modelName == "PGTransport")
return nullptr; // Todo open research question
}
......
......@@ -34,12 +34,11 @@ public:
vector<int> initSampleAmount;
int uniformSampleAmount = -1;
shared_ptr<Meshes> meshes;
shared_ptr<IDiscretizationT<>> disc;
shared_ptr<StochasticField> stochField;
shared_ptr<StochasticProblem> problem;
shared_ptr<IAssemble> assemble;
Meshes *meshes;
IDiscretization *disc;
StochasticField *stochField;
StochasticProblem *problem;
IAssemble *assemble;
unique_ptr<MultilevelMonteCarlo> mlmc;
......@@ -60,6 +59,14 @@ public:
checkValues();
}
~MainProgram() {
delete meshes;
delete disc;
delete stochField;
delete problem;
delete assemble;
}
void Initialize();
int Run();
......@@ -67,19 +74,20 @@ public:
int RunConvergenceTest();
int RunMLMCExperiment();
private:
void checkValues();
shared_ptr<Meshes> createMeshes();
Meshes *createMeshes();
shared_ptr<IDiscretizationT<>> createDiscretization();
IDiscretization *createDiscretization();
shared_ptr<StochasticField> createStochasticField();
StochasticField *createStochasticField();
shared_ptr<StochasticProblem> createStochasticProblem();
StochasticProblem *createStochasticProblem();
shared_ptr<IAssemble> createAssemble();
IAssemble *createAssemble();
};
#endif //MLMC_MLMCMAIN_H
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