MPS-Basic
Loading...
Searching...
No Matches
saver.cpp
Go to the documentation of this file.
1#include "saver.hpp"
2
3namespace fs = std::filesystem;
4
5Saver::Saver(const fs::path& dir, const bool outputVtkInBinary) {
6 this->dir = dir;
7 this->outputVtkInBinary = outputVtkInBinary;
8 fs::create_directories(dir / "prof");
9 fs::create_directories(dir / "vtu");
10 fs::create_directories(dir / "csv");
11};
12
13void Saver::save(const MPS& mps, const double time) {
15
16 std::stringstream profName;
17 profName << "output_" << std::setfill('0') << std::setw(4) << fileNumber << ".prof";
18 fs::path profPath = dir / "prof" / profName.str();
19 exporter.toProf(profPath, time);
20
21 std::stringstream vtuName;
22 vtuName << "output_" << std::setfill('0') << std::setw(4) << fileNumber << ".vtu";
23 fs::path vtuPath = dir / "vtu" / vtuName.str();
25
26 std::stringstream csvName;
27 csvName << "output_" << std::setfill('0') << std::setw(4) << fileNumber << ".csv";
28 fs::path csvPath = dir / "csv" / csvName.str();
29 exporter.toCsv(csvPath, time);
30
31 fileNumber++;
32}
33
35 return fileNumber;
36}
MPS simulation class.
Definition mps.hpp:25
RefValues refValuesForNumberDensity
Reference values for the simulation ( , )
Definition mps.hpp:28
Particles particles
Particles in the simulation.
Definition mps.hpp:31
void setParticles(const Particles &particles)
Set the particles to export to a file. This method is required before exporting.
void toVtu(const std::filesystem::path &path, const double &time, const double &n0ForNumberDensity=1.0, const bool binary=false)
Export the particles to a file in the VTK zlib format.
void toProf(const std::filesystem::path &path, const double &time)
Export the particles to a file in the Prof format.
void toCsv(const std::filesystem::path &path, const double &time)
Export the particles to a file in the CSV format.
double n0
reference value of number density for source term of pressure Poisson equation
Definition refvalues.hpp:10
bool outputVtkInBinary
Definition saver.hpp:22
std::filesystem::path dir
Definition saver.hpp:21
int getFileNumber() const
Definition saver.cpp:34
Saver()=default
int fileNumber
Definition saver.hpp:20
void save(const MPS &mps, const double time)
Definition saver.cpp:13
ParticlesExporter exporter
Definition saver.hpp:19