Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Element_node_enumerator Class Reference

An adaptor for enumerating node IDs of an element. More...

#include <Element_accessors.h>

Inheritance diagram for Element_node_enumerator:
Collaboration diagram for Element_node_enumerator:

Public Member Functions

 Element_node_enumerator ()
 
 Element_node_enumerator (const Pane *pane, int i, const Connectivity *conn=NULL)
 Constructor for an element in a structured or an unstructured mesh. More...
 
 Element_node_enumerator (const Pane *pane, const std::pair< int, int > &id)
 A constructor for an element in a structured mesh. More...
 
void next ()
 Go to the next element within the connectivity tables of a pane. More...
 
int type () const
 Obtain the type of the element. More...
 
int is_quadratic () const
 Check whether the element is quadratic. More...
 
int size_of_nodes () const
 Number of nodes per element. More...
 
int size_of_corners () const
 Number of corners per element. More...
 
void get_nodes (std::vector< int > &nodes)
 Get a vector of all of the nodes in the element. More...
 
int size_of_edges () const
 Number of edges per element. More...
 
int size_of_faces () const
 Number of faces per element. More...
 
int dimension () const
 Get the dimension of the base pane. More...
 
int id () const
 Get the local id of the element within the pane. More...
 
int vertex (int lvid, bool level=false) const
 Get the vertex index of an vertex within the element. More...
 
int operator[] (int i) const
 Obtain the pane-scope node ID from its element-scope index. More...
 
const Panepane () const
 

Protected Attributes

const Pane_pane
 
const Connectivity_conn
 
union {
   const int *   _start
 
   int   _base
 
}; 
 
int _res
 

Detailed Description

An adaptor for enumerating node IDs of an element.

Definition at line 43 of file Element_accessors.h.

Constructor & Destructor Documentation

Definition at line 45 of file Element_accessors.h.

45 : _pane(NULL), _conn(NULL), _start(NULL), _res(0){}
const Connectivity * _conn
COM_BEGIN_NAME_SPACE Element_node_enumerator ( const Pane pane,
int  i,
const Connectivity conn = NULL 
)

Constructor for an element in a structured or an unstructured mesh.

If conn==NULL, then i is an element index local to the pane. If conn!=NULL, then i is an element index local to the connectivity.

Definition at line 32 of file Element_accessors.C.

References _base, _conn, _pane, _res, _start, COM_assertion, Pane::dimension(), i, Connectivity::index_offset(), Pane::is_unstructured(), max(), Connectivity::pointer(), Pane::size_i(), Pane::size_of_elements(), Connectivity::size_of_elements(), and Connectivity::size_of_nodes_pe().

34  : _pane(pane), _conn( _pane->is_structured()?NULL:
35  (conn==NULL?pane->connectivity(i):conn))
36 {
37  if ( _pane->is_unstructured()) {
38  if ( conn == NULL && _conn != NULL) i -= _conn->index_offset()+1;
39  else --i;
40 
41  if ( _conn) {
42  COM_assertion( i>=0 && i<std::max(int(_conn->size_of_elements()),1));
45  }
46  else {
47  _pane = NULL;
48  _conn = NULL;
49  _start = NULL;
50  _res = -1;
51  }
52  }
53  else if ( _pane->dimension()==2) {
54  COM_assertion( i>=1 && i<=int(_pane->size_of_elements()));
55  _res = (i-1) % (_pane->size_i()-1);
56  _base = i + (i-1) / (_pane->size_i()-1);
57  }
58  else {
59  COM_assertion(false); // Not yet supported.
60  }
61 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
const int * pointer() const
Get a constant pointer to the connectivity array.
Definition: Connectivity.h:206
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
const Connectivity * _conn
bool is_structured() const
Is mesh of the pane structured?
Definition: Pane.h:110
Size size_of_elements() const
Get the total number of elements in the pane (including ghost elements).
Definition: Pane.h:142
Size index_offset() const
Get the index of the first element.
Definition: Connectivity.h:189
blockLoc i
Definition: read.cpp:79
bool is_unstructured() const
Is mesh of the pane unstructured?
Definition: Pane.h:103
int dimension() const
Dimension of the pane.
Definition: Pane.h:99
Size size_of_nodes_pe() const
Get the number of nodes per element of the current connectivity table.
Definition: Connectivity.h:147
Connectivity * connectivity(Size i)
Obtain the connectivity table containing the element with the given ID.
Definition: Pane.C:99
Size size_of_elements() const
Get the total number of elements (including ghost elements) in the table.
Definition: Connectivity.C:96
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

Element_node_enumerator ( const Pane pane,
const std::pair< int, int > &  id 
)

A constructor for an element in a structured mesh.

Parameters
panea pointer to the owner pane.
rthe row id of the element (starting from 1).
cthe column id of the element (starting from 1).

Definition at line 68 of file Element_accessors.C.

References _base, _pane, _res, COM_assertion, Pane::is_structured(), Pane::size_i(), and Pane::size_j().

70  : _pane(pane), _conn(NULL) {
71  COM_assertion( _pane != NULL && _pane->is_structured());
72  COM_assertion( id.first>0 && id.first<=int(_pane->size_i()));
73  COM_assertion( id.second>0 && id.second<=int(_pane->size_j()));
74 
75  _res = id.first-1;
76  _base = (id.second-1)*_pane->size_i()+id.first;
77 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
const Connectivity * _conn
bool is_structured() const
Is mesh of the pane structured?
Definition: Pane.h:110
Size size_j() const
Get the number of nodes in j-dimension if the mesh is structured.
Definition: Pane.h:219
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

Member Function Documentation

int dimension ( ) const
inline

Get the dimension of the base pane.

Definition at line 105 of file Element_accessors.h.

References _pane, and Pane::dimension().

Referenced by Facet_node_enumerator::Facet_node_enumerator().

105 { return _pane->dimension(); }
int dimension() const
Dimension of the pane.
Definition: Pane.h:99

Here is the call graph for this function:

Here is the caller graph for this function:

void get_nodes ( std::vector< int > &  nodes)

Get a vector of all of the nodes in the element.

Definition at line 146 of file Element_accessors.C.

References i, num_nodes, and size_of_nodes().

146  {
147  int num_nodes = size_of_nodes();
148  nodes.resize( num_nodes);
149 
150  for (int i=0; i<num_nodes; i++) nodes[i] = (*this)[i];
151 }
const int num_nodes
Definition: ex1.C:96
blockLoc i
Definition: read.cpp:79
int size_of_nodes() const
Number of nodes per element.

Here is the call graph for this function:

int id ( ) const
inline

Get the local id of the element within the pane.

Definition at line 108 of file Element_accessors.h.

References _base, _conn, _pane, _start, Connectivity::index_offset(), Pane::is_structured(), Connectivity::pointer(), Pane::size_i(), and Connectivity::size_of_nodes_pe().

Referenced by RFC_Pane_base::comp_nat_coors(), Transfer_base::compute_load_vector_wra(), Simple_manifold_2::determine_incident_halfedges(), Simple_manifold_2::determine_opposite_halfedges(), RFC_Pane_base::get_host_element_of_subface(), RFC_Pane_base::get_host_element_of_subnode(), RFC_Pane_base::get_nat_coor_in_element(), Transfer_base::init_load_vector(), Transfer_base::integrate_subface(), Transfer_base::make_field(), FaceOffset_3::obtain_face_offset(), Element_vectors_k_const< Value >::set(), and Transfer_base::transfer_2f().

108  {
109  if ( _pane->is_structured()) {
110  return _base - (_base-1) / _pane->size_i();
111  }
112  else {
113  return _conn->index_offset() + 1 +
115  }
116  }
const int * pointer() const
Get a constant pointer to the connectivity array.
Definition: Connectivity.h:206
const Connectivity * _conn
bool is_structured() const
Is mesh of the pane structured?
Definition: Pane.h:110
Size index_offset() const
Get the index of the first element.
Definition: Connectivity.h:189
Size size_of_nodes_pe() const
Get the number of nodes per element of the current connectivity table.
Definition: Connectivity.h:147
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

Here is the caller graph for this function:

int is_quadratic ( ) const
inline

Check whether the element is quadratic.

Definition at line 68 of file Element_accessors.h.

References _conn, and Connectivity::is_quadratic().

Referenced by Facet_node_enumerator::size_of_nodes().

68  {
69  if ( _conn) return _conn->is_quadratic();
70  else return false;
71  }
const Connectivity * _conn
bool is_quadratic() const
Determine whether the element type is quadratic.
Definition: Connectivity.h:132

Here is the call graph for this function:

Here is the caller graph for this function:

void next ( )

Go to the next element within the connectivity tables of a pane.

Definition at line 79 of file Element_accessors.C.

References _base, _conn, _pane, _res, _start, COM_assertion, Pane::connectivity(), Pane::dimension(), Connectivity::index_offset(), Connectivity::pointer(), Pane::size_i(), Connectivity::size_of_elements(), and Connectivity::size_of_nodes_pe().

Referenced by Propagation_3::bound_facial_speed(), rflu_modrepair3d::cavedg(), RFC_Pane_base::comp_nat_coors(), FaceOffset_3::compute_anisotropic_vertex_centers(), Rocsurf::compute_bounded_volumes(), Rocsurf::compute_element_areas(), Rocsurf::compute_element_normals(), Window_manifold_2::compute_mcn(), FaceOffset_3::compute_quadrics(), Window_manifold_2::compute_shortest_edgelen_elements(), Window_manifold_2::compute_shortest_edgelen_nodes(), Rocsurf::compute_signed_volumes(), Rocsurf::compute_swept_volumes(), Propagation_3::convert_constraints(), Pane_boundary::determine_border_nodes_3(), Propagation_3::determine_constraint_boundary(), Simple_manifold_2::determine_incident_halfedges(), Simple_manifold_2::determine_opposite_halfedges(), FaceOffset_3::distribute_volume_e2n(), Window_manifold_2::elements_to_nodes(), Rocmop::evaluate_face_normals(), FaceOffset_3::filter_and_identify_ridge_edges(), Rocmop::get_redist_safe_factor(), Rocmop::identify_ridge_edges(), FaceOffset_3::insert_boundary_edges(), Rocsurf::integrate(), data_declarations::length(), FaceOffset_3::nulaplacian_smooth(), rflu_modrepair3d::octfil(), rflu_modrepair3d::octfnd(), rflu_modoctree::octree(), rflu_modrepair3d::octrmv(), Rocmop::redistribute_vertices_smooth(), and FaceOffset_3::rescale_displacements().

79  {
80  if ( _conn) {
81  if ( --_res==0) {
84  if ( _conn) {
85  _start = _conn->pointer();
87  }
88  else {
89  _pane = NULL;
90  _conn = NULL;
91  _start = NULL;
92  _res = -1;
93  }
94  }
95  else
97  }
98  else if (_pane->dimension()==2) { // Structured mesh
99  ++_base;
100  if ( ++_res == int(_pane->size_i()-1)) { ++_base; _res=0; }
101  }
102  else {
103  COM_assertion(false); // Not yet supported.
104  }
105 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
const int * pointer() const
Get a constant pointer to the connectivity array.
Definition: Connectivity.h:206
const Connectivity * _conn
Size index_offset() const
Get the index of the first element.
Definition: Connectivity.h:189
int dimension() const
Dimension of the pane.
Definition: Pane.h:99
Size size_of_nodes_pe() const
Get the number of nodes per element of the current connectivity table.
Definition: Connectivity.h:147
Connectivity * connectivity(Size i)
Obtain the connectivity table containing the element with the given ID.
Definition: Pane.C:99
Size size_of_elements() const
Get the total number of elements (including ghost elements) in the table.
Definition: Connectivity.C:96
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

Here is the caller graph for this function:

int operator[] ( int  i) const
inline

Obtain the pane-scope node ID from its element-scope index.

Parameters
ithe element-scope index of a node (starting from 0).

Definition at line 124 of file Element_accessors.h.

References _base, _conn, _pane, _start, i, and Pane::size_i().

124  {
125  if ( _conn) // Unstructured mesh
126  return _start[i];
127  else { // Structured mesh; Only support 2-D mesh now.
128  int t=_base;
129  if ( i>1) t+=_pane->size_i();
130  return ( i==1 || i==2)? t+1 : t;
131  }
132  }
const Connectivity * _conn
blockLoc i
Definition: read.cpp:79
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

const Pane* pane ( ) const
inline

Definition at line 135 of file Element_accessors.h.

References _pane.

Referenced by RFC_Pane_base::comp_nat_coors(), RFC_Pane_base::get_host_element_of_subface(), RFC_Pane_base::get_host_element_of_subnode(), and Transfer_base::integrate_subface().

135 { return _pane; }

Here is the caller graph for this function:

int size_of_corners ( ) const
inline

Number of corners per element.

Definition at line 81 of file Element_accessors.h.

References _conn, _pane, Pane::dimension(), and Connectivity::size_of_corners_pe().

81  {
82  if ( _conn) return _conn->size_of_corners_pe();
83  if ( _pane->dimension()==2) return 4;
84  return 8;
85  }
const Connectivity * _conn
Size size_of_corners_pe() const
Get the number of corners per element of the current connectivity table.
Definition: Connectivity.h:139
int dimension() const
Dimension of the pane.
Definition: Pane.h:99

Here is the call graph for this function:

int size_of_edges ( ) const
inline

Number of edges per element.

Definition at line 91 of file Element_accessors.h.

References _conn, _pane, Pane::dimension(), and Connectivity::size_of_edges_pe().

Referenced by Propagation_3::bound_facial_speed(), FaceOffset_3::build_ridge_neighbor_list(), FaceOffset_3::compute_anisotropic_vertex_centers(), Rocsurf::compute_bounded_volumes(), Rocsurf::compute_element_areas(), Rocsurf::compute_element_normals(), Transfer_base::compute_load_vector_wra(), Window_manifold_2::compute_mcn(), FaceOffset_3::compute_quadrics(), Window_manifold_2::compute_shortest_edgelen_elements(), Window_manifold_2::compute_shortest_edgelen_nodes(), Rocsurf::compute_signed_volumes(), Rocsurf::compute_swept_volumes(), Propagation_3::convert_constraints(), Propagation_3::determine_constraint_boundary(), Simple_manifold_2::determine_incident_halfedges(), Simple_manifold_2::determine_opposite_halfedges(), FaceOffset_3::distribute_volume_e2n(), Window_manifold_2::elements_to_nodes(), Rocmop::evaluate_face_normals(), FaceOffset_3::filter_and_identify_ridge_edges(), RFC_Pane_base::get_nat_coor_in_element(), Facet_node_enumerator::get_nodes(), get_normal(), RFC_Pane_base::get_point_of_subnode(), Rocmop::get_redist_safe_factor(), FaceOffset_3::insert_boundary_edges(), Rocsurf::integrate(), Transfer_base::integrate_subface(), Transfer_base::interpolate_fe(), FaceOffset_3::nulaplacian_smooth(), FaceOffset_3::obtain_face_offset(), Facet_node_enumerator::operator[](), Rocmop::redistribute_vertices_ridge(), Rocmop::redistribute_vertices_smooth(), FaceOffset_3::rescale_displacements(), and FaceOffset_3::update_vertex_centers().

91  {
92  if ( _conn) return _conn->size_of_edges_pe();
93  if ( _pane->dimension()==2) return 4;
94  return 12;
95  }
const Connectivity * _conn
Size size_of_edges_pe() const
Get the number of edges per element of the current connectivity table.
Definition: Connectivity.h:155
int dimension() const
Dimension of the pane.
Definition: Pane.h:99

Here is the call graph for this function:

Here is the caller graph for this function:

int size_of_faces ( ) const
inline

Number of faces per element.

Definition at line 98 of file Element_accessors.h.

References _conn, _pane, Pane::dimension(), and Connectivity::size_of_faces_pe().

Referenced by Pane_boundary::determine_border_nodes_3().

98  {
99  if ( _conn) return _conn->size_of_faces_pe();
100  if ( _pane->dimension()==2) return 1;
101  return 6;
102  }
const Connectivity * _conn
int dimension() const
Dimension of the pane.
Definition: Pane.h:99
Size size_of_faces_pe() const
Get the number of faces per element of the current connectivity table.
Definition: Connectivity.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

int size_of_nodes ( ) const
inline
int type ( ) const
inline

Obtain the type of the element.

Definition at line 61 of file Element_accessors.h.

References _conn, _pane, Pane::dimension(), Connectivity::element_type(), Connectivity::ST2, and Connectivity::ST3.

61  {
62  if ( _conn) return _conn->element_type();
63  else if ( _pane->dimension()==2) return Connectivity::ST2;
64  else return Connectivity::ST3;
65  }
const Connectivity * _conn
int dimension() const
Dimension of the pane.
Definition: Pane.h:99
int element_type() const
Obtain element type ID.
Definition: Connectivity.h:122

Here is the call graph for this function:

int vertex ( int  lvid,
bool  level = false 
) const

Get the vertex index of an vertex within the element.

Definition at line 108 of file Element_accessors.C.

References _base, _conn, _pane, _start, NTS::abs(), COM_assertion, i, Pane::is_structured(), Pane::size_i(), Pane::size_j(), and Connectivity::size_of_nodes_pe().

Referenced by RFC_Pane_base::get_lvid().

108  {
109  if ( _pane->is_structured()) { // Structured mesh
110  if ( lvid == _base) return 0;
111  if ( lvid == _base+1) return 1;
112  const int nr = _pane->size_i();
113  if ( lvid == int(_base+nr)) return 3;
114  if ( lvid == int(_base+nr+1)) return 2;
115 
116  // There is a branch cut in the pane. Resort to more expensive step.
117  // Check which boundary lvid is on.
118  if ( !level) {
119  COM_assertion( nr>2 && _pane->size_j()>2);
120  const int c1 = (_base-1)/nr, r1 = (_base-1)%nr;
121  const int c2 = (lvid-1)/nr, r2 = (lvid-1)%nr;
122 
123  if ( std::abs( r1-r2)<=1) {
124  const int nc = _pane->size_j();
125  if ( c2 == 0) return vertex( (nc-1)*nr+r2+1, true);
126  if ( c2 == nc-1) return vertex( r2+1, true);
127  }
128  else {
129  COM_assertion( std::abs( c1-c2)<=1);
130  if ( r2 == 0) return vertex( (c2+1)*nr, true);
131  if ( r2 == nr-1) return vertex( c2*nr+1, true);
132  }
133  }
134  COM_assertion( false); return -1;
135  }
136  else { // Unstructured
137  const int *p=_start;
138  for ( int i=0, size=_conn->size_of_nodes_pe(); i<size; ++i,++p) {
139  if ( lvid == *p) return i;
140  }
141 
142  return -1; // The node is not in the table
143  }
144 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
int vertex(int lvid, bool level=false) const
Get the vertex index of an vertex within the element.
const Connectivity * _conn
bool is_structured() const
Is mesh of the pane structured?
Definition: Pane.h:110
blockLoc i
Definition: read.cpp:79
Size size_j() const
Get the number of nodes in j-dimension if the mesh is structured.
Definition: Pane.h:219
Size size_of_nodes_pe() const
Get the number of nodes per element of the current connectivity table.
Definition: Connectivity.h:147
NT abs(const NT &x)
Definition: number_utils.h:130
Size size_i() const
Get the number of nodes in i-dimension if the mesh is structured.
Definition: Pane.h:216

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

union { ... }

The documentation for this class was generated from the following files: