TECA
teca_cartesian_mesh.h
1 #ifndef teca_cartesian_mesh_h
2 #define teca_cartesian_mesh_h
3 
4 #include "teca_mesh.h"
5 #include "teca_shared_object.h"
6 TECA_SHARED_OBJECT_FORWARD_DECL(teca_cartesian_mesh)
7 
8 class teca_cartesian_mesh : public teca_mesh
10 {
11 public:
12  TECA_DATASET_STATIC_NEW(teca_cartesian_mesh)
13  TECA_DATASET_NEW_INSTANCE()
14  TECA_DATASET_NEW_COPY()
15 
16  virtual ~teca_cartesian_mesh() = default;
17 
18  // set/get metadata
19  TECA_DATASET_METADATA(whole_extent, unsigned long, 6)
20  TECA_DATASET_METADATA(extent, unsigned long, 6)
21  TECA_DATASET_METADATA(bounds, double, 6)
22  TECA_DATASET_METADATA(periodic_in_x, int, 1)
23  TECA_DATASET_METADATA(periodic_in_y, int, 1)
24  TECA_DATASET_METADATA(periodic_in_z, int, 1)
25  TECA_DATASET_METADATA(x_coordinate_variable, std::string, 1)
26  TECA_DATASET_METADATA(y_coordinate_variable, std::string, 1)
27  TECA_DATASET_METADATA(z_coordinate_variable, std::string, 1)
28  TECA_DATASET_METADATA(t_coordinate_variable, std::string, 1)
29 
30  // get x coordinate array
31  p_teca_variant_array get_x_coordinates()
32  { return m_coordinate_arrays->get("x"); }
33 
34  const_p_teca_variant_array get_x_coordinates() const
35  { return m_coordinate_arrays->get("x"); }
36 
37  // get y coordinate array
38  p_teca_variant_array get_y_coordinates()
39  { return m_coordinate_arrays->get("y"); }
40 
41  const_p_teca_variant_array get_y_coordinates() const
42  { return m_coordinate_arrays->get("y"); }
43 
44  // get z coordinate array
45  p_teca_variant_array get_z_coordinates()
46  { return m_coordinate_arrays->get("z"); }
47 
48  const_p_teca_variant_array get_z_coordinates() const
49  { return m_coordinate_arrays->get("z"); }
50 
51  // set coordinate arrays
52  void set_x_coordinates(const std::string &name,
53  const p_teca_variant_array &array);
54 
55  void set_y_coordinates(const std::string &name,
56  const p_teca_variant_array &array);
57 
58  void set_z_coordinates(const std::string &name,
59  const p_teca_variant_array &array);
60 
61 
62  // return a unique string identifier
63  std::string get_class_name() const override
64  { return "teca_cartesian_mesh"; }
65 
66  // return an integer identifier uniquely naming the dataset type
67  int get_type_code() const override;
68 
69  // copy data and metadata. shallow copy uses reference
70  // counting, while copy duplicates the data.
71  void copy(const const_p_teca_dataset &) override;
72  void shallow_copy(const p_teca_dataset &) override;
73 
74  // copy metadata. always a deep copy.
75  void copy_metadata(const const_p_teca_dataset &other) override;
76 
77  // swap internals of the two objects
78  void swap(p_teca_dataset &) override;
79 
80  // serialize the dataset to/from the given stream
81  // for I/O or communication
82  int to_stream(teca_binary_stream &) const override;
83  int from_stream(teca_binary_stream &) override;
84 
85  // stream to/from human readable representation
86  int to_stream(std::ostream &) const override;
87 
88 protected:
90 
91 private:
92  p_teca_array_collection m_coordinate_arrays;
93 };
94 
95 #endif
teca_binary_stream
Definition: teca_binary_stream.h:16
teca_mesh
a base class for geometric data
Definition: teca_mesh.h:17
teca_cartesian_mesh
data on a physically uniform cartesian mesh
Definition: teca_cartesian_mesh.h:10