22 #include <LbmLib/include/reportHandler/vtkFluidReporter.hpp>
23 #include <UtilLib/include/Exception.hpp>
24 #include <LbmLib/include/nodes/PhysicalNode.hpp>
25 #include <LbmLib/include/solver/CDESolver/CDEAbstractSolver.hpp>
26 #include <LbmLib/include/solver/FluidSolver/FluidSolver.hpp>
27 #include <LbmLib/include/solver/ForceSolver.hpp>
29 #include <vtkSmartPointer.h>
30 #include <vtkDoubleArray.h>
31 #include <vtkPointData.h>
32 #include <vtkMultiBlockDataSet.h>
33 #include <vtkXMLMultiBlockDataWriter.h>
34 #include <vtkXMLMultiBlockDataReader.h>
35 #include <vtkStructuredPoints.h>
43 namespace reportHandler {
45 std::stringstream filename;
46 filename <<
filename_ <<
"_" << time <<
".vtm";
48 vtkSmartPointer<vtkDoubleArray> densityfield =
49 vtkSmartPointer<vtkDoubleArray>::New();
50 vtkSmartPointer<vtkDoubleArray> velocityfield =
51 vtkSmartPointer<vtkDoubleArray>::New();
52 vtkSmartPointer<vtkStructuredPoints> uniformGrid =
53 vtkSmartPointer<vtkStructuredPoints>::New();
54 vtkSmartPointer<vtkMultiBlockDataSet> multiBDS =
55 vtkSmartPointer<vtkMultiBlockDataSet>::New ();
56 vtkSmartPointer<vtkXMLMultiBlockDataReader> reader =
57 vtkSmartPointer<vtkXMLMultiBlockDataReader>::New();
58 vtkSmartPointer<vtkXMLMultiBlockDataWriter> writer =
59 vtkSmartPointer<vtkXMLMultiBlockDataWriter>::New();
61 densityfield->SetNumberOfComponents(1);
62 densityfield->SetName(
"density");
63 velocityfield->SetNumberOfComponents(3);
64 velocityfield->SetName(
"velocity");
66 unsigned int xLatticeSize = (
unsigned int)(this->physicalNodes_[0].size()/this->cdecoarseningfactor_);
67 unsigned int yLatticeSize = (
unsigned int)(this->physicalNodes_.size()/this->cdecoarseningfactor_);
69 uniformGrid->SetDimensions(xLatticeSize,yLatticeSize,1);
70 uniformGrid->SetOrigin(0,0,0);
71 uniformGrid->SetSpacing(this->cdecoarseningfactor_,
72 this->cdecoarseningfactor_,
73 this->cdecoarseningfactor_);
75 for (
auto ity=0; ity<this->physicalNodes_.size(); ity+=this->cdecoarseningfactor_) {
76 for (
auto itx=0; itx<this->physicalNodes_[0].size(); itx+=this->cdecoarseningfactor_) {
77 densityfield->InsertNextValue(this->physicalNodes_[ity][itx]->getFluidSolver().getRho());
78 velocityfield->InsertNextTuple3(this->physicalNodes_[ity][itx]->getFluidSolver().getVelocity().x,
79 this->physicalNodes_[ity][itx]->getFluidSolver().getVelocity().y,
84 uniformGrid->GetPointData()->AddArray(densityfield);
85 uniformGrid->GetPointData()->AddArray(velocityfield);
87 reader->SetFileName(filename.str().c_str());
89 if (stat(filename.str().c_str(), &buffer) == 0) {
91 multiBDS->ShallowCopy(reader->GetOutput());
94 multiBDS->SetBlock(multiBDS->GetNumberOfBlocks(),uniformGrid);
96 writer->SetFileName(filename.str().c_str());
97 #if VTK_MAJOR_VERSION <= 5
98 writer->SetInput(multiBDS);
100 writer->SetInputData(multiBDS);
103 writer->SetDataModeToAscii();
const std::string filename_
filename_ Stores the filename of this functor
virtual void operator()(unsigned int time) const
operator() Writes the report