11 #ifndef OOPS_ASSIMILATION_COSTJBTOTAL_H_ 12 #define OOPS_ASSIMILATION_COSTJBTOTAL_H_ 16 #include <boost/scoped_ptr.hpp> 18 #include "eckit/config/LocalConfiguration.h" 25 #include "oops/util/Logger.h" 28 template<
typename MODEL>
class JqTerm;
29 template<
typename MODEL>
class JqTermTLAD;
35 template<
typename MODEL>
class CostJbTotal {
95 boost::scoped_ptr<JbState_>
jb_;
110 template<
typename MODEL>
114 jbModBias_(
conf.getSubConfiguration(
"ModelBiasCovariance"), resol),
115 jbObsBias_(
conf.getSubConfiguration(
"ObsBiasCovariance")),
118 Log::trace() <<
"CostJbTotal contructed." << std::endl;
123 template<
typename MODEL>
126 JqTerm_ * jqnl = jb_->initializeJq();
132 template<
typename MODEL>
138 jb_->computeIncrement(xb_.state(), fg_->state(), dx.
state());
141 dx.
modVar().
diff(fg_->modVar(), xb_.modVar());
142 dx.
obsVar().
diff(fg_->obsVar(), xb_.obsVar());
145 Log::info() <<
"CostJb: FG-BG" << dx << std::endl;
148 double zjb = this->evaluate(dx);
154 template<
typename MODEL>
160 jb_->linearize(fg.
state(), *resol_);
161 jbModBias_.linearize(fg.
modVar(), *resol_);
162 jbObsBias_.linearize(fg.
obsVar());
171 template<
typename MODEL>
178 jb_->computeIncrement(xb_.state(), fg_->state(), dxFG_->state());
181 dxFG_->modVar().diff(fg_->modVar(), xb_.modVar());
182 dxFG_->obsVar().diff(fg_->obsVar(), xb_.obsVar());
185 Log::info() <<
"CostJb: FG-BG" << *dxFG_ << std::endl;
190 template<
typename MODEL>
193 this->multiplyBinv(dx, gg);
196 double zz = 0.5 * dot_product(dx.
state(), gg.
state());
197 Log::info() <<
"CostJb : Nonlinear Jb State = " << zz << std::endl;
200 Log::info() <<
"CostJb : Nonlinear Jb Model Aux = " << zz << std::endl;
203 Log::info() <<
"CostJb : Nonlinear Jb Obs Aux = " << zz << std::endl;
206 Log::info() <<
"CostJb : Nonlinear Jb = " << zjb << std::endl;
211 Log::test() <<
"CostJb : Nonlinear Jb = " << ztest << std::endl;
218 template<
typename MODEL>
221 this->multiplyBinv(*dxFG_, gg);
227 template<
typename MODEL>
229 jb_->addGradient(dxFG_->state(), grad.
state(), gradJb.
state());
236 template<
typename MODEL>
244 template<
typename MODEL>
253 template<
typename MODEL>
263 template<
typename MODEL>
265 if (jqad) jqad->
clear();
270 template<
typename MODEL>
279 template<
typename MODEL>
282 jbModBias_.inverseMultiply(dxin.
modVar(), dxout.
modVar());
283 jbObsBias_.inverseMultiply(dxin.
obsVar(), dxout.
obsVar());
288 template<
typename MODEL>
290 jb_->randomize(dx.
state());
297 #endif // OOPS_ASSIMILATION_COSTJBTOTAL_H_
const ModelAuxCovar_ & jbModBias() const
void diff(const ObsAuxControl_ &, const ObsAuxControl_ &)
Linear algebra operators.
State4D_ & state()
Get state control variable.
boost::scoped_ptr< Geometry_ > resol_
Inner loop resolution.
void computeModelError(const State4D_ &, Increment4D_ &)
const JbState_ & jbState() const
ControlIncrement< MODEL > CtrlInc_
ControlVariable< MODEL > CtrlVar_
~CostJbTotal()
Destructor.
ObsAuxIncr_ & obsVar()
Get augmented observation control variable.
ModelAuxCovariance< MODEL > ModelAuxCovar_
ModelAuxIncr_ & modVar()
Get augmented model control variable.
ObsAuxCovariance< MODEL > ObsAuxCovar_
const Geometry_ & resolution() const
Jb terms for ControlIncrement constructor.
boost::scoped_ptr< JbState_ > jb_
void diff(const ModelAuxControl_ &, const ModelAuxControl_ &)
Linear algebra operators.
The namespace for the main oops code.
CostJbTotal(const CtrlVar_ &, JbState_ *, const eckit::Configuration &, const Geometry_ &)
Construct .
void computeModelErrorTraj(const State4D_ &, Increment4D_ &)
ModelAux_ & modVar()
Get augmented model control variable.
Geometry< MODEL > Geometry_
Increment4D_ & state()
Get state control variable.
double evaluate(const CtrlInc_ &) const
subroutine, public info(self)
const ObsAuxCovar_ & jbObsBias() const
void multiplyBinv(const CtrlInc_ &, CtrlInc_ &) const
void finalizeAD(JqTermTLAD_ *) const
void randomize(CtrlInc_ &) const
Randomize.
JqTermTLAD_ * initializeTL() const
Initialize before starting the TL run.
void addGradientFG(CtrlInc_ &) const
Add Jb gradient at first guess.
JqTermTLAD_ * initializeAD(CtrlInc_ &, const CtrlInc_ &) const
Initialize before starting the AD run.
ModelAuxCovar_ jbModBias_
void finalizeTraj(JqTermTLAD_ *)
Jb Cost Function Base Class.
void finalizeTL(JqTermTLAD_ *, const CtrlInc_ &, CtrlInc_ &) const
JqTermTLAD_ * initializeTraj(const CtrlVar_ &, const Geometry_ &)
real(kind=kind_real), parameter, public epsilon
boost::scoped_ptr< CtrlInc_ > dxFG_
First guess increment or more generally .
double finalize(JqTerm_ *) const
Finalize computation after nonlinear model integration.
void multiplyB(const CtrlInc_ &, CtrlInc_ &) const
Multiply by covariance matrix and its inverse.
JqTerm_ * initialize(const CtrlVar_ &) const
Initialize before nonlinear model integration.
void computeModelErrorTL(Increment4D_ &)
CostJbState< MODEL > JbState_
const CtrlVar_ & getBackground() const
Return background.
ObsAuxCtrl_ & obsVar()
Get augmented observation control variable.
const CtrlInc_ & getFirstGuess() const
Return first guess .
JqTermTLAD< MODEL > JqTermTLAD_