11 #ifndef OOPS_ASSIMILATION_COSTJCDFI_H_
12 #define OOPS_ASSIMILATION_COSTJCDFI_H_
17 #include "eckit/config/LocalConfiguration.h"
31 #include "oops/util/DateTime.h"
32 #include "oops/util/Duration.h"
33 #include "oops/util/Logger.h"
55 const util::Duration &,
const util::Duration & tstep = util::Duration(0));
62 const eckit::Configuration &)
override;
64 const eckit::Configuration &)
override;
71 std::shared_ptr<PostBaseTLAD_>
setupTL(
const CtrlInc_ &)
const override;
74 std::shared_ptr<PostBaseTLAD_>
setupAD(
75 std::shared_ptr<const GeneralizedDepartures>,
CtrlInc_ &)
const override;
78 std::unique_ptr<GeneralizedDepartures>
80 std::unique_ptr<GeneralizedDepartures>
84 std::unique_ptr<GeneralizedDepartures>
newDualVector()
const override;
87 std::unique_ptr<GeneralizedDepartures>
newGradientFG()
const override;
96 std::unique_ptr<WeightingFct>
wfct_;
102 mutable std::shared_ptr<WeightedDiff<MODEL, Increment_, State_> >
filter_;
103 mutable std::shared_ptr<WeightedDiffTLAD<MODEL> >
ftlad_;
109 template<
typename MODEL,
typename OBS>
111 const util::DateTime & vt,
const util::Duration & span,
112 const util::Duration & tstep)
113 : vt_(vt), span_(span), alpha_(0), wfct_(), gradFG_(),
114 resol_(resol), tstep_(tstep), tlres_(), tlstep_(), filter_(), vars_(conf,
"filtered variables")
116 alpha_ = conf.getDouble(
"alpha");
117 if (conf.has(
"ftime"))
vt_ = util::DateTime(conf.getString(
"ftime"));
118 if (conf.has(
"span"))
span_ = util::Duration(conf.getString(
"span"));
121 Log::trace() <<
"CostJcDFI created" << std::endl;
126 template<
typename MODEL,
typename OBS>
127 std::shared_ptr<PostBase<State<MODEL> > >
130 tstep_, resol_, *wfct_));
136 template<
typename MODEL,
typename OBS>
138 double zz = 0.5 * alpha_;
139 std::unique_ptr<Increment_> dx(filter_->releaseDiff());
140 zz *= dot_product(*dx, *dx);
141 Log::test() <<
"CostJcDFI: Nonlinear Jc = " << zz << std::endl;
147 template<
typename MODEL,
typename OBS>
148 std::shared_ptr<PostBaseTLAD<MODEL> >
150 const eckit::Configuration & innerConf) {
152 tlstep_ = util::Duration(innerConf.getString(
"linear model.tstep", tstep_.toString()));
159 template<
typename MODEL,
typename OBS>
161 gradFG_.reset(ftlad_->releaseDiff());
167 template<
typename MODEL,
typename OBS>
169 std::unique_ptr<Increment_> dx(
new Increment_(*tlres_, vars_, vt_));
170 return std::move(dx);
175 template<
typename MODEL,
typename OBS>
177 return std::unique_ptr<Increment_>(
new Increment_(*gradFG_));
182 template<
typename MODEL,
typename OBS>
183 std::shared_ptr<PostBaseTLAD<MODEL> >
185 ftlad_->setupTL(*tlres_);
191 template<
typename MODEL,
typename OBS>
192 std::shared_ptr<PostBaseTLAD<MODEL> >
194 std::shared_ptr<const Increment_>
195 dx = std::dynamic_pointer_cast<const Increment_>(pv);
202 template<
typename MODEL,
typename OBS>
203 std::unique_ptr<GeneralizedDepartures>
206 std::unique_ptr<Increment_> dx2(
new Increment_(dx1));
207 const double za = 1.0/alpha_;
209 return std::move(dx2);
214 template<
typename MODEL,
typename OBS>
215 std::unique_ptr<GeneralizedDepartures>
218 std::unique_ptr<Increment_> dx2(
new Increment_(dx1));
220 return std::move(dx2);
225 template<
typename MODEL,
typename OBS>
235 #endif // OOPS_ASSIMILATION_COSTJCDFI_H_