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

fixed multilevelplotter tests and made plotter external object

parent 7c04b095
#include "MultilevelPlotter.hpp"
//MultilevelPlotter *MultilevelPlotter::instance = nullptr;
\ No newline at end of file
std::shared_ptr<MultilevelPlotter> plotter;
......@@ -2,6 +2,7 @@
#define MULTILEVELPLOTTER_HPP
#include "Plot.h"
#include <memory>
//#include "plot/VtuPlot.h"
......@@ -64,4 +65,6 @@ public:
}
};
extern std::shared_ptr<MultilevelPlotter> plotter;
#endif //MULTILEVELPLOTTER_HPP
......@@ -4,80 +4,70 @@
class TestMultilevelPlotter : public ::Test {
protected:
Meshes *meshes;
// MultilevelPlotter *plotter;
shared_ptr<Meshes> meshes;
void SetUp() override {
meshes = new Meshes("UnitSquare", 0, 4);
meshes = make_shared<Meshes>("UnitSquare", 0, 4);
plotter = make_shared<MultilevelPlotter>(*meshes);
// Refactor
logging = new Logging;
logging->initialize();
//// plotter = MultilevelPlotter::GetInstance(*meshes);
// plotter = new MultilevelPlotter(*meshes);
}
void TearDown() override {
// delete meshes;
// delete plotter;
system("rm -rf data/vtk/*");
}
};
//TEST_F(TestMultilevelPlotter, TestSingelton) {
// MultilevelPlotter *secondInstance;
// secondInstance = MultilevelPlotter::GetInstance(*meshes);
// ASSERT_EQ(plotter, secondInstance);
//}
TEST_F(TestMultilevelPlotter, TestVertexData1D) {
// MatrixGraphs vertexMG(*meshes, dof("vertex", 1));
// for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
// Vector vertexData(vertexMG[l]);
// vertexData = 1.0;
// string name = "VertexData1D_" + to_string(l);
// plotter->PlotVector(name, vertexData, 1, l, "VertexData");
// if (PPM->master())
// ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
// }
MatrixGraphs vertexMG(*meshes, dof("vertex", 1));
for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
Vector vertexData(vertexMG[l]);
vertexData = 1.0;
string name = "VertexData1D_" + to_string(l);
plotter->PlotVector(name, vertexData, 1, l, "VertexData");
if (PPM->master())
ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
}
}
//TEST_F(TestMultilevelPlotter, TestVertexData2D) {
// MatrixGraphs vertexMG(*meshes, dof("vertex", 2));
// for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
// Vector vertexData(vertexMG[l]);
// vertexData = 1.0;
// string name = "VertexData2D_" + to_string(l);
// plotter->PlotVector(name, vertexData, 2, l, "VertexData");
// if (PPM->master())
// ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
// }
//}
//
//TEST_F(TestMultilevelPlotter, TestCellData1D) {
// MatrixGraphs cellMG(*meshes, dof("cell", 1));
// for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
// Vector cellData(cellMG[l]);
// cellData = 1.0;
// string name = "CellData1D_" + to_string(l);
// plotter->PlotVector(name, cellData, 1, l, "CellData");
// if (PPM->master())
// ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
// }
//}
//
//TEST_F(TestMultilevelPlotter, TestCellData2D) {
// MatrixGraphs cellMG(*meshes, dof("cell", 2));
// for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
// Vector cellData(cellMG[l]);
// cellData = 1.0;
// string name = "CellData2D_" + to_string(l);
// plotter->PlotVector(name, cellData, 2, l, "CellData");
// if (PPM->master())
// ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
// }
//}
TEST_F(TestMultilevelPlotter, TestVertexData2D) {
MatrixGraphs vertexMG(*meshes, dof("vertex", 2));
for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
Vector vertexData(vertexMG[l]);
vertexData = 1.0;
string name = "VertexData2D_" + to_string(l);
plotter->PlotVector(name, vertexData, 2, l, "VertexData");
if (PPM->master())
ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
}
}
TEST_F(TestMultilevelPlotter, TestCellData1D) {
MatrixGraphs cellMG(*meshes, dof("cell", 1));
for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
Vector cellData(cellMG[l]);
cellData = 1.0;
string name = "CellData1D_" + to_string(l);
plotter->PlotVector(name, cellData, 1, l, "CellData");
if (PPM->master())
ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
}
}
TEST_F(TestMultilevelPlotter, TestCellData2D) {
MatrixGraphs cellMG(*meshes, dof("cell", 2));
for (int l = meshes->pLevel(); l <= meshes->Level(); l++) {
Vector cellData(cellMG[l]);
cellData = 1.0;
string name = "CellData2D_" + to_string(l);
plotter->PlotVector(name, cellData, 2, l, "CellData");
if (PPM->master())
ASSERT_TRUE(FileExists("data/vtk/" + name + ".vtk"));
}
}
int main(int argc, char **argv) {
return MAIN_TEST_WITH_PPM(argc, argv, "../../mlmc/");
......
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