Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaxTimestep.hh
Go to the documentation of this file.
1/* Copyright (C) 2015, 2016, 2021 PISM Authors
2 *
3 * This file is part of PISM.
4 *
5 * PISM is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PISM; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef PISM_MAXTIMESTEP_HH
21#define PISM_MAXTIMESTEP_HH
22
23#include <string>
24
25namespace pism {
26
27//! @brief Combines the max. time step with the flag indicating if a
28//! restriction is active. Makes is possible to use the less-than
29//! operator (and `std::min`, etc) to choose the stricter of two
30//! restrictions.
32public:
33 //! @brief Create an instance corresponding to an "inactive"
34 //! time-step restriction (in other words, @f$ \Delta t = \infty @f$).
36 //! Create an instance corresponding to a max time step of `value`.
37 MaxTimestep(double value);
38
39 MaxTimestep(const std::string &new_description);
40 //! Create an instance and provide a description.
41 MaxTimestep(double value, const std::string &new_description);
42 //! Convert to `bool` to check if a time step restriction is "active".
43 bool finite() const;
44 bool infinite() const;
45
46 //! Get the value of the maximum time step.
47 double value() const;
48
49 std::string description() const;
50private:
52 double m_value;
53 std::string m_description;
54};
55
56//! Greater than operator for MaxTimestep.
57bool operator>(const MaxTimestep &a, const MaxTimestep &b);
58
59//! Less than operator for MaxTimestep.
60bool operator<(const MaxTimestep &a, const MaxTimestep &b);
61
62//! Equality operator for MaxTimestep.
63bool operator==(const MaxTimestep &a, const MaxTimestep &b);
64
65} // end of namespace pism
66
67#endif /* PISM_MAXTIMESTEP_HH */
bool infinite() const
MaxTimestep()
Create an instance corresponding to an "inactive" time-step restriction (in other words,...
std::string description() const
bool finite() const
Convert to bool to check if a time step restriction is "active".
std::string m_description
double value() const
Get the value of the maximum time step.
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
bool operator>(const MaxTimestep &a, const MaxTimestep &b)
Greater than operator for MaxTimestep.
bool operator<(const MaxTimestep &a, const MaxTimestep &b)
Less than operator for MaxTimestep.
bool operator==(const MaxTimestep &a, const MaxTimestep &b)
Equality operator for MaxTimestep.