SABER
ErrorCovarianceID.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 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 SABER_OOPS_ERRORCOVARIANCEID_H_
9 #define SABER_OOPS_ERRORCOVARIANCEID_H_
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "oops/base/ModelSpaceCovarianceBase.h"
16 #include "oops/base/Variables.h"
17 #include "oops/interface/Geometry.h"
18 #include "oops/interface/Increment.h"
19 #include "oops/interface/State.h"
20 #include "oops/util/Logger.h"
21 #include "oops/util/ObjectCounter.h"
22 #include "oops/util/Printable.h"
23 #include "oops/util/Timer.h"
24 
25 namespace eckit {
26  class LocalConfiguration;
27  class Configuration;
28 }
29 
30 namespace oops {
31  class Variables;
32 }
33 
34 namespace saber {
35 
36 // -------------------------------------------------------------------------------------------------
37 
38 /// Identity model space error covariance
39 
40 template <typename MODEL>
41 class ErrorCovarianceID : public oops::ModelSpaceCovarianceBase<MODEL>,
42  public util::Printable,
43  private util::ObjectCounter<ErrorCovarianceID<MODEL>> {
44  typedef oops::Geometry<MODEL> Geometry_;
45  typedef oops::Increment<MODEL> Increment_;
46  typedef oops::State<MODEL> State_;
47 
48  public:
49  static const std::string classname() {return "saber::ErrorCovarianceID";}
50 
51  ErrorCovarianceID(const Geometry_ &, const oops::Variables &, const eckit::Configuration &,
52  const State_ &, const State_ &);
53  virtual ~ErrorCovarianceID();
54 
55  private:
58 
59  private:
60  void doRandomize(Increment_ &) const override;
61  void doMultiply(const Increment_ &, Increment_ &) const override;
62  void doInverseMultiply(const Increment_ &, Increment_ &) const override;
63  void print(std::ostream &) const override;
64 };
65 
66 // =================================================================================================
67 
68 template<typename MODEL>
69 ErrorCovarianceID<MODEL>::ErrorCovarianceID(const Geometry_ & resol, const oops::Variables & vars,
70  const eckit::Configuration & conf, const State_ & xb,
71  const State_ & fg)
72  : oops::ModelSpaceCovarianceBase<MODEL>(xb, fg, resol, conf)
73 {
74  oops::Log::trace() << "ErrorCovarianceID::ErrorCovarianceID starting" << std::endl;
75  oops::Log::trace() << "ErrorCovarianceID::ErrorCovarianceID done" << std::endl;
76 }
77 
78 // -------------------------------------------------------------------------------------------------
79 
80 template<typename MODEL>
82  oops::Log::trace() << "ErrorCovarianceID<MODEL>::~ErrorCovarianceID starting" << std::endl;
83  util::Timer timer(classname(), "~ErrorCovarianceID");
84  oops::Log::trace() << "ErrorCovarianceID<MODEL>::~ErrorCovarianceID done" << std::endl;
85 }
86 
87 // -------------------------------------------------------------------------------------------------
88 
89 template<typename MODEL>
91  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doRandomize starting" << std::endl;
92  util::Timer timer(classname(), "doRandomize");
93  dx.random();
94  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doRandomize done" << std::endl;
95 }
96 
97 // -------------------------------------------------------------------------------------------------
98 
99 template<typename MODEL>
101  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doMultiply starting" << std::endl;
102  util::Timer timer(classname(), "doMultiply");
103  dxo = dxi;
104  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doMultiply done" << std::endl;
105 }
106 
107 // -------------------------------------------------------------------------------------------------
108 
109 template<typename MODEL>
111  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doInverseMultiply starting" << std::endl;
112  util::Timer timer(classname(), "doInverseMultiply");
113  dxo = dxi;
114  oops::Log::trace() << "ErrorCovarianceID<MODEL>::doInverseMultiply done" << std::endl;
115 }
116 
117 // -------------------------------------------------------------------------------------------------
118 
119 template<typename MODEL>
120 void ErrorCovarianceID<MODEL>::print(std::ostream & os) const {
121  oops::Log::trace() << "ErrorCovarianceID<MODEL>::print starting" << std::endl;
122  util::Timer timer(classname(), "print");
123  os << "ErrorCovarianceID<MODEL> B = I";
124  oops::Log::trace() << "ErrorCovarianceID<MODEL>::print done" << std::endl;
125 }
126 
127 // -------------------------------------------------------------------------------------------------
128 
129 } // namespace saber
130 
131 #endif // SABER_OOPS_ERRORCOVARIANCEID_H_
saber::ErrorCovarianceID::doRandomize
void doRandomize(Increment_ &) const override
Definition: ErrorCovarianceID.h:90
oops
Definition: ErrorCovarianceBUMP.h:33
saber::ErrorCovarianceID::ErrorCovarianceID
ErrorCovarianceID(const Geometry_ &, const oops::Variables &, const eckit::Configuration &, const State_ &, const State_ &)
Definition: ErrorCovarianceID.h:69
saber::ErrorCovarianceID::ErrorCovarianceID
ErrorCovarianceID(const ErrorCovarianceID &)
saber
Definition: type_bump.h:22
saber::ErrorCovarianceID::doInverseMultiply
void doInverseMultiply(const Increment_ &, Increment_ &) const override
Definition: ErrorCovarianceID.h:110
eckit
Definition: type_bump.h:18
saber::ErrorCovarianceID::operator=
ErrorCovarianceID & operator=(const ErrorCovarianceID &)
saber::ErrorCovarianceID::Increment_
oops::Increment< MODEL > Increment_
Definition: ErrorCovarianceID.h:45
saber::ErrorCovarianceID::State_
oops::State< MODEL > State_
Definition: ErrorCovarianceID.h:46
saber::ErrorCovarianceID::Geometry_
oops::Geometry< MODEL > Geometry_
Definition: ErrorCovarianceID.h:44
saber::ErrorCovarianceID::~ErrorCovarianceID
virtual ~ErrorCovarianceID()
Definition: ErrorCovarianceID.h:81
saber::ErrorCovarianceID
Identity model space error covariance.
Definition: ErrorCovarianceID.h:43
saber::ErrorCovarianceID::classname
static const std::string classname()
Definition: ErrorCovarianceID.h:49
saber::ErrorCovarianceID::print
void print(std::ostream &) const override
Definition: ErrorCovarianceID.h:120
saber::ErrorCovarianceID::doMultiply
void doMultiply(const Increment_ &, Increment_ &) const override
Definition: ErrorCovarianceID.h:100