Commit 7c12a32d authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

refactored SampleGeneratorContainer

parent 2cfcd5dd
Pipeline #148218 failed with stages
in 9 minutes and 44 seconds
#include "SampleGeneratorContainer.hpp"
void SampleGeneratorContainer::init(Meshes &meshes) {
scalarGenerator = new ScalarDummy(meshes);
complexGenerator = new ComplexDummy(meshes);
vectorFieldGenerator = new VectorFieldDummy(meshes);
tensorGenerator = new TensorDummy(meshes);
rVectorGenerator = new RVectorDummy(meshes);
cVectorGenerator = new CVectorDummy(meshes);
rMatrixGenerator = new RMatrixDummy(meshes);
cMatrixGenerator = new CMatrixDummy(meshes);
}
void SampleGeneratorContainer::initWithGenNames(Meshes &meshes, GeneratorNames names) {
void SampleGeneratorContainer::init(Meshes &meshes, GeneratorNames names) {
for (auto const &genName: names) {
if (genName == "NormalDistributionReal")
scalarGenerator = new NormalDistributionReal(meshes);
......@@ -33,7 +22,6 @@ void SampleGeneratorContainer::initWithGenNames(Meshes &meshes, GeneratorNames n
if (genName == "UniformDistributionRVector")
rVectorGenerator = new UniformDistributionRVector(meshes, 2, -1.0, 1.0);
if (genName == "CirculantEmbedding") {
if (meshes.dim() == 1)
tensorGenerator = new CirculantEmbedding1D(meshes);
......@@ -46,12 +34,20 @@ void SampleGeneratorContainer::initWithGenNames(Meshes &meshes, GeneratorNames n
}
void SampleGeneratorContainer::DrawSample(const SampleID &id) {
scalarGenerator->DrawSample(id);
complexGenerator->DrawSample(id);
vectorFieldGenerator->DrawSample(id);
tensorGenerator->DrawSample(id);
rVectorGenerator->DrawSample(id);
cVectorGenerator->DrawSample(id);
rMatrixGenerator->DrawSample(id);
cMatrixGenerator->DrawSample(id);
if (scalarGenerator != nullptr)
scalarGenerator->DrawSample(id);
if (complexGenerator != nullptr)
complexGenerator->DrawSample(id);
if (vectorFieldGenerator != nullptr)
vectorFieldGenerator->DrawSample(id);
if (tensorGenerator != nullptr)
tensorGenerator->DrawSample(id);
if (rVectorGenerator != nullptr)
rVectorGenerator->DrawSample(id);
if (cVectorGenerator != nullptr)
cVectorGenerator->DrawSample(id);
if (rMatrixGenerator != nullptr)
rMatrixGenerator->DrawSample(id);
if (cMatrixGenerator != nullptr)
cMatrixGenerator->DrawSample(id);
}
......@@ -11,35 +11,50 @@
typedef std::vector<std::string> GeneratorNames;
class SampleGeneratorContainer {
void init(Meshes &meshes);
void initWithGenNames(Meshes &meshes, GeneratorNames names);
void init(Meshes &meshes, GeneratorNames names);
public:
SampleGenerator<Scalar> *scalarGenerator;
SampleGenerator<Scalar> *scalarGenerator = nullptr;
SampleGenerator<Complex> *complexGenerator;
SampleGenerator<Complex> *complexGenerator = nullptr;
SampleGenerator<VectorField> *vectorFieldGenerator;
SampleGenerator<VectorField> *vectorFieldGenerator = nullptr;
SampleGenerator<Tensor> *tensorGenerator;
SampleGenerator<Tensor> *tensorGenerator = nullptr;
SampleGenerator<RVector> *rVectorGenerator;
SampleGenerator<RVector> *rVectorGenerator = nullptr;
SampleGenerator<CVector> *cVectorGenerator;
SampleGenerator<CVector> *cVectorGenerator = nullptr;
SampleGenerator<RMatrix> *rMatrixGenerator;
SampleGenerator<RMatrix> *rMatrixGenerator = nullptr;
SampleGenerator<CMatrix> *cMatrixGenerator;
SampleGenerator<CMatrix> *cMatrixGenerator = nullptr;
SampleGeneratorContainer(GeneratorNames names, Meshes &meshes) {
init(meshes);
initWithGenNames(meshes, names);
}
SampleGeneratorContainer(GeneratorNames names, Meshes &meshes) {
init(meshes, names);
}
// todo clean this up
~SampleGeneratorContainer() {
if (scalarGenerator != nullptr)
delete scalarGenerator;
if (complexGenerator != nullptr)
delete complexGenerator;
if (vectorFieldGenerator != nullptr)
delete vectorFieldGenerator;
if (tensorGenerator != nullptr)
delete tensorGenerator;
if (rVectorGenerator != nullptr)
delete rVectorGenerator;
if (cVectorGenerator != nullptr)
delete cVectorGenerator;
if (rMatrixGenerator != nullptr)
delete rMatrixGenerator;
if (cMatrixGenerator != nullptr)
delete cMatrixGenerator;
}
void DrawSample(const SampleID &id);
void DrawSample(const SampleID &id);
};
#endif //SAMPLEGENERATORCONTAINER_HPP
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