Commit 0c4b1521 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

refactored elliptic

parent 98a4a9eb
......@@ -4,35 +4,27 @@
using namespace std;
void MonteCarloElliptic::initialize() {
finePermeability = 0.0, coarsePermeability = 0.0;
fineSolution = 0.0, coarseSolution = 0.0;
fineQ = 0.0, coarseQ = 0.0, fineCost = 0.0, coarseCost = 0.0;
}
void MonteCarloElliptic::method() {
Vector finePerm(cellMatrixGraphs[l - pLevel]);
Vector coarsePerm(cellMatrixGraphs[l - pLevel - 1]);
Vector coarsePermeabilityUp(finePerm);
Vector fineSolution(solMatrixGraphs[l - pLevel]);
Vector coarseSolution(solMatrixGraphs[l - pLevel - 1]);
Vector coarseSolutionUp(fineSolution);
finePerm = 0.0, coarsePerm = 0.0, coarsePermeabilityUp = 0.0;
fineSolution = 0.0, coarseSolution = 0.0, coarseSolutionUp = 0.0;
double fineQ, coarseQ, fineCost, coarseCost;
fineQ = 0.0, coarseQ = 0.0, fineCost = 0.0, coarseCost = 0.0;
for (int m = M; m < M + dM; m++) {
string sampleDirName = mkSampleDirName(m, true);
mkSampleDir(m, sampleDirName);
stochasticField->SetSampleDir(l, sampleDirName);
stochasticField->SetPlot(l, finePlot);
stochasticField->GetFineSample(l, finePerm);
stochasticField->GetFineSample(l, finePermeability);
assemble->sampleDir = sampleDirName;
assemble->plot = finePlot;
assemble->problem->LoadNewSample(&finePerm);
assemble->problem->LoadNewSample(&finePermeability);
mout << finePermeability << endl;
solvePDE(l, 0, true, fineQ, fineCost, fineSolution);
solvePDE(l, m, true, fineQ, fineCost, fineSolution);
if (plotting) assemble->PlotResults(fineSolution);
......@@ -42,18 +34,18 @@ void MonteCarloElliptic::method() {
stochasticField->SetSampleDir(l, sampleDirName);
stochasticField->SetPlot(l, coarsePlot);
stochasticField->GetCoarseSample(l, finePerm, coarsePerm);
stochasticField->GetCoarseSample(l, finePermeability, coarsePermeability);
assemble->sampleDir = sampleDirName;
assemble->plot = coarsePlot;
assemble->problem->LoadNewSample(&coarsePerm);
assemble->problem->LoadNewSample(&coarsePermeability);
solvePDE(l, 0, false, coarseQ, coarseCost, coarseSolution);
if (plotting) assemble->PlotResults(coarseSolution);
} else {
coarseQ = 0.0, coarseCost = 0.0, coarseSolutionUp = 0.0;
coarseQ = 0.0, coarseCost = 0.0;
}
updateSums(fineCost, fineQ - coarseQ, fineQ);
}
......
......@@ -24,6 +24,11 @@ public:
MatrixGraphs cellMatrixGraphs;
MatrixGraphs solMatrixGraphs;
Vector finePermeability;
Vector coarsePermeability;
Vector fineSolution;
Vector coarseSolution;
MonteCarloElliptic(int l,
int dM,
bool onlyFineLevel,
......@@ -34,7 +39,13 @@ public:
MonteCarlo(l, dM, onlyFineLevel, meshes, plots, stochFields),
assemble(assemble),
cellMatrixGraphs(MatrixGraphs(*meshes, dof("cell", 3))),
solMatrixGraphs(MatrixGraphs(*meshes, *assemble->disc)) {
solMatrixGraphs(MatrixGraphs(*meshes, *assemble->disc)),
finePermeability(Vector(cellMatrixGraphs[l - pLevel])),
coarsePermeability(Vector(cellMatrixGraphs[l - pLevel - 1])),
fineSolution(Vector(solMatrixGraphs[l - pLevel])),
coarseSolution(Vector(solMatrixGraphs[l - pLevel - 1])) {
initialize();
}
};
......
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