11 #ifndef OOPS_ASSIMILATION_COSTFCT3DVAR_H_ 12 #define OOPS_ASSIMILATION_COSTFCT3DVAR_H_ 14 #include "eckit/config/Configuration.h" 27 #include "oops/util/DateTime.h" 28 #include "oops/util/Duration.h" 29 #include "oops/util/Logger.h" 85 template<
typename MODEL>
89 windowLength_(), windowHalf_(), zero_(0), ctlvars_(config), an2model_()
91 Log::trace() <<
"CostFct3DVar::CostFct3DVar start" << std::endl;
92 windowLength_ = util::Duration(config.getString(
"window_length"));
93 windowBegin_ = util::DateTime(config.getString(
"window_begin"));
97 Log::trace() <<
"CostFct3DVar::CostFct3DVar done" << std::endl;
102 template <
typename MODEL>
106 Log::trace() <<
"CostFct3DVar::newJb" << std::endl;
107 ASSERT(
xb.state().checkStatesNumber(1));
113 template <
typename MODEL>
115 Log::trace() <<
"CostFct3DVar::newJo" << std::endl;
116 return new CostJo<MODEL>(joConf, windowBegin_, windowEnd_, windowLength_);
121 template <
typename MODEL>
124 Log::trace() <<
"CostFct3DVar::newJc" << std::endl;
132 template <
typename MODEL>
135 Log::trace() <<
"CostFct3DVar::runNL start" << std::endl;
137 ASSERT(xx.
state()[0].validTime() == windowHalf_);
138 State_ xm(xx.
state()[0].geometry(), CostFct_::getModel().variables(), windowHalf_);
140 CostFct_::getModel().forecast(xm, xx.
modVar(), zero_, post);
142 ASSERT(xx.
state()[0].validTime() == windowHalf_);
143 Log::trace() <<
"CostFct3DVar::runNL done" << std::endl;
148 template<
typename MODEL>
150 const eckit::Configuration & innerConf,
152 Log::trace() <<
"CostFct3DVar::doLinearize start" << std::endl;
153 eckit::LocalConfiguration
conf(innerConf,
"linearmodel");
156 an2model_->setInputVariables(ctlvars_);
157 an2model_->setOutputVariables(CostFct_::getTLM().variables());
158 Log::trace() <<
"CostFct3DVar::doLinearize done" << std::endl;
163 template <
typename MODEL>
168 Log::trace() <<
"CostFct3DVar::runTLM start" << std::endl;
169 ASSERT(dx.
state()[0].validTime() == windowHalf_);
171 an2model_->multiply(dx.
state()[0], dxmodel);
172 CostFct_::getTLM().forecastTL(dxmodel, dx.
modVar(), zero_, post, cost);
173 an2model_->multiplyInverse(dxmodel, dx.
state()[0]);
174 ASSERT(dx.
state()[0].validTime() == windowHalf_);
175 Log::trace() <<
"CostFct3DVar::runTLM done" << std::endl;
180 template <
typename MODEL>
182 Log::trace() <<
"CostFct3DVar::zeroAD start" << std::endl;
186 Log::trace() <<
"CostFct3DVar::zeroAD done" << std::endl;
191 template <
typename MODEL>
196 Log::trace() <<
"CostFct3DVar::runADJ start" << std::endl;
197 ASSERT(dx.
state()[0].validTime() == windowHalf_);
199 an2model_->multiplyInverseAD(dx.
state()[0], dxmodel);
200 CostFct_::getTLM().forecastAD(dxmodel, dx.
modVar(), zero_, post, cost);
201 an2model_->multiplyAD(dxmodel, dx.
state()[0]);
202 ASSERT(dx.
state()[0].validTime() == windowHalf_);
203 Log::trace() <<
"CostFct3DVar::runADJ done" << std::endl;
208 template<
typename MODEL>
211 Log::trace() <<
"CostFct3DVar::addIncr start" << std::endl;
213 ASSERT(xx.
state()[0].validTime() == windowHalf_);
214 ASSERT(dx.
state()[0].validTime() == windowHalf_);
216 Log::trace() <<
"CostFct3DVar::addIncr done" << std::endl;
223 #endif // OOPS_ASSIMILATION_COSTFCT3DVAR_H_
State4D_ & state()
Get state control variable.
ControlVariable< MODEL > CtrlVar_
void runADJ(CtrlInc_ &, PostProcessorTLAD< MODEL > &, PostProcessor< Increment_ >, const bool) const override
Geometry< MODEL > Geometry_
CostJb3D< MODEL > * newJb(const eckit::Configuration &, const Geometry_ &, const CtrlVar_ &) const override
CostFct3DVar(const eckit::Configuration &, const Geometry_ &, const Model_ &)
ObsAuxIncr_ & obsVar()
Get augmented observation control variable.
ModelAuxIncr_ & modVar()
Get augmented model control variable.
boost::scoped_ptr< ChangeVar_ > an2model_
util::Duration windowLength_
Encapsulates the model state.
CostTermBase< MODEL > * newJc(const eckit::Configuration &, const Geometry_ &) const override
void doLinearize(const Geometry_ &, const eckit::Configuration &, const CtrlVar_ &, const CtrlVar_ &) override
The namespace for the main oops code.
CostFunction< MODEL > CostFct_
void runTLM(CtrlInc_ &, PostProcessorTLAD< MODEL > &, PostProcessor< Increment_ >, const bool) const override
ModelAux_ & modVar()
Get augmented model control variable.
Increment4D_ & state()
Get state control variable.
Increment< MODEL > Increment_
LinearVariableChangeFactory Factory.
Control model post processing.
CostJo< MODEL > * newJo(const eckit::Configuration &) const override
Base class for generic variable transform.
Encapsulates the nonlinear forecast model.
ControlIncrement< MODEL > CtrlInc_
Increment Class: Difference between two states.
void addIncr(CtrlVar_ &, const CtrlInc_ &, PostProcessor< Increment_ > &) const override
Base Class for Cost Function Terms.
Geometry_ geometry() const
Get geometry.
LinearVariableChangeBase< MODEL > ChangeVar_
void zeroAD(CtrlInc_ &) const override
bool checkStatesNumber(const unsigned int nn) const
Get model space control variable.
void runNL(CtrlVar_ &, PostProcessor< State_ > &) const override
Control model post processing.
util::DateTime windowEnd_
void setupTerms(const eckit::Configuration &)
util::DateTime windowHalf_
util::DateTime windowBegin_