atlas
Spacing.h
1 /*
2  * (C) Copyright 2013 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
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <array>
14 #include <string>
15 #include <vector>
16 
17 #include "atlas/library/config.h"
18 #include "atlas/util/ObjectHandle.h"
19 
20 //---------------------------------------------------------------------------------------------------------------------
21 #ifndef DOXYGEN_SHOULD_SKIP_THIS
22 // Forward declarations
23 namespace eckit {
24 class Parametrisation;
25 }
26 namespace atlas {
27 namespace util {
28 class Config;
29 }
30 namespace grid {
31 namespace spacing {
32 class Spacing;
33 }
34 } // namespace grid
35 } // namespace atlas
36 #endif
37 //---------------------------------------------------------------------------------------------------------------------
38 
39 namespace atlas {
40 namespace grid {
41 
42 //---------------------------------------------------------------------------------------------------------------------
43 
44 class Spacing : DOXYGEN_HIDE( public util::ObjectHandle<atlas::grid::spacing::Spacing> ) {
45 public:
46  using const_iterator = std::vector<double>::const_iterator;
47  using Interval = std::array<double, 2>;
48  using Spec = atlas::util::Config;
49 
50 public:
51  using Handle::Handle;
52  Spacing() = default;
53  Spacing( const eckit::Parametrisation& );
54 
55  size_t size() const;
56 
57  double operator[]( size_t i ) const;
58 
59  const_iterator begin() const;
60  const_iterator end() const;
61 
62  double front() const;
63  double back() const;
64 
65  Interval interval() const;
66 
67  double min() const;
68  double max() const;
69 
70  std::string type() const;
71 
72  Spec spec() const;
73 };
74 
75 //---------------------------------------------------------------------------------------------------------------------
76 
77 class LinearSpacing : public Spacing {
78 public:
79  using Interval = std::array<double, 2>;
80 
81 public:
82  using Spacing::Spacing;
83  LinearSpacing() = default;
84  LinearSpacing( double start, double stop, long N, bool endpoint = true );
85  LinearSpacing( const Interval&, long N, bool endpoint = true );
86  double step() const;
87 };
88 
89 //---------------------------------------------------------------------------------------------------------------------
90 
91 class GaussianSpacing : public Spacing {
92 public:
93  using Spacing::Spacing;
94  GaussianSpacing() = default;
95  GaussianSpacing( long N );
96 };
97 
98 //---------------------------------------------------------------------------------------------------------------------
99 
100 } // namespace grid
101 } // namespace atlas
Definition: Spacing.h:44
Definition: Domain.h:19
Definition: Spacing.h:91
Definition: Spacing.h:77
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
Configuration class used to construct various atlas components.
Definition: Config.h:27