Alsvinn  0.5.3
The fast FVM simulator with UQ support
StatisticsHelper.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 #include "alsuq/types.hpp"
21 
22 namespace alsuq {
23 namespace stats {
24 
25 class StatisticsHelper : public Statistics {
26 public:
27 
29 
30 
35  void addWriter(const std::string& name,
36  std::shared_ptr<alsfvm::io::Writer>& writer) override;
37 
39  virtual void combineStatistics() override;
40 
41 
42 
44  virtual void writeStatistics(const alsfvm::grid::Grid& grid) override;
45 
46 
47 
48 protected:
49  std::map<real, std::map<std::string, StatisticsSnapshot> > snapshots;
50 
57  StatisticsSnapshot& findOrCreateSnapshot(const std::string& name,
58  const alsfvm::simulator::TimestepInformation& timestepInformation,
59  const alsfvm::volume::Volume& conservedVariables);
60 
65  StatisticsSnapshot& findOrCreateSnapshot(const std::string& name,
66  const alsfvm::simulator::TimestepInformation& timestepInformation,
67  const alsfvm::volume::Volume& conservedVariables,
68  size_t nx, size_t ny, size_t nz, const std::string& platform = "default");
69 
70  void makeOwnGrid(size_t nx, size_t ny, size_t nz);
71 private:
72  size_t samples;
73 
74  std::map<std::string, std::vector<std::shared_ptr<alsfvm::io::Writer> > >
75  writers;
76 
78 
79  std::unique_ptr<alsfvm::grid::Grid> ownGrid{{nullptr}};
80 };
81 } // namespace stats
82 } // namespace alsuq
std::map< real, std::map< std::string, StatisticsSnapshot > > snapshots
Definition: StatisticsHelper.hpp:49
Holds a snapshot (in time) of the current statistics.
Definition: StatisticsSnapshot.hpp:24
Definition: Grid.hpp:27
simulator::SimulatorParameters & parameters
Definition: CellComputerFactory.cpp:60
StatisticsHelper(const StatisticsParameters &parameters)
Definition: StatisticsHelper.cpp:23
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
size_t nx
Definition: VolumeFactory.cpp:87
virtual void combineStatistics() override
Should be called at the end of the simulation.
Definition: StatisticsHelper.cpp:35
alsfvm::shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.hpp:53
std::string name
Definition: EquationParameterFactory.cpp:39
virtual void writeStatistics(const alsfvm::grid::Grid &grid) override
Writes the statistics to file.
Definition: StatisticsHelper.cpp:81
size_t ny
Definition: VolumeFactory.cpp:88
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
Definition: StatisticsParameters.hpp:24
Definition: StatisticsHelper.hpp:25
size_t nz
Definition: VolumeFactory.cpp:89
Definition: Statistics.hpp:25
StatisticsSnapshot & findOrCreateSnapshot(const std::string &name, const alsfvm::simulator::TimestepInformation &timestepInformation, const alsfvm::volume::Volume &conservedVariables)
Definition: StatisticsHelper.cpp:102
void addWriter(const std::string &name, std::shared_ptr< alsfvm::io::Writer > &writer) override
Definition: StatisticsHelper.cpp:30
Definition: Setup.hpp:22
void makeOwnGrid(size_t nx, size_t ny, size_t nz)
Definition: StatisticsHelper.cpp:163
Definition: TimestepInformation.hpp:22