1 /*****************************************************************************/ 2 /* XDMF */ 3 /* eXtensible Data Model and Format */ 4 /* */ 5 /* Id : XdmfGrid.hpp */ 6 /* */ 7 /* Author: */ 8 /* Kenneth Leiter */ 9 /* kenneth.leiter@arl.army.mil */ 10 /* US Army Research Laboratory */ 11 /* Aberdeen Proving Ground, MD */ 12 /* */ 13 /* Copyright @ 2011 US Army Research Laboratory */ 14 /* All Rights Reserved */ 15 /* See Copyright.txt for details */ 16 /* */ 17 /* This software is distributed WITHOUT ANY WARRANTY; without */ 18 /* even the implied warranty of MERCHANTABILITY or FITNESS */ 19 /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ 20 /* for more information. */ 21 /* */ 22 /*****************************************************************************/ 23 24 #ifndef XDMFGRID_HPP_ 25 #define XDMFGRID_HPP_ 26 27 // Forward Declarations 28 class XdmfAttribute; 29 class XdmfGeometry; 30 class XdmfMap; 31 class XdmfSet; 32 class XdmfTime; 33 class XdmfTopology; 34 35 // Includes 36 #include "Xdmf.hpp" 37 #include "XdmfItem.hpp" 38 39 /** 40 * @brief A mesh containing elements, points, and fields attached to 41 * the mesh. 42 * 43 * XdmfGrid represents a mesh. It is required to contain two other 44 * Xdmf data structures, an XdmfGeometry that stores point locations 45 * and an XdmfTopology that store connectivity 46 * information. XdmfAttributes can be inserted into the XdmfGrid to 47 * specify fields centered on various parts of the mesh. XdmfSets can 48 * be inserted into XdmfGrids to specify collections of mesh elements. 49 * 50 * XdmfGrid is an abstract base class. There are several 51 * implementations for representing both structured and unstructured 52 * grids. 53 */ 54 class XDMF_EXPORT XdmfGrid : public virtual XdmfItem { 55 56 public: 57 58 virtual ~XdmfGrid() = 0; 59 60 LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem) 61 XDMF_CHILDREN(XdmfGrid, XdmfAttribute, Attribute, Name) 62 XDMF_CHILDREN(XdmfGrid, XdmfSet, Set, Name) 63 XDMF_CHILDREN(XdmfGrid, XdmfMap, Map, Name) 64 static const std::string ItemTag; 65 66 /** 67 * Get the geometry associated with this grid. 68 * 69 * Example of use: 70 * 71 * C++ 72 * 73 * @dontinclude ExampleXdmfGrid.cpp 74 * @skipline //#initialization 75 * @until //#initialization 76 * @skipline //#getGeometry 77 * @until //#getGeometry 78 * 79 * Python 80 * 81 * @dontinclude XdmfExampleGrid.py 82 * @skipline #//initialization 83 * @until #//initialization 84 * @skipline #//getGeometry 85 * @until #//getGeometry 86 * 87 * @return The geometry associated with this grid. 88 */ 89 shared_ptr<const XdmfGeometry> getGeometry() const; 90 91 std::map<std::string, std::string> getItemProperties() const; 92 93 virtual std::string getItemTag() const; 94 95 /** 96 * Get the name of the grid. 97 * 98 * Example of use: 99 * 100 * C++ 101 * 102 * @dontinclude ExampleXdmfGrid.cpp 103 * @skipline //#initialization 104 * @until //#initialization 105 * @skipline //#setName 106 * @until //#setName 107 * @skipline //#getName 108 * @until //#getName 109 * 110 * Python 111 * 112 * @dontinclude XdmfExampleGrid.py 113 * @skipline #//initialization 114 * @until #//initialization 115 * @skipline #//setName 116 * @until #//setName 117 * @skipline #//getName 118 * @until #//getName 119 * 120 * @return The name of the grid. 121 */ 122 std::string getName() const; 123 124 /** 125 * Get the time associated with this grid. 126 * 127 * Example of use: 128 * 129 * C++ 130 * 131 * @dontinclude ExampleXdmfGrid.cpp 132 * @skipline //#initialization 133 * @until //#initialization 134 * @skipline //#setTime 135 * @until //#setTime 136 * @skipline //#getTime 137 * @until //#getTime 138 * 139 * Python 140 * 141 * @dontinclude XdmfExampleGrid.py 142 * @skipline #//initialization 143 * @until #//initialization 144 * @skipline #//setTime 145 * @until #//setTime 146 * @skipline #//getTime 147 * @until #//getTime 148 * 149 * @return Pointer to the XdmfTime attached to this grid. If no 150 * XdmfTime is attached, return a NULL pointer. 151 */ 152 shared_ptr<XdmfTime> getTime(); 153 154 /** 155 * Get the time associated with this grid (const version). 156 * 157 * Example of use: 158 * 159 * C++ 160 * 161 * @dontinclude ExampleXdmfGrid.cpp 162 * @skipline //#initialization 163 * @until //#initialization 164 * @skipline //#setTime 165 * @until //#setTime 166 * @skipline //#getTimeconst 167 * @until //#getTimeconst 168 * 169 * Python: Python doesn't have a constant version 170 * 171 * @return Pointer to the XdmfTime attached to this grid. If no 172 * XdmfTime is attached, return a NULL pointer. 173 */ 174 shared_ptr<const XdmfTime> getTime() const; 175 176 /** 177 * Get the topology associated with this grid. 178 * 179 * Example of use: 180 * 181 * C++ 182 * 183 * @dontinclude ExampleXdmfGrid.cpp 184 * @skipline //#initialization 185 * @until //#initialization 186 * @skipline //#getTopology 187 * @until //#getTopology 188 * 189 * Python 190 * 191 * @dontinclude XdmfExampleGrid.py 192 * @skipline #//initialization 193 * @until #//initialization 194 * @skipline #//getTopology 195 * @until #//getTopology 196 * 197 * @return The topology associated with this grid. 198 */ 199 shared_ptr<const XdmfTopology> getTopology() const; 200 201 using XdmfItem::insert; 202 203 /** 204 * Set the name of the grid. 205 * 206 * Example of use: 207 * 208 * C++ 209 * 210 * @dontinclude ExampleXdmfGrid.cpp 211 * @skipline //#initialization 212 * @until //#initialization 213 * @skipline //#setName 214 * @until //#setName 215 * 216 * Python 217 * 218 * @dontinclude XdmfExampleGrid.py 219 * @skipline #//initialization 220 * @until #//initialization 221 * @skipline #//setName 222 * @until #//setName 223 * 224 * @param name Name of the grid to set. 225 */ 226 void setName(const std::string & name); 227 228 /** 229 * Set the time associated with this grid. 230 * 231 * Example of use: 232 * 233 * C++ 234 * 235 * @dontinclude ExampleXdmfGrid.cpp 236 * @skipline //#initialization 237 * @until //#initialization 238 * @skipline //#setTime 239 * @until //#setTime 240 * 241 * Python 242 * 243 * @dontinclude XdmfExampleGrid.py 244 * @skipline #//initialization 245 * @until #//initialization 246 * @skipline #//setTime 247 * @until #//setTime 248 * 249 * @param time An XdmfTime to associate with this grid. 250 */ 251 void setTime(const shared_ptr<XdmfTime> time); 252 253 virtual void traverse(const shared_ptr<XdmfBaseVisitor> visitor); 254 255 protected: 256 257 XdmfGrid(const shared_ptr<XdmfGeometry> geometry, 258 const shared_ptr<XdmfTopology> topology, 259 const std::string & name = "Grid"); 260 261 virtual void 262 populateItem(const std::map<std::string, std::string> & itemProperties, 263 const std::vector<shared_ptr<XdmfItem> > & childItems, 264 const XdmfCoreReader * const reader); 265 266 shared_ptr<XdmfGeometry> mGeometry; 267 shared_ptr<XdmfTopology> mTopology; 268 269 private: 270 271 XdmfGrid(const XdmfGrid &); // Not implemented. 272 void operator=(const XdmfGrid &); // Not implemented. 273 274 std::string mName; 275 shared_ptr<XdmfTime> mTime; 276 277 }; 278 279 #endif /* XDMFGRID_HPP_ */ 280