11 #ifndef OOPS_ASSIMILATION_CONTROLINCREMENT_H_
12 #define OOPS_ASSIMILATION_CONTROLINCREMENT_H_
20 #include "eckit/config/Configuration.h"
25 #include "oops/util/dot_product.h"
26 #include "oops/util/Logger.h"
27 #include "oops/util/ObjectCounter.h"
28 #include "oops/util/Printable.h"
29 #include "oops/util/Serializable.h"
44 template<
typename MODEL,
typename OBS>
class CostJbTotal;
46 template<
typename MODEL,
typename OBS>
class ControlIncrement;
49 template<
typename MODEL,
typename OBS>
51 public util::Serializable,
52 private util::ObjectCounter<ControlIncrement<MODEL, OBS> > {
60 static const std::string
classname() {
return "oops::ControlIncrement";}
79 void read(
const eckit::Configuration &);
80 void write(
const eckit::Configuration &)
const;
99 void serialize(std::vector<double> &)
const override;
100 void deserialize(
const std::vector<double> &,
size_t &)
override;
106 void print(std::ostream &)
const override;
117 template<
typename MODEL,
typename OBS>
119 : increment_(*jb.jbState().newStateIncrement()),
120 modbias_(jb.resolution(), jb.jbModBias().config()),
121 obsbias_(jb.jbObsBias().obspaces(), jb.jbObsBias().config()),
122 windowBegin_(jb.windowBegin()), windowEnd_(jb.windowEnd())
124 this->setObjectSize(this->
serialSize()*
sizeof(
double));
125 Log::trace() <<
"ControlIncrement:ControlIncrement created." << std::endl;
128 template<
typename MODEL,
typename OBS>
130 : increment_(other.increment_, copy), modbias_(other.modbias_, copy),
131 obsbias_(other.obsbias_, copy), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
133 this->setObjectSize(this->
serialSize()*
sizeof(
double));
134 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
137 template<
typename MODEL,
typename OBS>
139 const eckit::Configuration & tlConf)
140 : increment_(other.increment_, tlConf), modbias_(other.modbias_, tlConf),
141 obsbias_(other.obsbias_, tlConf), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
143 this->setObjectSize(this->
serialSize()*
sizeof(
double));
144 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
147 template<
typename MODEL,
typename OBS>
150 : increment_(geom, other.increment_), modbias_(other.modbias_, true),
151 obsbias_(other.obsbias_, true), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
153 this->setObjectSize(this->
serialSize()*
sizeof(
double));
154 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
157 template<
typename MODEL,
typename OBS>
184 template<
typename MODEL,
typename OBS>
192 template<
typename MODEL,
typename OBS>
199 template<
typename MODEL,
typename OBS>
206 template<
typename MODEL,
typename OBS>
208 increment_.read(config);
209 modbias_.read(config);
210 obsbias_.read(config);
213 template<
typename MODEL,
typename OBS>
215 increment_.write(config);
216 modbias_.write(config);
217 obsbias_.write(config);
220 template <
typename MODEL,
typename OBS>
227 template<
typename MODEL,
typename OBS>
231 zz += dot_product(modbias_, x2.
modbias_);
232 zz += dot_product(obsbias_, x2.
obsbias_);
236 template<
typename MODEL,
typename OBS>
239 ss += increment_.serialSize();
240 ss += modbias_.serialSize();
241 ss += obsbias_.serialSize();
245 template<
typename MODEL,
typename OBS>
247 vec.reserve(vec.size() + this->serialSize());
249 vec.push_back(-111.0);
250 increment_.serialize(vec);
252 vec.push_back(-222.0);
253 modbias_.serialize(vec);
255 vec.push_back(-333.0);
256 obsbias_.serialize(vec);
258 vec.push_back(-444.0);
261 template<
typename MODEL,
typename OBS>
263 ASSERT(vec.at(indx) == -111.0);
266 increment_.deserialize(vec, indx);
268 ASSERT(vec.at(indx) == -222.0);
271 modbias_.deserialize(vec, indx);
273 ASSERT(vec.at(indx) == -333.0);
276 obsbias_.deserialize(vec, indx);
277 ASSERT(vec.at(indx) == -444.0);
281 template<
typename MODEL,
typename OBS>
283 increment_.shift_forward(windowBegin_);
287 template<
typename MODEL,
typename OBS>
289 increment_.shift_backward(windowEnd_);
ObsAuxIncrs_ & obsVar()
Get augmented observation control variable.
void zero()
Linear algebra operators.
ControlIncrement & operator=(const ControlIncrement &)
Increment_ & state()
Get state control variable.
const util::DateTime windowEnd_
const util::DateTime windowBegin_
Increment< MODEL > Increment_
double dot_product_with(const ControlIncrement &) const
void deserialize(const std::vector< double > &, size_t &) override
const Increment_ & state() const
ModelAuxIncrement< MODEL > ModelAuxIncr_
ControlIncrement & operator-=(const ControlIncrement &)
Geometry_ geometry() const
Get geometry.
ControlIncrement(const JbTotal_ &)
Constructor, destructor.
const ModelAuxIncr_ & modVar() const
ControlIncrement & operator*=(const double)
ControlIncrement & operator+=(const ControlIncrement &)
Geometry< MODEL > Geometry_
CostJbTotal< MODEL, OBS > JbTotal_
const ObsAuxIncrs_ & obsVar() const
void write(const eckit::Configuration &) const
ObsAuxIncrements< OBS > ObsAuxIncrs_
void serialize(std::vector< double > &) const override
static const std::string classname()
void read(const eckit::Configuration &)
I/O and diagnostics.
ModelAuxIncr_ & modVar()
Get augmented model control variable.
size_t serialSize() const override
Serialize and deserialize ControlIncrement.
void axpy(const double, const ControlIncrement &)
void print(std::ostream &) const override
Control variable increment.
Geometry class used in oops; subclass of interface class interface::Geometry.
Increment class used in oops.
Auxiliary Increment related to model, not used at the moment.
Holds a vector of ObsAuxIncrement.
Geometry_ geometry() const
Accessor to geometry associated with this Increment.
The namespace for the main oops code.