11 #ifndef OOPS_ASSIMILATION_COSTJBJQ_H_ 12 #define OOPS_ASSIMILATION_COSTJBJQ_H_ 17 #include <boost/ptr_container/ptr_vector.hpp> 18 #include <boost/scoped_ptr.hpp> 20 #include "eckit/config/LocalConfiguration.h" 30 #include "oops/util/dot_product.h" 31 #include "oops/util/Duration.h" 32 #include "oops/util/Logger.h" 35 template<
typename MODEL>
class ControlIncrement;
55 const util::Duration &,
const State4D_ &,
const bool);
87 unsigned int nstates()
const override {
return B_.size();}
91 boost::ptr_vector< ModelSpaceCovarianceBase<MODEL> >
B_;
96 boost::scoped_ptr<const Geometry_>
resol_;
98 const eckit::LocalConfiguration
conf_;
106 template<
typename MODEL>
110 : B_(0), xb_(
xb), subwin_(
len), forcing_(forcing), ctlvars_(ctlvars), resol_(), times_(),
113 Log::trace() <<
"CostJbJq contructed." << std::endl;
118 template<
typename MODEL>
124 std::vector<eckit::LocalConfiguration> confs;
125 conf_.get(
"Covariance", confs);
126 for (
unsigned jsub = 0; jsub < confs.size(); ++jsub) {
128 xb_[jsub], fg[jsub]));
129 times_.push_back(fg[jsub].validTime());
136 template<
typename MODEL>
141 Log::info() <<
"CostJbJq: x_0 - x_b" << dx[0] << std::endl;
146 template<
typename MODEL>
150 grad[0] += gradJb[0];
154 for (
unsigned jsub = 1; jsub < B_.size(); ++jsub) {
155 B_[jsub].inverseMultiply(dxFG[jsub], gg[jsub]);
156 grad[jsub] += gg[jsub];
162 template<
typename MODEL>
169 template<
typename MODEL>
176 template<
typename MODEL>
185 template<
typename MODEL>
197 template<
typename MODEL>
199 for (
unsigned jsub = 0; jsub < B_.size(); ++jsub) {
200 B_[jsub].multiply(dxin[jsub], dxout[jsub]);
204 << 0.5 * dot_product(dxin[0], dxout[0]) << std::endl;
206 Log::debug() <<
"CostJbJq:multiply Jq(" << jsub <<
") is " 207 << 0.5 * dot_product(dxin[jsub], dxout[jsub]) << std::endl;
214 template<
typename MODEL>
216 for (
unsigned jsub = 0; jsub < B_.size(); ++jsub) {
217 B_[jsub].randomize(dx[jsub]);
223 template<
typename MODEL>
225 Log::warning() <<
"*** B inverse might not always exist ***" << std::endl;
226 for (
unsigned jsub = 0; jsub < B_.size(); ++jsub) {
227 B_[jsub].inverseMultiply(dxin[jsub], dxout[jsub]);
230 Log::debug() <<
"CostJbJq:inverseMultiply Jb is " 231 << 0.5 * dot_product(dxin[0], dxout[0]) << std::endl;
233 Log::debug() <<
"CostJbJq:inverseMultiply Jq(" << jsub <<
") is " 234 << 0.5 * dot_product(dxin[jsub], dxout[jsub]) << std::endl;
237 Log::warning() <<
"*** B inverse might not always exist ***" << std::endl;
242 template<
typename MODEL>
253 #endif // OOPS_ASSIMILATION_COSTJBJQ_H_
JqTerm< MODEL > * initializeJq() const override
Finalize after the model run.
CostJbJq(const eckit::Configuration &, const Geometry_ &, const Variables &, const util::Duration &, const State4D_ &, const bool)
Construct .
void randomize(Increment4D_ &) const override
Randomize.
integer, parameter, public warning
JqTermTLAD< MODEL > * initializeJqAD(const Increment4D_ &) const override
Initialize forcing before the AD run.
const eckit::LocalConfiguration conf_
void diff(const State4D_ &, const State4D_ &)
Linear algebra operators.
void setupAD(const Increment4D_ &dx)
void addGradient(const Increment4D_ &, Increment4D_ &, Increment4D_ &) const override
Add Jb gradient.
The namespace for the main oops code.
Increment4D< MODEL > Increment4D_
JqTermTLAD< MODEL > * initializeJqTLAD() const override
boost::scoped_ptr< const Geometry_ > resol_
Increment< MODEL > Increment_
void Bmult(const Increment4D_ &, Increment4D_ &) const override
Multiply by and .
void computeIncrement(const State4D_ &, const State4D_ &, Increment4D_ &) const override
Get increment from state (usually first guess).
subroutine, public info(self)
Geometry< MODEL > Geometry_
boost::ptr_vector< ModelSpaceCovarianceBase< MODEL > > B_
virtual ~CostJbJq()
Destructor.
void linearize(const State4D_ &, const Geometry_ &) override
Linearize before the linear computations.
Increment_ * newStateIncrement(const unsigned int) const override
Jb Cost Function Base Class.
ControlIncrement< MODEL > CtrlInc_
const util::Duration subwin_
std::vector< util::DateTime > times_
Increment Class: Difference between two states.
bool checkStatesNumber(const unsigned int nn) const
Get model space control variable.
unsigned int nstates() const override
Create new increment (set to 0).
void Bminv(const Increment4D_ &, Increment4D_ &) const override
State4D< MODEL > State4D_
JqTermTLAD< MODEL > * initializeJqTL() const override
Finalize after the TL run.