Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RocMeshData.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 
24 /*******************************************************************
25  *
26  * RocMeshData.h
27  *
28  * Declaration for class RocMeshData. RocMeshData contains mesh
29  * data and ghost information from Rocstar's HDF file.
30  *
31  * COM_init() needed to be called before using this class.
32  *
33  *
34  * Pornput Suriyamongkol
35  * 10/10/06
36  *
37  *
38  * Modification
39  * ------------
40  * Add field information - Pornput 11/02/06
41  *
42  *******************************************************************/
43 
44 #ifndef _ROCMESHDATA_
45 #define _ROCMESHDATA_
46 
47 #include <iostream>
48 #include <string>
49 #include <sstream>
50 #include <vector>
51 #include <fstream>
52 #include <iomanip>
53 
54 using std::cout;
55 using std::endl;
56 using std::cerr;
57 using std::setw;
58 using std::string;
59 using std::vector;
60 using std::ofstream;
61 using std::ios;
62 
63 #include "roccom.h"
65 
66 
68 {
69  /****************************************************************
70  *
71  * Member variables
72  *
73  ***************************************************************/
74 
75  private:
76 
77  // Mesh Info
78  string _filename;
80  int _numVer;
82  int _numElem;
85  int * _elemData;
86  int * _elemType;
87  int * _pconnArray;
88  double * _coords;
89 
90  // Field Info
92  vector <string> _fieldNames;
93  vector <string> _fieldUnits;
94  vector <char> _fieldTypes;
95  vector <int> _fieldComp;
96  vector <double *> _fieldVals;
97 
98 
99  /****************************************************************
100  *
101  * Public Methods
102  *
103  ***************************************************************/
104 
105  public:
106  //
107  // Default constructor
108  //
109  RocMeshData();
110 
111  //
112  // Destructor
113  //
114  ~RocMeshData();
115 
116  //
117  // Constructor
118  //
119  RocMeshData(string const & filename);
120 
121  //
122  // Constructor (overloaded)
123  //
124  RocMeshData(char const * filename);
125 
126  //
127  // Copy constructor
128  //
129  RocMeshData(RocMeshData const & origVal);
130 
131  //
132  // Assignment operator
133  //
134  RocMeshData & operator=(RocMeshData const & origVal);
135 
136  //
137  // Show all RocMeshData info
138  //
139  void showAllInfo() const;
140 
141  //
142  // Check pconn. Return 0 if ok
143  //
144  int pconnCheck(string pltFile = "") const;
145 
146  //
147  // Set base index to 0
148  //
149  void set0IndexBase();
150 
151  //
152  // Set base index to 1
153  //
154  void set1IndexBase();
155 
156  //
157  // Return index base
158  //
159  int getIndexBase() const;
160 
161  //
162  // Return number of vertices
163  //
164  int numVer() const;
165 
166  //
167  // Return number of ghost vertices
168  //
169  int numVerGhost() const;
170 
171  //
172  // Return number of elements
173  //
174  int numElem() const;
175 
176  //
177  // Return pointer to coordinates
178  //
179  double * getCoords() const;
180 
181  //
182  // Return pointer to element types
183  //
184  int * getElemType() const;
185 
186  //
187  // Return pointer to element connectivity
188  //
189  int * getElemData() const;
190 
191  //
192  // Return PCONN array
193  //
194  int * getPCONN() const;
195 
196  //
197  // Return number of fields
198  //
199  int numField() const;
200 
201  //
202  // Return field types
203  //
204  vector <char> getFieldTypes() const;
205 
206  //
207  // Return field names
208  //
209  vector <string> getFieldNames() const;
210 
211  //
212  // Return field units
213  //
214  vector <string> getFieldUnits() const;
215 
216  //
217  // Return field numbers of components
218  //
219  vector <int> getFieldNumComp() const;
220 
221  //
222  // Return field value
223  //
224  vector <double *> getFieldData() const;
225 
226  /****************************************************************
227  *
228  * Helper functions
229  *
230  ***************************************************************/
231  private:
232 
233  //
234  // Free all dynamic memory
235  //
236  void free();
237 
238  //
239  // Copy all member variables
240  //
241  void copy(RocMeshData const & origVal);
242 
243  //
244  // Initialize RocMeshData in constructors
245  //
246  void initRocMeshData(char const * filename);
247 
248  //
249  // Load data from Rocstar's HDF file to window
250  //
251  void loadData(char const * hdfFilename, const char * winName);
252 
253  //
254  // Get pane id and connectivity table info
255  //
256  void getPaneInfo(const char * winName,
257  int & paneId, int & numCon, char * & conNames);
258 
259  //
260  // Get coordinates
261  //
262  void getCoord(const char * winName, int paneId);
263 
264  //
265  // Get total number of elements
266  //
267  void getElemInfo(const char * winName,
268  int paneId, int numCon, char * conNames,
269  int * & types, int * & numElemArray);
270 
271  //
272  // Allocate memory for elemType and elemData
273  //
274  void allocElemMem(int numCon, int * numElemArray, int * types);
275 
276  //
277  // Get element connectivity
278  //
279  void getElemConn(const char * winName, int paneId, int numCon,
280  char * conNames, int * types, int * numElemArray);
281 
282  //
283  // Get PCONN array and its size
284  //
285  void getPconnArray(const char * winName, int paneId);
286 
287  //
288  // Get field information
289  //
290  void getFieldInfo(const char * winName, int paneId);
291 
292  //
293  // Get field attributes and allocate field data memory
294  //
295  void getFieldAttributes(const char * winName);
296 
297  //
298  // Get field data
299  //
300  void getFieldData(const char * winName, int paneId);
301 
302  //
303  // Get Simmetrix element type number
304  //
305  int getSimElemTypeNum(string type);
306 
307  //
308  // Get #nodes / element given element type in Simmetrix format
309  //
310  int getNodePerElem(int num) const;
311 };
312 
313 #endif /* _ROCMESHDATA_ */
314 
315 
316 
317 
318 
319 
vector< double * > _fieldVals
Definition: RocMeshData.h:96
double * getCoords() const
int _numFields
Definition: RocMeshData.h:91
string _filename
Definition: RocMeshData.h:78
int * getElemData() const
int * _elemType
Definition: RocMeshData.h:86
void getFieldAttributes(const char *winName)
int numVer() const
int _pconnSize
Definition: RocMeshData.h:84
int * getPCONN() const
int _indexBase
Definition: RocMeshData.h:79
This file contains the prototypes for Roccom API.
vector< int > _fieldComp
Definition: RocMeshData.h:95
vector< int > getFieldNumComp() const
vector< string > getFieldUnits() const
void showAllInfo() const
void allocElemMem(int numCon, int *numElemArray, int *types)
void getFieldInfo(const char *winName, int paneId)
int getSimElemTypeNum(string type)
int numElem() const
void getElemConn(const char *winName, int paneId, int numCon, char *conNames, int *types, int *numElemArray)
int * getElemType() const
void getCoord(const char *winName, int paneId)
vector< char > _fieldTypes
Definition: RocMeshData.h:94
int _elemDataSize
Definition: RocMeshData.h:83
int numVerGhost() const
void set0IndexBase()
Definition: Rocin.h:64
vector< char > getFieldTypes() const
int pconnCheck(string pltFile="") const
void initRocMeshData(char const *filename)
void getPconnArray(const char *winName, int paneId)
vector< double * > getFieldData() const
int numField() const
void copy(RocMeshData const &origVal)
int _numVerGhost
Definition: RocMeshData.h:81
RocMeshData & operator=(RocMeshData const &origVal)
vector< string > _fieldNames
Definition: RocMeshData.h:92
void loadData(char const *hdfFilename, const char *winName)
void set1IndexBase()
void getPaneInfo(const char *winName, int &paneId, int &numCon, char *&conNames)
int * _pconnArray
Definition: RocMeshData.h:87
int getIndexBase() const
int getNodePerElem(int num) const
vector< string > getFieldNames() const
double * _coords
Definition: RocMeshData.h:88
int * _elemData
Definition: RocMeshData.h:85
void getElemInfo(const char *winName, int paneId, int numCon, char *conNames, int *&types, int *&numElemArray)
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116
vector< string > _fieldUnits
Definition: RocMeshData.h:93