Observers¶
Header file: <libs/observers/observers.hpp>
[source]
-
template<typename Obs>
concept Observer¶ - #include <observers.hpp>
Concept Observer is all types that have functions for timestepping and observations functions as constrained here.
- tparam Obs:
The type that satisfies the Observer concept.
-
template<Observer Obs1, Observer Obs2>
struct CombinedObserver¶ Structure CombinedObserver represents a new observer formed from combination of two Observers ‘a’ and ‘b’.
- Template Parameters:
Public Functions
-
inline CombinedObserver(const Obs1 obs1, const Obs2 obs2)¶
Construct a new CombinedObserver object.
-
inline void before_timestepping(const viewd_constgbx d_gbxs) const¶
Run before timestepping for combination of 2 observers.
Each observer is run sequentially.
- Parameters:
d_gbxs – The view of gridboxes in device memory.
-
inline void after_timestepping() const¶
Run after timestepping for combination of 2 observers.
Each observer is run sequentially.
-
inline unsigned int next_obs(const unsigned int t_mdl) const¶
Determine the next observation time for combination of 2 observers.
For combination of 2 observers, the next observation time is the smaller out of the two possible.
- Parameters:
t_mdl – The unsigned int parameter.
- Returns:
unsigned int The next observation time.
-
inline bool on_step(const unsigned int t_mdl) const¶
Check if on_step = true for combination of 2 observers.
For combination of 2 observers, return on_step = true if either observer is on_step. Else return false.
- Parameters:
t_mdl – The unsigned int parameter.
- Returns:
bool True if on step, false otherwise.
-
inline void at_start_step(const unsigned int t_mdl, const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const¶
Run at the start of a step for combination of 2 observers.
Each observer is run sequentially.
- Parameters:
t_mdl – The unsigned int parameter.
d_gbxs – The view of gridboxes in device memory.
-
auto operator>>(const Observer auto obs1, const Observer auto obs2)¶
Overloaded operator >> to combine two Observers.
-
struct NullObserver¶
Structure NullObserver does nothing at all.
NullObserver defined for completion of Observer’s Monoid Set.
Public Functions
-
inline void before_timestepping(const viewd_constgbx d_gbxs) const¶
No operations before timestepping.
- Parameters:
d_gbxs – The view of gridboxes in device memory.
-
inline void after_timestepping() const¶
No perations after timestepping.
-
inline unsigned int next_obs(const unsigned int t_mdl) const¶
Next observation time is largest possible value.
- Parameters:
t_mdl – Unsigned int for current timestep.
- Returns:
The next observation time (maximum unsigned int).
-
inline bool on_step(const unsigned int t_mdl) const¶
Check if on step always returns false.
Null observer is never on_step.
- Parameters:
t_mdl – The unsigned int parameter.
- Returns:
bool, always false.
-
inline void at_start_step(const unsigned int t_mdl, const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const¶
No operations at the start of a step.
- Parameters:
t_mdl – The unsigned int for the current timestep.
d_gbxs – The view of gridboxes in device memory.
-
inline void before_timestepping(const viewd_constgbx d_gbxs) const¶
-
template<typename OFs>
concept ObsFuncs¶ - #include <observers.hpp>
Concept ObsFuncs for all types that can be called used by ConstTstepObserver for observation functions.
Type in ConstTstepObserver obeying ObsFuncs makes it possible for ConstTstepObserver to obey Observer concept.
- tparam O:
Type that satisfies the ObsFuncs concept.
-
template<ObsFuncs O>
struct ConstTstepObserver¶ Structure ConstTstepObserver represents a type that satisfies the concept of an observer with a constant timestep interval between observations.
Struct can be used to create an observer with a constant timestep and with observation functionality as determined by the ‘do_obs’ instance of the ObsFuncs type ‘O’.
- Template Parameters:
O – Type that satisfies the ObsFuncs concept.
Public Functions
-
inline ConstTstepObserver(const unsigned int interval, const O o)¶
Construct a new ConstTstepObserver object.
- Parameters:
interval – Timestep interval.
o – Observer.
-
inline void before_timestepping(const viewd_constgbx d_gbxs) const¶
Perform operations before timestepping.
Calls
before_timestepping
function ofdo_obs
.- Parameters:
d_gbxs – The view of gridboxes in device memory.
-
inline void after_timestepping() const¶
Perform operations after timestepping.
Calls
after_timestepping
function ofdo_obs
.
-
inline unsigned int next_obs(const unsigned int t_mdl) const¶
Determine the next observation time.
Calculates the next observation time based on the current model time and this observer’s constant timestep between observations, ‘interval’.
- Parameters:
t_mdl – The unsigned int parameter representing the current model timestep.
- Returns:
Unsigned int for the next observation timestep.
-
inline bool on_step(const unsigned int t_mdl) const¶
Check if observer is “on step”.
Checks if the current model time is on an observation timestep.
- Parameters:
t_mdl – The unsigned int parameter representing the current model timestep.
- Returns:
True if the current timestep is an observation timestep, false otherwise.
-
inline void at_start_step(const unsigned int t_mdl, const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const¶
Perform operations at the start of a step.
Calls
at_start_step
function ofdo_obs
if the current model time is on an observation timestep.- Parameters:
t_mdl – The unsigned int parameter representing the current model time.
d_gbxs – The view of gridboxes in device memory.