22 #include <LbmLib/include/reportHandler/vtkForceReporter.hpp>
23 #include <UtilLib/include/Exception.hpp>
24 #include <LbmLib/include/nodes/PhysicalNode.hpp>
25 #include <LbmLib/include/solver/ForceSolver.hpp>
26 #include <LbmLib/include/solver/AbstractForceStruct.hpp>
28 #include <vtkSmartPointer.h>
29 #include <vtkPolyData.h>
31 #include <vtkCellData.h>
32 #include <vtkCellArray.h>
33 #include <vtkUnsignedIntArray.h>
34 #include <vtkMultiBlockDataSet.h>
35 #include <vtkXMLMultiBlockDataWriter.h>
36 #include <vtkXMLMultiBlockDataReader.h>
44 namespace reportHandler {
46 std::stringstream filename;
47 filename <<
filename_ <<
"_" << time <<
".vtm";
49 vtkSmartPointer<vtkMultiBlockDataSet> multiBDS =
50 vtkSmartPointer<vtkMultiBlockDataSet>::New ();
51 vtkSmartPointer<vtkXMLMultiBlockDataReader> reader =
52 vtkSmartPointer<vtkXMLMultiBlockDataReader>::New();
53 vtkSmartPointer<vtkXMLMultiBlockDataWriter> writer =
54 vtkSmartPointer<vtkXMLMultiBlockDataWriter>::New();
55 vtkSmartPointer<vtkPolyData> linePolyData =
56 vtkSmartPointer<vtkPolyData>::New();
57 vtkSmartPointer<vtkPoints> forcepoints =
58 vtkSmartPointer<vtkPoints>::New();
59 vtkSmartPointer<vtkCellArray> lines =
60 vtkSmartPointer<vtkCellArray>::New();
61 std::vector<vtkSmartPointer<vtkLine> > linevector;
62 vtkSmartPointer<vtkUnsignedIntArray> forcetype =
63 vtkSmartPointer<vtkUnsignedIntArray>::New();
64 forcetype->SetNumberOfComponents(1);
65 forcetype->SetName(
"ForceType");
67 LbmLib::solver::map_forcestruct forcemap = this->forcesolver_.
getAllForces();
68 unsigned int pointcounter = 0;
70 for (
auto iterator=forcemap.begin();
71 iterator != forcemap.end();
73 for (
int k=0; k<iterator->second.size();++k) {
74 if (iterator->second[k]->getPartnerGeometryNode() != 0) {
75 forcepoints->InsertNextPoint(this->geometryNodes_.at(iterator->first)->getXPos(),
76 this->geometryNodes_.at(iterator->first)->getYPos(),
78 forcepoints->InsertNextPoint(this->geometryNodes_.at(iterator->second[k]->getPartnerGeometryNode())->getXPos(),
79 this->geometryNodes_.at(iterator->second[k]->getPartnerGeometryNode())->getYPos(),
81 forcetype->InsertNextValue(iterator->second[k]->getType());
82 linevector.push_back(vtkSmartPointer<vtkLine>::New());
83 linevector.back()->GetPointIds()->SetId(0,pointcounter);
84 linevector.back()->GetPointIds()->SetId(1,pointcounter+1);
90 for (
int k=0; k<linevector.size(); ++k) {
91 lines->InsertNextCell(linevector[k]);
95 linePolyData->SetPoints(forcepoints);
96 linePolyData->SetLines(lines);
97 linePolyData->GetCellData()->AddArray(forcetype);
100 reader->SetFileName(filename.str().c_str());
102 if (stat(filename.str().c_str(), &buffer) == 0) {
104 multiBDS->ShallowCopy(reader->GetOutput());
107 multiBDS->SetBlock(multiBDS->GetNumberOfBlocks(),linePolyData);
109 writer->SetFileName(filename.str().c_str());
110 #if VTK_MAJOR_VERSION <= 5
111 writer->SetInput(multiBDS);
113 writer->SetInputData(multiBDS);
116 writer->SetDataModeToAscii();
virtual void operator()(unsigned int time) const
operator() Writes the report
const map_forcestruct getAllForces() const
getAllForces returns the entire map {nodeid, AbstractForceStruct}
const std::string filename_
filename_ Stores the filename of this functor