SPH
SsfToOut.cpp
Go to the documentation of this file.
1 
3 #include "Sph.h"
4 #include <iostream>
5 
6 using namespace Sph;
7 
8 int main(int argc, char* argv[]) {
9  if (argc != 2) {
10  std::cout << "Usage: ssftotxt file.ssf" << std::endl;
11  return 0;
12  }
13 
14  BinaryInput input;
15  Storage storage;
16  Statistics stats;
17  Path inputPath(argv[1]);
18  Path outputPath = Path(inputPath).replaceExtension("out");
19 
20  Outcome outcome = input.load(inputPath, storage, stats);
21  if (outcome) {
22  std::cout << "Success" << std::endl;
23  } else {
24  std::cout << "Cannot load binary file:" << std::endl << outcome.error() << std::endl;
25  return -1;
26  }
27 
28  PkdgravOutput output(outputPath, PkdgravParams{});
29  try {
30  output.dump(storage, stats);
31  } catch (const std::exception& e) {
32  std::cout << "Cannot save text file: " << std::endl << e.what() << std::endl;
33  return -2;
34  }
35 
36  return 0;
37 }
Includes common headers.
int main(int argc, char *argv[])
Definition: SsfToOut.cpp:8
INLINE const TError & error() const
Returns the error message.
Definition: Outcome.h:88
Input for the binary file, generated by BinaryOutput.
Definition: Output.h:352
virtual Outcome load(const Path &path, Storage &storage, Statistics &stats) override
Loads data from the file into the storage.
Definition: Output.cpp:718
Object representing a path on a filesystem.
Definition: Path.h:17
Path & replaceExtension(const std::string &newExtension)
Changes the extension of the file.
Definition: Path.cpp:76
Dumps data into a file that can be used as an input for pkdgrav code by Richardson et al.
Definition: Output.h:533
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats) override
Saves data from particle storage into the file.
Definition: Output.cpp:1357
Object holding various statistics about current run.
Definition: Statistics.h:22
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Definition: MemoryPool.h:5