File: XdmfGrid.h

package info (click to toggle)
vtk6 6.1.0+dfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 165,164 kB
  • ctags: 226,428
  • sloc: cpp: 1,354,490; ansic: 730,748; python: 227,134; tcl: 48,285; xml: 8,290; yacc: 4,832; java: 3,827; perl: 3,108; lex: 1,809; sh: 1,437; asm: 471; makefile: 229
file content (330 lines) | stat: -rw-r--r-- 11,837 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*******************************************************************/
/*                               XDMF                              */
/*                   eXtensible Data Model and Format              */
/*                                                                 */
/*  Id : Id  */
/*  Date : $Date$ */
/*  Version : $Revision$ */
/*                                                                 */
/*  Author:                                                        */
/*     Jerry A. Clarke                                             */
/*     clarke@arl.army.mil                                         */
/*     US Army Research Laboratory                                 */
/*     Aberdeen Proving Ground, MD                                 */
/*                                                                 */
/*     Copyright @ 2002 US Army Research Laboratory                */
/*     All Rights Reserved                                         */
/*     See Copyright.txt or http://www.arl.hpc.mil/ice 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.                                       */
/*                                                                 */
/*******************************************************************/
#ifndef __XdmfGrid_h
#define __XdmfGrid_h

#include "XdmfElement.h"


class XdmfGeometry;
class XdmfTopology;
class XdmfInformation;
class XdmfAttribute;
class XdmfArray;
class XdmfTime;
class XdmfSet;

#define XDMF_GRID_UNIFORM       0x00000 // Type xor XDMF_GRID_MASK = XdmfTopology Type
#define XDMF_GRID_COLLECTION    0x10000
#define XDMF_GRID_TREE          0x20000
#define XDMF_GRID_SUBSET        0x40000
#define XDMF_GRID_UNSET         0x0FFFF

#define XDMF_GRID_MASK          0xF0000


#define XDMF_GRID_SECTION_ALL           0x100000
#define XDMF_GRID_SECTION_DATA_ITEM     0x200000
#define XDMF_GRID_SECTION_MASK          0xF00000

#define XDMF_GRID_COLLECTION_TEMPORAL   0x0001
#define XDMF_GRID_COLLECTION_SPATIAL    0x0002
#define XDMF_GRID_COLLECTION_UNSET      0x0FFFF

//! In memory representation of an XDMF Grid
/*!
        XdmfGrid is the in memory representation of the Xdmf Grid
        structure defined in the XML. XdmfGrids can be one of four 
        types : \b Uniform , \b Collection \b Tree or \b Subset. Uniform is a 
        Homogeneous Single Grid (i.e. a group of triangles). A \b Collection
        is an array of Uniform grids. A Subset specifies a cell selection
        of a previously defined grid. A Tree is a Hierarchial group.
        Uniform XdmfGrids have \b Topolgy (i.e. 
        what type of grid and the connectivity if it's unstructured )
        \b Geometry ( the XYZ values for the grid nodes ) and zero
        or more \b Attributes (the computed values such as scalars, 
        vectors, tensors, etc.)

        The XML for a Uniform Grid might look like :
\verbatim
<Grid Name="Sphere of Tets"
>

    <Topology Type="Tetrahedron"
     NumberOfElements="1838"
     BaseOffset="1" >

        <DataStructure Format="HDF"
         Dimensions="1838 4"
         DataType="Int" >
                        Shapes.h5:/Block 1/Connections
        </DataStructure>
    </Topology>
    <Geometry Type="XYZ" >

        <DataStructure Format="HDF"
         Dimensions="1309 3"
         DataType="Float" >
                Shapes.h5:/Geometry
        </DataStructure>
    </Geometry>
 

    <!-- ReUse the Geometry as a Scalar Value of X Position -->

    <Attribute Type="Scalar" Center="Node" Name="X Position">
        <DataTransform Dimensions="1309 1" Type="HyperSlab" >
            <DataStructure Format="XML" Dimensions="2 3">
                0 0 1 3 1309 1
            </DataStructure>
            <DataStructure Format="HDF"
                 Dimensions="1309 3"
                 DataType="Float" >
                Shapes.h5:/Geometry
            </DataStructure>
        </DataTransform>
    </Attribute>
</Grid>



    XML Element : Grid
    XML Attribute : Name = Any String
    XML Attribute : GridType = Uniform* | Collection | Tree | Subset
    XML Attribute : Section = DataItem* | All  (Only Meaningful if GridType="Subset")

\endverbatim

        Typical API usage might look like :
        \code

        XdmfDOM *DOM = new XdmfDOM();
        XdmfGrid *Grid = new XdmfGrid();
        XdmfAttribute *XPos;
        XdmfXNode *GridNode;

        DOM->SetInputFileName("MyData.xmf");
        DOM->Parse();
        GridNode = DOM->FindElement("Grid");
        Grid->SetDOM(DOM);
        Grid->SetElement(GridNode);
        Grid->UpdateInformation(GridNode);
        cout << "First Grid has " << Grid->GetNumberOfAttributes() << " Attributes" << endl;
        Grid->AssignAttributeByName("X Position");
        XPos = Grid->GetAssignedAttribute();
        
        \endcode
*/

class XDMF_EXPORT XdmfGrid : public XdmfElement {

public:
  XdmfGrid();
  ~XdmfGrid();

  XdmfConstString GetClassName() { return ( "XdmfGrid" ) ; };

//! Explicitly set the XdmfGeometry for an XdmfGrid
  XdmfSetValueMacro( Geometry, XdmfGeometry *);
//! Get the XdmfGeometry for an XdmfGrid
  XdmfGetValueMacro( Geometry, XdmfGeometry *);
//! Explicitly set the XdmfTopology for an XdmfGrid
  XdmfSetValueMacro( Topology, XdmfTopology *);
//! Get the XdmfTopology for an XdmfGrid
  XdmfGetValueMacro( Topology, XdmfTopology *);
//! Explicitly set the XdmfTime for an XdmfGrid
  XdmfSetValueMacro( Time, XdmfTime *);
//! Get the XdmfTime for an XdmfGrid
  XdmfGetValueMacro( Time, XdmfTime *);

  //! Get the Grid Type as a string
  XdmfConstString GetGridTypeAsString();

  XdmfInt32 SetGridTypeFromString(XdmfConstString GridType);

  //! Get the Collection Type as a string
  XdmfConstString GetCollectionTypeAsString();
  XdmfInt32 SetCollectionTypeFromString(XdmfConstString CollectionType);


  //! Build the XML (OUTPUT)
  XdmfInt32 Build();

//! Create a XML node for the Topology of a Uniform Grid
  XdmfInt32 InsertTopology();
//! Create a XML node for the Geometry of a Uniform Grid
  XdmfInt32 InsertGeometry();
//! Insert an Element
  XdmfInt32 Insert(XdmfElement *Child);
  //! Get the Grid Type
  XdmfGetValueMacro( GridType, XdmfInt32);
  //! Set the Grid Type
  XdmfSetValueMacro( GridType, XdmfInt32);
  //! Get the Collection Type
  XdmfGetValueMacro( CollectionType, XdmfInt32);
  //! Set the Collection Type
  XdmfSetValueMacro( CollectionType, XdmfInt32);
  //! Get Build Time Flag
  XdmfGetValueMacro( BuildTime, XdmfInt32);
  //! Set the Build Time Flag
  XdmfSetValueMacro( BuildTime, XdmfInt32);

  //! Copy Information from Another DataItem
  XdmfInt32 Copy(XdmfElement *Source);

  //! Get the Number of Children
  XdmfGetValueMacro( NumberOfChildren, XdmfInt32);
  //! Set the Number Of Children
  XdmfSetValueMacro( NumberOfChildren, XdmfInt32);

  //! Is this a Uniform Grid ?
  XdmfInt32 IsUniform();

//! Get the number of Attributes defined for this grid.
/*!
        Attributes can be Scalars(1 value), Vectors(3 values),
        Tensors(9 values), or Matrix(NxM array). Attributes can be centered
        on the Node, Cell, Edge, Face, or Grid.
*/
  XdmfGetValueMacro( NumberOfAttributes, XdmfInt32 );

//! Get Number of Sets
  XdmfGetValueMacro( NumberOfSets, XdmfInt32 );

//! Get Number of Informations
  XdmfGetValueMacro( NumberOfInformations, XdmfInt32 );

//! Retreive a particilar XdmfAttribute
/*!
        Returns the Xdmf Attribute from the grid.
        \param Index    0 based index of the Attribute to retreive
*/
  XdmfGetIndexValueMacro( Attribute, XdmfAttribute * );

//! Get a particular Set
  XdmfGetIndexValueMacro( Sets, XdmfSet * );

//! Update an Attribute and Mark it as Primary
/*!
        When an XdmfGrid is read using SetGridFromElement() the Attribute
        values are not read in since there could potentially be an enourmous 
        amout of data associated with the computational grid. Instead, for
        each Attribute of interest, AssignAttribute is called. This updates
        the Heavy Data and marks it as the primary attribute. So the last
        Attribute read will be one marked : visualization readers might
        use this information in their filters. (i.e. An isosurface generator
        might use the primary scalar to determine the scalar value on which 
        to generate the surface.

        \param Index    0 based index of the Attribute to retreive
*/
  XdmfInt32 AssignAttribute( XdmfInt64 Index );
#ifndef SWIG
  XdmfInt32 AssignAttribute( XdmfAttribute *Attribute );
#endif
//! Same as AssignAttribute (more verbose for scripting languages)
  XdmfInt32 AssignAttributeByIndex( XdmfInt64 Index );
//! Assign the Attribute with the specified name
/*!
        In the XML of the grid, if an Attribute has a 
        \b Name value, this Attribute will be assigned.
        Example:
        \verbatim
        <Attribute Name="Pressure">
                <DataStructure
                        Format="HDF"
                        DataType="Float"
                        Precision="4"
                        Dimensions="10 20 30">
                                Pressure.h5:/Time01/Pressure
                </DataStructure>
        </Attribute>
        \endverbatim
*/
  XdmfInt32 AssignAttributeByName( XdmfString Name );

//! Return the currently marked as Primary
  XdmfAttribute *GetAssignedAttribute( void ) { return( this->AssignedAttribute ); };
//! Returns the index of the Attribute currently marked as Primary
  XdmfInt64 GetAssignedAttributeIndex( void );

  //! Initialize Grid from XML but don't access Heavy Data
  /*!
        Initializes the basic grid structure based on the information found
        in the specified XML Node but does not read any of the underlying
        Heavy data. This can be used to determine the type of grid (structured
        or unstructured, Hex or Tet) and to determine the rank and dimensions
        of the grid.
  */
  XdmfInt32  UpdateInformation();
//! Initialize the grid and read the Heavy Data
/*!
        Initializes the basic grid structure based on the information found
        in the specified XML Node and Read the associated Heavy Data for the
        Topology and Geometry. Heavy Data for the Attreibute(s) is not read.
        Use AssignAttribute to update Attribute Heavy Data.
*/
  XdmfInt32  Update();

 //! Get one of the child Grids from a Collection or Tree
  XdmfGrid  *GetChild(XdmfInt32 Index);

 //! Get one of the child Grids from a Collection or Tree
  XdmfInformation  *GetInformation(XdmfInt32 Index);

 //! Return indexes of first level children that are valid at a time
 XdmfInt32 FindGridsInTimeRange(XdmfFloat64 TimeMin, XdmfFloat64 TimeMax, XdmfArray *ArrayToFill);

 //! Return indexes of first level children that are valid at a time
 XdmfInt32 FindGridsAtTime(XdmfTime *Time, XdmfArray *ArrayToFill, XdmfFloat64 Epsilon = 0.0, XdmfInt32 Append=0);

 //! Release Big Data
 XdmfInt32 Release();

protected:

  XdmfGeometry  *Geometry;
  XdmfTopology  *Topology;
  XdmfTime      *Time;
  XdmfInt32     GeometryIsMine;
  XdmfInt32     TopologyIsMine;
  XdmfInt32     TimeIsMine;
  XdmfInt32     NumberOfAttributes;
  XdmfInt32	NumberOfInformations;
  XdmfInt32     NumberOfSets;
  XdmfInt32     GridType;
  XdmfInt32     CollectionType;
  XdmfInt32     NumberOfChildren;
  XdmfInt32     BuildTime;
  XdmfGrid      **Children;
  XdmfSet       **Sets;
  XdmfAttribute **Attribute;
  XdmfInformation **Informations;
  XdmfAttribute *AssignedAttribute;
};

//! Using a SWIG style Pointer return an XdmfGrid Pointer
extern XDMF_EXPORT XdmfGrid *HandleToXdmfGrid( XdmfString Source);
#endif // __XdmfGrid_h