/[escript]/trunk/dataexporter/src/ElementData.h
ViewVC logotype

Diff of /trunk/dataexporter/src/ElementData.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/tools/libescriptreader/src/escriptreader/ElementData.h revision 2806 by jfenwick, Mon Jul 20 06:20:06 2009 UTC trunk/dataexporter/src/ElementData.h revision 2810 by caltinay, Mon Dec 7 04:13:49 2009 UTC
# Line 11  Line 11 
11  *  *
12  *******************************************************/  *******************************************************/
13    
 //  
 // ElementData.h  
 //  
14  #ifndef __ELEMENTDATA_H__  #ifndef __ELEMENTDATA_H__
15  #define __ELEMENTDATA_H__  #define __ELEMENTDATA_H__
16    
17    #include <escriptexport/escriptexport.h>
18  #include <finley/ReferenceElements.h> // for ElementTypeId  #include <finley/ReferenceElements.h> // for ElementTypeId
 #include <escriptreader/Mesh.h>  
19    
20  class DBfile;  class DBfile;
21  class NcFile;  class NcFile;
22    
23  namespace EscriptReader {  struct Finley_ElementFile;
24    
25    namespace escriptexport {
26            
27    class NodeData;
28    
29  typedef enum {  typedef enum {
30      ZONETYPE_BEAM=1,      ZONETYPE_BEAM=1,
31      ZONETYPE_HEX,      ZONETYPE_HEX,
# Line 34  typedef enum { Line 35  typedef enum {
35      ZONETYPE_TRIANGLE      ZONETYPE_TRIANGLE
36  } ZoneType;  } ZoneType;
37    
38  /// \brief Holds information that is used to convert from escript element types  /// \brief Holds information that is used to convert from finley element types
39  /// to Silo.  ///        to elements supported by Silo and VTK.
40  struct FinleyElementInfo  struct FinleyElementInfo
41  {  {
42      ZoneType elementType, reducedElementType;      ZoneType elementType, reducedElementType;
# Line 44  struct FinleyElementInfo Line 45  struct FinleyElementInfo
45      const size_t* multiCellIndices;      const size_t* multiCellIndices;
46  };  };
47    
48  /// \brief A class that stores and manipulates one type of escript mesh elements  /// \brief Stores and manipulates one type of finley mesh elements (cells,
49  /// (elements, faces, contacts or points).  ///        faces or contacts).
50  ///  ///
51  /// The corresponding mesh nodes are not part of this class but stored in a Mesh  /// This class provides functionality to manipulate a finley element file.
52  /// object which has to be provided when constructing an ElementData object.  /// It is able to load element data from NetCDF files or retrieve it from
53    /// a Finley_ElementFile instance.
54    ///
55    /// \note The corresponding mesh nodes are not part of this class but are
56    ///       stored in a NodeData instance.
57  class ElementData  class ElementData
58  {  {
     friend class DataVar;  
     friend class MeshWithElements;  
59  public:  public:
60    
61      /// \brief Constructor with name and accompanying Mesh object.      /// \brief Constructor with name and accompanying NodeData object.
62      ElementData(const std::string& elementName, const Mesh* mainMesh);      ESCRIPTEXPORT_DLL_API
63        ElementData(const std::string& elementName, NodeData_ptr nodes);
64    
65      /// \brief Copy constructor      /// \brief Copy constructor
66        ESCRIPTEXPORT_DLL_API
67      ElementData(const ElementData& e);      ElementData(const ElementData& e);
68    
69        /// \brief Initialises with data from a Finley_ElementFile instance.
70        ESCRIPTEXPORT_DLL_API
71        bool initFromFinley(const Finley_ElementFile* finleyFile);
72    
73      /// \brief Destructor      /// \brief Destructor
74        ESCRIPTEXPORT_DLL_API
75      ~ElementData();      ~ElementData();
76    
77      /// \brief Reads element data from escript NetCDF file.      /// \brief Reads element data from escript/finley NetCDF file.
78        ESCRIPTEXPORT_DLL_API
79      bool readFromNc(NcFile* ncfile);      bool readFromNc(NcFile* ncfile);
80    
81      /// \brief Moves "ghost" elements and corresponding data to the end of the      /// \brief Moves "ghost" elements (whose owner does not match ownIndex)
82      /// arrays.      ///        and the corresponding data to the end of the arrays.
83      void handleGhostZones(int ownIndex);      ESCRIPTEXPORT_DLL_API
84        void reorderGhostZones(int ownIndex);
85    
86      /// \brief Removes "ghost" elements.      /// \brief Removes "ghost" elements.
87      void removeGhostZones();      ESCRIPTEXPORT_DLL_API
88        void removeGhostZones(int ownIndex);
89    
90      /// \brief Writes element data into given directory in given Silo file.      /// \brief Writes element data into given directory in given Silo file.
91      ///      ///
92      /// Since the mesh depends on element information this method also writes      /// Since the mesh depends on element information this method also writes
93      /// the mesh itself. If Silo was not available at compile time or if a Silo      /// the node mesh itself. If Silo was not available at compile time or if
94      /// function fails this method returns false.      /// a Silo function fails this method returns false.
95        ESCRIPTEXPORT_DLL_API
96      bool writeToSilo(DBfile* dbfile, const std::string& siloPath);      bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
97    
98      /// \brief Returns the names of the meshes associated with the elements.      /// \brief Returns the names of the meshes associated with the elements.
99        ESCRIPTEXPORT_DLL_API
100      StringVec getMeshNames() const;      StringVec getMeshNames() const;
101    
102      /// \brief Returns a vector with the mesh variable names.      /// \brief Returns a vector with the mesh variable names.
103        ESCRIPTEXPORT_DLL_API
104      StringVec getVarNames() const;      StringVec getVarNames() const;
105    
106      /// \brief Returns the number of elements.      /// \brief Returns the number of elements.
107      int getCount() const { return count; }      ESCRIPTEXPORT_DLL_API
108        int getNumElements() const { return numElements; }
109    
110      /// \brief Returns the number of reduced elements.      /// \brief Returns the number of reduced elements.
111      int getReducedCount() const { return reducedCount; }      ESCRIPTEXPORT_DLL_API
112        int getReducedNumElements() const { return reducedNumElements; }
113    
114      /// \brief Returns the number of nodes per element.      /// \brief Returns the number of nodes per element.
115        ESCRIPTEXPORT_DLL_API
116      int getNodesPerElement() const { return nodesPerElement; }      int getNodesPerElement() const { return nodesPerElement; }
117    
118      /// \brief Returns the number of nodes per reduced element.      /// \brief Returns the number of nodes per reduced element.
119        ESCRIPTEXPORT_DLL_API
120      int getReducedNodesPerElement() const { return reducedNodesPerElement; }      int getReducedNodesPerElement() const { return reducedNodesPerElement; }
121    
122      /// \brief Returns the number of "ghost" elements.      /// \brief Returns the number of "ghost" elements.
123        ESCRIPTEXPORT_DLL_API
124      int getGhostCount() const { return numGhostElements; }      int getGhostCount() const { return numGhostElements; }
125    
126      /// \brief Returns the number of "ghost" reduced elements.      /// \brief Returns the number of "ghost" reduced elements.
127        ESCRIPTEXPORT_DLL_API
128      int getReducedGhostCount() const { return numReducedGhostElements; }      int getReducedGhostCount() const { return numReducedGhostElements; }
129    
130      /// \brief Returns the type of the elements.      /// \brief Returns the type of the elements.
131        ESCRIPTEXPORT_DLL_API
132      ZoneType getType() const { return type; }      ZoneType getType() const { return type; }
133    
134      /// \brief Returns the type of reduced elements.      /// \brief Returns the type of reduced elements.
135        ESCRIPTEXPORT_DLL_API
136      ZoneType getReducedType() const { return reducedType; }      ZoneType getReducedType() const { return reducedType; }
137    
138      /// \brief Returns a vector of the node IDs used by the elements.      /// \brief Returns a vector of the node IDs used by the elements.
139        ESCRIPTEXPORT_DLL_API
140      const IntVec& getNodeList() const { return nodes; }      const IntVec& getNodeList() const { return nodes; }
141    
142      /// \brief Returns a vector of the node IDs used by the reduced elements.      /// \brief Returns a vector of the node IDs used by the reduced elements.
143        ESCRIPTEXPORT_DLL_API
144      const IntVec& getReducedNodeList() const { return reducedNodes; }      const IntVec& getReducedNodeList() const { return reducedNodes; }
145    
146      /// \brief Returns a vector of element IDs.      /// \brief Returns a vector of element IDs.
147        ESCRIPTEXPORT_DLL_API
148      const IntVec& getIDs() const { return ID; }      const IntVec& getIDs() const { return ID; }
149    
150        /// \brief Returns a mapping of element IDs to array index.
151        ESCRIPTEXPORT_DLL_API
152        IndexMap getIndexMap() const;
153    
154        /// \brief Returns an array of data values for the name provided.
155        ///
156        /// The name must be one of the names returned from getVarNames().
157        ESCRIPTEXPORT_DLL_API
158        const IntVec& getVarDataByName(const std::string varName) const;
159    
160        /// \brief Returns the node mesh instance used by the elements.
161        ESCRIPTEXPORT_DLL_API
162        NodeData_ptr getNodeMesh() const { return fullMesh; }
163    
164        /// \brief Returns the node mesh instance used by the reduced elements.
165        ESCRIPTEXPORT_DLL_API
166        NodeData_ptr getReducedNodeMesh() const { return reducedMesh; }
167    
168  private:  private:
169      ElementData() {}      ElementData() {}
170      FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);      FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);
     void buildIndexMap();  
171      void buildMeshes();      void buildMeshes();
172      void buildReducedElements(const FinleyElementInfo& f);      void buildReducedElements(const FinleyElementInfo& f);
173      void prepareGhostIndices(int ownIndex);      void prepareGhostIndices(int ownIndex, IntVec& indexArray,
174                                 IntVec& reducedIndexArray);
175      void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);      void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
176    
     const IntVec& getVarDataByName(const std::string varName) const;  
   
177      std::string name;      std::string name;
178      int count, reducedCount;      int numElements, reducedNumElements;
179      int numGhostElements, numReducedGhostElements;      int numGhostElements, numReducedGhostElements;
180      IndexMap ID2idx;      NodeData_ptr fullMesh;
181      IntVec indexArray, reducedIndexArray;      NodeData_ptr reducedMesh;
182      Mesh* fullMesh;      NodeData_ptr originalNodes;
     Mesh* reducedMesh;  
     const Mesh* originalMesh;  
183      bool fullMeshIsOriginalMesh;      bool fullMeshIsOriginalMesh;
184    
185      int numDims;      int numDims;
# Line 149  private: Line 190  private:
190      IntVec owner, reducedOwner;      IntVec owner, reducedOwner;
191  };  };
192    
193  //  
194  //  inline IndexMap ElementData::getIndexMap() const
 //  
 inline void ElementData::buildIndexMap()  
195  {  {
196      ID2idx.clear();      IndexMap ID2idx;
197      size_t idx = 0;      size_t idx = 0;
198      IntVec::const_iterator idIt;      IntVec::const_iterator idIt;
199      for (idIt = ID.begin(); idIt != ID.end(); idIt++, idx++)      for (idIt = ID.begin(); idIt != ID.end(); idIt++, idx++)
200          ID2idx[*idIt] = idx;          ID2idx[*idIt] = idx;
201        return ID2idx;
202  }  }
203    
204  } // namespace EscriptReader  } // namespace escriptexport
205    
206  #endif // __ELEMENTDATA_H__  #endif // __ELEMENTDATA_H__
207    

Legend:
Removed from v.2806  
changed lines
  Added in v.2810

  ViewVC Help
Powered by ViewVC 1.1.26