12 #ifndef OOPS_INTERFACE_INCREMENT_H_
13 #define OOPS_INTERFACE_INCREMENT_H_
19 #include "atlas/field.h"
27 #include "oops/util/DateTime.h"
28 #include "oops/util/Duration.h"
29 #include "oops/util/ObjectCounter.h"
30 #include "oops/util/Serializable.h"
31 #include "oops/util/Timer.h"
39 template <
typename MODEL>
41 public util::Serializable,
42 private util::ObjectCounter<Increment<MODEL> > {
49 static const std::string
classname() {
return "oops::Increment";}
73 void zero(
const util::DateTime & date);
77 void dirac(
const eckit::Configuration &);
87 void axpy(
const double & w,
const Increment & dx,
const bool check =
true);
99 void read(
const eckit::Configuration &);
101 void write(
const eckit::Configuration &)
const;
124 void setAtlas(atlas::FieldSet *)
const;
125 void toAtlas(atlas::FieldSet *)
const;
130 void serialize(std::vector<double> &)
const override;
131 void deserialize(
const std::vector<double> &,
size_t &)
override;
142 void print(std::ostream &)
const override;
147 template<
typename MODEL>
149 const util::DateTime & time)
152 Log::trace() <<
"Increment<MODEL>::Increment starting" << std::endl;
153 util::Timer timer(
classname(),
"Increment");
155 this->setObjectSize(
increment_->serialSize()*
sizeof(
double));
156 Log::trace() <<
"Increment<MODEL>::Increment done" << std::endl;
161 template<
typename MODEL>
165 Log::trace() <<
"Increment<MODEL>::Increment starting" << std::endl;
166 util::Timer timer(
classname(),
"Increment");
168 this->setObjectSize(
increment_->serialSize()*
sizeof(
double));
169 Log::trace() <<
"Increment<MODEL>::Increment done" << std::endl;
174 template<
typename MODEL>
178 Log::trace() <<
"Increment<MODEL>::Increment copy starting" << std::endl;
179 util::Timer timer(
classname(),
"Increment");
181 this->setObjectSize(
increment_->serialSize()*
sizeof(
double));
182 Log::trace() <<
"Increment<MODEL>::Increment copy done" << std::endl;
187 template<
typename MODEL>
189 Log::trace() <<
"Increment<MODEL>::~Increment starting" << std::endl;
190 util::Timer timer(classname(),
"~Increment");
192 Log::trace() <<
"Increment<MODEL>::~Increment done" << std::endl;
197 template<
typename MODEL>
199 Log::trace() <<
"Increment<MODEL>::diff starting" << std::endl;
200 util::Timer timer(classname(),
"diff");
202 Log::trace() <<
"Increment<MODEL>::diff done" << std::endl;
207 template<
typename MODEL>
209 Log::trace() <<
"Increment<MODEL>::zero starting" << std::endl;
210 util::Timer timer(classname(),
"zero");
212 Log::trace() <<
"Increment<MODEL>::zero done" << std::endl;
217 template<
typename MODEL>
219 Log::trace() <<
"Increment<MODEL>::zero starting" << std::endl;
220 util::Timer timer(classname(),
"zero");
221 increment_->zero(tt);
222 Log::trace() <<
"Increment<MODEL>::zero done" << std::endl;
227 template<
typename MODEL>
229 Log::trace() <<
"Increment<MODEL>::ones starting" << std::endl;
230 util::Timer timer(classname(),
"ones");
232 Log::trace() <<
"Increment<MODEL>::ones done" << std::endl;
237 template<
typename MODEL>
239 Log::trace() <<
"Increment<MODEL>::dirac starting" << std::endl;
240 util::Timer timer(classname(),
"dirac");
241 increment_->dirac(config);
242 Log::trace() <<
"Increment<MODEL>::dirac done" << std::endl;
247 template<
typename MODEL>
249 Log::trace() <<
"Increment<MODEL>::operator= starting" << std::endl;
250 util::Timer timer(classname(),
"operator=");
252 Log::trace() <<
"Increment<MODEL>::operator= done" << std::endl;
258 template<
typename MODEL>
260 Log::trace() <<
"Increment<MODEL>::operator+= starting" << std::endl;
261 util::Timer timer(classname(),
"operator+=");
263 Log::trace() <<
"Increment<MODEL>::operator+= done" << std::endl;
269 template<
typename MODEL>
271 Log::trace() <<
"Increment<MODEL>::operator-= starting" << std::endl;
272 util::Timer timer(classname(),
"operator-=");
274 Log::trace() <<
"Increment<MODEL>::operator-= done" << std::endl;
280 template<
typename MODEL>
282 Log::trace() <<
"Increment<MODEL>::operator*= starting" << std::endl;
283 util::Timer timer(classname(),
"operator*=");
285 Log::trace() <<
"Increment<MODEL>::operator*= done" << std::endl;
291 template<
typename MODEL>
293 Log::trace() <<
"Increment<MODEL>::axpy starting" << std::endl;
294 util::Timer timer(classname(),
"axpy");
296 Log::trace() <<
"Increment<MODEL>::axpy done" << std::endl;
301 template<
typename MODEL>
303 Log::trace() <<
"Increment<MODEL>::dot_product_with starting" << std::endl;
304 util::Timer timer(classname(),
"dot_product_with");
305 double zz = increment_->dot_product_with(*dx.
increment_);
306 Log::trace() <<
"Increment<MODEL>::dot_product_with done" << std::endl;
312 template<
typename MODEL>
314 Log::trace() <<
"Increment<MODEL>::schur_product_with starting" << std::endl;
315 util::Timer timer(classname(),
"schur_product_with");
316 increment_->schur_product_with(*dx.
increment_);
317 Log::trace() <<
"Increment<MODEL>::schur_product_with done" << std::endl;
322 template<
typename MODEL>
324 Log::trace() <<
"Increment<MODEL>::random starting" << std::endl;
325 util::Timer timer(classname(),
"random");
326 increment_->random();
327 Log::trace() <<
"Increment<MODEL>::random done" << std::endl;
332 template<
typename MODEL>
334 Log::trace() <<
"Increment<MODEL>::accumul starting" << std::endl;
335 util::Timer timer(classname(),
"accumul");
336 increment_->accumul(zz, xx.
state());
337 Log::trace() <<
"Increment<MODEL>::accumul done" << std::endl;
342 template<
typename MODEL>
344 Log::trace() <<
"Increment<MODEL>::getLocal starting" << std::endl;
345 util::Timer timer(classname(),
"getLocal");
347 Log::trace() <<
"Increment<MODEL>::getLocal done" << std::endl;
352 template<
typename MODEL>
355 Log::trace() <<
"Increment<MODEL>::setLocal starting" << std::endl;
356 util::Timer timer(classname(),
"setLocal");
358 Log::trace() <<
"Increment<MODEL>::setLocal done" << std::endl;
363 template<
typename MODEL>
365 Log::trace() <<
"Increment<MODEL>::read starting" << std::endl;
366 util::Timer timer(classname(),
"read");
367 increment_->read(conf);
368 Log::trace() <<
"Increment<MODEL>::read done" << std::endl;
373 template<
typename MODEL>
375 Log::trace() <<
"Increment<MODEL>::write starting" << std::endl;
376 util::Timer timer(classname(),
"write");
377 increment_->write(conf);
378 Log::trace() <<
"Increment<MODEL>::write done" << std::endl;
383 template<
typename MODEL>
385 Log::trace() <<
"Increment<MODEL>::norm starting" << std::endl;
386 util::Timer timer(classname(),
"norm");
387 double zz = increment_->norm();
388 Log::trace() <<
"Increment<MODEL>::norm done" << std::endl;
394 template<
typename MODEL>
396 Log::trace() <<
"Increment<MODEL>::geometry starting" << std::endl;
397 util::Timer timer(classname(),
"geometry");
399 Log::trace() <<
"Increment<MODEL>::geometry done" << std::endl;
405 template<
typename MODEL>
407 Log::trace() <<
"Increment<MODEL>::setAtlas starting" << std::endl;
408 util::Timer timer(classname(),
"setAtlas");
409 increment_->setAtlas(atlasFieldSet);
410 Log::trace() <<
"Increment<MODEL>::setAtlas done" << std::endl;
415 template<
typename MODEL>
417 Log::trace() <<
"Increment<MODEL>::toAtlas starting" << std::endl;
418 util::Timer timer(classname(),
"toAtlas");
419 increment_->toAtlas(atlasFieldSet);
420 Log::trace() <<
"Increment<MODEL>::toAtlas done" << std::endl;
425 template<
typename MODEL>
427 Log::trace() <<
"Increment<MODEL>::fromAtlas starting" << std::endl;
428 util::Timer timer(classname(),
"fromAtlas");
429 increment_->fromAtlas(atlasFieldSet);
430 Log::trace() <<
"Increment<MODEL>::fromAtlas done" << std::endl;
435 template<
typename MODEL>
437 Log::trace() <<
"Increment<MODEL>::serialSize" << std::endl;
438 util::Timer timer(classname(),
"serialSize");
439 return increment_->serialSize();
444 template<
typename MODEL>
446 Log::trace() <<
"Increment<MODEL>::serialize starting" << std::endl;
447 util::Timer timer(classname(),
"serialize");
448 increment_->serialize(vect);
449 Log::trace() <<
"Increment<MODEL>::serialize done" << std::endl;
454 template<
typename MODEL>
456 Log::trace() <<
"Increment<MODEL>::Increment deserialize starting" << std::endl;
457 util::Timer timer(classname(),
"deserialize");
458 increment_->deserialize(vect, current);
459 Log::trace() <<
"Increment<MODEL>::Increment deserialize done" << std::endl;
464 template<
typename MODEL>
466 Log::trace() <<
"Increment<MODEL>::print starting" << std::endl;
467 util::Timer timer(classname(),
"print");
469 Log::trace() <<
"Increment<MODEL>::print done" << std::endl;
Abstract base class for quantities.
Geometry class used in oops; subclass of interface class interface::Geometry.
const GeometryIterator_ & geometryiter() const
Interfacing.
State class used in oops; subclass of interface class interface::State.
const Geometry_ & geometry() const
void setLocal(const LocalIncrement &gp, const GeometryIterator_ &iter)
Set local (at iter local volume) increment to be gp (used in LocalEnsembleSolver)
void axpy(const double &w, const Increment &dx, const bool check=true)
const Increment_ & increment() const
void deserialize(const std::vector< double > &, size_t &) override
Increment & operator*=(const double &)
MODEL::Increment Increment_
void dirac(const eckit::Configuration &)
Set Increment according to the configuration (used in Dirac application)
void updateTime(const util::Duration &dt)
Updates this Increment's valid time by dt (used in PseudoModel)
static const std::string classname()
void schur_product_with(const Increment &other)
Compute Schur product of this Increment with other, assign to this Increment.
void fromAtlas(atlas::FieldSet *)
oops::State< MODEL > State_
void setAtlas(atlas::FieldSet *) const
Increment(const Geometry_ &geometry, const Variables &variables, const util::DateTime &date)
Constructor for specified geometry, with variables, valid on date.
Increment & operator+=(const Increment &)
Linear algebra operators.
void random()
Randomize the Increment (used in tests)
virtual ~Increment()
Destructor (defined explicitly for timing and tracing)
LocalIncrement getLocal(const GeometryIterator_ &iter) const
Get local (at iter local volume) increment (used in LocalEnsembleSolver)
void read(const eckit::Configuration &)
Read this Increment from file.
Geometry_ geometry() const
Accessor to geometry associated with this Increment.
Increment & operator-=(const Increment &)
GeometryIterator< MODEL > GeometryIterator_
void toAtlas(atlas::FieldSet *) const
void diff(const State_ &state1, const State_ &state2)
Set this Increment to be difference between state1 and state2.
double dot_product_with(const Increment &other) const
Compute dot product of this Increment with other.
double norm() const
Norm (used in tests)
void serialize(std::vector< double > &) const override
oops::Geometry< MODEL > Geometry_
void accumul(const double &w, const State_ &x)
Accumulate (add w * x to the increment), used in WeightedDiff with Accumulator.
std::unique_ptr< Increment_ > increment_
void print(std::ostream &) const override
pointer to the Increment implementation
void write(const eckit::Configuration &) const
Write this Increment out to file.
Increment & operator=(const Increment &)
Assignment operator.
void zero()
Zero out this Increment.
void ones()
Set this Increment to ones (used in tests)
size_t serialSize() const override
Serialize and deserialize (used in 4DEnVar, weak-constraint 4DVar and Block-Lanczos minimizer)
const util::DateTime validTime() const
Accessor to the time of this Increment.
State_ & state()
Accessor.
The namespace for the main oops code.