Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pane_node_accessors.C
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 #include "Pane_node_accessors.h"
25 #include "roccom_assertion.h"
26 #include <cstdlib>
27 #include <iostream>
28 #include <sstream>
29 
30 COM_BEGIN_NAME_SPACE
31 
33 Pane_node_enumerator( const Pane *pane, int i,
34  const Connectivity *conn)
35  : _pane(pane), _conn( _pane->is_structured()?NULL:
36  (conn==NULL?pane->connectivity(i-1):conn))
37 {
38  if ( _pane->is_unstructured()) {
39  if (i == 0) {
40  _node_num = 1;
42  }
43 
44  }
45  else if ( _pane->dimension()==2) {
46  ni = _pane->size_i();
47  nj = _pane->size_j();
48  nk=1;
50  _buffer = _buffer < 0 ? 0 : _buffer;
51  _node_num = 1;
52  set_first();
53  } else if ( _pane->dimension()==3) {
54  ni = _pane->size_i();
55  nj = _pane->size_i();
56  nk = _pane->size_k();
58  _buffer = _buffer < 0 ? 0 : _buffer;
59  _node_num = 1;
60  set_first();
61  } else {
62  COM_assertion(false); // Not yet supported.
63  }
64 }
68  int indx = _node_num - 1;
69  if (indx < ni*nj*_buffer) //too low
70  return false;
71  else if (((indx%(ni*nj))/ni) < _buffer) //too near top
72  return false;
73  else if ( indx%ni < _buffer ) //too far left
74  return false;
75  else if ( indx%ni > (ni-_buffer) ) //too far right
76  return false;
77  else if ( (indx%(ni*nj))/ni > (nk-_buffer) ) //too near bottom
78  return false;
79  else if ( indx > ni*nj*(nk-_buffer) ) //too high
80  return false;
81  else return true;
82 }
83 
87  int indx = _node_num - 1;
88  if (((indx%(ni*nj))/ni) < _buffer) //too near top
89  return false;
90  else if ( indx%ni < _buffer ) //too far left
91  return false;
92  else if ( indx%ni > (ni-_buffer) ) //too far right
93  return false;
94  else if ( (indx%(ni*nj))/ni > (nk-_buffer) ) //too near bottom
95  return false;
96 
97  else return true;
98 }
99 
104 
105  if (_node_num == _size_of_nodes)
106  return _node_num;
107 
108  if (_pane->is_unstructured()) {
109  return _node_num++;
110  }
111  else if (_pane->dimension()==2) { // Structured mesh
112  _node_num++;
113  while (!position_allowed2D()){
114  _node_num++;
115  }
116  return _node_num;
117  }
118  else if (_pane->dimension()==3) {
119 
120  _node_num++;
121  while (!position_allowed3D()){
122  _node_num++;
123  }
124  return _node_num++;
125  }
126  else {
127 
128  COM_assertion(false); // Not yet supported.
129  return -1;
130  }
131 }
132 
133 
134 COM_END_NAME_SPACE
135 
136 
137 
138 
139 
140 
A Pane object contains a mesh, pane attribute, and field variables.
Definition: Pane.h:43
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
Size size_k() const
Get the number of nodes in k-dimension if the mesh is structured.
Definition: Pane.h:222
int next()
Go to the next element within the connectivity tables of a pane.
Size size_of_ghost_layers() const
Dimension of the pane.
Definition: Pane.h:212
blockLoc i
Definition: read.cpp:79
bool position_allowed2D()
Determine in the current node number is a real node or a ghost node If it is a ghost node...
Size size_j() const
Get the number of nodes in j-dimension if the mesh is structured.
Definition: Pane.h:219
This file contains a set of routines for error assertion.
bool is_unstructured() const
Is mesh of the pane unstructured?
Definition: Pane.h:103
bool position_allowed3D()
Determine in the current node number is a real node or a ghost node If it is a ghost node...
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
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216
Encapsulates an element-connectivity of a mesh.
Definition: Connectivity.h:41
Some definitions of classes for accessing data in a mesh.