Debian Codegraph @

src/atlas/mesh/Mesh.h

raw
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 <iosfwd>
14
15 #include "atlas/library/config.h"
16 #include "atlas/mesh/detail/MeshImpl.h"
17 #include "atlas/util/ObjectHandle.h"
18
19 //----------------------------------------------------------------------------------------------------------------------
20 // Forward declarations
21
22 namespace atlas {
23 class Projection;
24 class Grid;
25 } // namespace atlas
26
27 namespace atlas {
28 namespace grid {
29 class Partitioner;
30 class Distribution;
31 }
32 } // namespace atlas
33
34 namespace atlas {
35 namespace util {
36 class Metadata;
37 class PartitionPolygons;
38 } // namespace util
39 } // namespace atlas
40
41 namespace atlas {
42 namespace mesh {
43 class MeshBuilder;
44 class Nodes;
45 class HybridElements;
46 typedef HybridElements Edges;
47 typedef HybridElements Cells;
48 } // namespace mesh
49 } // namespace atlas
50
51 namespace atlas {
52 namespace meshgenerator {
53 class MeshGeneratorImpl;
54 }
55 } // namespace atlas
56
57 //----------------------------------------------------------------------------------------------------------------------
58
59 namespace atlas {
60
61 //----------------------------------------------------------------------------------------------------------------------
62
63 class Mesh : DOXYGEN_HIDE(public util::ObjectHandle<mesh::detail::MeshImpl>) {
64 public:
65 using Nodes = mesh::Nodes;
66 using Cells = mesh::Cells;
67 using Edges = mesh::Edges;
68 using HybridElements = mesh::HybridElements;
69 using PartitionGraph = mesh::detail::PartitionGraph;
70 using Polygon = mesh::PartitionPolygon;
71 using Polygons = util::PartitionPolygons;
72
73 public:
74 using Handle::Handle;
75 Mesh();
76
77 operator bool() const;
78
79 /// @brief Generate a mesh from a Grid with recommended mesh generator and partitioner strategy
80 Mesh(const Grid&, const eckit::Configuration& = util::NoConfig());
81
82 Mesh(const Grid&, const grid::Partitioner&, const eckit::Configuration& = util::NoConfig());
83
84 Mesh(const Grid&, const grid::Distribution&, const eckit::Configuration& = util::NoConfig());
85
86 /// @brief Construct a mesh from a Stream (serialization)
87 explicit Mesh(eckit::Stream&);
88
89 /// @brief Serialization to Stream
90 void encode(eckit::Stream& s) const { return get()->encode(s); }
91
92 const util::Metadata& metadata() const { return get()->metadata(); }
93 util::Metadata& metadata() { return get()->metadata(); }
94
95 const Nodes& nodes() const { return get()->nodes(); }
96 Nodes& nodes() { return get()->nodes(); }
97
98 const Cells& cells() const { return get()->cells(); }
99 Cells& cells() { return get()->cells(); }
100
101 const Edges& edges() const { return get()->edges(); }
102 Edges& edges() { return get()->edges(); }
103
104 const HybridElements& facets() const { return get()->facets(); }
105 HybridElements& facets() { return get()->facets(); }
106
107 const HybridElements& ridges() const { return get()->ridges(); }
108 HybridElements& ridges() { return get()->ridges(); }
109
110 const HybridElements& peaks() const { return get()->peaks(); }
111 HybridElements& peaks() { return get()->peaks(); }
112
113 bool generated() const { return get()->generated(); }
114
115 /// @brief Return the memory footprint of the mesh
116 size_t footprint() const { return get()->footprint(); }
117
118 idx_t part() const { return get()->part(); }
119
120 idx_t nb_parts() const { return get()->nb_parts(); }
121
122 [[deprecated("Use 'atlas::mesh::Mesh::nb_parts() instead")]] // added in v0.35.0
123 idx_t nb_partitions() const { return nb_parts(); }
124
125 std::string mpi_comm() const { return get()->mpi_comm(); }
126
127 void updateDevice() const { get()->updateDevice(); }
128
129 void updateHost() const { get()->updateHost(); }
130
131 void syncHostDevice() const { get()->syncHostDevice(); }
132
133 const Projection& projection() const { return get()->projection(); }
134
135 const PartitionGraph& partitionGraph() const { return get()->partitionGraph(); }
136
137 PartitionGraph::Neighbours nearestNeighbourPartitions() const { return get()->nearestNeighbourPartitions(); }
138
139 const Polygon& polygon(idx_t halo = 0) const { return get()->polygon(halo); }
140 const Polygons& polygons() const { return get()->polygons(); }
141
142 const Grid grid() const { return get()->grid(); }
143
144 private: // methods
145 void print(std::ostream& out) const { get()->print(out); }
146
147 friend std::ostream& operator<<(std::ostream& s, const Mesh& p) {
148 p.print(s);
149 return s;
150 }
151
152 friend class mesh::MeshBuilder;
153 friend class meshgenerator::MeshGeneratorImpl;
154 void setProjection(const Projection& p) { get()->setProjection(p); }
155 void setGrid(const Grid& p) { get()->setGrid(p); }
156 };
157
158 //----------------------------------------------------------------------------------------------------------------------
159
160 } // namespace atlas