MPS-Basic
Loading...
Searching...
No Matches
Saver Class Reference

#include <saver.hpp>

Collaboration diagram for Saver:

Public Member Functions

 Saver ()=default
 
 Saver (const std::filesystem::path &dir, const bool binaryFormat)
 
void save (const MPS &mps, const double time)
 
int getFileNumber () const
 

Private Attributes

ParticlesExporter exporter
 
int fileNumber = 0
 
std::filesystem::path dir
 
bool outputVtkInBinary = false
 

Detailed Description

Saver class

This class is responsible for saving the simulation results. It saves the results to the file system. It uses the ParticlesExporter class to export the particles to a file.

Definition at line 17 of file saver.hpp.

Constructor & Destructor Documentation

◆ Saver() [1/2]

Saver::Saver ( )
default

◆ Saver() [2/2]

Saver::Saver ( const std::filesystem::path & dir,
const bool binaryFormat )

Member Function Documentation

◆ save()

void Saver::save ( const MPS & mps,
const double time )

Definition at line 13 of file saver.cpp.

13 {
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}
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 fileNumber
Definition saver.hpp:20
ParticlesExporter exporter
Definition saver.hpp:19
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileNumber()

int Saver::getFileNumber ( ) const

Definition at line 34 of file saver.cpp.

34 {
35 return fileNumber;
36}
Here is the caller graph for this function:

Member Data Documentation

◆ exporter

ParticlesExporter Saver::exporter
private

Definition at line 19 of file saver.hpp.

◆ fileNumber

int Saver::fileNumber = 0
private

Definition at line 20 of file saver.hpp.

◆ dir

std::filesystem::path Saver::dir
private

Definition at line 21 of file saver.hpp.

◆ outputVtkInBinary

bool Saver::outputVtkInBinary = false
private

Definition at line 22 of file saver.hpp.


The documentation for this class was generated from the following files: