SABER
ErrorCovarianceBUMP.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 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_ERRORCOVARIANCEBUMP_H_
9 #define SABER_OOPS_ERRORCOVARIANCEBUMP_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 #include "saber/oops/OoBump.h"
27 
28 namespace eckit {
29  class LocalConfiguration;
30  class Configuration;
31 }
32 
33 namespace oops {
34  class Variables;
35 }
36 
37 namespace saber {
38 
39 // -----------------------------------------------------------------------------
40 
41 /// Model space error covariance with BUMP
42 
43 template <typename MODEL>
44 class ErrorCovarianceBUMP : public oops::ModelSpaceCovarianceBase<MODEL>,
45  public util::Printable,
46  private util::ObjectCounter<ErrorCovarianceBUMP<MODEL>> {
47  typedef oops::Geometry<MODEL> Geometry_;
48  typedef oops::Increment<MODEL> Increment_;
50  typedef oops::State<MODEL> State_;
52 
53  public:
54  static const std::string classname() {return "saber::ErrorCovarianceBUMP";}
55 
56  ErrorCovarianceBUMP(const Geometry_ &, const oops::Variables &,
57  const eckit::Configuration &, const State_ &, const State_ &);
58  virtual ~ErrorCovarianceBUMP();
59 
60  private:
63 
64  private:
65  void doRandomize(Increment_ &) const override;
66  void doMultiply(const Increment_ &, Increment_ &) const override;
67  void doInverseMultiply(const Increment_ &, Increment_ &) const override;
68 
69  void print(std::ostream &) const override;
70 
71  std::unique_ptr<OoBump_> ooBump_;
72 };
73 
74 // =============================================================================
75 
76 template<typename MODEL>
78  const oops::Variables & vars,
79  const eckit::Configuration & conf,
80  const State_ & xb, const State_ & fg)
81  : oops::ModelSpaceCovarianceBase<MODEL>(xb, fg, resol, conf), ooBump_()
82 {
83  oops::Log::trace() << "ErrorCovarianceBUMP::ErrorCovarianceBUMP starting" << std::endl;
84 
85 // Setup parameters
86  ParametersBUMP_ param(resol, vars, xb.validTime(), conf);
87 
88 // Transfer OoBump pointer
89  ooBump_.reset(new OoBump_(param.getOoBump()));
90 
91  oops::Log::trace() << "ErrorCovarianceBUMP::ErrorCovarianceBUMP done" << std::endl;
92 }
93 
94 // -----------------------------------------------------------------------------
95 
96 template<typename MODEL>
98  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::~ErrorCovarianceBUMP starting" << std::endl;
99  util::Timer timer(classname(), "~ErrorCovarianceBUMP");
100  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::~ErrorCovarianceBUMP done" << std::endl;
101 }
102 
103 // -----------------------------------------------------------------------------
104 
105 template<typename MODEL>
107  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doRandomize starting" << std::endl;
108  util::Timer timer(classname(), "doRandomize");
109  ooBump_->randomize(dx);
110  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doRandomize done" << std::endl;
111 }
112 
113 // -----------------------------------------------------------------------------
114 
115 template<typename MODEL>
117  Increment_ & dxo) const {
118  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doMultiply starting" << std::endl;
119  util::Timer timer(classname(), "doMultiply");
120  ooBump_->multiplyNicas(dxi, dxo);
121  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doMultiply done" << std::endl;
122 }
123 
124 // -----------------------------------------------------------------------------
125 
126 template<typename MODEL>
128  Increment_ & dxo) const {
129  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doInverseMultiply starting" << std::endl;
130  util::Timer timer(classname(), "doInverseMultiply");
131  ooBump_->inverseMultiplyNicas(dxi, dxo);
132  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::doInverseMultiply done" << std::endl;
133 }
134 
135 // -----------------------------------------------------------------------------
136 
137 template<typename MODEL>
138 void ErrorCovarianceBUMP<MODEL>::print(std::ostream & os) const {
139  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::print starting" << std::endl;
140  util::Timer timer(classname(), "print");
141  os << "ErrorCovarianceBUMP<MODEL>::print not implemented";
142  oops::Log::trace() << "ErrorCovarianceBUMP<MODEL>::print done" << std::endl;
143 }
144 
145 // -----------------------------------------------------------------------------
146 
147 } // namespace saber
148 
149 #endif // SABER_OOPS_ERRORCOVARIANCEBUMP_H_
saber::ErrorCovarianceBUMP::ErrorCovarianceBUMP
ErrorCovarianceBUMP(const ErrorCovarianceBUMP &)
oops
Definition: ErrorCovarianceBUMP.h:33
saber::ParametersBUMP
BUMP parameters.
Definition: ParametersBUMP.h:43
saber::ErrorCovarianceBUMP::OoBump_
OoBump< MODEL > OoBump_
Definition: ErrorCovarianceBUMP.h:49
saber::ErrorCovarianceBUMP
Model space error covariance with BUMP.
Definition: ErrorCovarianceBUMP.h:46
saber::ErrorCovarianceBUMP::ooBump_
std::unique_ptr< OoBump_ > ooBump_
Definition: ErrorCovarianceBUMP.h:71
ParametersBUMP.h
saber::ErrorCovarianceBUMP::ParametersBUMP_
ParametersBUMP< MODEL > ParametersBUMP_
Definition: ErrorCovarianceBUMP.h:51
saber::ErrorCovarianceBUMP::Geometry_
oops::Geometry< MODEL > Geometry_
Definition: ErrorCovarianceBUMP.h:47
saber::ErrorCovarianceBUMP::print
void print(std::ostream &) const override
Definition: ErrorCovarianceBUMP.h:138
saber
Definition: type_bump.h:22
saber::OoBump
OoBump C++ interface.
Definition: OoBump.h:47
saber::ErrorCovarianceBUMP::Increment_
oops::Increment< MODEL > Increment_
Definition: ErrorCovarianceBUMP.h:48
eckit
Definition: type_bump.h:18
OoBump.h
saber::ParametersBUMP::getOoBump
OoBump_ & getOoBump()
Definition: ParametersBUMP.h:60
saber::ErrorCovarianceBUMP::doInverseMultiply
void doInverseMultiply(const Increment_ &, Increment_ &) const override
Definition: ErrorCovarianceBUMP.h:127
saber::ErrorCovarianceBUMP::doRandomize
void doRandomize(Increment_ &) const override
Definition: ErrorCovarianceBUMP.h:106
saber::ErrorCovarianceBUMP::operator=
ErrorCovarianceBUMP & operator=(const ErrorCovarianceBUMP &)
saber::ErrorCovarianceBUMP::classname
static const std::string classname()
Definition: ErrorCovarianceBUMP.h:54
saber::ErrorCovarianceBUMP::State_
oops::State< MODEL > State_
Definition: ErrorCovarianceBUMP.h:50
saber::ErrorCovarianceBUMP::~ErrorCovarianceBUMP
virtual ~ErrorCovarianceBUMP()
Definition: ErrorCovarianceBUMP.h:97
saber::ErrorCovarianceBUMP::doMultiply
void doMultiply(const Increment_ &, Increment_ &) const override
Definition: ErrorCovarianceBUMP.h:116
saber::ErrorCovarianceBUMP::ErrorCovarianceBUMP
ErrorCovarianceBUMP(const Geometry_ &, const oops::Variables &, const eckit::Configuration &, const State_ &, const State_ &)
Definition: ErrorCovarianceBUMP.h:77