FV3 Bundle
oops/interface/ModelAuxCovariance.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_INTERFACE_MODELAUXCOVARIANCE_H_
12 #define OOPS_INTERFACE_MODELAUXCOVARIANCE_H_
13 
14 #include <iostream>
15 #include <string>
16 
17 #include <boost/noncopyable.hpp>
18 #include <boost/scoped_ptr.hpp>
19 
20 #include "eckit/config/Configuration.h"
24 #include "oops/util/Logger.h"
25 #include "oops/util/ObjectCounter.h"
26 #include "oops/util/Printable.h"
27 #include "oops/util/Timer.h"
28 
29 namespace oops {
30 
31 // -----------------------------------------------------------------------------
32 
33 template <typename MODEL>
34 class ModelAuxCovariance : public util::Printable,
35  private boost::noncopyable,
36  private util::ObjectCounter<ModelAuxCovariance<MODEL> > {
37  typedef typename MODEL::ModelAuxCovariance ModelAuxCovariance_;
41 
42  public:
43  static const std::string classname() {return "oops::ModelAuxCovariance";}
44 
45  ModelAuxCovariance(const eckit::Configuration &, const Geometry_ &);
47 
48 /// Operators
49  void linearize(const ModelAuxControl_ &, const Geometry_ &);
50  void multiply(const ModelAuxIncrement_ &, ModelAuxIncrement_ &) const;
52  void randomize(ModelAuxIncrement_ &) const;
53 
54  const eckit::Configuration & config() const {return cov_->config();}
55 
56  private:
57  void print(std::ostream &) const;
58  boost::scoped_ptr<ModelAuxCovariance_> cov_;
59 };
60 
61 // =============================================================================
62 
63 template<typename MODEL>
65  const Geometry_ & resol) : cov_()
66 {
67  Log::trace() << "ModelAuxCovariance<MODEL>::ModelAuxCovariance starting" << std::endl;
68  util::Timer timer(classname(), "ModelAuxCovariance");
69  cov_.reset(new ModelAuxCovariance_(conf, resol.geometry()));
70  Log::trace() << "ModelAuxCovariance<MODEL>::ModelAuxCovariance done" << std::endl;
71 }
72 
73 // -----------------------------------------------------------------------------
74 
75 template<typename MODEL>
77  Log::trace() << "ModelAuxCovariance<MODEL>::~ModelAuxCovariance starting" << std::endl;
78  util::Timer timer(classname(), "~ModelAuxCovariance");
79  cov_.reset();
80  Log::trace() << "ModelAuxCovariance<MODEL>::~ModelAuxCovariance done" << std::endl;
81 }
82 
83 // -----------------------------------------------------------------------------
84 
85 template<typename MODEL>
87  Log::trace() << "ModelAuxCovariance<MODEL>::linearize starting" << std::endl;
88  util::Timer timer(classname(), "linearize");
89  cov_->linearize(xx.modelauxcontrol(), resol.geometry());
90  Log::trace() << "ModelAuxCovariance<MODEL>::linearize done" << std::endl;
91 }
92 
93 // -----------------------------------------------------------------------------
94 
95 template<typename MODEL>
97  ModelAuxIncrement_ & dx2) const {
98  Log::trace() << "ModelAuxCovariance<MODEL>::multiply starting" << std::endl;
99  util::Timer timer(classname(), "multiply");
100  cov_->multiply(dx1.modelauxincrement(), dx2.modelauxincrement());
101  Log::trace() << "ModelAuxCovariance<MODEL>::multiply done" << std::endl;
102 }
103 
104 // -----------------------------------------------------------------------------
105 
106 template<typename MODEL>
108  ModelAuxIncrement_ & dx2) const {
109  Log::trace() << "ModelAuxCovariance<MODEL>::inverseMultiply starting" << std::endl;
110  util::Timer timer(classname(), "inverseMultiply");
111  cov_->inverseMultiply(dx1.modelauxincrement(), dx2.modelauxincrement());
112  Log::trace() << "ModelAuxCovariance<MODEL>::inverseMultiply done" << std::endl;
113 }
114 
115 // -----------------------------------------------------------------------------
116 
117 template<typename MODEL>
119  Log::trace() << "ModelAuxCovariance<MODEL>::randomize starting" << std::endl;
120  util::Timer timer(classname(), "randomize");
121  cov_->randomize(dx.modelauxincrement());
122  Log::trace() << "ModelAuxCovariance<MODEL>::randomize done" << std::endl;
123 }
124 
125 // -----------------------------------------------------------------------------
126 
127 template<typename MODEL>
128 void ModelAuxCovariance<MODEL>::print(std::ostream & os) const {
129  Log::trace() << "ModelAuxCovariance<MODEL>::print starting" << std::endl;
130  util::Timer timer(classname(), "print");
131  os << *cov_;
132  Log::trace() << "ModelAuxCovariance<MODEL>::print done" << std::endl;
133 }
134 
135 // -----------------------------------------------------------------------------
136 
137 } // namespace oops
138 
139 #endif // OOPS_INTERFACE_MODELAUXCOVARIANCE_H_
Definition: conf.py:1
void randomize(ModelAuxIncrement_ &) const
const eckit::Configuration & config() const
ModelAuxIncrement< MODEL > ModelAuxIncrement_
boost::scoped_ptr< ModelAuxCovariance_ > cov_
The namespace for the main oops code.
void inverseMultiply(const ModelAuxIncrement_ &, ModelAuxIncrement_ &) const
const ModelAuxControl_ & modelauxcontrol() const
Interfacing.
void multiply(const ModelAuxIncrement_ &, ModelAuxIncrement_ &) const
ModelAuxCovariance(const eckit::Configuration &, const Geometry_ &)
const Geometry_ & geometry() const
Interfacing.
const ModelAuxIncrement_ & modelauxincrement() const
Interfacing.
void linearize(const ModelAuxControl_ &, const Geometry_ &)
Operators.
MODEL::ModelAuxCovariance ModelAuxCovariance_