OOPS
IncrementQG.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  * (C) Copyright 2017-2019 UCAR.
4  *
5  * This software is licensed under the terms of the Apache Licence Version 2.0
6  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7  * In applying this licence, ECMWF does not waive the privileges and immunities
8  * granted to it by virtue of its status as an intergovernmental organisation nor
9  * does it submit to any jurisdiction.
10  */
11 
12 #ifndef QG_MODEL_INCREMENTQG_H_
13 #define QG_MODEL_INCREMENTQG_H_
14 
15 #include <memory>
16 #include <ostream>
17 #include <string>
18 #include <vector>
19 
20 #include "atlas/field.h"
21 
22 #include "eckit/config/LocalConfiguration.h"
23 
25 #include "oops/util/DateTime.h"
26 #include "oops/util/dot_product.h"
27 #include "oops/util/Duration.h"
28 #include "oops/util/ObjectCounter.h"
29 #include "oops/util/Printable.h"
30 #include "oops/util/Serializable.h"
31 
32 #include "oops/qg/FieldsQG.h"
33 #include "oops/qg/GeometryQG.h"
34 #include "oops/qg/GeometryQGIterator.h"
35 
36 namespace eckit {
37  class Configuration;
38 }
39 
40 namespace oops {
41  class LocalIncrement;
42  class Variables;
43 }
44 
45 namespace qg {
46  class GomQG;
47  class LocationsQG;
48  class GeometryQG;
49  class ModelBiasIncrement;
50  class ErrorCovarianceQG;
51  class StateQG;
52 
53 /// Increment Class: Difference between two states
54 /*!
55  * Some fields that are present in a State may not be present in
56  * an Increment. The Increment contains everything that is needed by
57  * the tangent-linear and adjoint models.
58  */
59 
60 // -----------------------------------------------------------------------------
61 
62 class IncrementQG : public util::Printable,
63  public util::Serializable,
64  private util::ObjectCounter<IncrementQG> {
65  public:
66  static const std::string classname() {return "qg::IncrementQG";}
67 
68 /// Constructor, destructor
69  IncrementQG(const GeometryQG &, const oops::Variables &, const util::DateTime &);
70  IncrementQG(const GeometryQG &, const IncrementQG &);
71  IncrementQG(const IncrementQG &, const bool);
72  IncrementQG(const IncrementQG &);
73  virtual ~IncrementQG();
74 
75 /// Basic operators
76  void diff(const StateQG &, const StateQG &);
77  void zero();
78  void zero(const util::DateTime &);
79  void ones();
83  IncrementQG & operator*=(const double &);
84  void axpy(const double &, const IncrementQG &, const bool check = true);
85  double dot_product_with(const IncrementQG &) const;
86  void schur_product_with(const IncrementQG &);
87  void random();
88  void dirac(const eckit::Configuration &);
89 
90 /// I/O and diagnostics
91  void read(const eckit::Configuration &);
92  void write(const eckit::Configuration &) const;
93  double norm() const {return fields_->norm();}
94  const util::DateTime & validTime() const {return fields_->time();}
95  util::DateTime & validTime() {return fields_->time();}
96  void updateTime(const util::Duration & dt) {fields_->time() += dt;}
97 
98 /// ATLAS FieldSet
99  void setAtlas(atlas::FieldSet *) const;
100  void toAtlas(atlas::FieldSet *) const;
101  void fromAtlas(atlas::FieldSet *);
102 
103 /// Access to fields
104  FieldsQG & fields() {return *fields_;}
105  const FieldsQG & fields() const {return *fields_;}
106 
107  std::shared_ptr<const GeometryQG> geometry() const {
108  return fields_->geometry();
109  }
110 
111 /// Other
112  void accumul(const double &, const StateQG &);
114  void setLocal(const oops::LocalIncrement &, const GeometryQGIterator &);
115 
116 /// Serialization
117  size_t serialSize() const override;
118  void serialize(std::vector<double> &) const override;
119  void deserialize(const std::vector<double> &, size_t &) override;
120 
121 /// Data
122  private:
123  void print(std::ostream &) const override;
124  const bool lbc_ = false;
125  std::unique_ptr<FieldsQG> fields_;
126 };
127 // -----------------------------------------------------------------------------
128 
129 } // namespace qg
130 
131 #endif // QG_MODEL_INCREMENTQG_H_
Class to represent a Fields for the QG model.
Definition: FieldsQG.h:52
GeometryQG handles geometry for QG model.
Definition: GeometryQG.h:58
Increment Class: Difference between two states.
Definition: IncrementQG.h:64
void updateTime(const util::Duration &dt)
Definition: IncrementQG.h:96
double dot_product_with(const IncrementQG &) const
Definition: IncrementQG.cc:128
virtual ~IncrementQG()
Definition: IncrementQG.cc:68
void setAtlas(atlas::FieldSet *) const
ATLAS FieldSet.
Definition: IncrementQG.cc:144
void axpy(const double &, const IncrementQG &, const bool check=true)
Definition: IncrementQG.cc:114
void setLocal(const oops::LocalIncrement &, const GeometryQGIterator &)
Definition: IncrementQG.cc:190
void print(std::ostream &) const override
Data.
Definition: IncrementQG.cc:181
void read(const eckit::Configuration &)
I/O and diagnostics.
Definition: IncrementQG.cc:158
const util::DateTime & validTime() const
Definition: IncrementQG.h:94
void toAtlas(atlas::FieldSet *) const
Definition: IncrementQG.cc:148
void dirac(const eckit::Configuration &)
Definition: IncrementQG.cc:136
void write(const eckit::Configuration &) const
Definition: IncrementQG.cc:162
IncrementQG & operator+=(const IncrementQG &)
Definition: IncrementQG.cc:85
const FieldsQG & fields() const
Definition: IncrementQG.h:105
std::shared_ptr< const GeometryQG > geometry() const
Definition: IncrementQG.h:107
IncrementQG & operator=(const IncrementQG &)
Definition: IncrementQG.cc:80
void schur_product_with(const IncrementQG &)
Definition: IncrementQG.cc:124
static const std::string classname()
Definition: IncrementQG.h:66
void serialize(std::vector< double > &) const override
Definition: IncrementQG.cc:173
IncrementQG & operator-=(const IncrementQG &)
Definition: IncrementQG.cc:91
void diff(const StateQG &, const StateQG &)
Basic operators.
Definition: IncrementQG.cc:74
void deserialize(const std::vector< double > &, size_t &) override
Definition: IncrementQG.cc:177
size_t serialSize() const override
Serialization.
Definition: IncrementQG.cc:168
void fromAtlas(atlas::FieldSet *)
Definition: IncrementQG.cc:152
oops::LocalIncrement getLocal(const GeometryQGIterator &) const
Definition: IncrementQG.cc:186
const bool lbc_
Definition: IncrementQG.h:124
IncrementQG(const GeometryQG &, const oops::Variables &, const util::DateTime &)
Constructor, destructor.
Definition: IncrementQG.cc:42
FieldsQG & fields()
Access to fields.
Definition: IncrementQG.h:104
util::DateTime & validTime()
Definition: IncrementQG.h:95
std::unique_ptr< FieldsQG > fields_
Definition: IncrementQG.h:125
double norm() const
Definition: IncrementQG.h:93
IncrementQG & operator*=(const double &)
Definition: IncrementQG.cc:97
void accumul(const double &, const StateQG &)
Other.
Definition: IncrementQG.cc:120
QG model state.
Definition: StateQG.h:42
Definition: FieldL95.h:22
The namespace for the main oops code.
The namespace for the qg model.