SPH
Common.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Sph.h"
4 #include <fstream>
5 #include <iostream>
6 
8 
9 static const Path REFERENCE_DIR = Path("/home/pavel/projects/astro/sph/src/cli/problems/reference/");
10 
12 Outcome areFilesIdentical(const Path& path1, const Path& path2);
13 
15 Outcome areFilesApproxEqual(const Path& path1, const Path& path2);
16 
17 void measureRun(const Path& file, Function<void()> run);
18 
19 class ProgressLog : public PeriodicTrigger {
20 public:
21  ProgressLog(const Float period)
22  : PeriodicTrigger(period, 0._f) {
23  std::cout << std::endl;
24  }
25 
26  virtual AutoPtr<ITrigger> action(Storage& UNUSED(storage), Statistics& stats) override {
27  const Float progress = stats.get<Float>(StatisticsId::RELATIVE_PROGRESS);
28  std::cout << int(progress * 100) << "%" << std::endl;
29  return nullptr;
30  }
31 };
32 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
Includes common headers.
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
Object representing a path on a filesystem.
Definition: Path.h:17
Trigger executing given action every period.
Definition: Trigger.h:37
ProgressLog(const Float period)
Definition: Common.h:21
virtual AutoPtr< ITrigger > action(Storage &UNUSED(storage), Statistics &stats) override
Definition: Common.h:26
Object holding various statistics about current run.
Definition: Statistics.h:22
TValue get(const StatisticsId idx) const
Returns value of a statistic.
Definition: Statistics.h:88
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Outcome areFilesIdentical(const Path &path1, const Path &path2)
Checks whether the two files are identical (to the bit).
Definition: Common.cpp:6
void measureRun(const Path &file, Function< void()> run)
Definition: Common.cpp:67
Outcome areFilesApproxEqual(const Path &path1, const Path &path2)
Checks if two .ssf files are almost equal (may have eps-differences in quantities).
Definition: Common.cpp:29