atlas
Mesh.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 <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 util {
29 class Metadata;
30 class PartitionPolygons;
31 } // namespace util
32 } // namespace atlas
33 
34 namespace atlas {
35 namespace mesh {
36 class Nodes;
37 class HybridElements;
38 typedef HybridElements Edges;
39 typedef HybridElements Cells;
40 } // namespace mesh
41 } // namespace atlas
42 
43 namespace atlas {
44 namespace meshgenerator {
45 class MeshGeneratorImpl;
46 }
47 } // namespace atlas
48 
49 //----------------------------------------------------------------------------------------------------------------------
50 
51 namespace atlas {
52 
53 //----------------------------------------------------------------------------------------------------------------------
54 
55 class Mesh : DOXYGEN_HIDE( public util::ObjectHandle<mesh::detail::MeshImpl> ) {
56 public:
57  using Nodes = mesh::Nodes;
58  using Cells = mesh::Cells;
59  using Edges = mesh::Edges;
64 
65 public:
66  using Handle::Handle;
67  Mesh();
68 
70  Mesh( const Grid& );
71 
73  explicit Mesh( eckit::Stream& );
74 
76  void encode( eckit::Stream& s ) const { return get()->encode( s ); }
77 
78  const util::Metadata& metadata() const { return get()->metadata(); }
79  util::Metadata& metadata() { return get()->metadata(); }
80 
81  const Nodes& nodes() const { return get()->nodes(); }
82  Nodes& nodes() { return get()->nodes(); }
83 
84  const Cells& cells() const { return get()->cells(); }
85  Cells& cells() { return get()->cells(); }
86 
87  const Edges& edges() const { return get()->edges(); }
88  Edges& edges() { return get()->edges(); }
89 
90  const HybridElements& facets() const { return get()->facets(); }
91  HybridElements& facets() { return get()->facets(); }
92 
93  const HybridElements& ridges() const { return get()->ridges(); }
94  HybridElements& ridges() { return get()->ridges(); }
95 
96  const HybridElements& peaks() const { return get()->peaks(); }
97  HybridElements& peaks() { return get()->peaks(); }
98 
99  bool generated() const { return get()->generated(); }
100 
102  size_t footprint() const { return get()->footprint(); }
103 
104  idx_t partition() const { return get()->partition(); }
105 
106  idx_t nb_partitions() const { return get()->nb_partitions(); }
107 
108  void updateDevice() const { get()->updateDevice(); }
109 
110  void updateHost() const { get()->updateHost(); }
111 
112  void syncHostDevice() const { get()->syncHostDevice(); }
113 
114  const Projection& projection() const { return get()->projection(); }
115 
116  const PartitionGraph& partitionGraph() const { return get()->partitionGraph(); }
117 
118  PartitionGraph::Neighbours nearestNeighbourPartitions() const { return get()->nearestNeighbourPartitions(); }
119 
120  const Polygon& polygon( idx_t halo = 0 ) const { return get()->polygon( halo ); }
121  const Polygons& polygons() const { return get()->polygons(); }
122 
123  const Grid grid() const { return get()->grid(); }
124 
125 private: // methods
126  void print( std::ostream& out ) const { get()->print( out ); }
127 
128  friend std::ostream& operator<<( std::ostream& s, const Mesh& p ) {
129  p.print( s );
130  return s;
131  }
132 
134  void setProjection( const Projection& p ) { get()->setProjection( p ); }
135  void setGrid( const Grid& p ) { get()->setGrid( p ); }
136 };
137 
138 //----------------------------------------------------------------------------------------------------------------------
139 
140 } // namespace atlas
Definition: MeshGeneratorImpl.h:38
void encode(eckit::Stream &s) const
Serialization to Stream.
Definition: Mesh.h:76
Definition: Polygon.h:155
Definition: Projection.h:49
Definition: Mesh.h:55
Definition: PartitionGraph.h:29
Most general grid container.
Definition: Grid.h:64
Definition: Metadata.h:23
size_t footprint() const
Return the memory footprint of the mesh.
Definition: Mesh.h:102
Nodes class that owns a collection of fields defined in nodes of the mesh.
Definition: Nodes.h:43
HybridElements class that describes elements of different types.
Definition: HybridElements.h:64
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
Polygon class that holds the boundary of a mesh partition.
Definition: PartitionPolygon.h:41