Commit 309cb3f9 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

refactoring VTKPlot

parent cf222ed4
......@@ -28,13 +28,7 @@ void EllipticPDESolver::computeCost(SampleSolution &solution) {
void EllipticPDESolver::plotSolution(SampleSolution &solution) {
if (!plotting) return;
auto disc = this->GetDisc();
auto typeName = typeid(*disc).name();
if (typeName == typeid(LagrangeDiscretization).name())
plotMap.VtkPlot(solution, 1, "VertexData");
if (typeName == typeid(RTLagrangeDiscretization).name())
plotMap.VtkPlot(solution, 1, "CellData");
// if (typeName == typeid(DGDiscretization).name())
plotMap.VtkPlot(solution);
// Todo plot flux
// const auto d = dof(new CellDoF(3));
......
......@@ -4,6 +4,7 @@
#include "Sample.hpp"
#include "Plot.hpp"
#include "dof/LagrangeDoF.hpp"
#include <sys/stat.h>
......@@ -40,7 +41,7 @@ struct PlotMap : public std::map<int, Plot *> {
return;
}
int GetLevelInteger(SampleSolution &dataToPlot) {
int GetLevelInteger(const SampleSolution &dataToPlot) {
int level;
if (dataToPlot.id.coarse)
level = dataToPlot.id.level.coarse;
......@@ -49,29 +50,38 @@ struct PlotMap : public std::map<int, Plot *> {
return level;
}
// Todo refactor
void VtkPlot(SampleSolution &dataToPlot, int dataDim, const string &dataType) {
string checkData(const SampleSolution &dataToPlot) {
return dataToPlot.U.dof::Name();
}
void VtkPlot(const SampleSolution &dataToPlot) {
string dataType = checkData(dataToPlot);
int level = GetLevelInteger(dataToPlot);
int dataDim = dataToPlot.U.dof::size();
UpdateDirectory(dataToPlot);
UpdateMap(level, dataToPlot.U.GetMesh());
if (dataType == "VertexData") {
if (dataType.find(LagrangeDoF(1).Name()) != -1) {
(*this)[level]->vertexdata(dataToPlot.U, dataDim);
if (dataDim > 1)
(*this)[level]->vtk_vertexvector(currentFileShort);
else
(*this)[level]->vtk_vertexdata(currentFileShort);
return;
}
if (dataType == "CellData") {
if (dataType.find(LagrangeDoF(0).Name()) != -1) {
(*this)[level]->celldata(dataToPlot.U, dataDim);
if (dataDim > 1)
(*this)[level]->vtk_cellvector(currentFileShort);
else
(*this)[level]->vtk_celldata(currentFileShort);
return;
}
Warning(dataType + " is not plottable")
}
void UpdateDirectory(SampleSolution &dataToPlot) {
void UpdateDirectory(const SampleSolution &dataToPlot) {
currentDirShort = dataToPlot.id.Str();
currentDir = defaultDir + currentDirShort;
char *currentDirAsCharArr = const_cast<char *> (currentDir.c_str());
......
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