MCPcopy Create free account
hub / github.com/FreeFem/FreeFem-sources / PvdWriter

Function PvdWriter

plugin/seq/iovtk.cpp:380–418  ·  view source on GitHub ↗

--------------------------------------------------------------------------------// A function to output a .pvd file for ParaView usage when PETSc or HPDDM is used --------------------------------------------------------------------------------//

Source from the content-addressed store, hash-verified

378// A function to output a .pvd file for ParaView usage when PETSc or HPDDM is used
379//--------------------------------------------------------------------------------//
380void PvdWriter(string*& pffname, const int size, const int time, const string base_filename, const string, const string) {
381 std::ostringstream marker;
382 marker << std::setw(to_string(size).length()) << std::setfill('0') << "0";
383 std::string zero;
384 if (size > 1)
385 zero = "_" + marker.str() + ".vtu";
386 else
387 zero = ".vtu";
388 std::string full_filename(*pffname);
389 std::size_t found = full_filename.find(zero);
390 if (found != std::string::npos) {
391 std::string file_without_extension;
392 if (size > 1)
393 file_without_extension = full_filename.substr(0, found - 6 - string(to_string(size)).length());
394 else
395 file_without_extension = full_filename.substr(0, found - 5);
396 ofstream pvd;
397 pvd.open(file_without_extension + (size > 1 ? "_" + to_string(size) : "") + ".pvd");
398 pvd << "<?xml version=\"1.0\"?>\n"
399 "<VTKFile T=\""
400 "" + to_string(time) + ""
401 "\" type=\"Collection\" version=\"0.1\"\n"
402 " byte_order=\"LittleEndian\"\n"
403 " compressor=\"vtkZLibDataCompressor\">\n"
404 " <Collection>\n";
405 for (int t = 0; t < time + 1; ++t) {
406 pvd << " <DataSet timestep=\"" << t << "\" group=\"\" part=\"1\"\n"
407 " file=\""
408 "" + base_filename + ""
409 "_";
410 if(size > 1)
411 pvd << to_string(size) + "_";
412 pvd << std::setw(4) << std::setfill('0') << t;
413 pvd << ".pvtu\"/>\n";
414 }
415 pvd << " </Collection>\n"
416 "</VTKFile>\n";
417 }
418}
419
420void VTU_DATA_ARRAY(FILE *fp, const string &type, const string &name, bool binary) {
421 fprintf(fp, "<DataArray type=\"%s\"", type.c_str( ));

Callers 1

iovtk.cppFile · 0.85

Calls 4

to_stringFunction · 0.70
lengthMethod · 0.45
findMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected