55std::shared_ptr<AnalyticalResults2DToVTKWriterImp>
58 static std::shared_ptr<AnalyticalResults2DToVTKWriterImp>
uniqueInstance;
60 uniqueInstance = std::shared_ptr<AnalyticalResults2DToVTKWriterImp>(
65AnalyticalResults2DToVTKWriterImp::AnalyticalResults2DToVTKWriterImp(
bool writeAnalyticalResults)
66 : writeAnalyticalResults(writeAnalyticalResults)
71 std::shared_ptr<AnalyticalResults> analyticalResult)
73 if (writeAnalyticalResults) {
74 std::cout <<
"Write Analytical Result To VTK-Files" << std::endl;
75 for (
int level = para->getCoarse(); level <= para->getFine(); level++) {
76#pragma omp parallel for
77 for (
int timeStep = 0; timeStep < analyticalResult->getNumberOfTimeSteps(); timeStep++) {
79 std::vector<std::string> fname;
81 analyticalResult->getTimeSteps().at(timeStep) * analyticalResult->getTimeStepLength();
83 std::string filePath = para->getFName();
84 filePath.resize(filePath.size() - 5);
85 fname.push_back(filePath +
"AnalyticalResult/Analytical_cells_bin_lev_" +
86 StringUtil::toString<int>(level) +
"_ID_" +
87 StringUtil::toString<int>(para->getMyProcessID()) +
"_Part_" +
88 StringUtil::toString<int>(
j) +
"_t_" + StringUtil::toString<int>(time) +
".vtk");
90 std::cout <<
"\t Write TimeStep=" << timeStep <<
" t=" << time <<
"...";
91 writeTimeStep(para, analyticalResult, level, fname, timeStep);
92 std::cout <<
"done." << std::endl;
95 std::cout << std::endl;
99void AnalyticalResults2DToVTKWriterImp::writeTimeStep(std::shared_ptr<Parameter> para,
100 std::shared_ptr<AnalyticalResults> analyticalResult,
int level,
101 std::vector<std::string> &fname,
int timeStep)
103 std::vector<UbTupleFloat3> nodes;
104 std::vector<UbTupleUInt8> cells;
120 maxX = para->getGridX().at(level);
121 maxY = para->getGridY().at(level);
122 maxZ = para->getGridZ().at(level);
124 std::vector<double> press = analyticalResult->getPress()[timeStep];
125 std::vector<double> rho = analyticalResult->getRho()[timeStep];
126 std::vector<double> vx = analyticalResult->getVx()[timeStep];
127 std::vector<double> vy = analyticalResult->getVy()[timeStep];
128 std::vector<double> vz = analyticalResult->getVz()[timeStep];
130 for (
unsigned int part = 0; part < fname.size(); part++) {
147 std::cout <<
"BEGIN POS: " <<
pos << std::endl;
148 if (para->getParH(level)->typeOfGridNode[
pos] ==
GEO_FLUID) {
150 double x1 = para->getParH(level)->coordinateX[
pos];
151 double x2 = para->getParH(level)->coordinateY[
pos];
152 double x3 = para->getParH(level)->coordinateZ[
pos];
158 nodes[
dn1] = (
makeUbTuple((
float)(x1), (
float)(x2), (
float)(x3)));
175 std::cout <<
"NeighborIndex1 " <<
number1 << std::endl <<
176 "NeighborIndex2 " <<
number2 << std::endl <<
177 "NeighborIndex3 " <<
number3 << std::endl <<
178 "NeighborIndex4 " <<
number4 << std::endl <<
179 "NeighborIndex5 " <<
number5 << std::endl <<
180 "NeighborIndex6 " <<
number6 << std::endl <<
181 "NeighborIndex7 " <<
number7 << std::endl <<
182 "NeighborIndex8 " <<
number8 << std::endl;
191 std::cout <<
"Neighbor1 " <<
neighbor1 << std::endl <<
192 "Neighbor2 " <<
neighbor2 << std::endl <<
193 "Neighbor3 " <<
neighbor3 << std::endl <<
194 "Neighbor4 " <<
neighbor4 << std::endl <<
195 "Neighbor5 " <<
neighbor5 << std::endl <<
196 "Neighbor6 " <<
neighbor6 << std::endl <<
222 std::cout <<
"END POS: " <<
pos << std::endl;
229int AnalyticalResults2DToVTKWriterImp::CoordResults2DTo1D(
int x,
int z)
231 return z * (maxX - 1) +
x;
static WbWriterVtkXmlBinary * getInstance()
static uint calculateNumberOfParts(uint numberOfNodes)
calculate how many output vtk-files are created for one timestep of the given grid level
static uint calculateStartingPostionOfPart(uint indexOfPart)
static uint calculateNumberOfNodesInPart(uint numberOfNodes, uint indexOfFilePart)
calculate how many grid nodes are written to the file with the given index
static std::shared_ptr< AnalyticalResults2DToVTKWriterImp > getInstance(bool writeAnalyticalResults)
void writeAnalyticalResult(std::shared_ptr< vf::gpu::Parameter > para, std::shared_ptr< AnalyticalResults > analyticalResult)
std::shared_ptr< T > SPtr
UbTuple< T1 > makeUbTuple(T1 const &a1)
std::string writeOctsWithNodeData(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleUInt8 > &cells, std::vector< std::string > &datanames, std::vector< std::vector< double > > &nodedata) override