OOPS
FieldsQG.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 QG_MODEL_FIELDSQG_H_
12 #define QG_MODEL_FIELDSQG_H_
13 
14 #include <memory>
15 #include <ostream>
16 #include <string>
17 #include <vector>
18 
19 #include "atlas/field.h"
20 
21 #include "eckit/config/LocalConfiguration.h"
22 
24 #include "oops/base/Variables.h"
25 #include "oops/util/DateTime.h"
26 #include "oops/util/Duration.h"
27 #include "oops/util/ObjectCounter.h"
28 #include "oops/util/Printable.h"
29 #include "oops/util/Serializable.h"
30 
31 #include "oops/qg/GeometryQG.h"
32 #include "oops/qg/GeometryQGIterator.h"
33 
34 // Forward declarations
35 namespace eckit {
36  class Configuration;
37 }
38 
39 namespace oops {
40  class Variables;
41  class LocalIncrement;
42 }
43 
44 namespace qg {
45  class LocationsQG;
46  class GomQG;
47 
48 // -----------------------------------------------------------------------------
49 /// Class to represent a Fields for the QG model
50 class FieldsQG : public util::Printable,
51  public util::Serializable,
52  private util::ObjectCounter<FieldsQG> {
53  public:
54  static const std::string classname() {return "qg::FieldsQG";}
55 
56 // Constructors and basic operators
57  FieldsQG(const GeometryQG &, const oops::Variables &, const bool &, const util::DateTime &);
58  FieldsQG(const FieldsQG &, const GeometryQG &);
59  FieldsQG(const FieldsQG &, const oops::Variables &);
60  FieldsQG(const FieldsQG &, const bool);
61  FieldsQG(const FieldsQG &);
62  ~FieldsQG();
63 
64  void zero();
65  void zero(const util::DateTime &);
66  void ones();
67  FieldsQG & operator=(const FieldsQG &);
68  FieldsQG & operator+=(const FieldsQG &);
69  FieldsQG & operator-=(const FieldsQG &);
70  FieldsQG & operator*=(const double &);
71  void axpy(const double &, const FieldsQG &);
72  double dot_product_with(const FieldsQG &) const;
73  void schur_product_with(const FieldsQG &);
74  void dirac(const eckit::Configuration &);
75  void random();
76 
77 // Interpolate full fields
78  void changeResolution(const FieldsQG &);
79  void add(const FieldsQG &);
80  void diff(const FieldsQG &, const FieldsQG &);
81 
82 // ATLAS FieldSet
83  void setAtlas(atlas::FieldSet *) const;
84  void toAtlas(atlas::FieldSet *) const;
85  void fromAtlas(atlas::FieldSet *);
86 
87 // Utilities
88  void read(const eckit::Configuration &);
89  void analytic_init(const eckit::Configuration &);
90  void write(const eckit::Configuration &) const;
91  double norm() const;
92  std::shared_ptr<const GeometryQG> geometry() const {return geom_;}
93  const oops::Variables & variables() const {return vars_;}
94 
95  const util::DateTime & time() const {return time_;}
96  util::DateTime & time() {return time_;}
97  void updateTime(const util::Duration & dt) {time_ += dt;}
98 
99  const int & toFortran() const {return keyFlds_;}
100 
101  bool isForModel(const bool &) const;
102 
104  void setLocal(const oops::LocalIncrement &, const GeometryQGIterator &);
105 
106 /// Serialization
107  size_t serialSize() const override;
108  void serialize(std::vector<double> &) const override;
109  void deserialize(const std::vector<double> &, size_t &) override;
110 
111  private:
112  void print(std::ostream &) const override;
114  std::shared_ptr<const GeometryQG> geom_;
116  const bool lbc_;
117  util::DateTime time_;
118 };
119 // -----------------------------------------------------------------------------
120 
121 } // namespace qg
122 #endif // QG_MODEL_FIELDSQG_H_
Class to represent a Fields for the QG model.
Definition: FieldsQG.h:52
FieldsQG & operator*=(const double &)
Definition: FieldsQG.cc:96
void toAtlas(atlas::FieldSet *) const
Definition: FieldsQG.cc:155
void deserialize(const std::vector< double > &, size_t &) override
Definition: FieldsQG.cc:265
void random()
Definition: FieldsQG.cc:128
const int & toFortran() const
Definition: FieldsQG.h:99
FieldsQG & operator=(const FieldsQG &)
Definition: FieldsQG.cc:80
util::DateTime time_
Definition: FieldsQG.h:117
FieldsQG & operator-=(const FieldsQG &)
Definition: FieldsQG.cc:91
void add(const FieldsQG &)
Definition: FieldsQG.cc:140
void print(std::ostream &) const override
Definition: FieldsQG.cc:181
void updateTime(const util::Duration &dt)
Definition: FieldsQG.h:97
void fromAtlas(atlas::FieldSet *)
Definition: FieldsQG.cc:159
void analytic_init(const eckit::Configuration &)
Definition: FieldsQG.cc:167
static const std::string classname()
Definition: FieldsQG.h:54
void serialize(std::vector< double > &) const override
Definition: FieldsQG.cc:251
void setAtlas(atlas::FieldSet *) const
Definition: FieldsQG.cc:151
void setLocal(const oops::LocalIncrement &, const GeometryQGIterator &)
Definition: FieldsQG.cc:234
void write(const eckit::Configuration &) const
Definition: FieldsQG.cc:171
const bool lbc_
Definition: FieldsQG.h:116
bool isForModel(const bool &) const
Definition: FieldsQG.cc:211
void zero()
Definition: FieldsQG.cc:101
double norm() const
Definition: FieldsQG.cc:175
const oops::Variables vars_
Definition: FieldsQG.h:115
FieldsQG & operator+=(const FieldsQG &)
Definition: FieldsQG.cc:86
void schur_product_with(const FieldsQG &)
Definition: FieldsQG.cc:124
oops::LocalIncrement getLocal(const GeometryQGIterator &) const
Definition: FieldsQG.cc:221
void axpy(const double &, const FieldsQG &)
Definition: FieldsQG.cc:114
std::shared_ptr< const GeometryQG > geom_
Definition: FieldsQG.h:114
void read(const eckit::Configuration &)
Definition: FieldsQG.cc:163
FieldsQG(const GeometryQG &, const oops::Variables &, const bool &, const util::DateTime &)
Definition: FieldsQG.cc:38
std::shared_ptr< const GeometryQG > geometry() const
Definition: FieldsQG.h:92
void changeResolution(const FieldsQG &)
Definition: FieldsQG.cc:136
void dirac(const eckit::Configuration &)
Definition: FieldsQG.cc:132
void ones()
Definition: FieldsQG.cc:110
double dot_product_with(const FieldsQG &) const
Definition: FieldsQG.cc:118
F90flds keyFlds_
Definition: FieldsQG.h:113
void diff(const FieldsQG &, const FieldsQG &)
Definition: FieldsQG.cc:145
size_t serialSize() const override
Serialization.
Definition: FieldsQG.cc:239
const oops::Variables & variables() const
Definition: FieldsQG.h:93
const util::DateTime & time() const
Definition: FieldsQG.h:95
util::DateTime & time()
Definition: FieldsQG.h:96
GeometryQG handles geometry for QG model.
Definition: GeometryQG.h:58
Definition: FieldL95.h:22
The namespace for the main oops code.
The namespace for the qg model.
int F90flds
Definition: QgFortran.h:49