OOPS
oops/interface/LinearGetValues.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019-2020 UCAR
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  */
7 
8 #ifndef OOPS_INTERFACE_LINEARGETVALUES_H_
9 #define OOPS_INTERFACE_LINEARGETVALUES_H_
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
16 #include "oops/interface/GeoVaLs.h"
19 #include "oops/interface/State.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/Duration.h"
22 #include "oops/util/ObjectCounter.h"
23 #include "oops/util/Printable.h"
24 #include "oops/util/Timer.h"
25 
26 namespace oops {
27 
28 /// \brief sets trajectory and computes TL and AD for GetValues
29 // -----------------------------------------------------------------------------
30 
31 template <typename MODEL, typename OBS>
32 class LinearGetValues : public util::Printable,
33  private util::ObjectCounter<LinearGetValues<MODEL, OBS> > {
34  typedef typename MODEL::LinearGetValues LinearGetValues_;
40 
41  public:
42  static const std::string classname() {return "oops::LinearGetValues";}
43 
44 /// Constructor, destructor
45  LinearGetValues(const Geometry_ &, const Locations_ &);
46  virtual ~LinearGetValues();
47 
48 /// Interfacing
50  const LinearGetValues_ & lingetvalues() const {return *lingetvalues_;}
51 
52 /// set trajectory for GetValues
53  void setTrajectory(const State_ &, const util::DateTime &, const util::DateTime &,
54  GeoVaLs_ &);
55 /// compute TL of GetValues
56  void fillGeoVaLsTL(const Increment_ &, const util::DateTime &, const util::DateTime &,
57  GeoVaLs_ &) const;
58 /// compute AD of GetValues
59  void fillGeoVaLsAD(Increment_ &, const util::DateTime &, const util::DateTime &,
60  const GeoVaLs_ &) const;
61 
62  private:
63  void print(std::ostream &) const;
64  std::unique_ptr<LinearGetValues_> lingetvalues_;
65 };
66 
67 // =============================================================================
68 /// Constructor, destructor
69 // -----------------------------------------------------------------------------
70 
71 template<typename MODEL, typename OBS>
73  const Locations_ & loc) : lingetvalues_()
74 {
75  Log::trace() << "LinearGetValues<MODEL, OBS>::LinearGetValues starting" << std::endl;
76  util::Timer timer(classname(), "LinearGetValues");
77  lingetvalues_.reset(new LinearGetValues_(resol.geometry(), loc.locations()));
78  Log::trace() << "LinearGetValues<MODEL, OBS>::LinearGetValues done" << std::endl;
79 }
80 
81 // -----------------------------------------------------------------------------
82 
83 template<typename MODEL, typename OBS>
85  Log::trace() << "LinearGetValues<MODEL, OBS>::~LinearGetValues starting" << std::endl;
86  util::Timer timer(classname(), "~LinearGetValues");
87  lingetvalues_.reset();
88  Log::trace() << "LinearGetValues<MODEL, OBS>::~LinearGetValues done" << std::endl;
89 }
90 
91 // -----------------------------------------------------------------------------
92 
93 template<typename MODEL, typename OBS>
94 void LinearGetValues<MODEL, OBS>::setTrajectory(const State_ & state, const util::DateTime & t1,
95  const util::DateTime & t2, GeoVaLs_ & gvals) {
96  Log::trace() << "LinearGetValues<MODEL, OBS>::setTrajectory starting" << std::endl;
97  util::Timer timer(classname(), "setTrajectory");
98  lingetvalues_->setTrajectory(state.state(), t1, t2, gvals.geovals());
99  Log::trace() << "LinearGetValues<MODEL, OBS>::setTrajectory done" << std::endl;
100 }
101 
102 // -----------------------------------------------------------------------------
103 
104 template<typename MODEL, typename OBS>
105 void LinearGetValues<MODEL, OBS>::fillGeoVaLsTL(const Increment_ & inc, const util::DateTime & t1,
106  const util::DateTime & t2, GeoVaLs_ & gvals) const {
107  Log::trace() << "LinearGetValues<MODEL, OBS>::fillGeoVaLsTL starting" << std::endl;
108  util::Timer timer(classname(), "fillGeoVaLsTL");
109  lingetvalues_->fillGeoVaLsTL(inc.increment(), t1, t2, gvals.geovals());
110  Log::trace() << "LinearGetValues<MODEL, OBS>::fillGeoVaLsTL done" << std::endl;
111 }
112 
113 // -----------------------------------------------------------------------------
114 
115 template<typename MODEL, typename OBS>
116 void LinearGetValues<MODEL, OBS>::fillGeoVaLsAD(Increment_ & inc, const util::DateTime & t1,
117  const util::DateTime & t2, const GeoVaLs_ & gvals) const {
118  Log::trace() << "LinearGetValues<MODEL, OBS>::fillGeoVaLsAD starting" << std::endl;
119  util::Timer timer(classname(), "fillGeoVaLsAD");
120  lingetvalues_->fillGeoVaLsAD(inc.increment(), t1, t2, gvals.geovals());
121  Log::trace() << "LinearGetValues<MODEL, OBS>::fillGeoVaLsAD done" << std::endl;
122 }
123 
124 // -----------------------------------------------------------------------------
125 
126 template<typename MODEL, typename OBS>
127 void LinearGetValues<MODEL, OBS>::print(std::ostream & os) const {
128  Log::trace() << "LinearGetValues<MODEL, OBS>::print starting" << std::endl;
129  util::Timer timer(classname(), "print");
130  os << *lingetvalues_;
131  Log::trace() << "LinearGetValues<MODEL, OBS>::print done" << std::endl;
132 }
133 
134 // -----------------------------------------------------------------------------
135 
136 } // namespace oops
137 
138 #endif // OOPS_INTERFACE_LINEARGETVALUES_H_
oops
The namespace for the main oops code.
Definition: ErrorCovarianceL95.cc:22
oops::LinearGetValues::Increment_
Increment< MODEL > Increment_
Definition: oops/interface/LinearGetValues.h:37
oops::GeoVaLs::geovals
const GeoVaLs_ & geovals() const
Interfacing.
Definition: oops/interface/GeoVaLs.h:47
Locations.h
oops::LinearGetValues::lingetvalues
LinearGetValues_ & lingetvalues()
Interfacing.
Definition: oops/interface/LinearGetValues.h:49
oops::LinearGetValues::lingetvalues
const LinearGetValues_ & lingetvalues() const
Definition: oops/interface/LinearGetValues.h:50
oops::LinearGetValues::classname
static const std::string classname()
Definition: oops/interface/LinearGetValues.h:42
oops::LinearGetValues::Locations_
Locations< OBS > Locations_
Definition: oops/interface/LinearGetValues.h:38
oops::LinearGetValues::fillGeoVaLsAD
void fillGeoVaLsAD(Increment_ &, const util::DateTime &, const util::DateTime &, const GeoVaLs_ &) const
compute AD of GetValues
Definition: oops/interface/LinearGetValues.h:116
oops::LinearGetValues::State_
State< MODEL > State_
Definition: oops/interface/LinearGetValues.h:39
oops::State::state
State_ & state()
Interfacing.
Definition: oops/interface/State.h:56
oops::LinearGetValues::~LinearGetValues
virtual ~LinearGetValues()
Definition: oops/interface/LinearGetValues.h:84
oops::LinearGetValues
sets trajectory and computes TL and AD for GetValues
Definition: oops/interface/LinearGetValues.h:33
oops::LinearGetValues::LinearGetValues
LinearGetValues(const Geometry_ &, const Locations_ &)
Constructor, destructor.
Definition: oops/interface/LinearGetValues.h:72
oops::LinearGetValues::setTrajectory
void setTrajectory(const State_ &, const util::DateTime &, const util::DateTime &, GeoVaLs_ &)
set trajectory for GetValues
Definition: oops/interface/LinearGetValues.h:94
oops::LinearGetValues::print
void print(std::ostream &) const
Definition: oops/interface/LinearGetValues.h:127
oops::Increment::increment
Increment_ & increment()
Interfacing.
Definition: oops/interface/Increment.h:65
oops::Geometry
Geometry class used in oops; subclass of interface class above.
Definition: oops/interface/Geometry.h:189
oops::LinearGetValues::LinearGetValues_
MODEL::LinearGetValues LinearGetValues_
Definition: oops/interface/LinearGetValues.h:34
oops::Locations::locations
const Locations_ & locations() const
Interfacing.
Definition: oops/interface/Locations.h:54
oops::State
Encapsulates the model state.
Definition: CostJbState.h:28
State.h
oops::LinearGetValues::Geometry_
Geometry< MODEL > Geometry_
Definition: oops/interface/LinearGetValues.h:35
oops::LinearGetValues::lingetvalues_
std::unique_ptr< LinearGetValues_ > lingetvalues_
Definition: oops/interface/LinearGetValues.h:64
oops::Increment
Increment Class: Difference between two states.
Definition: CostJbState.h:27
oops::Locations
Locations of observations for observation operator.
Definition: oops/interface/Locations.h:36
oops::LinearGetValues::fillGeoVaLsTL
void fillGeoVaLsTL(const Increment_ &, const util::DateTime &, const util::DateTime &, GeoVaLs_ &) const
compute TL of GetValues
Definition: oops/interface/LinearGetValues.h:105
GeoVaLs.h
oops::GeoVaLs
Definition: oops/interface/GeoVaLs.h:32
Geometry.h
oops::Geometry::geometry
const Geometry_ & geometry() const
Interfacing with other oops classes.
Definition: oops/interface/Geometry.h:206
Increment.h
oops::LinearGetValues::GeoVaLs_
GeoVaLs< OBS > GeoVaLs_
Definition: oops/interface/LinearGetValues.h:36