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

adaption to new pdesolver and pdesolver creator -> refactoring

parent 700d8de4
......@@ -17,8 +17,8 @@ void MonteCarlo::Method() {
}
void MonteCarlo::method() {
SampleSolution coarseSolution(solMGraphs, coarseId);
SampleSolution fineSolution(solMGraphs, fineId);
SampleSolution coarseSolution(pdeSolver->MGraphs(), coarseId);
SampleSolution fineSolution(pdeSolver->MGraphs(), fineId);
// int m = ctr.M + ctr.dMComm * PPM->Proc(0);
// for (; m < ctr.M + ctr.dMComm * PPM->Proc(0) + ctr.dMComm; m++) {
for (int m = ctr.M; m < ctr.M + ctr.dMComm; m++) {
......@@ -35,13 +35,3 @@ void MonteCarlo::computeSampleSolution(int m, SampleID &id, SampleSolution &solu
pdeSolver->DrawSample(id);
pdeSolver->Run(solution);
}
void MonteCarlo::readConfigEntries() {
config.get("MCPlotting", plotting);
config.get("MCVerbose", verbose);
config.get("Problem", problemName);
config.get("Model", modelName);
config.get("degree", degree);
}
......@@ -13,12 +13,6 @@ protected:
int plotting = 0;
std::string problemName;
std::string modelName;
int degree = 1;
bool onlyFine = false;
Level level;
......@@ -27,68 +21,53 @@ protected:
PDESolver *pdeSolver;
MatrixGraphs *solMGraphs;
public:
SampleCounter ctr;
Sums sums;
Averages avgs;
Variances vars;
Kurtosis kurtosis;
PDESolverCreator pdeSolverCreator;
MeshesCreator meshesCreator;
SampleID coarseId;
SampleID fineId;
MonteCarlo(Level level, int dM, bool onlyFine) :
level(level), ctr(SampleCounter(dM)), onlyFine(onlyFine) {
readConfigEntries();
// Todo make function problemName -> meshes
if (problemName.find("1D") != string::npos)
meshes = MeshesCreator("Interval").
WithCommSplit(ctr.commSplit).
WithPLevel(level.coarse).
WithLevel(level.fine).
Create();
else if (problemName.find("2D") != string::npos)
meshes = MeshesCreator("Square").
WithCommSplit(ctr.commSplit).
WithPLevel(level.coarse).
WithLevel(level.fine).
Create();
else
meshes = MeshesCreator("Square").
WithCommSplit(ctr.commSplit).
WithPLevel(level.coarse).
WithLevel(level.fine).
Create();
pdeSolver = PDESolverCreator().
WithProblem(problemName).
WithModel(modelName).
WithDegree(degree).
Create(*meshes);
solMGraphs = pdeSolver->CreateSolutionMatrixGraphs(*meshes);
fineId.level = level;
fineId.coarse = false;
coarseId.level = level;
coarseId.coarse = true;
level(level),
onlyFine(onlyFine),
ctr(SampleCounter(dM)),
pdeSolverCreator(PDESolverCreator()),
meshesCreator(MeshesCreator(pdeSolverCreator.GetMeshName()).
WithCommSplit(ctr.commSplit).
WithPLevel(level.coarse).
WithLevel(level.fine)) {
Init();
}
MonteCarlo(Level level, int dM, bool onlyFine,
MeshesCreator meshesCreator, PDESolverCreator pdeCreator) :
level(level), ctr(SampleCounter(dM)), onlyFine(onlyFine) {
level(level),
ctr(SampleCounter(dM)),
onlyFine(onlyFine),
pdeSolverCreator(pdeCreator),
meshesCreator(meshesCreator) {
Init();
}
readConfigEntries();
void Init() {
config.get("MCPlotting", plotting);
config.get("MCVerbose", verbose);
meshes = meshesCreator.Create();
pdeSolver = pdeCreator.Create(*meshes);
solMGraphs = pdeSolver->CreateSolutionMatrixGraphs(*meshes);
pdeSolver = pdeSolverCreator.Create(*meshes);
fineId.level = level;
fineId.coarse = false;
......@@ -97,7 +76,6 @@ public:
}
~MonteCarlo() {
if (!solMGraphs) delete solMGraphs;
if (!pdeSolver) delete pdeSolver;
if (!meshes) delete meshes;
}
......@@ -108,8 +86,6 @@ private:
void method();
void computeSampleSolution(int m, SampleID &id, SampleSolution &solution);
void readConfigEntries();
};
#endif //MLMC_MC_HPP
\ No newline at end of file
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