SPH
SsfToScf.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: ssftoscf file.ssf" << std::endl;
11  return 0;
12  }
13 
14  BinaryInput input;
15  Storage storage;
16  Statistics stats;
17  Path inputPath(argv[1]);
18  Expected<BinaryInput::Info> info = input.getInfo(inputPath);
19  if (!info) {
20  std::cout << "Cannot get binary file info: " << std::endl << info.error() << std::endl;
21  return -1;
22  }
23 
24  Outcome outcome = input.load(inputPath, storage, stats);
25  if (outcome) {
26  std::cout << "Success" << std::endl;
27  } else {
28  std::cout << "Cannot load binary file:" << std::endl << outcome.error() << std::endl;
29  return -1;
30  }
31 
32  Path outputPath = inputPath.replaceExtension("scf");
33  CompressedOutput output(outputPath, CompressionEnum::NONE, info->runType.valueOr(RunTypeEnum::SPH));
34  try {
35  output.dump(storage, stats);
36  } catch (const std::exception& e) {
37  std::cout << "Cannot save compressed file: " << std::endl << e.what() << std::endl;
38  return -2;
39  }
40 
41  return 0;
42 }
@ SPH
Main SPH simulation.
Includes common headers.
int main(int argc, char *argv[])
Definition: SsfToScf.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
Expected< Info > getInfo(const Path &path) const
Opens the file and reads header info without reading the rest of the file.
Definition: Output.cpp:814
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats) override
Saves data from particle storage into the file.
Definition: Output.cpp:933
Wrapper of type that either contains a value of given type, or an error message.
Definition: Expected.h:25
const Error & error() const
Returns the error message.
Definition: Expected.h:94
Type valueOr(const Type &other) const
Returns the expected value or given alternative if the object contains unexpected value.
Definition: Expected.h:83
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
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