TECA
teca_mesh.h
1 #ifndef teca_mesh_h
2 #define teca_mesh_h
3 
4 #include "teca_mesh_fwd.h"
5 #include "teca_dataset.h"
6 #include "teca_metadata.h"
7 #include "teca_array_collection.h"
8 
10 
16 class teca_mesh : public teca_dataset
17 {
18 public:
19  ~teca_mesh() = default;
20 
21  // set/get temporal metadata
22  TECA_DATASET_METADATA(time, double, 1)
23  TECA_DATASET_METADATA(calendar, std::string, 1)
24  TECA_DATASET_METADATA(time_units, std::string, 1)
25  TECA_DATASET_METADATA(time_step, unsigned long, 1)
26 
27  // set/get attribute metadata
28  TECA_DATASET_METADATA(attributes, teca_metadata, 1)
29 
30  // get the array collection for the given centering
31  // the centering enumeration is defined in teca_array_attributes
32  // the centering attribute is typically stored in array attribute
33  // metadata
34  p_teca_array_collection &get_arrays(int centering);
35  const_p_teca_array_collection get_arrays(int centering) const;
36 
37  // get point centered data
38  p_teca_array_collection &get_point_arrays()
39  { return m_impl->point_arrays; }
40 
41  const_p_teca_array_collection get_point_arrays() const
42  { return m_impl->point_arrays; }
43 
44  // get cell centered data
45  p_teca_array_collection &get_cell_arrays()
46  { return m_impl->cell_arrays; }
47 
48  const_p_teca_array_collection get_cell_arrays() const
49  { return m_impl->cell_arrays; }
50 
51  // get edge centered data
52  p_teca_array_collection &get_x_edge_arrays()
53  { return m_impl->x_edge_arrays; }
54 
55  const_p_teca_array_collection get_x_edge_arrays() const
56  { return m_impl->x_edge_arrays; }
57 
58  p_teca_array_collection &get_y_edge_arrays()
59  { return m_impl->y_edge_arrays; }
60 
61  const_p_teca_array_collection get_y_edge_arrays() const
62  { return m_impl->y_edge_arrays; }
63 
64  p_teca_array_collection &get_z_edge_arrays()
65  { return m_impl->z_edge_arrays; }
66 
67  const_p_teca_array_collection get_z_edge_arrays() const
68  { return m_impl->z_edge_arrays; }
69 
70  // get face centered data
71  p_teca_array_collection &get_x_face_arrays()
72  { return m_impl->x_face_arrays; }
73 
74  const_p_teca_array_collection get_x_face_arrays() const
75  { return m_impl->x_face_arrays; }
76 
77  p_teca_array_collection &get_y_face_arrays()
78  { return m_impl->y_face_arrays; }
79 
80  const_p_teca_array_collection get_y_face_arrays() const
81  { return m_impl->y_face_arrays; }
82 
83  p_teca_array_collection &get_z_face_arrays()
84  { return m_impl->z_face_arrays; }
85 
86  const_p_teca_array_collection get_z_face_arrays() const
87  { return m_impl->z_face_arrays; }
88 
89  // get non-geometric data
90  p_teca_array_collection &get_information_arrays()
91  { return m_impl->info_arrays; }
92 
93  const_p_teca_array_collection get_information_arrays() const
94  { return m_impl->info_arrays; }
95 
96  // return true if the dataset is empty.
97  bool empty() const noexcept override;
98 
99  // copy data and metadata. shallow copy uses reference
100  // counting, while copy duplicates the data.
101  void copy(const const_p_teca_dataset &) override;
102  void shallow_copy(const p_teca_dataset &) override;
103 
104  // append array based data from another mesh. No consistency
105  // checks are performed.
106  void append_arrays(const const_p_teca_mesh &);
107  void shallow_append_arrays(const p_teca_mesh &);
108 
109  // swap internals of the two objects
110  void swap(p_teca_dataset &) override;
111 
112  // serialize the dataset to/from the given stream
113  // for I/O or communication
114  int to_stream(teca_binary_stream &) const override;
115  int from_stream(teca_binary_stream &) override;
116 
117  // stream to/from human readable representation
118  int to_stream(std::ostream &) const override;
119  int from_stream(std::istream &) override { return -1; }
120 
121 protected:
122  teca_mesh();
123 
124 public:
125  struct impl_t
126  {
127  impl_t();
128  //
129  p_teca_array_collection cell_arrays;
130  p_teca_array_collection x_edge_arrays;
131  p_teca_array_collection y_edge_arrays;
132  p_teca_array_collection z_edge_arrays;
133  p_teca_array_collection x_face_arrays;
134  p_teca_array_collection y_face_arrays;
135  p_teca_array_collection z_face_arrays;
136  p_teca_array_collection point_arrays;
137  p_teca_array_collection info_arrays;
138  p_teca_array_collection invalid;
139  };
140  std::shared_ptr<impl_t> m_impl;
141 };
142 
143 #endif
teca_binary_stream
Definition: teca_binary_stream.h:16
teca_metadata
Definition: teca_metadata.h:17
teca_mesh
a base class for geometric data
Definition: teca_mesh.h:17
teca_dataset
Definition: teca_dataset.h:14
teca_mesh::impl_t
Definition: teca_mesh.h:126