Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Connectivity.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 // $Id: Connectivity.h,v 1.17 2008/12/06 08:43:24 mtcampbe Exp $
24 
29 /* Author: Xiangmin Jiao */
30 
31 #ifndef __ROCCOM_CONNECTIVITY_H__
32 #define __ROCCOM_CONNECTIVITY_H__
33 
34 #include "Attribute.h"
35 
36 COM_BEGIN_NAME_SPACE
37 
41 class Connectivity : protected Attribute {
42 public:
44  { ST1, ST2, ST3, /* structured mesh */
45  BAR2, BAR3, /* 1d unstructured mesh */
46  TRI3, TRI6, QUAD4, QUAD8, QUAD9, /* 2d unstructured mesh */
48  HEX8, HEX20, HEX27, /* 3d unstructured mesh */
53 
55  using Attribute::Size;
56  using Attribute::name;
57  using Attribute::fullname;
58  using Attribute::id;
59  using Attribute::location;
61  using Attribute::pane;
62  using Attribute::window;
71  using Attribute::capacity;
72  using Attribute::stride;
73  using Attribute::empty;
74  using Attribute::status;
78 
90  Connectivity( Pane *pane, const std::string &name, int id,
91  const int sizes[], int type=COM_INT)
92  : Attribute( pane, name, id, 'p', type,
93  /* for structured meshes, ncomp is 1 */
94  (sizes[TYPE_ID]<=ST3)?1:sizes[SIZE_NNODES], ""),
95  _offset(0), _size_info(sizes) {}
96 
99  const std::string &name, int id)
100  : Attribute( pane, (Attribute*)con, name, id),
101  _offset(con->_offset), _size_info( con->_size_info) {}
102  //\}
103 
107  Connectivity *parent() { return (Connectivity*)_parent; }
109  const Connectivity *parent() const { return (const Connectivity*)_parent; }
110 
113  { return (Connectivity*)(Attribute::root()); }
114  const Connectivity *root() const
115  { return (const Connectivity*)(Attribute::root()); }
116 
118  void inherit( Connectivity *parent, bool clone, bool withghost) throw(COM_exception)
119  { Attribute::inherit( parent, clone, withghost); }
120 
122  int element_type() const { return _size_info[TYPE_ID]; }
123 
125  int dimension() const { return _size_info[SIZE_DIM]; }
126 
128  bool is_structured() const
129  { return _size_info[TYPE_ID] <= ST3; }
130 
132  bool is_quadratic() const { return _size_info[ORDER] == 2; }
133  //\}
134 
138  Size size_of_corners_pe() const
140  { return _size_info[SIZE_NCORN]; }
141 
143  static Size size_of_corners_pe( int type)
144  { return _sizes[type][SIZE_NCORN]; }
145 
148  { return _size_info[SIZE_NNODES]; }
149 
151  static Size size_of_nodes_pe( int type)
152  { return _sizes[type][SIZE_NNODES]; }
153 
156  { return _size_info[SIZE_NEDGES]; }
157 
159  static Size size_of_edges_pe(int type)
160  { return _sizes[type][SIZE_NEDGES]; }
161 
164  { return _size_info[SIZE_NFACES]; }
165 
167  static Size size_of_faces_pe( int type)
168  { return _sizes[type][SIZE_NFACES]; }
169 
171  Size size_of_elements() const;
172 
175 
177  Size size_of_real_elements() const;
178 
180  Size size_of_nodes() const;
181 
183  Size size_of_ghost_nodes() const;
184 
186  Size size_of_real_nodes() const;
187 
189  Size index_offset() const { return root()->_offset; }
190 
192  Size size_i() const
193  { return pointer()[0]; }
195  Size size_j() const
196  { return dimension()>1?pointer()[1]:1; }
198  Size size_k() const
199  { return dimension()>2?pointer()[2]:1; }
200  //\}
201 
205  const int *pointer() const { return (const int*)Attribute::pointer(); }
207 
209  int *pointer() { return (int*)Attribute::pointer(); }
210 
214  const int *get_addr( int i, int j=0) const throw(COM_exception);
215 
216  int *get_addr( int i, int j=0) throw(COM_exception) {
217  if ( is_const()) throw COM_exception( COM_ERR_ATTRIBUTE_CONST);
218  return (int*)(((const Connectivity*)this)->get_addr(i,j));
219  }
220  //\}
221 
223  bool is_const() const { return is_structured() || Attribute::is_const(); }
224 
228  static bool is_element_name( const std::string &aname) {
229  return aname[0] == ':';
230  }
231 
233  static const int*get_size_info( const std::string &aname);
234 
236  void *allocate( int strd, int cap, bool force) throw(COM_exception) {
237  if ( !is_structured()) return Attribute::allocate( strd, cap, force);
239  }
240 
243  void set_size( int nitems, int ngitems=0) throw(COM_exception);
244  //\}
245 
246 protected:
248  void set_pointer( void *p, int strd, int cap,
249  bool is_const) throw(COM_exception);
250 
252  void set_offset( Size offset) throw(COM_exception);
253 
254 protected:
255  int _offset;
256  const int *_size_info;
257  // Tables of pre-defined connectivity types
258  static const int _sizes[TYPE_MAX_CONN][SIZE_MAX_CONN];
259 };
260 
261 COM_END_NAME_SPACE
262 
263 #endif
264 
265 
266 
267 
268 
269 
void inherit(Attribute *a, bool clone, bool withghost, int depth=0)
Inherit from parent. If depth&gt;0, then the procedure is for the subcomponents.
Definition: Attribute.C:426
Attribute * _parent
Parent attribute being used.
Definition: Attribute.h:299
int * pointer()
Get a pointer to the connectivity array.
Definition: Connectivity.h:209
Size size_of_ghost_elements() const
Get the number of ghost elements.
Definition: Connectivity.C:117
A Pane object contains a mesh, pane attribute, and field variables.
Definition: Pane.h:43
bool initialized() const
Returns whether the array for the attribute has been set or allocated.
Definition: Attribute.h:244
int maxsize_of_real_items() const
Obtain the maximum allowed number of real items in the attribute.
Definition: Attribute.C:179
const int * pointer() const
Get a constant pointer to the connectivity array.
Definition: Connectivity.h:206
An Attribute object is a data member of a window.
Definition: Attribute.h:51
const Connectivity * root() const
Definition: Connectivity.h:114
bool is_structured() const
Determine whether the mesh is quadratic.
Definition: Connectivity.h:128
int dimension() const
Get the dimension of the mesh.
Definition: Connectivity.h:125
Connectivity * parent()
Parent attribute being used.
Definition: Connectivity.h:108
static Size size_of_edges_pe(int type)
Get the number of edges per element of the given type of element.
Definition: Connectivity.h:159
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
Size size_of_corners_pe() const
Get the number of corners per element of the current connectivity table.
Definition: Connectivity.h:139
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
const Window * window() const
Obtain a constant pointer to the parent window of the attribute.
Definition: Attribute.C:80
bool is_quadratic() const
Determine whether the element type is quadratic.
Definition: Connectivity.h:132
Size size_of_ghost_nodes() const
Get the number of ghost nodes of the owner pane.
Definition: Connectivity.C:178
int maxsize_of_items() const
Obtain the maximum allowed number of items in the attribute.
Definition: Attribute.C:125
Shorter_size location() const
Obtain the location of the attribute.
Definition: Attribute.h:186
static const int * get_size_info(const std::string &aname)
Obtain the size info of pre-defined connectivity.
Definition: Connectivity.C:234
Encapsulates the states of an exception.
int deallocate()
Deallocate memory if it was allocated by allocate().
Definition: Attribute.C:473
Size size_k() const
Get the number of nodes in k-dimension if the mesh is structured.
Definition: Connectivity.h:198
Connectivity * root()
Root of use-inheritance.
Definition: Connectivity.h:112
int capacity() const
Obtain the capacity of the array.
Definition: Attribute.h:230
Attribute * root()
Root of use-inheritance.
Definition: Attribute.h:134
unsigned int Size
Unsighed int.
Definition: Attribute.h:54
const void * pointer() const
Obtain a constant pointer to the physical address.
Definition: Attribute.h:150
Size index_offset() const
Get the index of the first element.
Definition: Connectivity.h:189
const Connectivity * parent() const
Definition: Connectivity.h:109
int size_of_ghost_items() const
Obtain the number of ghost items in the attribute.
Definition: Attribute.C:139
Size size_of_nodes() const
Get the total number of nodes (including ghost nodes) of the owner pane.
Definition: Connectivity.C:158
int _offset
Offset of the first element.
Definition: Connectivity.h:255
Connectivity(Pane *pane, Connectivity *con, const std::string &name, int id)
Construct from another connectivity table.
Definition: Connectivity.h:98
Size size_of_real_elements() const
Get the number of real elements.
Definition: Connectivity.C:139
void set_pointer(void *p, int strd, int cap, bool is_const)
Set pointer of connectivity table.
Definition: Connectivity.C:216
const std::string & name() const
Obtain the name of the attribute.
Definition: Attribute.h:113
blockLoc i
Definition: read.cpp:79
static bool is_element_name(const std::string &aname)
Definition: Connectivity.h:228
static Size size_of_nodes_pe(int type)
Get the number of nodes per element of the given type of element.
Definition: Connectivity.h:151
const int * _size_info
Definition: Connectivity.h:256
void set_offset(Size offset)
Set the index of the first element.
Definition: Connectivity.C:92
Size size_of_edges_pe() const
Get the number of edges per element of the current connectivity table.
Definition: Connectivity.h:155
int stride() const
Obtain the stride of the attribute in base datatype.
Definition: Attribute.h:233
int maxsize_of_ghost_items() const
Obtain the maximum allowed number of items in the attribute.
Definition: Attribute.C:153
int size_of_real_items() const
Obtain the number of real items in the attribute.
Definition: Attribute.C:167
void set_size(int nitems, int ngitems=0)
Set the size of items and ghost items.
Definition: Connectivity.C:76
const Pane * pane() const
Obtain a constant pointer to the owner pane of the attribute.
Definition: Attribute.h:172
bool is_const() const
Returns whether the array is set to be read-only.
Definition: Connectivity.h:223
static Size size_of_corners_pe(int type)
Get the number of corners per element of the given type of element.
Definition: Connectivity.h:143
static Size size_of_faces_pe(int type)
Get the number of faces per element of the given type of element.
Definition: Connectivity.h:167
bool is_staggered() const
Check how the attribute values are organized.
Definition: Attribute.h:258
j indices j
Definition: Indexing.h:6
Size size_of_nodes_pe() const
Get the number of nodes per element of the current connectivity table.
Definition: Connectivity.h:147
Size size_j() const
Get the number of nodes in j-dimension if the mesh is structured.
Definition: Connectivity.h:195
const int * get_addr(int i, int j=0) const
Obtain the address of the jth component of the ith item, where 0&lt;=i&lt;size_of_items.
Definition: Connectivity.C:64
void * allocate(int strd, int cap, bool force)
Allocate memory for the attribute.
Definition: Attribute.C:345
void inherit(Connectivity *parent, bool clone, bool withghost)
Inherit a connectivity table.
Definition: Connectivity.h:118
Size size_of_elements() const
Get the total number of elements (including ghost elements) in the table.
Definition: Connectivity.C:96
int element_type() const
Obtain element type ID.
Definition: Connectivity.h:122
void copy_array(void *buf, int strd, int nitem, int offset=0, int direction=COPY_IN)
Definition: Attribute.C:249
void * allocate(int strd, int cap, bool force)
Allocate memory for unstructured mesh.
Definition: Connectivity.h:236
Contains the prototype of Attriubte.
unsigned char Shorter_size
One byte unsighed int.
Definition: Attribute.h:53
COM_Type data_type() const
Obtain the data type of each component of the attribute.
Definition: Attribute.h:197
int id() const
Obtain the id (or index) of the attribute.
Definition: Attribute.h:120
static const int _sizes[TYPE_MAX_CONN][SIZE_MAX_CONN]
Definition: Connectivity.h:258
Size size_of_real_nodes() const
Get the number of real nodes of the owner pane.
Definition: Connectivity.C:198
Size size_of_faces_pe() const
Get the number of faces per element of the current connectivity table.
Definition: Connectivity.h:163
bool empty() const
Check whether the number of items of the attribute is zero.
Definition: Attribute.h:227
bool is_const() const
Returns whether the array is set to be read-only.
Definition: Attribute.h:253
Connectivity(Pane *pane, const std::string &name, int id, const int sizes[], int type=COM_INT)
Create an attribute with name n in window w.
Definition: Connectivity.h:90
Encapsulates an element-connectivity of a mesh.
Definition: Connectivity.h:41
int size_of_items() const
Obtain the number of items in the attribute.
Definition: Attribute.C:111
std::string fullname() const
Obtain the full name of the attribute including window name suitable for printing out error messages...
Definition: Attribute.C:82
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Connectivity.h:192
int size_of_components() const
Obtain the number of components in the attribute.
Definition: Attribute.h:203