XdmfTopology.hpp 6.73 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 : XdmfTopology.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.                                                 */
/*                                                                           */
/*****************************************************************************/

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
24 25 26
#ifndef XDMFTOPOLOGY_HPP_
#define XDMFTOPOLOGY_HPP_

27
// C Compatible Includes
28
#include "Xdmf.hpp"
29
#include "XdmfArray.hpp"
30 31 32
#include "XdmfTopologyType.hpp"

#ifdef __cplusplus
33

34
/**
35
 * @brief Holds the connectivity information in an XdmfGrid.
36
 *
37 38 39 40
 * XdmfTopology is a required part of an XdmfGrid. It stores the
 * connectivity information for all points contained in an
 * XdmfGrid. XdmfTopology contains an XdmfTopologyType property which
 * should be set that specifies the element type stored.
41 42 43 44 45 46 47 48 49 50 51 52 53
 *
 * In the case of mixed topology types, the connectivity stores
 * topology type ids prior to each element's connectivity
 * information. For element types of varying sizes (Polyvertex,
 * Polyline, and Polygon), the topology type id is followed by a
 * number specifying the number of nodes in the element.  For example,
 * a tetrahedron element (id 6) followed by a polygon element (id 3)
 * with 5 points would look similar the following:
 *
 * 6 20 25 100 200 3 5 300 301 302 303 304
 *
 * The tetrahedron is composed of nodes 20, 25, 100, and 200. The
 * polygon is composed of nodes 300 to 304.
54 55 56 57
 *
 * Elements of type Polyhedron (i.e. N face cells, where each face is a M edge
 * polygon) are in the following format:
 * [nCellFaces, nFace0Pts, id0_0, id0_1, ..., nFace1Pts, id1_0, id1_1, ..., ...]
58
 */
59
class XDMF_EXPORT XdmfTopology : public XdmfArray {
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
60

61
public:
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
62

63 64 65
  /**
   * Create a new XdmfTopology.
   *
66 67 68 69
   * Example of use:
   *
   * C++
   *
70
   * @dontinclude ExampleXdmfTopology.cpp
71 72
   * @skipline //#initialization
   * @until //#initialization
73 74 75
   *
   * Python
   *
76
   * @dontinclude XdmfExampleTopology.py
77 78
   * @skipline #//initialization
   * @until #//initialization
79
   *
80
   * @return    Constructed XdmfTopology.
81
   */
82
  static shared_ptr<XdmfTopology> New();
83

84
  virtual ~XdmfTopology();
85

86
  LOKI_DEFINE_VISITABLE(XdmfTopology, XdmfArray)
87
  static const std::string ItemTag;
88

89 90 91 92 93
  /**
   * 
   */
  int getBaseOffset() const;

94
  std::map<std::string, std::string> getItemProperties() const;
95

96
  std::string getItemTag() const;
97

98 99 100
  /**
   * Get the number of elements this Topology contains.
   *
101 102 103 104
   * Example of use:
   *
   * C++
   *
105
   * @dontinclude ExampleXdmfTopology.cpp
106 107 108 109
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#getNumberElements
   * @until //#getNumberElements
110 111 112
   *
   * Python
   *
113
   * @dontinclude XdmfExampleTopology.py
114 115 116 117
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//getNumberElements
   * @until #//getNumberElements
118
   *
119
   * @return    Int of number elements in the Topology.
120 121
   */
  virtual unsigned int getNumberElements() const;
122

123 124 125
  /**
   * Get the XdmfTopologyType associated with this topology.
   *
126 127 128 129
   * Example of use:
   *
   * C++
   *
130
   * @dontinclude ExampleXdmfTopology.cpp
131 132 133 134 135 136
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setType
   * @until //#setType
   * @skipline //#getType
   * @until //#getType
137 138 139
   *
   * Python
   *
140
   * @dontinclude XdmfExampleTopology.py
141 142 143 144 145 146
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setType
   * @until #//setType
   * @skipline #//getType
   * @until #//getType
147
   *
148
   * @return    XdmfTopologyType of the topology.
149
   */
150
  shared_ptr<const XdmfTopologyType> getType() const;
151

152 153 154 155 156
  /**
   *
   */
  void setBaseOffset(int offset);

157 158 159
  /**
   * Set the XdmfTopologyType associated with this topology.
   *
160 161 162 163
   * Example of use:
   *
   * C++
   *
164
   * @dontinclude ExampleXdmfTopology.cpp
165 166 167 168
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setType
   * @until //#setType
169 170 171
   *
   * Python
   *
172
   * @dontinclude XdmfExampleTopology.py
173 174 175 176
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setType
   * @until #//setType
177
   *
178
   * @param     type    The XdmfTopologyType to set.
179
   */
180
  void setType(const shared_ptr<const XdmfTopologyType> type);
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
181

182 183
  XdmfTopology(XdmfTopology &);

184
protected:
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
185

186
  XdmfTopology();
187

188 189
  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
190
               const std::vector<shared_ptr<XdmfItem> > & childItems,
191
               const XdmfCoreReader * const reader);
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
192

193
private:
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
194

195
  XdmfTopology(const XdmfTopology &);
196 197
  void operator=(const XdmfTopology &);  // Not implemented.

198
  shared_ptr<const XdmfTopologyType> mType;
199 200

  int mBaseOffset;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
201 202
};

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

struct XDMFTOPOLOGY; // Simply as a typedef to ensure correct typing
typedef struct XDMFTOPOLOGY XDMFTOPOLOGY;

XDMF_EXPORT XDMFTOPOLOGY * XdmfTopologyNew();

XDMF_EXPORT unsigned int XdmfTopologyGetNumberElements(XDMFTOPOLOGY * topology, int * status);

XDMF_EXPORT int XdmfTopologyGetType(XDMFTOPOLOGY * topology);

XDMF_EXPORT void XdmfTopologySetType(XDMFTOPOLOGY * topology, int type, int * status);

XDMF_EXPORT void XdmfTopologySetPolyType(XDMFTOPOLOGY * topology, int type, int nodes, int * status);

XDMF_ITEM_C_CHILD_DECLARE(XdmfTopology, XDMFTOPOLOGY, XDMF)
XDMF_ARRAY_C_CHILD_DECLARE(XdmfTopology, XDMFTOPOLOGY, XDMF)

#ifdef __cplusplus
}
#endif

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
231
#endif /* XDMFTOPOLOGY_HPP_ */