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

added upscaling

parent 6a1abfee
......@@ -22,7 +22,7 @@ Experiment = ConvergenceTest
#Experiment = MLMCExperiment
#Experiment = MLMCOverEpsilon
initLevels = 4, 5
initLevels = 3, 4
initSampleAmount = 0, 1
#l_init = 3, 4, 5
......@@ -101,4 +101,4 @@ rkorder = -2 #Implicit MP-rule
gamma = 0.01
plotPermForTransport = true
\ No newline at end of file
plotPermForTransport = false
\ No newline at end of file
......@@ -43,14 +43,17 @@ void MonteCarloTransport::Method() {
if (!onlyFineLevel) {
stochasticField->GetCoarseSample(l - 1, fineFlux, coarseFlux);
assemble->problem->LoadNewSample(&coarseFlux);
solveTransport(l, false, coarseQ, coarseCost, coarseSolution);
UpscaleSolution(coarseSolution, coarseSolutionUp);
UpscaleFlux(coarseFlux, coarseFluxUp);
if (plotting > 1) {
const char *name = buildString(m, "flux_down");
plot.celldata(coarseFlux, 3);
const char *name = buildString(m, "flux_up");
plot.celldata(coarseFluxUp, 3);
plot.vtk_cellvector(name);
}
solveTransport(l, false, coarseQ, coarseCost, coarseSolution);
} else {
coarseQ = 0.0, coarseCost = 0.0, coarseSolutionUp = 0.0;
}
......
......@@ -4,6 +4,7 @@
#include "MonteCarlo.h"
#include "assemble/DGTransportAssemble.h"
#include "timestepping/TimeIntegrator.h"
#include "timestepping/TimeIntegrator2.h"
class MonteCarloTransport : public MonteCarlo {
......@@ -38,8 +39,9 @@ public:
config.get("startTime", startTime);
config.get("endTime", endTime);
// transfer = new MatrixTransfer(*assemble);
// transfer->Construct((solMatrixGraphs)[l - pLevel], (solMatrixGraphs)[l - pLevel - 1]);
transfer = new MatrixTransfer(*assemble);
transfer->Construct((solMatrixGraphs)[l - pLevel], (solMatrixGraphs)[l - pLevel - 1]);
}
~MonteCarloTransport() {
......@@ -47,6 +49,22 @@ public:
delete transfer;
}
void UpscaleSolution(const Vector &coarseSol, Vector &coarseSolUp) {
coarseSolUp = (*transfer) * coarseSol;
}
static void UpscaleFlux(const Vector &coarseFlux, Vector &coarseFluxUp) {
coarseFluxUp = 0;
for (cell c = coarseFlux.cells(); c != coarseFlux.cells_end(); c++) {
row coarseRow = coarseFlux.find_row(c());
for (int k = 0; k < c.Children(); ++k) {
row fineRow = coarseFluxUp.find_row(c.Child(k));
for (int i = 0; i < fineRow.n(); ++i)
coarseFluxUp(fineRow, i) += coarseFlux(coarseRow, i);
}
}
}
void Method() override;
};
......
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