Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pane.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: Pane.h,v 1.8 2008/12/06 08:43:24 mtcampbe Exp $
24 
29 /* Author: Xiangmin Jiao */
30 
31 #ifndef __ROCCOM_PANE_H__
32 #define __ROCCOM_PANE_H__
33 
34 #include <string>
35 #include <vector>
36 #include "Connectivity.h"
37 
38 COM_BEGIN_NAME_SPACE
39 
43 class Pane {
44 public:
45  typedef std::vector<Attribute*> Attr_set;
46  typedef std::vector<Connectivity*> Cnct_set;
47  typedef unsigned int Size;
50 
51  class Attribute_friend : public Attribute {
52  explicit Attribute_friend( Attribute&);
53  public:
54  Attribute_friend( Pane *p, int i) : Attribute(p, i) {}
56  using Attribute::inherit;
57  };
58 
61  public:
65  };
66 
70  Pane(Window *w, int i);
72 
74  Pane(Pane *p, int i);
75 
77  virtual ~Pane();
78  //\}
79 
83  void init_done() throw(COM_exception);
85  //\}
86 
90  const Window *window() const { return _window; }
93  Window *window() { return _window; }
94 
96  int id() const { return _id; }
97 
99  int dimension() const
100  { return _cnct_set.empty()?0:_cnct_set[0]->dimension(); }
101 
103  bool is_unstructured() const
104  { return _cnct_set.size()!=1 || !_cnct_set[0]->is_structured(); }
105 
107  bool is_mixed() const { return _cnct_set.size()>1; }
108 
110  bool is_structured() const
111  { return _cnct_set.size()==1 && _cnct_set[0]->is_structured(); }
112  //\}
113 
117  Size size_of_nodes() const
119  { return _attr_set[COM_NC]->size_of_items(); }
120 
123  { return _attr_set[COM_NC]->maxsize_of_items(); }
124 
127  { return _attr_set[COM_NC]->size_of_ghost_items(); }
128 
131  { return _attr_set[COM_NC]->maxsize_of_ghost_items(); }
132 
135  { return _attr_set[COM_NC]->size_of_real_items(); }
136 
139  { return _attr_set[COM_NC]->maxsize_of_real_items(); }
140 
143  { return _attr_set[COM_CONN]->size_of_items(); }
144 
147  { return _attr_set[COM_CONN]->maxsize_of_items(); }
148 
151  { return _attr_set[COM_CONN]->size_of_ghost_items(); }
152 
155  { return _attr_set[COM_CONN]->maxsize_of_ghost_items(); }
156 
159  { return _attr_set[COM_CONN]->size_of_real_items(); }
160 
163  { return _attr_set[COM_CONN]->maxsize_of_real_items(); }
164 
167  double *coordinates() { return (double *)_attr_set[COM_NC]->pointer(); }
170  double *x_coordinates() { return (double *)_attr_set[COM_NC1]->pointer(); }
173  double *y_coordinates() { return (double *)_attr_set[COM_NC2]->pointer(); }
176  double *z_coordinates() { return (double *)_attr_set[COM_NC3]->pointer(); }
177 
179  const double *coordinates() const
180  { return (const double *)_attr_set[COM_NC]->pointer(); }
183  const double *x_coordinates() const
184  { return (const double *)_attr_set[COM_NC1]->pointer(); }
187  const double *y_coordinates() const
188  { return (const double *)_attr_set[COM_NC2]->pointer(); }
191  const double *z_coordinates() const
192  { return (const double *)_attr_set[COM_NC3]->pointer(); }
193 
196  { return (int*)_attr_set[COM_PCONN]->pointer(); }
197 
199  const int *pane_connectivity() const
200  { return (const int *)_attr_set[COM_PCONN]->pointer(); }
201 
202  bool ignore_ghost() const { return _ignore_ghost; }
203 
204  void set_ignore_ghost(bool ignore){ _ignore_ghost = ignore; }
205  //\}
206 
210  Size size_of_ghost_layers() const
213  { return _cnct_set.empty()?0:_cnct_set[0]->size_of_ghost_items(); }
214 
216  Size size_i() const
217  { return !is_structured()?0:_cnct_set[0]->size_i(); }
219  Size size_j() const
220  { return !is_structured()?0:_cnct_set[0]->size_j(); }
222  Size size_k() const
223  { return !is_structured()?0:_cnct_set[0]->size_k(); }
224  //\}
225 
229  void attributes( std::vector<Attribute*> &as);
231 
233  void attributes( std::vector< const Attribute*> &as) const
234  { const_cast<Pane*>(this)->attributes((std::vector<Attribute*>&)as); }
235 
237  Attribute *attribute( const std::string &a); // Locate by name.
239  const Attribute *attribute( const std::string &a) const
240  { return const_cast<Pane*>(this)->attribute(a); }
241 
243  Attribute *attribute( int i);
244 
246  const Attribute *attribute( int i) const
247  { return const_cast<Pane*>(this)->attribute(i); }
248  //\}
249 
253  void connectivities( std::vector<Connectivity*> &es)
255  { es = _cnct_set; }
256 
257  void connectivities( std::vector<const Connectivity*> &es) const
258  { const_cast<Pane*>(this)->connectivities
259  ( (std::vector<Connectivity*> &)es); }
260 
264  { return const_cast<Pane*>(this)->connectivity( i); }
265 
268  void elements( std::vector<Connectivity*> &es) { connectivities(es); }
269  void elements( std::vector< const Connectivity*> &es) const
270  { connectivities(es); }
271 
273  void refresh_connectivity() throw(COM_exception);
274  //\}
275 
276 protected: // The following functions to be called by the Window class.
277  // Add a new attribute into the pane.
278  Attribute *new_attribute( const std::string &aname, int aid,
279  const char loc, const int type, int ncomp,
280  const std::string &unit) throw(COM_exception);
281 
283  void insert( Attribute *attr) throw(COM_exception);
284 
286  void delete_attribute( int id) throw (COM_exception);
287 
288  void reinit_attr( int aid, OP_Init op, void **addr,
289  int strd, int cap) throw(COM_exception);
290 
292  const Connectivity *connectivity( const std::string &a)
293  const throw(COM_exception)
294  { return const_cast<Pane*>(this)->connectivity( a); }
295 
296  Connectivity *connectivity( const std::string &a,
297  bool insert=false) throw(COM_exception);
298 
299  void reinit_conn( Connectivity *con, OP_Init op, int **addr,
300  int strd, int cap) throw (COM_exception);
301 
303  Attribute *inherit( Attribute *from, const std::string &aname,
304  int mode, bool withghost) throw(COM_exception);
305 
307  void set_size( Attribute *a, int nitems, int ng) throw( COM_exception);
308 
310  void set_size( Connectivity *con, int nitems, int ng) throw( COM_exception);
311 
312 protected:
314  int _id;
318 
319 private:
320 #ifdef DOXYGEN
321  // This is to fool DOXYGEN to generate the correct collabration diagram
324 #endif
325  // Disable the following two functions (they are dangerous)
326  Pane( const Pane&);
327  Pane &operator=( const Pane&);
328 };
329 
330 COM_END_NAME_SPACE
331 
332 #endif
333 
334 
335 
336 
337 
338 
const double * z_coordinates() const
Get a constant pointer to the values of the z-coordinates, if the coordinates are staggered...
Definition: Pane.h:191
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
Size maxsize_of_ghost_elements() const
Get the maximum number of elements allowed in the pane (including ghost elements) ...
Definition: Pane.h:154
Size size_of_real_elements() const
Get the number of real elements in the pane (excluding ghost elements).
Definition: Pane.h:158
const Window * window() const
Obtain a constant pointer to its owner window object.
Definition: Pane.h:91
A Pane object contains a mesh, pane attribute, and field variables.
Definition: Pane.h:43
int * pane_connectivity()
Get a pointer to the values of the pane connectivity.
Definition: Pane.h:195
Size maxsize_of_elements() const
Get the maximum number of elements allowed in the pane (including ghost elements) ...
Definition: Pane.h:146
Connectivity_friend(Connectivity &)
void set_pointer(void *p, int strd, int cap, int offset, bool is_const)
Set the physical address of the attribute values.
Definition: Attribute.C:208
Size maxsize_of_real_elements() const
Get the maximum number of real elements allowed in the pane (excluding ghost elements).
Definition: Pane.h:162
An Attribute object is a data member of a window.
Definition: Attribute.h:51
bool _ignore_ghost
Whether the ghosts were ignored.
Definition: Pane.h:317
const Attribute * attribute(const std::string &a) const
Obtain the attribute from given name.
Definition: Pane.h:239
Size maxsize_of_nodes() const
Get the maximum number of real nodes in the pane (excluding ghost nodes).
Definition: Pane.h:122
void reinit_conn(Connectivity *con, OP_Init op, int **addr, int strd, int cap)
Definition: Pane.C:400
A Window object contains multiple panes and multiple data attributes.
Definition: Window.h:42
const double * x_coordinates() const
Get a constant pointer to the values of the x-coordinates, if the coordinates are staggered...
Definition: Pane.h:183
void set_size(Attribute *a, int nitems, int ng)
Set the size of an attribute.
Definition: Pane.C:630
bool is_structured() const
Is mesh of the pane structured?
Definition: Pane.h:110
Window * window()
Obtain a pointer to its owner window object.
Definition: Pane.h:93
const double * y_coordinates() const
Get a constant pointer to the values of the y-coordinates, if the coordinates are staggered...
Definition: Pane.h:187
Pane(Window *w, int i)
Create a pane in window w with ID i.
Definition: Pane.C:33
Size maxsize_of_ghost_nodes() const
Get the maximum number of real nodes in the pane (excluding ghost nodes).
Definition: Pane.h:130
Size size_of_ghost_nodes() const
Get the number of ghost nodes.
Definition: Pane.h:126
void delete_attribute(int id)
Delete an existing attribute with given id.
Definition: Pane.C:240
void attributes(std::vector< const Attribute * > &as) const
Obtain all the attributes of the pane.
Definition: Pane.h:233
Size size_of_ghost_elements() const
Get the total number of ghost elements.
Definition: Pane.h:150
Size size_k() const
Get the number of nodes in k-dimension if the mesh is structured.
Definition: Pane.h:222
bool is_mixed() const
Does the pane contain more than one type of elements?
Definition: Pane.h:107
void connectivities(std::vector< const Connectivity * > &es) const
Definition: Pane.h:257
double * x_coordinates()
Get the pointer to the values of the x-coordinates, if the coordinates are staggered.
Definition: Pane.h:170
Encapsulates the states of an exception.
void init_done()
Finalize the initialization of a pane.
Definition: Pane.C:85
Attribute * attribute(const std::string &a)
Obtain the attribute from given name.
Definition: Pane.C:148
Size size_of_elements() const
Get the total number of elements in the pane (including ghost elements).
Definition: Pane.h:142
Attribute_friend(Attribute &)
int _id
Pane id.
Definition: Pane.h:314
Window * _window
Point to the parent window.
Definition: Pane.h:313
const Attribute * attribute(int i) const
Obtain the attribute from its ID.
Definition: Pane.h:246
Attribute_friend(Pane *p, int i)
Definition: Pane.h:54
bool ignore_ghost() const
Definition: Pane.h:202
Size size_of_ghost_layers() const
Dimension of the pane.
Definition: Pane.h:212
void set_pointer(void *p, int strd, int cap, bool is_const)
Set pointer of connectivity table.
Definition: Connectivity.C:216
Size maxsize_of_real_nodes() const
Get the maximum number of real nodes in the pane (excluding ghost nodes).
Definition: Pane.h:138
blockLoc i
Definition: read.cpp:79
void reinit_attr(int aid, OP_Init op, void **addr, int strd, int cap)
Definition: Pane.C:265
Size size_j() const
Get the number of nodes in j-dimension if the mesh is structured.
Definition: Pane.h:219
virtual ~Pane()
Default destructor.
Definition: Pane.C:75
void connectivities(std::vector< Connectivity * > &es)
Obtain all the element connectivities of the pane.
Definition: Pane.h:254
std::vector< Attribute * > Attr_set
Vector of attributs.
Definition: Pane.h:45
void set_offset(Size offset)
Set the index of the first element.
Definition: Connectivity.C:92
bool is_unstructured() const
Is mesh of the pane unstructured?
Definition: Pane.h:103
unsigned int Size
Unsighed int.
Definition: Pane.h:47
Contains the prototype of Connectivity.
void elements(std::vector< Connectivity * > &es)
Obtain all the element connectivities of the pane.
Definition: Pane.h:268
Size size_of_real_nodes() const
Get the number of real nodes in the pane (excluding ghost nodes).
Definition: Pane.h:134
void set_ignore_ghost(bool ignore)
Definition: Pane.h:204
Cnct_set _cnct_set
Set of element connectivity.
Definition: Pane.h:316
const double * coordinates() const
Get a constant pointer to the values of the coordinates.
Definition: Pane.h:179
double * y_coordinates()
Get the pointer to the values of the y-coordinates, if the coordinates are staggered.
Definition: Pane.h:173
Size size_of_nodes() const
Get the total number of nodes in the pane (including ghost nodes).
Definition: Pane.h:118
int dimension() const
Dimension of the pane.
Definition: Pane.h:99
std::vector< Connectivity * > Cnct_set
Vector of connectivities.
Definition: Pane.h:46
Connectivity * connectivity(Size i)
Obtain the connectivity table containing the element with the given ID.
Definition: Pane.C:99
double * coordinates()
Get the pointer to the values of the coordinates.
Definition: Pane.h:167
void refresh_connectivity()
Update offsets and sizes of connectivity of an unstructured mesh.
Definition: Pane.C:667
Inherit_Modes
Definition: Pane.h:49
double * z_coordinates()
Get the pointer to the values of the z-coordinates, if the coordinates are staggered.
Definition: Pane.h:176
void inherit(Connectivity *parent, bool clone, bool withghost)
Inherit a connectivity table.
Definition: Connectivity.h:118
const int * pane_connectivity() const
Get a const pointer to the values of the pane connectivity.
Definition: Pane.h:199
Pane & operator=(const Pane &)
void elements(std::vector< const Connectivity * > &es) const
Definition: Pane.h:269
Attribute * new_attribute(const std::string &aname, int aid, const char loc, const int type, int ncomp, const std::string &unit)
Definition: Pane.C:178
Attribute * inherit(Attribute *from, const std::string &aname, int mode, bool withghost)
Inherit an attribute from another pane onto the current pane:
Definition: Pane.C:451
const Connectivity * connectivity(Size i) const
Definition: Pane.h:263
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216
Attr_set _attr_set
Set of attributes.
Definition: Pane.h:315
void attributes(std::vector< Attribute * > &as)
Obtain all the attributes of the pane.
Definition: Pane.C:165
OP_Init
Definition: Pane.h:48
void insert(Attribute *attr)
Insert an attribute onto the pane.
Definition: Pane.C:224
Encapsulates an element-connectivity of a mesh.
Definition: Connectivity.h:41
int id() const
Get the ID of the pane.
Definition: Pane.h:96