Alsvinn  0.5.3
The fast FVM simulator with UQ support
FixedIntervalStatistics.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
19 #include "alsuq/types.hpp"
20 namespace alsuq {
21 namespace stats {
22 
28 public:
29 
36  FixedIntervalStatistics(alsfvm::shared_ptr<Statistics>& writer,
37  real timeInterval, real endTime, bool writeInitialTimestep = true);
38 
39 
40  virtual real adjustTimestep(real dt,
41  const alsfvm::simulator::TimestepInformation& timestepInformation) const
42  override;
43 
45  virtual void combineStatistics() override;
46 
51  virtual void addWriter(const std::string& name,
52  std::shared_ptr<alsfvm::io::Writer>& writer) override;
53 
56  virtual std::vector<std::string> getStatisticsNames() const override;
57 
58  void writeStatistics(const alsfvm::grid::Grid& grid) override;
59 
60 
63  virtual void finalizeStatistics() override;
64 
65 protected:
66  virtual void computeStatistics(const alsfvm::volume::Volume& conservedVariables,
67  const alsfvm::grid::Grid& grid,
68  const alsfvm::simulator::TimestepInformation& timestepInformation) override;
69 
70 private:
71  alsfvm::shared_ptr<Statistics> statistics;
72  const real timeInterval;
73  const real endTime;
74  size_t numberSaved = 0;
75  const bool writeInitialTimestep;
76 
77 };
78 } // namespace stats
79 } // namespace alsuq
Definition: FixedIntervalStatistics.hpp:26
virtual void addWriter(const std::string &name, std::shared_ptr< alsfvm::io::Writer > &writer) override
Definition: FixedIntervalStatistics.cpp:47
Definition: Grid.hpp:27
virtual std::vector< std::string > getStatisticsNames() const override
Definition: FixedIntervalStatistics.cpp:52
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
virtual void finalizeStatistics() override
Definition: FixedIntervalStatistics.cpp:60
double real
Definition: types.hpp:65
virtual void computeStatistics(const alsfvm::volume::Volume &conservedVariables, const alsfvm::grid::Grid &grid, const alsfvm::simulator::TimestepInformation &timestepInformation) override
Definition: FixedIntervalStatistics.cpp:64
virtual real adjustTimestep(real dt, const alsfvm::simulator::TimestepInformation &timestepInformation) const override
adjustTimestep returns the new timestep that the simulator should use
Definition: FixedIntervalStatistics.cpp:33
std::string name
Definition: EquationParameterFactory.cpp:39
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
void writeStatistics(const alsfvm::grid::Grid &grid) override
Definition: FixedIntervalStatistics.cpp:56
FixedIntervalStatistics(alsfvm::shared_ptr< Statistics > &writer, real timeInterval, real endTime, bool writeInitialTimestep=true)
Definition: FixedIntervalStatistics.cpp:22
The TimestepAdjuster class is an abstract interface for adjusting timesteps.
Definition: TimestepAdjuster.hpp:31
Definition: Statistics.hpp:25
virtual void combineStatistics() override
To be called when the statistics should be combined.
Definition: FixedIntervalStatistics.cpp:43
Definition: Setup.hpp:22
Definition: TimestepInformation.hpp:22