11 #ifndef OOPS_BASE_ENSEMBLECOVARIANCE_H_
12 #define OOPS_BASE_ENSEMBLECOVARIANCE_H_
18 #include "eckit/config/LocalConfiguration.h"
19 #include "eckit/exception/Exceptions.h"
20 #include "eckit/system/ResourceUsage.h"
31 #include "oops/util/Logger.h"
32 #include "oops/util/ObjectCounter.h"
39 template <
typename MODEL>
41 private util::ObjectCounter<EnsembleCovariance<MODEL>> {
50 static const std::string
classname() {
return "oops::EnsembleCovariance";}
53 const eckit::Configuration &,
const State_ &,
const State_ &);
62 std::unique_ptr<Localization_>
loc_;
70 template<
typename MODEL>
72 const eckit::Configuration & conf,
76 Log::trace() <<
"EnsembleCovariance::EnsembleCovariance start" << std::endl;
77 size_t init = eckit::system::ResourceUsage().maxResidentSetSize();
79 if (conf.has(
"localization")) {
80 const eckit::LocalConfiguration confloc(conf,
"localization");
83 size_t current = eckit::system::ResourceUsage().maxResidentSetSize();
84 this->setObjectSize(current - init);
85 Log::trace() <<
"EnsembleCovariance::EnsembleCovariance done" << std::endl;
88 template<
typename MODEL>
90 Log::trace() <<
"EnsembleCovariance destructed." << std::endl;
93 template<
typename MODEL>
98 for (
unsigned int ie = 0; ie < ens_->size(); ++ie) {
100 loc_->randomize(tmp);
102 dx.
axpy(1.0, tmp,
false);
106 util::NormalDistribution<double> normalDist(ens_->size(), 0.0, 1.0, seed_);
107 for (
unsigned int ie = 0; ie < ens_->size(); ++ie) {
108 dx.
axpy(normalDist[ie], (*ens_)[ie]);
111 dx *= 1.0/sqrt(
static_cast<double>(ens_->size()-1));
114 template<
typename MODEL>
117 for (
unsigned int ie = 0; ie < ens_->size(); ++ie) {
124 dxo.
axpy(1.0, dx,
false);
128 dxo.
axpy(wgt, (*ens_)[ie],
false);
131 const double rk = 1.0/
static_cast<double>(ens_->size()-1);
135 template<
typename MODEL>
139 GMRESR(dxo, dxi, *
this, Id, 10, 1.0e-3);
Generic ensemble based model space error covariance.
EnsembleCovariance(const Geometry_ &, const Variables &, const eckit::Configuration &, const State_ &, const State_ &)
Constructor, destructor.
Increment< MODEL > Increment_
Geometry< MODEL > Geometry_
static const std::string classname()
void doMultiply(const Increment_ &, Increment_ &) const override
std::shared_ptr< IncrementEnsemble< MODEL > > EnsemblePtr_
std::unique_ptr< Localization_ > loc_
void doRandomize(Increment_ &) const override
void doInverseMultiply(const Increment_ &, Increment_ &) const override
Localization< MODEL > Localization_
IncrementEnsemble< MODEL > Ensemble_
Geometry class used in oops; subclass of interface class interface::Geometry.
Increment class used in oops.
double dot_product_with(const Increment &other) const
dot product with the other increment
Abstract model-space localization class used by high level algorithms and applications.
State class used in oops; subclass of interface class interface::State.
void axpy(const double &w, const Increment &dx, const bool check=true)
void schur_product_with(const Increment &other)
Compute Schur product of this Increment with other, assign to this Increment.
void zero()
Zero out this Increment.
The namespace for the main oops code.
double GMRESR(VECTOR &xx, const VECTOR &bb, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance)