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

made SampleID const reference and used new Level class

parent 5a4ae929
......@@ -10,7 +10,7 @@ public:
HybridEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem)
: MixedEllipticAssemble(disc, problem) {}
virtual void DrawSample(SampleID id) override {
virtual void DrawSample(const SampleID &id) override {
problem->DrawSample(id);
};
......
......@@ -26,7 +26,7 @@ public:
void Jacobi(const cell &c, const Vector &u, Matrix &A) const override = 0;
virtual void DrawSample(SampleID id) = 0;
virtual void DrawSample(const SampleID &id) = 0;
virtual IDiscretization *GetDisc() = 0;
......
......@@ -16,7 +16,7 @@ public:
IStochasticAssemble(), problem(problem) {
};
void DrawSample(SampleID id) override {
void DrawSample(const SampleID &id) override {
problem->DrawSample(id);
}
......
......@@ -14,7 +14,7 @@ public:
IStochasticAssemble(), problem(problem) {
};
void DrawSample(SampleID id) override {
void DrawSample(const SampleID &id) override {
problem->DrawSample(id);
}
......
......@@ -45,7 +45,7 @@ public:
virtual IDiscretization *GetDisc() = 0;
virtual void DrawSample(SampleID id) = 0;
virtual void DrawSample(const SampleID &id) = 0;
virtual IStochasticAssemble *GetAssemble() = 0;
};
......@@ -78,7 +78,7 @@ public:
return assemble->GetDisc();
}
void DrawSample(SampleID id) override {
void DrawSample(const SampleID &id) override {
assemble->DrawSample(id);
}
......
......@@ -39,7 +39,7 @@ public:
generators.clear();
};
void DrawSample(SampleID id) {
void DrawSample(const SampleID &id) {
for (auto &gen : generators)
gen.second->DrawSample(id);
}
......
......@@ -4,7 +4,7 @@
void CirculantEmbedding1D::generateFineSample(SampleID id,
Vector *&fineSample,
Vector *&coarseSample) {
fineSample = new Vector(cellMGraphs[id.level - this->meshes.pLevel()]);
fineSample = new Vector(cellMGraphs[id.level.mGfine]);
if (internalCounter == 0)
fineComplexField = generateField();
......@@ -33,7 +33,7 @@ void CirculantEmbedding1D::generateFineSample(SampleID id,
void CirculantEmbedding1D::generateCoarseSample(SampleID id,
Vector *&fineSample,
Vector *&coarseSample) {
coarseSample = new Vector(cellMGraphs[id.level - this->meshes.pLevel() - 1]);
coarseSample = new Vector(cellMGraphs[id.level.mGcoarse]);
(*coarseSample) = 0;
for (cell c = coarseSample->cells(); c != coarseSample->cells_end(); c++) {
......@@ -160,7 +160,7 @@ SqrtEigenValues1D CirculantEmbedding1D::computeSqrtEV() {
void CirculantEmbedding2D::generateFineSample(SampleID id,
Vector *&fineSample,
Vector *&coarseSample) {
fineSample = new Vector(cellMGraphs[id.level - this->meshes.pLevel()]);
fineSample = new Vector(cellMGraphs[id.level.mGfine]);
if (internalCounter == 0)
fineComplexField = generateField();
......@@ -192,7 +192,7 @@ void CirculantEmbedding2D::generateFineSample(SampleID id,
void CirculantEmbedding2D::generateCoarseSample(SampleID id,
Vector *&fineSample,
Vector *&coarseSample) {
coarseSample = new Vector(cellMGraphs[id.level - this->meshes.pLevel() - 1]);
coarseSample = new Vector(cellMGraphs[id.level.mGcoarse]);
*coarseSample = 0;
for (cell c = coarseSample->cells(); c != coarseSample->cells_end(); ++c) {
......
......@@ -180,19 +180,19 @@ private:
Vector *coarseSample = nullptr;
protected:
void drawSample(SampleID id) override {
void drawSample(const SampleID &id) override {
if (!id.coarse) {
circulantEmbeddings[id.level]->generateFineSample(id, fineSample,
coarseSample);
circulantEmbeddings[id.level.fine]->generateFineSample(id, fineSample,
coarseSample);
if (plotting)
plotter->PlotVector("kappa", *fineSample, 1,
id.level - 1, "CellData");
id.level.coarse, "CellData");
} else {
circulantEmbeddings[id.level]->generateCoarseSample(id, fineSample,
coarseSample);
circulantEmbeddings[id.level.fine]->generateCoarseSample(id, fineSample,
coarseSample);
if (plotting)
plotter->PlotVector("kappa", *coarseSample, 1,
id.level, "CellData");
id.level.fine, "CellData");
}
}
......
......@@ -29,17 +29,17 @@ protected:
Newton *newton;
Meshes &meshes;
void drawSample(SampleID id) override {
void drawSample(const SampleID &id) override {
if (!id.coarse) {
generateFineSample(id);
if (plotting)
plotter->PlotVector("flux", *cellFlux, 3,
id.level, "CellData");
id.level.fine, "CellData");
} else {
generateCoarseSample(id);
if (plotting)
plotter->PlotVector("flux", *cellFlux, 3,
id.level, "CellData");
id.level.coarse, "CellData");
}
}
......@@ -74,9 +74,9 @@ public:
string Name() const override { return "Hybrid Flux Generator"; }
void generateFineSample(SampleID id) {
cellFlux = new Vector(cellMGraphs[id.level - this->meshes.pLevel()]);
faceValues = new Vector(faceMGraphs[id.level - this->meshes.pLevel()]);
faceFlux = new Vector(faceMGraphs[id.level - this->meshes.pLevel()]);
cellFlux = new Vector(cellMGraphs[id.level.mGfine]);
faceValues = new Vector(faceMGraphs[id.level.mGfine]);
faceFlux = new Vector(faceMGraphs[id.level.mGfine]);
assemble->DrawSample(id);
newton->operator()(*assemble, *faceValues);
......@@ -85,9 +85,9 @@ public:
}
void generateCoarseSample(SampleID id) {
cellFlux = new Vector(cellMGraphs[id.level - 1 - this->meshes.pLevel()]);
faceValues = new Vector(faceMGraphs[id.level - 1 - this->meshes.pLevel()]);
faceFlux = new Vector(faceMGraphs[id.level - 1 - this->meshes.pLevel()]);
cellFlux = new Vector(cellMGraphs[id.level.mGcoarse]);
faceValues = new Vector(faceMGraphs[id.level.mGcoarse]);
faceFlux = new Vector(faceMGraphs[id.level.mGcoarse]);
assemble->DrawSample(id);
newton->operator()(*assemble, *faceValues);
......
......@@ -11,7 +11,7 @@ protected:
int verbose = 0;
virtual void drawSample(SampleID id) = 0;
virtual void drawSample(const SampleID &id) = 0;
public:
Meshes &meshes;
......@@ -23,8 +23,8 @@ public:
virtual ~SampleGenerator() {}
void DrawSample(SampleID id) {
mout.StartBlock(Name()); // Todo use Generator Name
void DrawSample(const SampleID &id) {
mout.StartBlock(Name());
vout(1) << id.Str() << endl;
drawSample(id);
mout.EndBlock(verbose == 0);
......
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