FV3 Bundle
JqTerm.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_ASSIMILATION_JQTERM_H_
12 #define OOPS_ASSIMILATION_JQTERM_H_
13 
14 #include <vector>
15 
18 #include "oops/base/PostBase.h"
19 #include "oops/interface/State.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/Duration.h"
22 
23 namespace oops {
24 
25 // -----------------------------------------------------------------------------
26 
27 template <typename MODEL> class JqTerm : public PostBase< State<MODEL> > {
31 
32  public:
33  explicit JqTerm(unsigned nsub) : mxi_(), nsubwin_(nsub) {}
34  ~JqTerm() {}
35 
36  void computeModelError(const State4D_ &, Increment4D_ &);
37 
38  private:
39  void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override {}
40  void doProcessing(const State_ &) override {}
41  void doFinalize(const State_ &) override;
42 
43  std::vector<State_> mxi_;
44  const unsigned nsubwin_;
45 };
46 
47 // =============================================================================
48 
49 template <typename MODEL>
51  Log::trace() << "JqTerm::doFinalize start" << std::endl;
52  if (mxi_.size() < nsubwin_ - 1) mxi_.push_back(xx);
53  Log::trace() << "JqTerm::doFinalize done" << std::endl;
54 }
55 
56 // -----------------------------------------------------------------------------
57 
58 template <typename MODEL>
60  Log::trace() << "JqTerm::computeModelError start" << std::endl;
61 // Compute x_i - M(x_{i-1})
62  for (unsigned jsub = 1; jsub < nsubwin_; ++jsub) {
63  dx[jsub].diff(fg[jsub], mxi_[jsub-1]);
64  Log::info() << "CostJbJq: x_" << jsub << " - M(x_" << jsub-1 << ")" << dx[jsub] << std::endl;
65  }
66  mxi_.clear();
67  Log::trace() << "JqTerm::computeModelError done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 } // namespace oops
73 
74 #endif // OOPS_ASSIMILATION_JQTERM_H_
const unsigned nsubwin_
Definition: JqTerm.h:44
void doProcessing(const State_ &) override
Actual processing.
Definition: JqTerm.h:40
State< MODEL > State_
Definition: JqTerm.h:28
void computeModelError(const State4D_ &, Increment4D_ &)
Definition: JqTerm.h:59
JqTerm(unsigned nsub)
Definition: JqTerm.h:33
State4D< MODEL > State4D_
Definition: JqTerm.h:30
void diff(const State4D_ &, const State4D_ &)
Linear algebra operators.
Definition: Increment4D.h:171
Encapsulates the model state.
void doFinalize(const State_ &) override
Definition: JqTerm.h:50
std::vector< State_ > mxi_
Definition: JqTerm.h:43
The namespace for the main oops code.
subroutine, public info(self)
Increment4D< MODEL > Increment4D_
Definition: JqTerm.h:29
State increment.
Definition: CostJbState.h:28
Four dimensional state.
Definition: CostJbState.h:29
void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override
Definition: JqTerm.h:39