OOPS
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 
18 #include "oops/base/Variables.h"
23 #include "oops/interface/State.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_
LinearModelBase.h
oops
The namespace for the main oops code.
Definition: ErrorCovarianceL95.cc:22
oops::LinearModelId::print
void print(std::ostream &) const override
Definition: LinearModelId.h:73
oops::LinearModelId::Geometry_
MODEL::Geometry Geometry_
Definition: LinearModelId.h:46
oops::LinearModelId::Increment_
MODEL::Increment Increment_
Definition: LinearModelId.h:45
oops::LinearModelId::finalizeAD
void finalizeAD(Increment_ &) const override
Definition: LinearModelId.h:143
oops::LinearModelId::~LinearModelId
~LinearModelId()
Definition: LinearModelId.h:92
oops::LinearModelId::vars_
const Variables vars_
Definition: LinearModelId.h:77
oops::LinearModelId::initializeTL
void initializeTL(Increment_ &) const override
Definition: LinearModelId.h:106
oops::LinearModelId::ModelAuxIncr_
MODEL::ModelAuxIncrement ModelAuxIncr_
Definition: LinearModelId.h:48
oops::LinearModelId::stepAD
void stepAD(Increment_ &dx, ModelAuxIncr_ &) const override
Definition: LinearModelId.h:135
oops::LinearModelId::LinearModelId
LinearModelId(const Geometry_ &, const eckit::Configuration &)
Definition: LinearModelId.h:83
oops::LinearModelId::setTrajectory
void setTrajectory(const State_ &, State_ &, const ModelAux_ &) override
Definition: LinearModelId.h:99
oops::ModelAuxControl
Definition: oops/interface/ModelAuxControl.h:35
oops::LinearModelId::variables
const oops::Variables & variables() const override
Definition: LinearModelId.h:72
oops::LinearModelId::stepTL
void stepTL(Increment_ &dx, const ModelAuxIncr_ &) const override
Definition: LinearModelId.h:113
eckit
Definition: FieldL95.h:22
oops::LinearModelId::tstep_
const util::Duration tstep_
Definition: LinearModelId.h:76
oops::LinearModelId::initializeAD
void initializeAD(Increment_ &) const override
Definition: LinearModelId.h:128
oops::LinearModelId::ModelAux_
MODEL::ModelAuxControl ModelAux_
Definition: LinearModelId.h:47
oops::LinearModelId::timeResolution
const util::Duration & timeResolution() const override
Definition: LinearModelId.h:71
oops::LinearModelId::finalizeTL
void finalizeTL(Increment_ &) const override
Definition: LinearModelId.h:121
oops::LinearModelId
Encapsulates the linear forecast model.
Definition: LinearModelId.h:44
ModelAuxIncrement.h
oops::Geometry
Geometry class used in oops; subclass of interface class above.
Definition: oops/interface/Geometry.h:189
oops::LinearModelBase
Base class for encapsulation of the linear forecast model.
Definition: LinearModelBase.h:53
oops::Increment::updateTime
void updateTime(const util::Duration &dt)
Definition: oops/interface/Increment.h:73
oops::ModelAuxIncrement
Definition: oops/interface/ModelAuxIncrement.h:39
oops::State
Encapsulates the model state.
Definition: CostJbState.h:28
oops::LinearModelId::classname
static const std::string classname()
Definition: LinearModelId.h:52
oops::LinearModelId::State_
MODEL::State State_
Definition: LinearModelId.h:49
State.h
oops::Variables
Definition: oops/base/Variables.h:23
oops::Increment
Increment Class: Difference between two states.
Definition: CostJbState.h:27
util
Definition: ObservationL95.h:32
Variables.h
ModelAuxControl.h
Geometry.h
Increment.h