58 return "_ID_" + StringUtil::toString<int>(
ID) +
"_t_" + StringUtil::toString<int>(timestep) +
".vtk";
84 return prefix +
"_bin" +
"_ID_" + StringUtil::toString<int>(mpiProcessID);
88void FileWriter::writeInit(std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager)
90 unsigned int timestep = para->getTimestepInit();
91 for (
int level = para->getCoarse(); level <= para->getFine(); level++) {
92 cudaMemoryManager->cudaCopyPrint(level);
96 this->fileNamesForCollectionFileTimeSeries[timestep] = this->fileNamesForCollectionFile;
97 this->writeCollectionFile(para, timestep);
99 if( para->getCalcMean() )
100 this->writeCollectionFileMean(para, timestep);
105 for (
int level = para->getCoarse(); level <= para->getFine(); level++)
108 this->fileNamesForCollectionFileTimeSeries[timestep] = this->fileNamesForCollectionFile;
109 if (timestep == para->getTimestepEnd())
110 this->writePvdCollectionFileForTimeSeries(*para);
112 this->writeCollectionFile(para, timestep);
114 if( para->getCalcMean() )
115 this->writeCollectionFileMean(para, timestep);
121 std::vector<std::string>
fnames;
126 std::string fname =
makePartFileName(para->getFName(), level, para->getMyProcessID(),
i, timestep);
133 std::vector<std::string>
fnamesLong = writeUnstructuredGridLT(para, level,
fnames);
137 if (para->getCalcMean())
145std::vector<std::string> FileWriter::getNodeDataNames(std::shared_ptr<Parameter> para)
148 std::vector<std::string> nodeDataNames;
149 nodeDataNames.push_back(
"press");
150 nodeDataNames.push_back(
"rho");
151 nodeDataNames.push_back(
"vx1");
152 nodeDataNames.push_back(
"vx2");
153 nodeDataNames.push_back(
"vx3");
154 nodeDataNames.push_back(
"geo");
156 if(para->getDiffOn())
157 nodeDataNames.push_back(
"conc");
159 if(para->getIsBodyForce())
161 nodeDataNames.push_back(
"Fx");
162 nodeDataNames.push_back(
"Fy");
163 nodeDataNames.push_back(
"Fz");
166 if(para->getUseTurbulentViscosity())
168 nodeDataNames.push_back(
"nut");
171 if (para->getCalcTurbulenceIntensity()) {
172 nodeDataNames.push_back(
"vxx");
173 nodeDataNames.push_back(
"vyy");
174 nodeDataNames.push_back(
"vzz");
175 nodeDataNames.push_back(
"vxy");
176 nodeDataNames.push_back(
"vxz");
177 nodeDataNames.push_back(
"vyz");
179 return nodeDataNames;
182std::vector<std::string> FileWriter::getMeanNodeDataNames(std::shared_ptr<Parameter> para)
184 std::vector<std::string> nodeDataNames;
186 if(para->getDiffOn())
187 nodeDataNames.push_back(
"conc");
188 nodeDataNames.push_back(
"pressMed");
189 nodeDataNames.push_back(
"rhoMed");
190 nodeDataNames.push_back(
"vx1Med");
191 nodeDataNames.push_back(
"vx2Med");
192 nodeDataNames.push_back(
"vx3Med");
193 nodeDataNames.push_back(
"geo");
195 return nodeDataNames;
198std::string FileWriter::writeCollectionFile(std::shared_ptr<Parameter> para,
unsigned int timestep)
201 auto nodeDataNames = this->getNodeDataNames(para);
202 std::vector<std::string> cellDataNames;
204 this->fileNamesForCollectionFile.clear();
208std::string FileWriter::writeCollectionFileMean(std::shared_ptr<Parameter> para,
unsigned int timestep)
211 std::vector<std::string> nodeDataNames = getMeanNodeDataNames(para);
212 std::vector<std::string> cellDataNames;
214 this->fileNamesForCollectionFileMean.clear();
218std::string FileWriter::writePvdCollectionFileForTimeSeries(
const Parameter ¶)
224std::vector<std::string> FileWriter::writeUnstructuredGridLT(std::shared_ptr<Parameter> para,
int level, std::vector<std::string >& fname)
226 std::vector< UbTupleFloat3 > nodes;
227 std::vector< UbTupleUInt8 > cells;
228 std::vector< std::string > nodeDataNames = getNodeDataNames(para);
241 if(para->getUseTurbulentViscosity())
dataIndex++;
244 if (para->getCalcTurbulenceIntensity())
dataIndex += 6;
250 unsigned int startPosition;
251 unsigned int endPosition;
253 std::vector< std::vector< double > >
nodeData(nodeDataNames.size());
255 for (
unsigned int part = 0; part < fname.size(); part++)
257 const LBMSimulationParameter& parH = para->getParHostAsReference(level);
266 for (
uint i = 0;
i < (
uint)nodeDataNames.size();
i++)
270 for (
unsigned int pos = startPosition;
pos < endPosition;
pos++) {
273 double x1 = parH.coordinateX[
pos];
274 double x2 = parH.coordinateY[
pos];
275 double x3 = parH.coordinateZ[
pos];
287 if(para->getDiffOn())
290 if(para->getIsBodyForce())
297 if(para->getUseTurbulentViscosity())
302 if (para->getCalcTurbulenceIntensity()) {
334std::vector<std::string> FileWriter::writeUnstructuredGridMeanLT(std::shared_ptr<Parameter> para,
int level, std::vector<std::string >& fname)
338 std::vector< UbTupleFloat3 > nodes;
339 std::vector< UbTupleUInt8 > cells;
341 std::vector< std::string > nodeDataNames = getMeanNodeDataNames(para);
347 unsigned int startPosition;
348 unsigned int endPosition;
350 std::vector< std::vector< double > >
nodeData(nodeDataNames.size());
353 for (
unsigned int part = 0; part < fname.size(); part++)
364 for (
size_t i = 0;
i < nodeDataNames.size();
i++)
368 for (
unsigned int pos = startPosition;
pos < endPosition;
pos++)
370 if (para->getParH(level)->typeOfGridNode[
pos] ==
GEO_FLUID)
373 double x1 = para->getParH(level)->coordinateX[
pos];
374 double x2 = para->getParH(level)->coordinateY[
pos];
375 double x3 = para->getParH(level)->coordinateZ[
pos];
378 dn1 =
pos - startPosition;
381 nodes[
dn1] = (
makeUbTuple((
float)(x1), (
float)(x2), (
float)(x3)));
382 if(para->getDiffOn())
383 nodeData[0][
dn1] = (
double)para->getParH(level)->meanConcentrationOut[
pos];
384 nodeData[
startIndex ][
dn1] = para->getParH(level)->meanPressureOut[
pos] / 3.0f * para->getDensityRatio() * para->getVelocityRatio() * para->getVelocityRatio();
385 nodeData[
startIndex + 1][
dn1] = para->getParH(level)->meanDensityOut[
pos] / 3.0f * para->getDensityRatio() * para->getVelocityRatio() * para->getVelocityRatio();
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
void writeTimestep(std::shared_ptr< Parameter > para, unsigned int timestep) override
void writeInit(std::shared_ptr< Parameter > para, std::shared_ptr< CudaMemoryManager > cudaMemoryManager) override
static void getIndicesOfAllNodesInOct(std::array< uint, 8 > &nodeIndices, uint baseNodeOfOct, const LBMSimulationParameter &parH)
use the neighbor relations to find the indices of all nodes in an oct cell
static bool isPeriodicCell(const LBMSimulationParameter &parH, unsigned int baseNodeOfCell, unsigned int otherNodeInCell)
check whether a grid cell is part of a periodic boundary condition
static std::string makePartFileNameEnding(uint level, int processID, int part, int timestep)
create the ending of the file name for a file part
static void calculateRelativeNodeIndexInPart(std::array< uint, 8 > &relativePositionInPart, const std::array< uint, 8 > &indicesOfOct, uint startPositionOfPart)
calculate the node index relative to the start position of the part
static bool areAllNodesInOctValidForWriting(const std::array< uint, 8 > &indicesOfOct, const LBMSimulationParameter &parH, uint endPositionOfPart)
check if all nodes in an oct are valid to be written into an output file
std::shared_ptr< T > SPtr
UbTuple< T, T, T, T, T, T, T, T > makeUbTupleFromArray(const std::array< T, 8 > &array)
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
std::string writeParallelFile(const std::string &filename, std::vector< std::string > &pieceSources, std::vector< std::string > &pointDataNames, std::vector< std::string > &cellDataNames) const
std::string writeCollectionForTimeSeries(const std::string &filename, const std::map< uint, std::vector< std::string > > &filesNamesForTimeSteps, bool separateGroups) const
std::string makeCollectionFileName(const std::string &prefix, int ID, int timestep)
std::string makeMeanPartFileName(const std::string &prefix, uint level, int ID, int part, int timestep)
std::string makePartFileName(const std::string &prefix, uint level, int ID, int part, int timestep)
std::string makePvdCollectionFileName(const std::string &prefix, int mpiProcessID)
std::string makeMeanCollectionFileName(const std::string &prefix, int ID, int timestep)
std::string makeCollectionFileNameEnding(int ID, int timestep)