Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • irmb/VirtualFluids
1 result
Show changes
Commits on Source (11)
...@@ -97,9 +97,7 @@ int main() ...@@ -97,9 +97,7 @@ int main()
// setup gridGenerator // setup gridGenerator
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
auto gridFactory = GridFactory::make(); auto gridBuilder = std::make_shared<MultipleGridBuilder>();
gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT);
auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// compute parameters in lattice units // compute parameters in lattice units
......
...@@ -39,50 +39,78 @@ ...@@ -39,50 +39,78 @@
using namespace std; using namespace std;
/*===============================================================================*/ ofstream createFileStream(const std::string &vtkFilename)
const std::string WbWriterVtkXmlBinary::pvdEndTag = " </Collection>\n</VTKFile>";
/*===============================================================================*/
string WbWriterVtkXmlBinary::writeCollection(const string &filename, const vector<string> &filenames,
const double &timeStep, const bool &sepGroups)
{ {
string vtkfilename = filename + ".pvd"; ofstream outputFileStream(vtkFilename.c_str(), ios::out | ios::binary);
ofstream out(vtkfilename.c_str()); if (!outputFileStream) {
if (!out) { outputFileStream.clear();
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! const std::string path = UbSystem::getPathFromString(vtkFilename);
string path = UbSystem::getPathFromString(vtkfilename); if (!path.empty()) {
if (path.size() > 0) {
UbSystem::makeDirectory(path); UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str()); outputFileStream.open(vtkFilename.c_str(), ios::out | ios::binary);
} }
if (!out) if (!outputFileStream) throw UbException(UB_EXARGS, "couldn't open file " + vtkFilename);
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
} }
return outputFileStream;
}
string endian; void addCollectionHeader(std::ofstream &outputFileStream)
if (UbSystem::isLittleEndian()) {
endian = "LittleEndian"; std::string endian = UbSystem::isLittleEndian() ? "LittleEndian" : "BigEndian";
else outputFileStream << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"" << endian << "\" >" << endl;
endian = "BigEndian"; outputFileStream << " <Collection>" << endl;
out << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"" << endian << "\" >" << endl; }
out << " <Collection>" << endl;
void addCollectionDatasetsForTimeStep(std::ofstream &outputFileStream, const vector<string> &filenames, double timeStep, bool separateGroups)
{
int group = 0, part = 0; int group = 0, part = 0;
for (size_t i = 0; i < filenames.size(); i++) { for (size_t i = 0; i < filenames.size(); i++) {
out << " <DataSet timestep=\"" << timeStep << "\" group=\"" << group << "\" part=\"" << part outputFileStream << " <DataSet timestep=\"" << timeStep << "\" group=\"" << group << "\" part=\"" << part << "\" file=\"" << filenames[i] << "\"/>" << endl;
<< "\" file=\"" << filenames[i] << "\"/>" << endl; if (separateGroups)
if (sepGroups)
group++; group++;
else else
part++; part++;
} }
out << pvdEndTag; }
out.close();
return vtkfilename; std::string getCollectionEndString()
{
return " </Collection>\n</VTKFile>";
}
void finalizeCollectionFile(std::ofstream &outputFileStream)
{
outputFileStream << getCollectionEndString();
outputFileStream.close();
}
std::string WbWriterVtkXmlBinary::writeCollectionForTimeSeries(const std::string &filename,
const std::map<uint, std::vector<std::string>> &filesNamesForTimeSteps, bool separateGroups) const
{
std::string vtkFilename = filename + ".pvd";
ofstream out = createFileStream(vtkFilename);
addCollectionHeader(out);
for (auto [timeStep, filenames]: filesNamesForTimeSteps) {
addCollectionDatasetsForTimeStep(out, filenames, timeStep, separateGroups);
}
finalizeCollectionFile(out);
return vtkFilename;
} }
string WbWriterVtkXmlBinary::writeCollection(const string &filename, const vector<string> &filenames,
const double &timeStep, const bool &separateGroups) const
{
std::string vtkFilename = filename + ".pvd";
ofstream out = createFileStream(vtkFilename);
addCollectionHeader(out);
addCollectionDatasetsForTimeStep(out, filenames, timeStep, separateGroups);
finalizeCollectionFile(out);
return vtkFilename;
}
/*===============================================================================*/ /*===============================================================================*/
string WbWriterVtkXmlBinary::addFilesToCollection(const string &filename, const vector<string> &filenames, string WbWriterVtkXmlBinary::addFilesToCollection(const string &filename, const vector<string> &filenames,
const double &timeStep, const bool &sepGroups) const double &timeStep, const bool &separateGroups) const
{ {
string vtkfilename = filename; string vtkfilename = filename;
fstream test(vtkfilename.c_str(), ios::in); fstream test(vtkfilename.c_str(), ios::in);
...@@ -91,41 +119,31 @@ string WbWriterVtkXmlBinary::addFilesToCollection(const string &filename, const ...@@ -91,41 +119,31 @@ string WbWriterVtkXmlBinary::addFilesToCollection(const string &filename, const
vtkfilename += ".pvd"; vtkfilename += ".pvd";
test.open(vtkfilename.c_str(), ios::in); test.open(vtkfilename.c_str(), ios::in);
if (!test) if (!test)
return this->writeCollection(filename, filenames, timeStep, sepGroups); return this->writeCollection(filename, filenames, timeStep, separateGroups);
} }
fstream out(vtkfilename.c_str(), ios::in | ios::out); fstream out(vtkfilename.c_str(), ios::in | ios::out);
out.seekp(-(int)pvdEndTag.size() - 1, ios_base::end); out.seekp(-(int)getCollectionEndString().size() - 1, ios_base::end);
int group = 0; int group = 0;
for (size_t i = 0; i < filenames.size(); i++) { for (size_t i = 0; i < filenames.size(); i++) {
out << " <DataSet timestep=\"" << timeStep << "\" group=\"" << group << "\" part=\"" << i << "\" file=\"" out << " <DataSet timestep=\"" << timeStep << "\" group=\"" << group << "\" part=\"" << i << "\" file=\""
<< filenames[i] << "\"/>" << endl; << filenames[i] << "\"/>" << endl;
if (sepGroups) if (separateGroups)
group++; group++;
} }
out << pvdEndTag; out << getCollectionEndString();
return vtkfilename; return vtkfilename;
} }
/*===============================================================================*/ /*===============================================================================*/
string WbWriterVtkXmlBinary::writeParallelFile(const string &filename, vector<string> &pieceSources, string WbWriterVtkXmlBinary::writeParallelFile(const string &filename, vector<string> &pieceSources,
vector<string> &pointDataNames, vector<string> &cellDataNames) vector<string> &pointDataNames, vector<string> &cellDataNames) const
{ {
string vtkfilename = filename + ".pvtu"; string vtkfilename = filename + ".pvtu";
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeParallelFile to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeParallelFile to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str()); std::ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str());
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
// VTK FILE // VTK FILE
out << "<?xml version=\"1.0\"?>\n"; out << "<?xml version=\"1.0\"?>\n";
...@@ -160,25 +178,6 @@ string WbWriterVtkXmlBinary::writeParallelFile(const string &filename, vector<st ...@@ -160,25 +178,6 @@ string WbWriterVtkXmlBinary::writeParallelFile(const string &filename, vector<st
/*===============================================================================*/ /*===============================================================================*/
// helper functions
ofstream createFileStream(std::string vtkfilename)
{
ofstream out(vtkfilename.c_str(), ios::out | ios::binary);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
return out;
}
void writeVtkHeader(ofstream &out, int numberOfNodes, int numberOfCells) void writeVtkHeader(ofstream &out, int numberOfNodes, int numberOfCells)
{ {
out << "<?xml version=\"1.0\"?>\n"; out << "<?xml version=\"1.0\"?>\n";
...@@ -286,7 +285,7 @@ void writeCellData(ofstream &out, int bytesPerByteVal, int bytesScalarData, vect ...@@ -286,7 +285,7 @@ void writeCellData(ofstream &out, int bytesPerByteVal, int bytesScalarData, vect
} }
} }
void writeEndOfFile(ofstream &out) void writeEndOfVtkFile(ofstream &out)
{ {
out << "\n</AppendedData>\n"; out << "\n</AppendedData>\n";
out << "</VTKFile>"; out << "</VTKFile>";
...@@ -323,7 +322,7 @@ string WbWriterVtkXmlBinary::writeLines(const string &filename, vector<UbTupleFl ...@@ -323,7 +322,7 @@ string WbWriterVtkXmlBinary::writeLines(const string &filename, vector<UbTupleFl
writeCellConnectivity(out, bytesPerByteVal, bytesCellConnectivity, lines); writeCellConnectivity(out, bytesPerByteVal, bytesCellConnectivity, lines);
writeCellOffsets(out, bytesPerByteVal, bytesCellOffsets, nofCells); writeCellOffsets(out, bytesPerByteVal, bytesCellOffsets, nofCells);
writeCellTypes(out, bytesPerByteVal, bytesCellTypes, nofCells); writeCellTypes(out, bytesPerByteVal, bytesCellTypes, nofCells);
writeEndOfFile(out); writeEndOfVtkFile(out);
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeLines to " << vtkfilename << " - end"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeLines to " << vtkfilename << " - end");
return vtkfilename; return vtkfilename;
...@@ -362,7 +361,7 @@ string WbWriterVtkXmlBinary::writeLinesWithLineData(const string &filename, vect ...@@ -362,7 +361,7 @@ string WbWriterVtkXmlBinary::writeLinesWithLineData(const string &filename, vect
writeCellOffsets(out, bytesPerByteVal, bytesCellOffsets, nofCells); writeCellOffsets(out, bytesPerByteVal, bytesCellOffsets, nofCells);
writeCellTypes(out, bytesPerByteVal, bytesCellTypes, nofCells); writeCellTypes(out, bytesPerByteVal, bytesCellTypes, nofCells);
writeCellData(out, bytesPerByteVal, bytesScalarData, datanames, celldata); writeCellData(out, bytesPerByteVal, bytesScalarData, datanames, celldata);
writeEndOfFile(out); writeEndOfVtkFile(out);
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeLinesWithLineData to " << vtkfilename << " - end"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeLinesWithLineData to " << vtkfilename << " - end");
...@@ -494,17 +493,7 @@ string WbWriterVtkXmlBinary::writeTriangles(const string &filename, vector<UbTup ...@@ -494,17 +493,7 @@ string WbWriterVtkXmlBinary::writeTriangles(const string &filename, vector<UbTup
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeTriangles to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeTriangles to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)triangles.size(); int nofCells = (int)triangles.size();
...@@ -599,17 +588,7 @@ string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string &filename, ...@@ -599,17 +588,7 @@ string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string &filename,
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeTrianglesWithNodeData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeTrianglesWithNodeData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -722,17 +701,7 @@ string WbWriterVtkXmlBinary::writeQuads(const string &filename, vector<UbTupleFl ...@@ -722,17 +701,7 @@ string WbWriterVtkXmlBinary::writeQuads(const string &filename, vector<UbTupleFl
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuads to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuads to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -827,17 +796,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string &filename, vect ...@@ -827,17 +796,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string &filename, vect
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithNodeData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithNodeData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -952,17 +911,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string &filename, vect ...@@ -952,17 +911,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string &filename, vect
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithCellData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithCellData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -1081,17 +1030,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string &filenam ...@@ -1081,17 +1030,7 @@ string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string &filenam
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -1225,17 +1164,7 @@ string WbWriterVtkXmlBinary::writeOctsWithCellData(const string &filename, vecto ...@@ -1225,17 +1164,7 @@ string WbWriterVtkXmlBinary::writeOctsWithCellData(const string &filename, vecto
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOctsWithCellData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOctsWithCellData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -1354,17 +1283,7 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string &filename, vecto ...@@ -1354,17 +1283,7 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string &filename, vecto
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOctsWithNodeData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOctsWithNodeData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -1483,17 +1402,7 @@ string WbWriterVtkXmlBinary::writeOcts(const string &filename, vector<UbTupleFlo ...@@ -1483,17 +1402,7 @@ string WbWriterVtkXmlBinary::writeOcts(const string &filename, vector<UbTupleFlo
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOcts to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeOcts to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
int nofCells = (int)cells.size(); int nofCells = (int)cells.size();
...@@ -1589,17 +1498,7 @@ std::string WbWriterVtkXmlBinary::writeNodes(const std::string &filename, std::v ...@@ -1589,17 +1498,7 @@ std::string WbWriterVtkXmlBinary::writeNodes(const std::string &filename, std::v
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeNodes to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeNodes to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
...@@ -1684,17 +1583,7 @@ std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string &file ...@@ -1684,17 +1583,7 @@ std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string &file
string vtkfilename = filename + getFileExtension(); string vtkfilename = filename + getFileExtension();
UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeNodesWithNodeData to " << vtkfilename << " - start"); UBLOG(logDEBUG1, "WbWriterVtkXmlBinary::writeNodesWithNodeData to " << vtkfilename << " - start");
ofstream out(vtkfilename.c_str(), ios::out | ios::binary); ofstream out = createFileStream(vtkfilename);
if (!out) {
out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
string path = UbSystem::getPathFromString(vtkfilename);
if (path.size() > 0) {
UbSystem::makeDirectory(path);
out.open(vtkfilename.c_str(), ios::out | ios::binary);
}
if (!out)
throw UbException(UB_EXARGS, "couldn't open file " + vtkfilename);
}
int nofNodes = (int)nodes.size(); int nofNodes = (int)nodes.size();
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <string> #include <string>
#include <basics/writer/WbWriter.h> #include <basics/writer/WbWriter.h>
#include <basics/DataTypes.h>
#include "basics_export.h" #include "basics_export.h"
...@@ -69,11 +70,13 @@ public: ...@@ -69,11 +70,13 @@ public:
// write a metafile // write a metafile
std::string writeCollection(const std::string &filename, const std::vector<std::string> &filenames, std::string writeCollection(const std::string &filename, const std::vector<std::string> &filenames,
const double &timestep, const bool &sepGroups); const double &timeStep, const bool &separateGroups) const;
std::string writeCollectionForTimeSeries(const std::string &filename,
const std::map<uint, std::vector<std::string>> &filesNamesForTimeSteps, bool separateGroups) const;
std::string addFilesToCollection(const std::string &filename, const std::vector<std::string> &filenames, std::string addFilesToCollection(const std::string &filename, const std::vector<std::string> &filenames,
const double &timestep, const bool &sepGroups); const double &timeStep, const bool &separateGroups) const;
std::string writeParallelFile(const std::string &filename, std::vector<std::string> &pieceSources, std::string writeParallelFile(const std::string &filename, std::vector<std::string> &pieceSources,
std::vector<std::string> &pointDataNames, std::vector<std::string> &cellDataNames); std::vector<std::string> &pointDataNames, std::vector<std::string> &cellDataNames) const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// nodes // nodes
......
...@@ -54,6 +54,12 @@ std::string makeMedianCollectionFileName(const std::string &prefix, int ID, int ...@@ -54,6 +54,12 @@ std::string makeMedianCollectionFileName(const std::string &prefix, int ID, int
return prefix + "_bin_median" + makeCollectionFileNameEnding(ID, timestep); return prefix + "_bin_median" + makeCollectionFileNameEnding(ID, timestep);
} }
std::string makePvdCollectionFileName(const std::string &prefix, int mpiProcessID)
{
return prefix + "_bin" + "_ID_" + StringUtil::toString<int>(mpiProcessID);
}
void FileWriter::writeInit(std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager) void FileWriter::writeInit(std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager)
{ {
unsigned int timestep = para->getTimestepInit(); unsigned int timestep = para->getTimestepInit();
...@@ -62,6 +68,7 @@ void FileWriter::writeInit(std::shared_ptr<Parameter> para, std::shared_ptr<Cuda ...@@ -62,6 +68,7 @@ void FileWriter::writeInit(std::shared_ptr<Parameter> para, std::shared_ptr<Cuda
writeTimestep(para, timestep, level); writeTimestep(para, timestep, level);
} }
this->fileNamesForCollectionFileTimeSeries[timestep] = this->fileNamesForCollectionFile;
this->writeCollectionFile(para, timestep); this->writeCollectionFile(para, timestep);
if( para->getCalcMedian() ) if( para->getCalcMedian() )
...@@ -73,6 +80,10 @@ void FileWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int tim ...@@ -73,6 +80,10 @@ void FileWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int tim
for (int level = para->getCoarse(); level <= para->getFine(); level++) for (int level = para->getCoarse(); level <= para->getFine(); level++)
writeTimestep(para, timestep, level); writeTimestep(para, timestep, level);
this->fileNamesForCollectionFileTimeSeries[timestep] = this->fileNamesForCollectionFile;
if (timestep == para->getTimestepEnd())
this->writePvdCollectionFileForTimeSeries(*para);
this->writeCollectionFile(para, timestep); this->writeCollectionFile(para, timestep);
if( para->getCalcMedian() ) if( para->getCalcMedian() )
...@@ -98,7 +109,6 @@ void FileWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int tim ...@@ -98,7 +109,6 @@ void FileWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int tim
for(auto fname : fnamesLong) for(auto fname : fnamesLong)
this->fileNamesForCollectionFile.push_back(fname.substr( fname.find_last_of('/') + 1 )); this->fileNamesForCollectionFile.push_back(fname.substr( fname.find_last_of('/') + 1 ));
if (para->getCalcMedian()) if (para->getCalcMedian())
{ {
std::vector<std::string> fnamesMedianLong = writeUnstructuredGridMedianLT(para, level, fnamesMed); std::vector<std::string> fnamesMedianLong = writeUnstructuredGridMedianLT(para, level, fnamesMed);
...@@ -187,6 +197,12 @@ std::string VIRTUALFLUIDS_GPU_EXPORT FileWriter::writeCollectionFileMedian(std:: ...@@ -187,6 +197,12 @@ std::string VIRTUALFLUIDS_GPU_EXPORT FileWriter::writeCollectionFileMedian(std::
return pFileName; return pFileName;
} }
std::string FileWriter::writePvdCollectionFileForTimeSeries(const Parameter &para)
{
const std::string filename = makePvdCollectionFileName(para.getFName(), para.getMyProcessID());
return WbWriterVtkXmlBinary::getInstance()->writeCollectionForTimeSeries(filename, this->fileNamesForCollectionFileTimeSeries, false);
}
std::vector<std::string> FileWriter::writeUnstructuredGridLT(std::shared_ptr<Parameter> para, int level, std::vector<std::string >& fname) std::vector<std::string> FileWriter::writeUnstructuredGridLT(std::shared_ptr<Parameter> para, int level, std::vector<std::string >& fname)
{ {
std::vector< UbTupleFloat3 > nodes; std::vector< UbTupleFloat3 > nodes;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <string> #include <string>
#include <map>
#include "DataWriter.h" #include "DataWriter.h"
...@@ -29,10 +29,14 @@ private: ...@@ -29,10 +29,14 @@ private:
std::string writeCollectionFileMedian( std::shared_ptr<Parameter> para, unsigned int timestep ); std::string writeCollectionFileMedian( std::shared_ptr<Parameter> para, unsigned int timestep );
std::string writePvdCollectionFileForTimeSeries(const Parameter &para);
std::vector<std::string> getNodeDataNames(std::shared_ptr<Parameter> para); std::vector<std::string> getNodeDataNames(std::shared_ptr<Parameter> para);
std::vector<std::string> getMedianNodeDataNames(std::shared_ptr<Parameter> para); std::vector<std::string> getMedianNodeDataNames(std::shared_ptr<Parameter> para);
std::vector< std::string > fileNamesForCollectionFile; std::vector< std::string > fileNamesForCollectionFile;
std::vector< std::string > fileNamesForCollectionFileMedian; std::vector< std::string > fileNamesForCollectionFileMedian;
std::map<uint, std::vector<std::string>> fileNamesForCollectionFileTimeSeries; // key: timeStep, value: fileNames for timeStep
}; };
#endif #endif
\ No newline at end of file
...@@ -1883,7 +1883,7 @@ std::string Parameter::getOutputPrefix() ...@@ -1883,7 +1883,7 @@ std::string Parameter::getOutputPrefix()
{ {
return this->oPrefix; return this->oPrefix;
} }
std::string Parameter::getFName() std::string Parameter::getFName() const
{ {
return this->fname; return this->fname;
} }
...@@ -1955,11 +1955,11 @@ int Parameter::getMaxDev() ...@@ -1955,11 +1955,11 @@ int Parameter::getMaxDev()
{ {
return this->maxdev; return this->maxdev;
} }
int Parameter::getMyProcessID() int Parameter::getMyProcessID() const
{ {
return this->myProcessId; return this->myProcessId;
} }
int Parameter::getNumprocs() int Parameter::getNumprocs() const
{ {
return this->numprocs; return this->numprocs;
} }
......
...@@ -730,11 +730,11 @@ public: ...@@ -730,11 +730,11 @@ public:
int getTimeCalcMedEnd(); int getTimeCalcMedEnd();
int getMaxDev(); int getMaxDev();
//! \returns the ID of the current MPI process //! \returns the ID of the current MPI process
int getMyProcessID(); int getMyProcessID() const;
int getNumprocs(); int getNumprocs() const;
std::string getOutputPath(); std::string getOutputPath();
std::string getOutputPrefix(); std::string getOutputPrefix();
std::string getFName(); std::string getFName() const;
std::string getGridPath(); std::string getGridPath();
std::string getGeometryFileC(); std::string getGeometryFileC();
std::string getGeometryFileM(); std::string getGeometryFileM();
......