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

added initSampleCount and PDESolver

parent 8ac6f891
......@@ -5,12 +5,14 @@ using namespace std;
void MainProgram::Initialize() {
meshes = createMeshes();
disc = createDiscretization();
problem = createStochasticProblem();
assemble = createAssemble();
assemble = createStochasticAssemble();
pdeSolver = createPDESolver();
plotter = new MultilevelPlotter(*meshes);
mlmc = new MultilevelMonteCarlo(initLevels, initSampleAmount, meshes, assemble);
mlmc = new MultilevelMonteCarlo(initSampleCount, meshes, assemble, pdeSolver);
meshes->PrintInfo();
mlmc->PrintInfo();
......@@ -54,11 +56,6 @@ int MainProgram::RunMLMCExperiment() {
}
void MainProgram::checkValues() {
if (verbose == -1) Exit("\nPlease set MainVerbose\n")
if (problemName.empty()) Exit("\nPlease set Problem\n")
if (modelName.empty()) Exit("\nPlease set Model\n")
if (problemName.empty()) Exit("\nPlease set StochasticField\n")
if (experimentName.empty()) Exit("\nPlease set Experiment\n")
if (pLevel == -1) Exit("\nPlease set plevel\n")
if (maxLevel == -1) Exit("\nPlease set maxLevel\n")
if (degree == -1) Exit("\nPlease set degree\n")
......@@ -117,15 +114,15 @@ IStochasticProblem *MainProgram::createStochasticProblem() {
Exit("\nProblem field not found in " + problemName + "\n")
}
IStochasticAssemble * MainProgram::createAssemble() {
IStochasticAssemble *MainProgram::createStochasticAssemble() {
IStochasticEllipticProblem *ellipticProblem =
dynamic_cast<IStochasticEllipticProblem * >(problem);
// IStochasticTransportProblem *transportProblem =
// dynamic_cast<IStochasticTransportProblem * >(problem);
if (ellipticProblem != nullptr) {
if (modelName == "LagrangeFEM")
return new LagrangeEllipticAssemble(disc, ellipticProblem);
if (modelName == "LagrangeFEM")
return new LagrangeEllipticAssemble(disc, ellipticProblem);
if (modelName == "MixedFEM")
return new MixedEllipticAssemble(disc, ellipticProblem);
if (modelName == "HybridFEM")
......@@ -144,3 +141,7 @@ IStochasticAssemble * MainProgram::createAssemble() {
Exit(("\nAssembling for Problem=" + problemName + " with Model=" +
modelName + " not implemented\n"))
}
PDESolver *MainProgram::createPDESolver() {
return new EllipticPDESolver(static_cast<IStochasticEllipticAssemble *>(assemble));
}
......@@ -17,12 +17,12 @@
class MainProgram {
public:
int verbose = 0;
int verbose = 1;
string problemName = "";
string modelName = "";
string fieldName = "";
string experimentName = "";
string problemName;
string modelName;
string fieldName;
string experimentName;
double epsilon = 0.0;
int pLevel = -1;
......@@ -31,6 +31,7 @@ public:
vector<int> initLevels;
vector<int> initSampleAmount;
std::map<int, int> initSampleCount;
int uniformSampleAmount = -1;
Meshes *meshes;
......@@ -38,6 +39,7 @@ public:
IStochasticProblem *problem;
IStochasticAssemble *assemble;
MultilevelMonteCarlo *mlmc;
PDESolver *pdeSolver;
MainProgram() {
config.get("MainVerbose", verbose);
......@@ -53,6 +55,13 @@ public:
config.get("StochasticField", fieldName);
config.get("Experiment", experimentName);
int index = 0;
for(auto &level: initLevels) {
initSampleCount[level] = initSampleAmount[index];
index++;
}
checkValues();
}
......@@ -83,7 +92,9 @@ private:
IStochasticProblem *createStochasticProblem();
IStochasticAssemble * createAssemble();
IStochasticAssemble * createStochasticAssemble();
PDESolver *createPDESolver();
};
#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