Loading [MathJax]/extensions/tex2jax.js
OOPS
All Classes Namespaces Files Functions Variables Typedefs Macros Pages
FieldL95.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 LORENZ95_FIELDL95_H_
12 #define LORENZ95_FIELDL95_H_
13 
14 #include <ostream>
15 #include <string>
16 #include <vector>
17 
18 #include "oops/util/Printable.h"
19 #include "oops/util/Serializable.h"
20 
21 // Forward declarations
22 namespace eckit {
23  class Configuration;
24 }
25 
26 namespace lorenz95 {
27  class LocsL95;
28  class GomL95;
29  class Resolution;
30 
31 // -----------------------------------------------------------------------------
32 /// Class to represent fields for the L95 model
33 class FieldL95 : public util::Printable,
34  public util::Serializable {
35  public:
36  static const std::string classname() {return "lorenz95::FieldL95";}
37 
38 /// Constructors and basic operators
39  explicit FieldL95(const Resolution &);
40  FieldL95(const FieldL95 &, const Resolution &);
41  explicit FieldL95(const FieldL95 &, const bool copy = true);
42  ~FieldL95() {}
43 
44 /// Linear algebra
45  void zero();
46  void ones();
47  void dirac(const eckit::Configuration &);
48  FieldL95 & operator=(const FieldL95 &);
49  FieldL95 & operator+=(const FieldL95 &);
50  FieldL95 & operator-=(const FieldL95 &);
51  FieldL95 & operator*=(const double &);
52  void diff(const FieldL95 &, const FieldL95 &);
53  void axpy(const double &, const FieldL95 &);
54  double dot_product_with(const FieldL95 &) const;
55  void schur(const FieldL95 &);
56  void random();
57  void generate(const eckit::Configuration &);
58 
59 /// Utilities
60  void read(std::ifstream &);
61  void write(std::ofstream &) const;
62  double rms() const;
63 
64 /// Set and get
65  const int & resol() const {return resol_;}
66  double & operator[](const int ii) {return x_[ii];}
67  const double & operator[](const int ii) const {return x_[ii];}
68  std::vector<double> & asVector() {return x_;}
69  const std::vector<double> & asVector() const {return x_;}
70 
71 /// Serialize and deserialize
72  size_t serialSize() const override;
73  void serialize(std::vector<double> &) const override;
74  void deserialize(const std::vector<double> &, size_t &) override;
75 
76  private:
77  void print(std::ostream &) const override;
78  const int resol_;
79  std::vector<double> x_;
80 };
81 // -----------------------------------------------------------------------------
82 
83 } // namespace lorenz95
84 
85 #endif // LORENZ95_FIELDL95_H_
Class to represent fields for the L95 model.
Definition: FieldL95.h:34
FieldL95(const Resolution &)
Constructors and basic operators.
Definition: FieldL95.cc:31
void generate(const eckit::Configuration &)
Definition: FieldL95.cc:80
FieldL95 & operator-=(const FieldL95 &)
Definition: FieldL95.cc:111
FieldL95 & operator+=(const FieldL95 &)
Definition: FieldL95.cc:105
void write(std::ofstream &) const
Definition: FieldL95.cc:157
void diff(const FieldL95 &, const FieldL95 &)
Definition: FieldL95.cc:122
const int & resol() const
Set and get.
Definition: FieldL95.h:65
void deserialize(const std::vector< double > &, size_t &) override
Definition: FieldL95.cc:177
void axpy(const double &, const FieldL95 &)
Definition: FieldL95.cc:130
const int resol_
Definition: FieldL95.h:78
const double & operator[](const int ii) const
Definition: FieldL95.h:67
double & operator[](const int ii)
Definition: FieldL95.h:66
void schur(const FieldL95 &)
Definition: FieldL95.cc:142
static const std::string classname()
Definition: FieldL95.h:36
void zero()
Linear algebra.
Definition: FieldL95.cc:57
FieldL95 & operator*=(const double &)
Definition: FieldL95.cc:117
FieldL95 & operator=(const FieldL95 &)
Definition: FieldL95.cc:99
void dirac(const eckit::Configuration &)
Definition: FieldL95.cc:65
const std::vector< double > & asVector() const
Definition: FieldL95.h:69
double dot_product_with(const FieldL95 &) const
Definition: FieldL95.cc:135
std::vector< double > x_
Definition: FieldL95.h:79
void serialize(std::vector< double > &) const override
Definition: FieldL95.cc:173
std::vector< double > & asVector()
Definition: FieldL95.h:68
void read(std::ifstream &)
Utilities.
Definition: FieldL95.cc:152
size_t serialSize() const override
Serialize and deserialize.
Definition: FieldL95.cc:169
void print(std::ostream &) const override
Definition: FieldL95.cc:184
double rms() const
Definition: FieldL95.cc:162
Handles resolution.
Definition: Resolution.h:43
Definition: FieldL95.h:22
The namespace for the L95 model.