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

Constructs the dual connectivity for the whole pane (including ghost nodes and elements), which contains information about incident elements for each node. More...

#include <Dual_connectivity.h>

Collaboration diagram for Pane_dual_connectivity:

Public Member Functions

 Pane_dual_connectivity (const COM::Pane *p, bool with_ghost=true)
 Constructs the dual connectivity for a given pane. More...
 
void incident_elements (int node_id, std::vector< int > &elists)
 Obtain the IDs of the elements incident on a given node. More...
 

Protected Member Functions

void construct_connectivity_str_2 ()
 Construct dual connectivity for 2-D structured meshes. More...
 
void construct_connectivity_unstr ()
 Construct dual connectivity for unstructured meshes. More...
 

Private Attributes

const COM::Pane & _pane
 
bool _with_ghost
 
std::vector< int > _offsets
 
std::vector< int > _eids
 

Detailed Description

Constructs the dual connectivity for the whole pane (including ghost nodes and elements), which contains information about incident elements for each node.

Definition at line 36 of file Dual_connectivity.h.

Constructor & Destructor Documentation

MAP_BEGIN_NAMESPACE Pane_dual_connectivity ( const COM::Pane *  p,
bool  with_ghost = true 
)
explicit

Constructs the dual connectivity for a given pane.

Definition at line 31 of file Dual_connectivity.C.

References construct_connectivity_str_2(), and construct_connectivity_unstr().

33  : _pane(*p), _with_ghost(with_ghost) {
34 
35  if ( p->dimension()==2 && p->is_structured())
37  else {
38  assert( !p->is_structured());
40  }
41 }
const COM::Pane & _pane
void construct_connectivity_unstr()
Construct dual connectivity for unstructured meshes.
void construct_connectivity_str_2()
Construct dual connectivity for 2-D structured meshes.

Here is the call graph for this function:

Member Function Documentation

void construct_connectivity_str_2 ( )
protected

Construct dual connectivity for 2-D structured meshes.

Definition at line 50 of file Dual_connectivity.C.

References _eids, _offsets, _pane, _with_ghost, COM_assertion_msg, i, k, n, Element_node_enumerator_str_2::next(), ni, and nj.

Referenced by Pane_dual_connectivity().

50  {
51  COM_assertion_msg( _with_ghost || _pane.size_of_ghost_layers()==0,
52  "Not yet implemented for structured mesh with ghosts");
53 
54  int n=_with_ghost ? _pane.size_of_nodes() : _pane.size_of_real_nodes();
55  { // First, count the number of incident elements of each .
56  std::vector<char> nielems(n);
57  std::fill_n( nielems.begin(), n, 4);
58 
59  int ni=_pane.size_i(), nj=_pane.size_j();
60 
61  std::fill_n( nielems.begin(), ni, 2);
62  std::fill_n( nielems.begin()+ni*(nj-1), ni, 2);
63 
64  for ( int i=ni; i<ni*(nj-1); i+=ni)
65  nielems[i] = nielems[i+ni-1] = 2;
66 
67  nielems[0] = nielems[ni-1] = 1;
68  nielems[ni*nj-ni] = nielems[ni*nj-1] = 1;
69 
70  // Now construct a vector for storing the offsets
71  _offsets.clear(); _offsets.resize(n+1, 0);
72 
73  for ( int i=1; i<=n; ++i) _offsets[i] = _offsets[i-1]+nielems[i-1];
74  _eids.resize( _offsets[n]);
75  }
76 
77  { // Fill in the connectivity table
78  const int nn = 4;
80  for ( int i=1,size=_pane.size_of_elements(); i<=size; ++i, ene.next())
81  for ( int k=0; k<nn; ++k)
82  _eids[ _offsets[ene[k]-1]++] = i;
83 
84  // Recover _offsets
85  for ( int i=n; i>0; --i) _offsets[i] = _offsets[i-1];
86  _offsets[0] = 0;
87  }
88 }
j indices k indices k
Definition: Indexing.h:6
#define COM_assertion_msg(EX, msg)
std::vector< int > _eids
const COM::Pane & _pane
blockLoc i
Definition: read.cpp:79
std::vector< int > _offsets
const NT & n
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void int * nj
Definition: read.cpp:74
Optimized version for 2-D structured meshes.

Here is the call graph for this function:

Here is the caller graph for this function:

void construct_connectivity_unstr ( )
protected

Construct dual connectivity for unstructured meshes.

Definition at line 90 of file Dual_connectivity.C.

References _eids, _offsets, _pane, _with_ghost, i, k, Element_node_enumerator_uns::next(), and Element_node_enumerator_uns::size_of_nodes().

Referenced by Pane_dual_connectivity().

90  {
91 
92  int nnodes, nelems;
93 
94  if ( _with_ghost) {
95  nnodes=_pane.size_of_nodes();
96  nelems=_pane.size_of_elements();
97  }
98  else {
99  nnodes=_pane.size_of_real_nodes();
100  nelems=_pane.size_of_real_elements();
101  }
102 
103  { // First, count the number of incident elements of each node.
104  std::vector<char> nielems(nnodes);
105  std::fill_n( nielems.begin(), nnodes, 0);
106 
108  for ( int i=1; i<=nelems; ++i, ene.next())
109  for ( int k=0, nn=ene.size_of_nodes(); k<nn; ++k)
110  ++nielems[ ene[k]-1];
111 
112  // Now construct a vector for storing the offsets
113  _offsets.clear(); _offsets.resize(nnodes+1);
114  _offsets[0] = 0;
115  for ( int i=1; i<=nnodes; ++i) _offsets[i] = _offsets[i-1]+nielems[i-1];
116 
117  _eids.resize( _offsets[nnodes]);
118  }
119 
120  { // Fill in the connectivity table
122  for ( int i=1; i<=nelems; ++i, ene.next())
123  for ( int k=0, nn=ene.size_of_nodes(); k<nn; ++k)
124  _eids[ _offsets[ene[k]-1]++] = i;
125 
126  // Recover _offsets
127  for ( int i=nnodes; i>0; --i) _offsets[i] = _offsets[i-1];
128  _offsets[0] = 0;
129  }
130 }
j indices k indices k
Definition: Indexing.h:6
std::vector< int > _eids
const COM::Pane & _pane
blockLoc i
Definition: read.cpp:79
std::vector< int > _offsets
Optimized version for unstructured meshes.

Here is the call graph for this function:

Here is the caller graph for this function:

void incident_elements ( int  node_id,
std::vector< int > &  elists 
)

Obtain the IDs of the elements incident on a given node.

Definition at line 43 of file Dual_connectivity.C.

References _eids, _offsets, and COM_assertion.

Referenced by Simple_manifold_2::determine_opposite_halfedges().

44  {
45  COM_assertion( node_id > 0); // Node id start from 1.
46  elists.clear();
47  elists.insert( elists.begin(), &_eids[_offsets[node_id-1]], &_eids[_offsets[node_id]]);
48 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
std::vector< int > _eids
std::vector< int > _offsets

Here is the caller graph for this function:

Member Data Documentation

std::vector< int> _eids
private
std::vector< int> _offsets
private
const COM::Pane& _pane
private
bool _with_ghost
private

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