22 #include <LbmLib/include/reportHandler/vtkCDEReporter.hpp>
23 #include <UtilLib/include/Exception.hpp>
24 #include <LbmLib/include/nodes/PhysicalNode.hpp>
25 #include <LbmLib/include/solver/CDESolver/CDEAbstractSolver.hpp>
27 #include <vtkSmartPointer.h>
28 #include <vtkDoubleArray.h>
29 #include <vtkPointData.h>
31 #include <vtkMultiBlockDataSet.h>
32 #include <vtkXMLMultiBlockDataWriter.h>
33 #include <vtkXMLMultiBlockDataReader.h>
34 #include <vtkStructuredPoints.h>
42 namespace reportHandler {
44 std::stringstream filename;
45 filename <<
filename_ <<
"_" << time <<
".vtm";
47 std::vector<solver::CDEAbstractSolver*> cdesolvers;
48 std::map<std::string,vtkSmartPointer<vtkDoubleArray> > cdesolvermap;
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<vtkStructuredPoints> uniformGrid =
56 vtkSmartPointer<vtkStructuredPoints>::New();
58 cdesolvers = this->physicalNodes_[0][0]->getCDESolvers();
59 unsigned int numcdesolvers = cdesolvers.size();
60 for (
auto k=0; k<numcdesolvers; ++k) {
61 cdesolvermap[cdesolvers[k]->getName()] = vtkSmartPointer<vtkDoubleArray>::New();
62 cdesolvermap[cdesolvers[k]->getName()]->SetNumberOfComponents(1);
63 cdesolvermap[cdesolvers[k]->getName()]->SetName(cdesolvers[k]->getName().c_str());
66 unsigned int xLatticeSize = (
unsigned int)(this->physicalNodes_[0].size()/this->cdecoarseningfactor_);
67 unsigned int yLatticeSize = (
unsigned int)(this->physicalNodes_.size()/this->cdecoarseningfactor_);
70 uniformGrid->SetDimensions(xLatticeSize,yLatticeSize,1);
71 uniformGrid->SetOrigin(0,0,0);
72 uniformGrid->SetSpacing(this->cdecoarseningfactor_,
73 this->cdecoarseningfactor_,
74 this->cdecoarseningfactor_);
76 for (
auto ity=0; ity<this->physicalNodes_.size(); ity+=this->cdecoarseningfactor_) {
77 for (
auto itx=0; itx<this->physicalNodes_[0].size(); itx+=this->cdecoarseningfactor_) {
78 cdesolvers =this->physicalNodes_[ity][itx]->getCDESolvers();
79 for (
auto k=0; k<numcdesolvers; ++k) {
80 cdesolvermap[cdesolvers[k]->getName()]->InsertNextValue(cdesolvers[k]->getC());
85 for (
auto it : cdesolvermap) {
86 uniformGrid->GetPointData()->AddArray(it.second);
89 reader->SetFileName(filename.str().c_str());
91 if (stat(filename.str().c_str(), &buffer) == 0) {
93 multiBDS->ShallowCopy(reader->GetOutput());
96 multiBDS->SetBlock(multiBDS->GetNumberOfBlocks(),uniformGrid);
98 writer->SetFileName(filename.str().c_str());
99 #if VTK_MAJOR_VERSION <= 5
100 writer->SetInput(multiBDS);
102 writer->SetInputData(multiBDS);
105 writer->SetDataModeToAscii();
virtual void operator()(unsigned int time) const
operator() Writes the report
const std::string filename_
filename_ Stores the filename of this functor