IODA Bundle
LinearModelId.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_GENERIC_LINEARMODELID_H_
12 #define OOPS_GENERIC_LINEARMODELID_H_
13 
14 #include <string>
15 #include <vector>
16 
17 #include "oops/base/Geometry.h"
18 #include "oops/base/Increment.h"
20 #include "oops/base/State.h"
21 #include "oops/base/Variables.h"
24 #include "oops/util/Duration.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/ObjectCounter.h"
27 #include "oops/util/Printable.h"
28 #include "oops/util/Timer.h"
29 
30 namespace eckit {
31  class Configuration;
32 }
33 
34 namespace oops {
35 
36 /// Encapsulates the linear forecast model.
37 /*!
38  * Generic implementation of the identity linear model.
39  */
40 
41 // -----------------------------------------------------------------------------
42 
43 template <typename MODEL>
44 class LinearModelId : public LinearModelBase<MODEL> {
45  typedef typename MODEL::Increment Increment_;
46  typedef typename MODEL::Geometry Geometry_;
47  typedef typename MODEL::ModelAuxControl ModelAux_;
48  typedef typename MODEL::ModelAuxIncrement ModelAuxIncr_;
49  typedef typename MODEL::State State_;
50 
51  public:
52  static const std::string classname() {return "oops::LinearModelId";}
53 
54  LinearModelId(const Geometry_ &, const eckit::Configuration &);
56 
57 // Set the linearization trajectory
58  void setTrajectory(const State_ &, State_ &, const ModelAux_ &) override;
59 
60 // Run the TL forecast
61  void initializeTL(Increment_ &) const override;
62  void stepTL(Increment_ & dx, const ModelAuxIncr_ &) const override;
63  void finalizeTL(Increment_ &) const override;
64 
65 // Run the AD forecast:
66  void initializeAD(Increment_ &) const override;
67  void stepAD(Increment_ & dx, ModelAuxIncr_ &) const override;
68  void finalizeAD(Increment_ &) const override;
69 
70 // Information and diagnostics
71  const util::Duration & timeResolution() const override {return tstep_;}
72  const oops::Variables & variables() const override {return vars_;}
73  void print(std::ostream &) const override {}
74 
75  private:
76  const util::Duration tstep_;
78 };
79 
80 // =============================================================================
81 
82 template<typename MODEL>
83 LinearModelId<MODEL>::LinearModelId(const Geometry_ &, const eckit::Configuration & tlConf)
84  : tstep_(util::Duration(tlConf.getString("tstep"))), vars_()
85 {
86  Log::trace() << "LinearModelId<MODEL>::LinearModelId" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
91 template<typename MODEL>
93  Log::trace() << "LinearModelId<MODEL>::~LinearModelId" << std::endl;
94 }
95 
96 // -----------------------------------------------------------------------------
97 
98 template<typename MODEL>
100  Log::trace() << "LinearModelId<MODEL>::setTrajectory" << std::endl;
101 }
102 
103 // -----------------------------------------------------------------------------
104 
105 template<typename MODEL>
107  Log::trace() << "LinearModelId<MODEL>::initializeTL" << std::endl;
108 }
109 
110 // -----------------------------------------------------------------------------
111 
112 template<typename MODEL>
114  dx.updateTime(tstep_);
115  Log::trace() << "LinearModelId<MODEL>::stepTL" << std::endl;
116 }
117 
118 // -----------------------------------------------------------------------------
119 
120 template<typename MODEL>
122  Log::trace() << "LinearModelId<MODEL>::finalizeTL" << std::endl;
123 }
124 
125 // -----------------------------------------------------------------------------
126 
127 template<typename MODEL>
129  Log::trace() << "LinearModelId<MODEL>::initializeAD" << std::endl;
130 }
131 
132 // -----------------------------------------------------------------------------
133 
134 template<typename MODEL>
136  dx.updateTime(-tstep_);
137  Log::trace() << "LinearModelId<MODEL>::stepAD" << std::endl;
138 }
139 
140 // -----------------------------------------------------------------------------
141 
142 template<typename MODEL>
144  Log::trace() << "LinearModelId<MODEL>::finalizeAD" << std::endl;
145 }
146 
147 // -----------------------------------------------------------------------------
148 } // namespace oops
149 
150 #endif // OOPS_GENERIC_LINEARMODELID_H_
Geometry class used in oops; subclass of interface class interface::Geometry.
Increment class used in oops.
Base class for encapsulation of the linear forecast model.
Encapsulates the linear forecast model.
Definition: LinearModelId.h:44
const Variables vars_
Definition: LinearModelId.h:77
void initializeAD(Increment_ &) const override
MODEL::Increment Increment_
Definition: LinearModelId.h:45
void stepAD(Increment_ &dx, ModelAuxIncr_ &) const override
const util::Duration tstep_
Definition: LinearModelId.h:76
void finalizeAD(Increment_ &) const override
void setTrajectory(const State_ &, State_ &, const ModelAux_ &) override
Definition: LinearModelId.h:99
MODEL::ModelAuxIncrement ModelAuxIncr_
Definition: LinearModelId.h:48
LinearModelId(const Geometry_ &, const eckit::Configuration &)
Definition: LinearModelId.h:83
void finalizeTL(Increment_ &) const override
const util::Duration & timeResolution() const override
Definition: LinearModelId.h:71
void initializeTL(Increment_ &) const override
const oops::Variables & variables() const override
Definition: LinearModelId.h:72
void print(std::ostream &) const override
Definition: LinearModelId.h:73
void stepTL(Increment_ &dx, const ModelAuxIncr_ &) const override
static const std::string classname()
Definition: LinearModelId.h:52
MODEL::Geometry Geometry_
Definition: LinearModelId.h:46
MODEL::State State_
Definition: LinearModelId.h:49
MODEL::ModelAuxControl ModelAux_
Definition: LinearModelId.h:47
State class used in oops; subclass of interface class interface::State.
void updateTime(const util::Duration &dt)
Updates this Increment's valid time by dt (used in PseudoModel)
The namespace for the main oops code.