XdmfGridCollection.hpp 6.26 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfGridCollection.hpp                                              */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/

24 25 26
#ifndef XDMFGRIDCOLLECTION_HPP_
#define XDMFGRIDCOLLECTION_HPP_

27
// C Compatible Includes
28
#include "Xdmf.hpp"
29
#include "XdmfDomain.hpp"
30
#include "XdmfGrid.hpp"
31 32 33
#include "XdmfGridCollectionType.hpp"

#ifdef __cplusplus
34 35 36 37

/**
 * @brief A spatial or temporal collection of XdmfGrids.
 *
38 39 40 41
 * A temporal collection is timestep data.  Each child grid represents
 * the state at a single timestep.  A spatial collection consists of
 * XdmfGrids that are arranged together in space. E.g. a partitioned
 * mesh.
42
 *
43 44
 * It is valid to nest collections. A spatial collection inside a
 * temporal collection is commonly used.
45
 */
46
class XDMF_EXPORT XdmfGridCollection : public virtual XdmfDomain,
47
                                       public XdmfGrid {
48

49
public:
50

51 52 53
  /**
   * Create a new XdmfGridCollection.
   *
54 55 56 57
   * Example of use:
   *
   * C++
   *
58
   * @dontinclude ExampleXdmfGridCollection.cpp
59 60
   * @skipline //#initalization
   * @until //#initalization
61 62 63
   *
   * Python
   *
64
   * @dontinclude XdmfExampleGridCollection.py
65 66
   * @skipline #//initalization
   * @until #//initalization
67
   *
68
   * @return    Constructed XdmfGridCollection.
69
   */
70
  static shared_ptr<XdmfGridCollection> New();
71

72
  virtual ~XdmfGridCollection();
73

74
  LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid)
75
  static const std::string ItemTag;
76

77
  std::map<std::string, std::string> getItemProperties() const;
78

79
  std::string getItemTag() const;
80

81 82 83
  /**
   * Get the XdmfGridCollectionType associated with this grid collection.
   *
84 85 86 87
   * Example of use:
   *
   * C++
   *
88
   * @dontinclude ExampleXdmfGridCollection.cpp
89 90 91 92
   * @skipline //#initalization
   * @until //#initalization
   * @skipline //#getType
   * @until //#getType
93 94 95
   *
   * Python
   *
96
   * @dontinclude XdmfExampleGridCollection.py
97 98 99 100
   * @skipline #//initalization
   * @until #//initalization
   * @skipline #//getType
   * @until #//getType
101
   *
102
   * @return    XdmfGridCollectionType of this collection.
103
   */
104
  shared_ptr<const XdmfGridCollectionType> getType() const;
105

106 107
  using XdmfDomain::insert;
  using XdmfGrid::insert;
108

109
  /**
110
   * Insert an information into the grid collection.
111
   *
112 113 114 115
   * Example of use:
   *
   * C++
   *
116
   * @dontinclude ExampleXdmfGridCollection.cpp
117 118 119 120
   * @skipline //#initalization
   * @until //#initalization
   * @skipline //#insert
   * @until //#insert
121 122 123
   *
   * Python
   *
124
   * @dontinclude XdmfExampleGridCollection.py
125 126 127 128
   * @skipline #//initalization
   * @until #//initalization
   * @skipline #//insert
   * @until #//insert
129
   *
130
   * @param     information     An XdmfInformation to attach to this item.
131
   */
132
  void insert(const shared_ptr<XdmfInformation> information);
133

134 135 136 137
  void read();

  void release();

138
  /**
139 140
   * Set the XdmfGridCollectionType associated with this grid
   * collection.
141
   *
142 143 144 145
   * Example of use:
   *
   * C++
   *
146
   * @dontinclude ExampleXdmfGridCollection.cpp
147 148 149 150
   * @skipline //#initalization
   * @until //#initalization
   * @skipline //#setType
   * @until //#setType
151 152 153
   *
   * Python
   *
154
   * @dontinclude XdmfExampleGridCollection.py
155 156 157 158
   * @skipline #//initalization
   * @until #//initalization
   * @skipline #//setType
   * @until #//setType
159
   *
160
   * @param     type    The XdmfGridCollectionType to set.
161
   */
162
  void setType(const shared_ptr<const XdmfGridCollectionType> type);
163

164
  void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
165

166
protected:
167

168
  XdmfGridCollection();
169

170 171
  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
172
               const std::vector<shared_ptr<XdmfItem> > & childItems,
173
               const XdmfCoreReader * const reader);
174

175 176
  void copyGrid(shared_ptr<XdmfGrid> sourceGrid);

177
private:
178

179 180 181
  XdmfGridCollection(const XdmfGridCollection &);  // Not implemented.
  void operator=(const XdmfGridCollection &);  // Not implemented.

182
  shared_ptr<const XdmfGridCollectionType> mType;
183

184 185
};

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

#ifndef XDMFGRIDCOLLECTIONCDEFINE
#define XDMFGRIDCOLLECTIONCDEFINE
struct XDMFGRIDCOLLECTION; // Simply as a typedef to ensure correct typing
typedef struct XDMFGRIDCOLLECTION XDMFGRIDCOLLECTION;
#endif

XDMF_EXPORT XDMFGRIDCOLLECTION * XdmfGridCollectionNew();

XDMF_EXPORT int XdmfGridCollectionGetType(XDMFGRIDCOLLECTION * collection, int * status);

XDMF_EXPORT void XdmfGridCollectionSetType(XDMFGRIDCOLLECTION * collection, int type, int * status);

XDMF_DOMAIN_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF)
XDMF_GRID_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF)
XDMF_ITEM_C_CHILD_DECLARE(XdmfGridCollection, XDMFGRIDCOLLECTION, XDMF)

#ifdef __cplusplus
}
#endif

214
#endif /* XDMFGRID_HPP_ */