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

added print info and sample getter

parent 12a6d5ea
......@@ -5,10 +5,10 @@
template<typename Sample>
SampleGenerator<Sample> *IStochasticProblemT<Sample>
::createGenerator(int l, GeneratorName generatorName) {
if (generatorName == "CirculantEmbedding1D")
::createGenerator(int l, GeneratorName genName) {
if (genName == "CirculantEmbedding1D")
return new CirculantEmbedding1D(l, meshes);
if (generatorName == "CirculantEmbedding2D")
if (genName == "CirculantEmbedding2D")
return new CirculantEmbedding2D(l, meshes);
// if (generatorName == "HybridFluxGenerator1D")
// return new HybridFluxGenerator1D(l, meshes);
......
......@@ -4,6 +4,7 @@
#include "Algebra.h"
#include "montecarlo/SampleID.hpp"
#include "stochastics/SampleGenerator.hpp"
#include "main/Utils.hpp"
typedef std::string GeneratorName;
......@@ -13,29 +14,35 @@ typedef std::vector<GeneratorName> GeneratorNames;
template<typename Sample=Vector>
class IStochasticProblemT {
private:
SampleGenerator<Sample> *createGenerator(int l, GeneratorName generatorName);
int verbose = 1;
GeneratorNames genNames;
SampleGenerator<Sample> *createGenerator(int l, GeneratorName genName);
Meshes &meshes;
Meshes &meshes; // Todo: should be removed at some point
protected:
typedef std::map<int, std::vector<SampleGenerator<Sample> *>> SampleGenerators;
SampleGenerators generators;
Sample *fineSample = nullptr;
Sample *coarseSample = nullptr;
public:
IStochasticProblemT(GeneratorNames generatorNames, Meshes &meshes) :
meshes(meshes) {
IStochasticProblemT(GeneratorNames genNames, Meshes &meshes) :
genNames(genNames), meshes(meshes) {
config.get("problemVerbose", verbose);
for (int l = meshes.pLevel(); l <= meshes.Level(); l++)
for (auto &name : generatorNames)
for (auto &name : genNames)
generators[l].push_back(createGenerator(l, name));
}
virtual ~IStochasticProblemT() {
delete fineSample;
delete coarseSample;
if (fineSample) delete fineSample;
if (coarseSample) delete coarseSample;
for (auto &[level, gens]: generators)
for (auto &gen : gens)
delete gen;
......@@ -47,7 +54,19 @@ public:
gens->DrawSample(id, fineSample, coarseSample);
}
virtual void PrintInfo() const {}; // Todo make pure virtual at some point
virtual void PrintInfo() const {
mout.PrintInfo("Stochastic Problem", verbose,
PrintInfoEntry("Problem Name", Name()),
PrintInfoEntry("Generators", vec2str(genNames)));
};
Sample *GetFineSample() {
return fineSample;
}
Sample *GetCoarseSample() {
return coarseSample;
}
virtual string Name() const = 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