XdmfUnstructuredGrid.hpp 8.2 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 : XdmfUnstructuredGrid.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
#ifndef XDMFUNSTRUCTUREDGRID_HPP_
#define XDMFUNSTRUCTUREDGRID_HPP_
26

27 28 29
// Forward Declarations
class XdmfRegularGrid;

30
// Includes
31
#include "Xdmf.hpp"
32 33 34
#include "XdmfGrid.hpp"

/**
35 36
 * @brief An unstructured grid that consists of elements, points, and
 * fields attached to the mesh.
37
 *
38 39 40 41
 * After creating an unstructured grid, the XdmfGeometry and
 * XdmfTopology must be set. The XdmfTopology describes the element
 * types contained in the grid and their connectivity. The
 * XdmfGeometry describes the positions of nodes.
42
 */
43
class XDMF_EXPORT XdmfUnstructuredGrid : public XdmfGrid {
44

45
public:
46

47
  /**
48
   * Create a new XdmfUnstructuredGrid.
49
   *
50 51 52 53
   * Example of use:
   *
   * C++
   *
54
   * @code {.cpp}
55
   * shared_ptr<XdmfUnstructuredGrid> exampleGrid = XdmfUnstructuredGrid::New();
56
   * @endcode
57 58 59
   *
   * Python
   *
60
   * @code {.py}
61
   * exampleGrid = XdmfUnstructuredGrid.New()
62
   * @endcode
63
   *
64
   * @return constructed XdmfUnstructuredGrid.
65
   */
66
  static shared_ptr<XdmfUnstructuredGrid> New();
67

68 69 70
  /**
   * Create a new XdmfUnstructuredGrid from a XdmfRegularGrid.
   *
71 72 73 74
   * Example of use:
   *
   * C++
   *
75
   * @code {.cpp}
76 77 78 79 80 81 82 83
   * double newBrickX = 0.0;
   * double newBrickY = 0.0;
   * unsigned int newPointsX = 5;
   * unsigned int newPointsY = 5;
   * double newOriginX = 20.0;
   * double newOriginY = 20.0;
   * shared_ptr<XdmfRegularGrid> baseGrid = XdmfRegularGrid::New(newBrickX, newBrickY, newPointsX, newPointsY, newOriginX, newOriginY);
   * shared_ptr<XdmfUnstructuredGrid> exampleGrid = XdmfUnstructuredGrid::New(baseGrid);
84
   * @endcode
85 86 87
   *
   * Python
   *
88
   * @code {.py}
89 90 91 92 93 94 95 96
   * newBrickX = 0.0
   * newBrickY = 0.0
   * newPointsX = 5
   * newPointsY = 5
   * newOriginX = 20.0
   * newOriginY = 20.0
   * baseGrid = XdmfRegularGrid.New(newBrickX, newBrickY, newPointsX, newPointsY, newOriginX, newOriginY)
   * exampleGrid = XdmfUnstructuredGrid.New(baseGrid)
97
   * @endcode
98 99 100
   *
   * @param regularGrid	The grid that the unstructured grid will be created from
   *
101 102 103 104 105
   * @return constructed XdmfUnstructuredGrid.
   */
  static shared_ptr<XdmfUnstructuredGrid> 
  New(const shared_ptr<XdmfRegularGrid> regularGrid);

106
  virtual ~XdmfUnstructuredGrid();
107

108
  static const std::string ItemTag;
109

110 111 112
  /**
   * Get the geometry associated with this grid.
   *
113 114 115 116
   * Example of use:
   *
   * C++
   *
117
   * @code {.cpp}
118 119
   * //Assuming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
   * shared_ptr<XdmfGeometry> exampleGeometry = exampleGrid->getGeometry();
120
   * @endcode
121 122 123
   *
   * Python
   *
124
   * @code {.py}
125 126 127 128
   * '''
   * Assuming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
   * '''
   * exampleGeometry = exampleGrid.getGeometry()
129
   * @endcode
130
   *
131 132
   * @return the geometry associated with this grid.
   */
133
  shared_ptr<XdmfGeometry> getGeometry();
134

135
  virtual std::string getItemTag() const;
136

137 138 139
  /**
   * Get the topology associated with this grid.
   *
140 141 142 143
   * Example of use:
   *
   * C++
   *
144
   * @code {.cpp}
145 146
   * //Assuming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
   * shared_ptr<XdmfTopology> exampleTopology = exampleGrid->getTopology();
147
   * @endcode
148 149 150
   *
   * Python
   *
151
   * @code {.py}
152 153 154 155
   * '''
   * Assuming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
   * '''
   * exampleTopology = exampleGrid.getTopology()
156
   * @endcode
157
   *
158 159
   * @return the topology associated with this grid.
   */
160
  shared_ptr<XdmfTopology> getTopology();
161

162 163 164
  /**
   * Set the geometry associated with this grid.
   *
165 166 167 168
   * Example of use:
   *
   * C++
   *
169
   * @code {.cpp}
170 171 172 173 174 175 176 177 178 179 180 181 182
   * shared_ptr<XdmfUnstructuredGrid> exampleGrid = XdmfUnstructuredGrid::New();
   * shared_ptr<XdmfGeometry> newGeometry = XdmfGeometry::New();
   * newGeometry->setType(XdmfGeometryType::XYZ());
   * newGeometry->pushBack(1);
   * newGeometry->pushBack(2);
   * newGeometry->pushBack(3);
   * newGeometry->pushBack(4);
   * newGeometry->pushBack(5);
   * newGeometry->pushBack(6);
   * newGeometry->pushBack(7);
   * newGeometry->pushBack(8);
   * newGeometry->pushBack(9);
   * exampleGrid->setGeometry(newGeometry);
183
   * @endcode
184 185 186
   *
   * Python
   *
187
   * @code {.py}
188 189 190 191 192 193 194 195 196 197 198 199 200
   * exampleGrid = XdmfUnstructuredGrid.New()
   * newGeometry = XdmfGeometry.New()
   * newGeometry.setType(XdmfGeometryType.XYZ())
   * newGeometry.pushBackAsInt32(1)
   * newGeometry.pushBackAsInt32(2)
   * newGeometry.pushBackAsInt32(3)
   * newGeometry.pushBackAsInt32(4)
   * newGeometry.pushBackAsInt32(5)
   * newGeometry.pushBackAsInt32(6)
   * newGeometry.pushBackAsInt32(7)
   * newGeometry.pushBackAsInt32(8)
   * newGeometry.pushBackAsInt32(9)
   * exampleGrid.setGeometry(newGeometry)
201
   * @endcode
202
   *
203 204
   * @param geometry an XdmfGeometry to associate with this grid.
   */
205
  void setGeometry(const shared_ptr<XdmfGeometry> geometry);
206

207 208 209
  /**
   * Set the topology associated with this grid.
   *
210 211 212 213
   * Example of use:
   *
   * C++
   *
214
   * @code {.cpp}
215 216 217 218 219 220 221 222 223 224 225 226 227
   * shared_ptr<XdmfUnstructuredGrid> exampleGrid = XdmfUnstructuredGrid::New();
   * shared_ptr<XdmfTopology> newTopology = XdmfTopology::New();
   * newTopology->setType(XdmfTopologyType::Triangle());
   * newTopology->pushBack(1);
   * newTopology->pushBack(2);
   * newTopology->pushBack(3);
   * newTopology->pushBack(4);
   * newTopology->pushBack(5);
   * newTopology->pushBack(6);
   * newTopology->pushBack(7);
   * newTopology->pushBack(8);
   * newTopology->pushBack(9);
   * exampleGrid->setTopology(newTopology);
228
   * @endcode
229 230 231
   *
   * Python
   *
232
   * @code {.py}
233 234 235 236 237 238 239 240 241 242 243 244 245
   * exampleGrid = XdmfUnstructuredGrid.New()
   * newTopology = XdmfTopology.New()
   * newTopology.setType(XdmfTopologyType.Triangle())
   * newTopology.pushBackAsInt32(1)
   * newTopology.pushBackAsInt32(2)
   * newTopology.pushBackAsInt32(3)
   * newTopology.pushBackAsInt32(4)
   * newTopology.pushBackAsInt32(5)
   * newTopology.pushBackAsInt32(6)
   * newTopology.pushBackAsInt32(7)
   * newTopology.pushBackAsInt32(8)
   * newTopology.pushBackAsInt32(9)
   * exampleGrid.setTopology(newTopology)
246
   * @endcode
247
   *
248 249
   * @param topology an XdmfTopology to associate with this grid.
   */
250
  void setTopology(const shared_ptr<XdmfTopology> topology);
251

252
protected:
253

254
  XdmfUnstructuredGrid();
255
  XdmfUnstructuredGrid(const shared_ptr<XdmfRegularGrid> regularGrid);
256

257
private:
258

259 260
  XdmfUnstructuredGrid(const XdmfUnstructuredGrid &);  // Not implemented.
  void operator=(const XdmfUnstructuredGrid &);  // Not implemented.
261 262 263

};

264
#ifdef _WIN32
265
XDMF_TEMPLATE template class XDMF_EXPORT
266
shared_ptr<XdmfTopology>;
267
XDMF_TEMPLATE template class XDMF_EXPORT
268
shared_ptr<XdmfGeometry>;
269 270
#endif

271
#endif /* XDMFUNSTRUCTUREDGRID_HPP_ */