Commit 3a2c61f5 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

using plot map with int as index and not Level

parent 5e74948d
#include "PlotMap.hpp"
PlotMap *plotMap;
......@@ -3,7 +3,6 @@
#include "Sample.hpp"
#include "LevelMap.hpp"
#include "Plot.hpp"
#include <sys/stat.h>
......@@ -13,57 +12,67 @@
* Todo make singelton
*/
struct PlotMap : public LevelMap<Plot *> {
struct PlotMap : public std::map<int, Plot *> {
const std::string defaultDir = "data/vtk/";
string currentDir = defaultDir;
string currentDirShort = "";
public:
PlotMap() {};
std::string currentDir = defaultDir;
PlotMap(std::initializer_list<std::pair<Level, Plot *>> plotMap) :
LevelMap<class Plot *>(plotMap) {};
std::string currentDirShort = "";
void UpdateMap(SampleSolution &dataToPlot) {
Update(dataToPlot.id.level, dataToPlot.U.GetMesh());
}
std::string currentFileShort = "";
std::string currentFile = "";
PlotMap() {};
void Update(Level newLevel, const Mesh &mesh) {
PlotMap(std::allocator<std::pair<int, Plot *>> plotMap) :
std::map<int, Plot *>(plotMap) {};
void UpdateMap(int newLevel, const Mesh &mesh) {
if (this->find(newLevel) == this->end())
(*this)[newLevel] = new Plot(mesh);
else
return;
}
int GetLevelInteger(SampleSolution &dataToPlot) {
int level;
if (dataToPlot.id.coarse)
level = dataToPlot.id.level.coarse;
else
level = dataToPlot.id.level.fine;
return level;
}
// Todo refactor
void VtkPlot(SampleSolution &dataToPlot, int dataDim, const string &dataType) {
UpdateDirectory(dataToPlot.id);
UpdateMap(dataToPlot);
if (dataType == "VertexData") { // Todo refactor
(*this)[dataToPlot.id.level]->vertexdata(dataToPlot.U, dataDim);
if (dataDim > 1) // Todo refactor
(*this)[dataToPlot.id.level]->vtk_vertexvector(
currentDirShort + "/" + dataToPlot.name);
int level = GetLevelInteger(dataToPlot);
UpdateDirectory(dataToPlot);
UpdateMap(level, dataToPlot.U.GetMesh());
if (dataType == "VertexData") {
(*this)[level]->vertexdata(dataToPlot.U, dataDim);
if (dataDim > 1)
(*this)[level]->vtk_vertexvector(currentFileShort);
else
(*this)[dataToPlot.id.level]->vtk_vertexdata(
currentDirShort + "/" + dataToPlot.name);
(*this)[level]->vtk_vertexdata(currentFileShort);
}
if (dataType == "CellData") {
(*this)[dataToPlot.id.level]->celldata(dataToPlot.U, dataDim);
(*this)[level]->celldata(dataToPlot.U, dataDim);
if (dataDim > 1)
(*this)[dataToPlot.id.level]->vtk_cellvector(
currentDirShort + "/" + dataToPlot.name);
(*this)[level]->vtk_cellvector(currentFileShort);
else
(*this)[dataToPlot.id.level]->vtk_celldata(
currentDirShort + "/" + dataToPlot.name);
(*this)[level]->vtk_celldata(currentFileShort);
}
}
void UpdateDirectory(SampleID id) {
currentDirShort = id.Str();
void UpdateDirectory(SampleSolution &dataToPlot) {
currentDirShort = dataToPlot.id.Str();
currentDir = defaultDir + currentDirShort;
char *currentDirAsCharArr = const_cast<char *> (currentDir.c_str());
mkdir(currentDirAsCharArr, 0777);
currentFileShort = currentDirShort + "/" + dataToPlot.name;
currentFile = defaultDir + currentFileShort + ".vtk";
}
};
......
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