11 #ifndef OOPS_INTERFACE_MODELAUXINCREMENT_H_
12 #define OOPS_INTERFACE_MODELAUXINCREMENT_H_
21 #include "oops/util/Logger.h"
22 #include "oops/util/ObjectCounter.h"
23 #include "oops/util/Printable.h"
24 #include "oops/util/Serializable.h"
25 #include "oops/util/Timer.h"
39 template <
typename MODEL>
41 public util::Serializable,
42 private util::ObjectCounter<ModelAuxIncrement<MODEL> > {
48 static const std::string
classname() {
return "oops::ModelAuxIncrement";}
79 void read(
const eckit::Configuration &);
81 void write(
const eckit::Configuration &)
const;
87 void serialize(std::vector<double> &)
const override;
88 void deserialize(
const std::vector<double> &,
size_t &)
override;
91 void print(std::ostream &)
const override;
92 std::unique_ptr<ModelAuxIncrement_>
aux_;
97 template <
typename MODEL>
100 Log::trace() <<
"operator+=(ModelAuxControl, ModelAuxIncrement) starting" << std::endl;
101 util::Timer timer(
"oops::ModelAuxIncrement",
"operator+=ModelAuxControl");
103 Log::trace() <<
"operator+=(ModelAuxControl, ModelAuxIncrement) done" << std::endl;
109 template<
typename MODEL>
111 const eckit::Configuration & conf) : aux_()
113 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement starting" << std::endl;
114 util::Timer timer(
classname(),
"ModelAuxIncrement");
116 this->setObjectSize(
aux_->serialSize()*
sizeof(
double));
117 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement done" << std::endl;
120 template<
typename MODEL>
122 const bool copy) : aux_()
124 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement copy starting" << std::endl;
125 util::Timer timer(
classname(),
"ModelAuxIncrement");
127 this->setObjectSize(
aux_->serialSize()*
sizeof(
double));
128 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement copy done" << std::endl;
131 template<
typename MODEL>
133 const eckit::Configuration & conf) : aux_()
135 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement interpolated starting" << std::endl;
136 util::Timer timer(
classname(),
"ModelAuxIncrement");
138 this->setObjectSize(
aux_->serialSize()*
sizeof(
double));
139 Log::trace() <<
"ModelAuxIncrement<MODEL>::ModelAuxIncrement interpolated done" << std::endl;
142 template<
typename MODEL>
144 Log::trace() <<
"ModelAuxIncrement<MODEL>::~ModelAuxIncrement starting" << std::endl;
145 util::Timer timer(classname(),
"~ModelAuxIncrement");
147 Log::trace() <<
"ModelAuxIncrement<MODEL>::~ModelAuxIncrement done" << std::endl;
150 template<
typename MODEL>
152 Log::trace() <<
"ModelAuxIncrement<MODEL>::diff starting" << std::endl;
153 util::Timer timer(classname(),
"diff");
155 Log::trace() <<
"ModelAuxIncrement<MODEL>::diff done" << std::endl;
158 template<
typename MODEL>
160 Log::trace() <<
"ModelAuxIncrement<MODEL>::zero starting" << std::endl;
161 util::Timer timer(classname(),
"zero");
163 Log::trace() <<
"ModelAuxIncrement<MODEL>::zero done" << std::endl;
166 template<
typename MODEL>
168 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator= starting" << std::endl;
169 util::Timer timer(classname(),
"operator=");
171 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator= done" << std::endl;
175 template<
typename MODEL>
177 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator+= starting" << std::endl;
178 util::Timer timer(classname(),
"operator+=");
180 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator+= done" << std::endl;
184 template<
typename MODEL>
186 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator-= starting" << std::endl;
187 util::Timer timer(classname(),
"operator-=");
189 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator-= done" << std::endl;
193 template<
typename MODEL>
195 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator*= starting" << std::endl;
196 util::Timer timer(classname(),
"operator*=");
198 Log::trace() <<
"ModelAuxIncrement<MODEL>::operator*= done" << std::endl;
202 template<
typename MODEL>
204 Log::trace() <<
"ModelAuxIncrement<MODEL>::axpy starting" << std::endl;
205 util::Timer timer(classname(),
"axpy");
206 aux_->axpy(zz, *dx.
aux_);
207 Log::trace() <<
"ModelAuxIncrement<MODEL>::axpy done" << std::endl;
210 template<
typename MODEL>
212 Log::trace() <<
"ModelAuxIncrement<MODEL>::dot_product_with starting" << std::endl;
213 util::Timer timer(classname(),
"dot_product_with");
214 double zz = aux_->dot_product_with(*dx.
aux_);
215 Log::trace() <<
"ModelAuxIncrement<MODEL>::dot_product_with done" << std::endl;
219 template<
typename MODEL>
221 Log::trace() <<
"ModelAuxIncrement<MODEL>::read starting" << std::endl;
222 util::Timer timer(classname(),
"read");
224 Log::trace() <<
"ModelAuxIncrement<MODEL>::read done" << std::endl;
227 template<
typename MODEL>
229 Log::trace() <<
"ModelAuxIncrement<MODEL>::write starting" << std::endl;
230 util::Timer timer(classname(),
"write");
232 Log::trace() <<
"ModelAuxIncrement<MODEL>::write done" << std::endl;
235 template<
typename MODEL>
237 Log::trace() <<
"ModelAuxIncrement<MODEL>::norm starting" << std::endl;
238 util::Timer timer(classname(),
"norm");
239 double zz = aux_->norm();
240 Log::trace() <<
"ModelAuxIncrement<MODEL>::norm done" << std::endl;
244 template<
typename MODEL>
246 Log::trace() <<
"ModelAuxIncrement<MODEL>::serialSize" << std::endl;
247 util::Timer timer(classname(),
"serialSize");
248 return aux_->serialSize();
251 template<
typename MODEL>
253 Log::trace() <<
"ModelAuxIncrement<MODEL>::serialize starting" << std::endl;
254 util::Timer timer(classname(),
"serialize");
255 aux_->serialize(vect);
256 Log::trace() <<
"ModelAuxIncrement<MODEL>::serialize done" << std::endl;
259 template<
typename MODEL>
261 Log::trace() <<
"ModelAuxIncrement<MODEL>::deserialize starting" << std::endl;
262 util::Timer timer(classname(),
"deserialize");
263 aux_->deserialize(vect, current);
264 Log::trace() <<
"ModelAuxIncrement<MODEL>::deserialize done" << std::endl;
267 template<
typename MODEL>
269 Log::trace() <<
"ModelAuxIncrement<MODEL>::print starting" << std::endl;
270 util::Timer timer(classname(),
"print");
272 Log::trace() <<
"ModelAuxIncrement<MODEL>::print done" << std::endl;
Geometry class used in oops; subclass of interface class interface::Geometry.
Auxiliary state related to model (could be e.g. model bias), not used at the moment.
const ModelAuxControl_ & modelauxcontrol() const
const Accessor
Auxiliary Increment related to model, not used at the moment.
double norm() const
Norm (used in tests)
void deserialize(const std::vector< double > &, size_t &) override
ModelAuxIncrement & operator+=(const ModelAuxIncrement &)
ModelAuxIncrement & operator=(const ModelAuxIncrement &)
Linear algebra operators.
Geometry< MODEL > Geometry_
MODEL::ModelAuxIncrement ModelAuxIncrement_
void serialize(std::vector< double > &) const override
const ModelAuxIncrement_ & modelauxincrement() const
const Accessor
ModelAuxIncrement(const Geometry_ &resol, const eckit::Configuration &conf)
Constructor for specified resol and conf.
size_t serialSize() const override
Serialize and deserialize (used in 4DEnVar, weak-constraint 4DVar and Block-Lanczos minimizer)
void read(const eckit::Configuration &)
Read this ModelAuxIncrement from file.
void write(const eckit::Configuration &) const
Write this ModelAuxIncrement out to file.
void zero()
Zero out this ModelAuxIncrement.
ModelAuxIncrement_ & modelauxincrement()
Accessor.
std::unique_ptr< ModelAuxIncrement_ > aux_
void diff(const ModelAuxControl_ &, const ModelAuxControl_ &)
Sets this ModelAuxIncrement to the difference between two ModelAuxControl objects.
~ModelAuxIncrement()
Destructor (defined explicitly for timing and tracing)
static const std::string classname()
ModelAuxControl< MODEL > ModelAuxControl_
double dot_product_with(const ModelAuxIncrement &other) const
dot product with the other ModelAuxIncrement
void print(std::ostream &) const override
ModelAuxIncrement & operator-=(const ModelAuxIncrement &)
void axpy(const double &, const ModelAuxIncrement &)
ModelAuxIncrement & operator*=(const double &)
const Geometry_ & geometry() const
The namespace for the main oops code.
State< MODEL > & operator+=(State< MODEL > &xx, const Increment< MODEL > &dx)
Add on dx incrment to model state xx.