XdmfTopologyType.hpp 17.9 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 : XdmfTopologyType.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 XDMFTOPOLOGYTYPE_HPP_
#define XDMFTOPOLOGYTYPE_HPP_

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

#ifdef __cplusplus

// Includes
33
#include "XdmfItemProperty.hpp"
34 35
#include <map>
#include <vector>
Kenneth Leiter's avatar
Kenneth Leiter committed
36

37
/**
38 39
 * @brief Property describing the types of elements stored in an
 * XdmfTopology.
40
 *
41 42 43 44
 * XdmfTopologyType is a property used by XdmfTopology to specify the
 * element types stored. A specific XdmfTopologyType can be created by
 * calling one of the static methods in the class,
 * i.e. XdmfTopologyType::Tetrahedron().
45
 *
46 47
 * Example of use:
 *
48 49 50
 * C++
 *
 * @dontinclude ExampleXdmfTopologyType.cpp
51 52
 * @skipline //#getType
 * @until //#getType
53 54 55 56
 *
 * Python
 *
 * @dontinclude XdmfExampleTopologyType.py
57 58
 * @skipline #//getType
 * @until #//getType
59
 *
60
 * Xdmf supports the following topology types:
61 62 63 64 65 66 67 68 69
 *   NoTopologyType
 *   Polyvertex - Unconnected Points
 *   Polyline - Line Segments
 *   Polygon - N Edge Polygon
 *   Triangle - 3 Edge Polygon
 *   Quadrilateral - 4 Edge Polygon
 *   Tetrahedron - 4 Triangular Faces
 *   Wedge - 4 Triangular Faces, Quadrilateral Base
 *   Hexahedron - 6 Quadrilateral Faces
70
 *   Polyhedron - N Face Cell, where each Face is a M Edge Polygon
71 72 73 74 75 76 77 78 79 80 81 82 83
 *   Edge_3 - 3 Node Quadratic Line
 *   Triangle_6 - 6 Node Quadratic Triangle
 *   Quadrilateral_8 - 8 Node Quadratic Quadrilateral
 *   Quadrilateral_9 - 9 Node Bi-Quadratic Quadrilateral
 *   Tetrahedron_10 - 10 Node Quadratic Tetrahedron
 *   Pyramid_13 - 13 Node Quadratic Pyramid
 *   Wedge_15 - 15 Node Quadratic Wedge
 *   Wedge_18 - 18 Node Bi-Quadratic Wedge
 *   Hexahedron_20 - 20 Node Quadratic Hexahedron
 *   Hexahedron_24 - 24 Node Bi-Quadratic Hexahedron
 *   Hexahedron_27 - 27 Node Tri-Quadratic Hexahedron
 *   Hexahedron_64 - 64 Node Tri-Cubic Hexahedron
 *   Hexahedron_125 - 125 Node Tri-Quartic Hexahedron
84 85 86 87 88 89
 *   Hexahedron_216 - 216 Node Tri-Quintic Hexahedron
 *   Hexahedron_343 - 343 Node Tri-Hexic Hexahedron
 *   Hexahedron_512 - 512 Node Tri-Septic Hexahedron
 *   Hexahedron_729 - 729 Node Tri-Octic Hexahedron
 *   Hexahedron_1000 - 1000 Node Tri-Nonic Hexahedron
 *   Hexahedron_1331 - 1331 Node Tri-Decic Hexahedron
90 91 92 93 94 95 96 97
 *   Hexahedron_Spectral_64 - 64 Node Spectral Tri-Cubic Hexahedron
 *   Hexahedron_Spectral_125 - 125 Node Spectral Tri-Quartic Hexahedron
 *   Hexahedron_Spectral_216 - 216 Node Spectral Tri-Quintic Hexahedron
 *   Hexahedron_Spectral_343 - 343 Node Spectral Tri-Hexic Hexahedron
 *   Hexahedron_Spectral_512 - 512 Node Spectral Tri-Septic Hexahedron
 *   Hexahedron_Spectral_729 - 729 Node Spectral Tri-Octic Hexahedron
 *   Hexahedron_Spectral_1000 - 1000 Node Spectral Tri-Nonic Hexahedron
 *   Hexahedron_Spectral_1331 - 1331 Node Spectral Tri-Decic Hexahedron
98
 *   Mixed - Mixture of Unstructured Topologies
99
 */
100
class XDMF_EXPORT XdmfTopologyType : public XdmfItemProperty {
101

102
public:
103 104 105 106 107 108

  virtual ~XdmfTopologyType();

  friend class XdmfTopology;

  enum CellType {
109 110 111 112 113 114 115 116 117 118 119 120 121
    NoCellType = 0,
    Linear = 1,
    Quadratic = 2,
    Cubic = 3,
    Quartic = 4,
    Quintic = 5,
    Sextic = 6,
    Septic = 7,
    Octic = 8,
    Nonic = 9,
    Decic = 10,
    Arbitrary = 100,
    Structured = 101
122 123
  };

124 125 126
  /**
   * Supported Xdmf Topology Types
   */
127 128
  static shared_ptr<const XdmfTopologyType> NoTopologyType();
  static shared_ptr<const XdmfTopologyType> Polyvertex();
129
  static shared_ptr<const XdmfTopologyType>
130
  Polyline(const unsigned int nodesPerElement);
131 132 133 134 135 136 137 138
  static shared_ptr<const XdmfTopologyType>
  Polygon(const unsigned int nodesPerElement);
  static shared_ptr<const XdmfTopologyType> Triangle();
  static shared_ptr<const XdmfTopologyType> Quadrilateral();
  static shared_ptr<const XdmfTopologyType> Tetrahedron();
  static shared_ptr<const XdmfTopologyType> Pyramid();
  static shared_ptr<const XdmfTopologyType> Wedge();
  static shared_ptr<const XdmfTopologyType> Hexahedron();
139
  static shared_ptr<const XdmfTopologyType> Polyhedron();
140 141 142 143 144 145 146 147 148 149 150 151 152
  static shared_ptr<const XdmfTopologyType> Edge_3();
  static shared_ptr<const XdmfTopologyType> Triangle_6();
  static shared_ptr<const XdmfTopologyType> Quadrilateral_8();
  static shared_ptr<const XdmfTopologyType> Quadrilateral_9();
  static shared_ptr<const XdmfTopologyType> Tetrahedron_10();
  static shared_ptr<const XdmfTopologyType> Pyramid_13();
  static shared_ptr<const XdmfTopologyType> Wedge_15();
  static shared_ptr<const XdmfTopologyType> Wedge_18();
  static shared_ptr<const XdmfTopologyType> Hexahedron_20();
  static shared_ptr<const XdmfTopologyType> Hexahedron_24();
  static shared_ptr<const XdmfTopologyType> Hexahedron_27();
  static shared_ptr<const XdmfTopologyType> Hexahedron_64();
  static shared_ptr<const XdmfTopologyType> Hexahedron_125();
153 154 155 156 157 158
  static shared_ptr<const XdmfTopologyType> Hexahedron_216();
  static shared_ptr<const XdmfTopologyType> Hexahedron_343();
  static shared_ptr<const XdmfTopologyType> Hexahedron_512();
  static shared_ptr<const XdmfTopologyType> Hexahedron_729();
  static shared_ptr<const XdmfTopologyType> Hexahedron_1000();
  static shared_ptr<const XdmfTopologyType> Hexahedron_1331();
159 160 161 162 163 164 165 166
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_64();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_125();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_216();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_343();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_512();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_729();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_1000();
  static shared_ptr<const XdmfTopologyType> Hexahedron_Spectral_1331();
167
  static shared_ptr<const XdmfTopologyType> Mixed();
168

169 170 171
  /**
   * Get a topology type from id.
   *
172 173
   * Example of use:
   *
174 175
   * C++
   *
176
   * @dontinclude ExampleXdmfTopologyType.cpp
177 178
   * @skipline //#initialization
   * @until //#initialization
179 180 181
   *
   * Python
   *
182
   * @dontinclude XdmfExampleTopologyType.py
183 184
   * @skipline #//initialization
   * @until #//initialization
185
   *
186 187
   * @param id of the topology type.
   *
188 189
   * @return	Topology type corresponding to id - if no topology type is found
   * 		an NULL pointer is returned.
190
   */
191
  static shared_ptr<const XdmfTopologyType> New(const unsigned int id);
192

193 194 195
  /**
   * Get the cell type associated with this topology type.
   *
196 197
   * Example of use:
   *
198 199
   * C++
   *
200
   * @dontinclude ExampleXdmfTopologyType.cpp
201 202
   * @skipline //#getCellType
   * @until //#getCellType
203 204 205
   *
   * Python
   *
206
   * @dontinclude XdmfExampleTopologyType.py
207 208
   * @skipline #//getCellType
   * @until #//getCellType
209
   *
210
   * @return 	A CellType containing the cell type.
211 212 213
   */
  CellType getCellType() const;

214 215 216
  /**
   * Get the number of edges per element associated with this topology type.
   *
217 218
   * Example of use:
   *
219 220
   * C++
   *
221
   * @dontinclude ExampleXdmfTopologyType.cpp
222 223
   * @skipline //#getEdgesPerElement
   * @until //#getEdgesPerElement
224 225 226
   *
   * Python
   *
227
   * @dontinclude XdmfExampleTopologyType.py
228 229
   * @skipline #//getEdgesPerElement
   * @until #//getEdgesPerElement
230
   *
231
   * @return	An unsigned int containing the number of edges per element.
232 233 234 235 236 237
   */
  virtual unsigned int getEdgesPerElement() const;

  /**
   * Get the number of faces per element associated with this topology type.
   *
238 239
   * Example of use:
   *
240 241
   * C++
   *
242
   * @dontinclude ExampleXdmfTopologyType.cpp
243 244
   * @skipline //#getFacesPerElement
   * @until //#getFacesPerElement
245 246 247
   *
   * Python
   *
248
   * @dontinclude XdmfExampleTopologyType.py
249 250
   * @skipline #//getFacesPerElement
   * @until #//getFacesPerElement
251
   *
252
   * @return	An unsigned int containing the number of faces per element.
253 254 255
   */
  virtual unsigned int getFacesPerElement() const;

256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
  /**
   * Gets the type of the faces of the topology.
   *
   * Example of use:
   *
   * C++
   *
   * @dontinclude ExampleXdmfTopologyType.cpp
   * @skipline //#getFaceType
   * @until //#getFaceType
   *
   * Python
   *
   * @dontinclude XdmfExampleTopologyType.py
   * @skipline #//getFaceType
   * @until #//getFaceType
   *
273
   * @return	The face's topology type
274
   */
275
  shared_ptr<const XdmfTopologyType>  getFaceType() const;
276

277 278 279 280
  /**
   * Get the id of this cell type, necessary in order to create grids
   * containing mixed cells.
   *
281 282
   * Example of use:
   *
283 284
   * C++
   *
285
   * @dontinclude ExampleXdmfTopologyType.cpp
286 287
   * @skipline //#getID
   * @until //#getID
288 289 290
   *
   * Python
   *
291
   * @dontinclude XdmfExampleTopologyType.py
292 293
   * @skipline //#getID
   * @until //#getID
294
   *
295
   * @return	The ID of the topology type.
296 297 298 299 300 301
   */
  virtual unsigned int getID() const;

  /**
   * Get the name of this topology type.
   *
302 303
   * Example of use:
   *
304 305
   * C++
   *
306
   * @dontinclude ExampleXdmfTopologyType.cpp
307 308
   * @skipline //#getName
   * @until //#getName
309
   *
310
   * Python
311
   *
312
   * @dontinclude XdmfExampleTopologyType.py
313 314
   * @skipline #//getName
   * @until #//getName
315
   *
316
   * @return	The name of this topology type.
317 318 319 320
   */
  virtual std::string getName() const;

  /**
321 322
   * Get the number of nodes per element associated with this topology
   * type.
323
   *
324 325
   * Example of use:
   *
326 327
   * C++
   *
328
   * @dontinclude ExampleXdmfTopologyType.cpp
329 330
   * @skipline //#getNodesPerElement
   * @until //#getNodesPerElement
331 332 333
   *
   * Python
   *
334
   * @dontinclude XdmfExampleTopologyType.py
335 336
   * @skipline #//getNodesPerElement
   * @until #//getNodesPerElement
337
   *
338
   * @return	An unsigned int containing number of nodes per element.
339 340 341 342 343 344
   */
  virtual unsigned int getNodesPerElement() const;

  void
  getProperties(std::map<std::string, std::string> & collectedProperties) const;

345
protected:
346 347

  /**
348 349 350 351
   * Protected constructor for XdmfTopologyType. The constructor is
   * protected because all topology types supported by Xdmf should be
   * accessed through more specific static methods that construct
   * XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron()
352 353
   */
  XdmfTopologyType(const unsigned int nodesPerElement,
354
                   const unsigned int facesPerElement,
355
                   const std::vector<shared_ptr<const XdmfTopologyType> > & faces,
356
                   const unsigned int edgesPerElement,
357 358 359 360
                   const std::string & name,
                   const CellType cellType,
                   const unsigned int id);

361 362 363 364 365 366
  unsigned int calculateHypercubeNumElements(unsigned int numDims, unsigned int elementNumDims) const;

  static std::map<std::string, shared_ptr<const XdmfTopologyType>(*)()> mTopologyDefinitions;

  static void InitTypes();

367
private:
368 369 370 371

  XdmfTopologyType(const XdmfTopologyType &); // Not implemented.
  void operator=(const XdmfTopologyType &); // Not implemented.

372
  static shared_ptr<const XdmfTopologyType>
373 374 375
  New(const std::map<std::string, std::string> & itemProperties);

  const CellType mCellType;
376 377
  const unsigned int mEdgesPerElement;
  const unsigned int mFacesPerElement;
378
  std::vector<shared_ptr<const XdmfTopologyType> > mFaces;
379 380 381
  const unsigned int mID;
  const std::string mName;
  const unsigned int mNodesPerElement;
382

383 384
};

385 386 387 388 389 390 391 392
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

David DeMarle's avatar
David DeMarle committed
393 394
#ifndef XDMF_C_TOPOLOGY_TYPES
#define XDMF_C_TOPOLOGY_TYPES
395 396 397
#define XDMF_TOPOLOGY_TYPE_POLYVERTEX                    500
#define XDMF_TOPOLOGY_TYPE_POLYLINE                      501
#define XDMF_TOPOLOGY_TYPE_POLYGON                       502
David DeMarle's avatar
David DeMarle committed
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
#define XDMF_TOPOLOGY_TYPE_POLYHEDRON                    503
#define XDMF_TOPOLOGY_TYPE_TRIANGLE                      504
#define XDMF_TOPOLOGY_TYPE_QUADRILATERAL                 505
#define XDMF_TOPOLOGY_TYPE_TETRAHEDRON                   506
#define XDMF_TOPOLOGY_TYPE_PYRAMID                       507
#define XDMF_TOPOLOGY_TYPE_WEDGE                         508
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON                    509
#define XDMF_TOPOLOGY_TYPE_EDGE_3                        510
#define XDMF_TOPOLOGY_TYPE_TRIANGLE_6                    511
#define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8               512
#define XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9               513
#define XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10                514
#define XDMF_TOPOLOGY_TYPE_PYRAMID_13                    515
#define XDMF_TOPOLOGY_TYPE_WEDGE_15                      516
#define XDMF_TOPOLOGY_TYPE_WEDGE_18                      517
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20                 518
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24                 519
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27                 520
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64                 521
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125                522
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216                523
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343                524
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512                525
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729                526
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000               527
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331               528
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64        529
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125       530
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216       531
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343       532
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512       533
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729       534
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000      535
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331      536
#define XDMF_TOPOLOGY_TYPE_MIXED                         537
#endif
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505

#define XDMF_TOPOLOGY_CELL_TYPE_NO_CELL_TYPE             0
#define XDMF_TOPOLOGY_CELL_TYPE_LINEAR                   1
#define XDMF_TOPOLOGY_CELL_TYPE_QUADRATIC                2
#define XDMF_TOPOLOGY_CELL_TYPE_CUBIC                    3
#define XDMF_TOPOLOGY_CELL_TYPE_QUARTIC                  4
#define XDMF_TOPOLOGY_CELL_TYPE_QUINTIC                  5
#define XDMF_TOPOLOGY_CELL_TYPE_SEXTIC                   6
#define XDMF_TOPOLOGY_CELL_TYPE_SEPTIC                   7
#define XDMF_TOPOLOGY_CELL_TYPE_OCTIC                    8
#define XDMF_TOPOLOGY_CELL_TYPE_NONIC                    9
#define XDMF_TOPOLOGY_CELL_TYPE_DECIC                    10
#define XDMF_TOPOLOGY_CELL_TYPE_ARBITRARY                100
#define XDMF_TOPOLOGY_CELL_TYPE_STRUCTURED               101

XDMF_EXPORT int XdmfTopologyTypePolyvertex();
XDMF_EXPORT int XdmfTopologyTypePolyline();
XDMF_EXPORT int XdmfTopologyTypePolygon();
XDMF_EXPORT int XdmfTopologyTypeTriangle();
XDMF_EXPORT int XdmfTopologyTypeQuadrilateral();
XDMF_EXPORT int XdmfTopologyTypeTetrahedron();
XDMF_EXPORT int XdmfTopologyTypePyramid();
XDMF_EXPORT int XdmfTopologyTypeWedge();
XDMF_EXPORT int XdmfTopologyTypeHexahedron();
XDMF_EXPORT int XdmfTopologyTypeEdge_3();
XDMF_EXPORT int XdmfTopologyTypeTriangle_6();
XDMF_EXPORT int XdmfTopologyTypeQuadrilateral_8();
XDMF_EXPORT int XdmfTopologyTypeQuadrilateral_9();
XDMF_EXPORT int XdmfTopologyTypeTetrahedron_10();
XDMF_EXPORT int XdmfTopologyTypePyramid_13();
XDMF_EXPORT int XdmfTopologyTypeWedge_15();
XDMF_EXPORT int XdmfTopologyTypeWedge_18();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_20();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_24();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_27();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_64();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_125();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_216();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_343();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_512();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_729();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_1000();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_1331();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_64();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_125();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_216();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_343();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_512();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_729();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_1000();
XDMF_EXPORT int XdmfTopologyTypeHexahedron_Spectral_1331();
XDMF_EXPORT int XdmfTopologyTypeMixed();


XDMF_EXPORT int XdmfTopologyTypeGetCellType(int type);

XDMF_EXPORT unsigned int XdmfTopologyTypeGetEdgesPerElement(int type, int * status);

XDMF_EXPORT unsigned int XdmfTopologyTypeGetFacesPerElement(int type, int * status);

XDMF_EXPORT int XdmfTopologyTypeGetFaceType(int type);

XDMF_EXPORT unsigned int XdmfTopologyTypeGetID(int type);

XDMF_EXPORT char * XdmfTopologyTypeGetName(int type);

XDMF_EXPORT unsigned int XdmfTopologyTypeGetNodesPerElement(int type);

#ifdef __cplusplus
}
#endif

506
#endif /* XDMFTOPOLOGYTYPE_HPP_ */