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

#include <Pane_boundary.h>

Collaboration diagram for Pane_boundary:

Public Types

typedef int Node_ID
 
typedef int Element_ID
 
typedef std::pair< Node_ID,
Node_ID
Node_pair
 

Public Member Functions

 Pane_boundary (const COM::Pane *p)
 Constructors. More...
 
 Pane_boundary (const Simple_manifold_2 *pm)
 Constructors. More...
 
void determine_border_nodes (std::vector< bool > &is_border, std::vector< bool > &is_isolated, std::vector< Facet_ID > *b=NULL, int ghost_level=0) throw (int)
 Determine the border nodes (excluding isolated nodes) More...
 
double min_squared_edge_len (const std::vector< Facet_ID > &) throw (int)
 Compute the minimum squared edge length of given edges. More...
 

Static Public Member Functions

static void determine_borders (const COM::Attribute *mesh, COM::Attribute *isborder, int ghost_level=0)
 Determine the nodes at pane boundaries of a given mesh. More...
 

Protected Member Functions

void determine_border_nodes_3 (std::vector< bool > &is_border, std::vector< Facet_ID > *b, int ghost_level) throw (int)
 Determine the border nodes for a 3-D mesh. More...
 
void determine_isolated_nodes (std::vector< bool > &is_isolated, int ghost_level) throw (int)
 Determine the isolated nodes (i.e. not belonging to any element) More...
 

Private Attributes

const COM::Pane & _pane
 
const Simple_manifold_2 *const _pm
 

Detailed Description

Definition at line 42 of file Pane_boundary.h.

Member Typedef Documentation

typedef int Element_ID

Definition at line 45 of file Pane_boundary.h.

typedef int Node_ID

Definition at line 44 of file Pane_boundary.h.

typedef std::pair<Node_ID, Node_ID> Node_pair

Definition at line 46 of file Pane_boundary.h.

Constructor & Destructor Documentation

Pane_boundary ( const COM::Pane *  p)
inline

Constructors.

Definition at line 49 of file Pane_boundary.h.

49 : _pane(*p),_pm(NULL) {}
const COM::Pane & _pane
Definition: Pane_boundary.h:87
const Simple_manifold_2 *const _pm
Definition: Pane_boundary.h:88
Pane_boundary ( const Simple_manifold_2 pm)
inline

Constructors.

Definition at line 52 of file Pane_boundary.h.

53  : _pane(*pm->pane()),_pm(pm) {}
const COM::Pane & _pane
Definition: Pane_boundary.h:87
const COM::Pane * pane() const
Obtain a const pointer to the pane.
const Simple_manifold_2 *const _pm
Definition: Pane_boundary.h:88

Member Function Documentation

MAP_BEGIN_NAMESPACE void determine_border_nodes ( std::vector< bool > &  is_border,
std::vector< bool > &  is_isolated,
std::vector< Facet_ID > *  b = NULL,
int  ghost_level = 0 
)
throw (int
)

Determine the border nodes (excluding isolated nodes)

Definition at line 37 of file Pane_boundary.C.

Referenced by determine_borders(), and Pane_connectivity::get_local_boundary_nodes().

40  {
41  if ( _pane.dimension() == 2) {
42  int ng;
43  int *ng_ptr = ghost_level ? &ng : (int*)NULL;
44 
45  if ( _pm) {
46  _pm->get_borders( is_border, is_isolated, b, ng_ptr);
47  }
48  else
49  Simple_manifold_2( &_pane, NULL, ghost_level).
50  get_borders( is_border, is_isolated, b, ng_ptr);
51  }
52  else {
53 
54  determine_border_nodes_3( is_border, b, ghost_level);
55  determine_isolated_nodes( is_isolated, ghost_level);
56  }
57 }
const COM::Pane & _pane
Definition: Pane_boundary.h:87
void get_borders(std::vector< bool > &is_border, std::vector< bool > &is_isolated, std::vector< Edge_ID > *b, int *ng=NULL) const
Obtain all the border nodes, isolated nodes, and border edges.
void determine_isolated_nodes(std::vector< bool > &is_isolated, int ghost_level)
Determine the isolated nodes (i.e. not belonging to any element)
Provides a data structure accessing nodes, elements, and edges in a pane, in a manner similar to the ...
void determine_border_nodes_3(std::vector< bool > &is_border, std::vector< Facet_ID > *b, int ghost_level)
Determine the border nodes for a 3-D mesh.
const Simple_manifold_2 *const _pm
Definition: Pane_boundary.h:88

Here is the caller graph for this function:

void determine_border_nodes_3 ( std::vector< bool > &  is_border,
std::vector< Facet_ID > *  b,
int  ghost_level 
)
throw (int
)
protected

Determine the border nodes for a 3-D mesh.

A ghost level of 0 returns all real border nodes A ghost level of 1,2,3 returns the border nodes for the 1st, 2nd, 3rd... ghost layer (structured meshes) A ghost level > 0 returns the border ghost nodes (unstructured meshes)

Definition at line 106 of file Pane_boundary.C.

References check_face_unique(), COM_assertion_msg, Facet_ID::eid(), Facet_node_enumerator::get_nodes(), i, j, k, Facet_ID::lid(), n, Element_node_enumerator::next(), ni, nj, nk, num_elmts, num_nodes, s, Facet_node_enumerator::size_of_edges(), and Element_node_enumerator::size_of_faces().

108  {
109  int num_nodes, num_elmts;
110 
111  if (ghost_level == 0){
112  num_nodes=_pane.size_of_real_nodes();
113  num_elmts=_pane.size_of_real_elements();
114  }
115  else {
116  COM_assertion_msg(ghost_level > 0, "Ghost level must be positive");
117  num_nodes=_pane.size_of_nodes();
118  num_elmts=_pane.size_of_elements();
119  }
120 
121  // Initialize is_border to false for all nodes.
122  is_border.clear(); is_border.resize( num_nodes, false);
123 
124  // Handle structured meshes
125  if ( _pane.is_structured()) {
126 
127  const int ni=_pane.size_i(), nj=_pane.size_j(), nk=_pane.size_k();
128 
129  // s = the first index on the level above the bottom
130  // t = the first index on the top level
131  // h = an offset for the first index on a layer with ghosts
132  // w = the length of the i dimension with ghosts
133  // buffer = number of layers we 'skip' for determining borders
134 
135  int buffer = _pane.size_of_ghost_layers() - ghost_level;
136  buffer = buffer < 0 ? 0 : buffer;
137  int s = ni*nj;
138  int t = ni*nj*(nk-1);
139  int h = buffer*ni + buffer;
140  int w = ni - 2*buffer;
141 
142  //bottom
143  for ( int j=s*(buffer) + h, j_end = s*(1+buffer) - ni*buffer; j< j_end; j += ni){
144  std::fill_n( is_border.begin() +j, w, true);
145  }
146  //top
147  for ( int j= t+h-s*buffer, end = s*nk - s*buffer- ni*buffer; j< end; j += ni){
148  std::fill_n( is_border.begin() +j, w, true);
149  }
150 
151  //left and right
152  for ( int j= s*(1+buffer)+h, stop = t-s*buffer+h; j< stop; j += ni*nj){
153  std::fill_n( is_border.begin() +j, w, true);
154  std::fill_n( is_border.begin() +j + ni*((nj-1) - 2*buffer), w, true);
155  }
156 
157  //upper and lower
158  for ( int j= s*(1+buffer)+h; j< t-s*buffer+h; j += ni*nj){
159  for (int k=ni, k_end = ni*(nj-(1+2*buffer)); k< k_end; k += ni){
160  is_border[j+k] = true;
161  is_border[j+k + (ni - (2*buffer+ 1)) ] = true;
162  }
163  }
164 
165  return;
166  }
167 
168  // Now consider unstructured panes
169  std::vector< Corners2Face_Map> c2f_vec(num_nodes);
170  int num_external_face=0;
171 
172 
173  // Determine all border faces
174  Element_node_enumerator ene( &_pane, 1);
175  int counter = 0;
176  int count2 = 0;
177 
178  for (int i=1; i<=num_elmts; ++i, ene.next()) {
179  //for (int i=1; i<=6; ++i, ene.next()) {
180  for (int j=0, nf=ene.size_of_faces(); j<nf; ++j ){
181  Facet_node_enumerator fne( &ene, j) ;
182 
183  Four_tuple ns( fne[0], fne[1], fne[2], fne.size_of_edges()>3?fne[3]:-1);
184  count2++;
185  check_face_unique( ns, Facet_ID(i, j), c2f_vec, num_external_face, counter);
186  }
187  }
188 
189  // Mark all nodes of the border faces as border nodes, and
190  // insert their edges into b.
191  if ( b)
192  { b->clear(); b->reserve( num_external_face); }
193 
194  std::vector<int> nodes; nodes.reserve(9);
195 
196  for (int i=0; i<num_nodes; ++i){
197  Corners2Face_Map::const_iterator vit = c2f_vec[i].begin();
198  Corners2Face_Map::const_iterator v_end = c2f_vec[i].end();
199 
200  for ( ; vit != v_end; ++vit) {
201  // Get all nodes of the face into vector nodes.
202  const Facet_ID &fid = vit->second;
203  Element_node_enumerator_uns ene( &_pane, fid.eid());
204  Facet_node_enumerator fne( &ene, fid.lid());
205  fne.get_nodes( nodes, true);
206 
207  for ( int i=0, n=nodes.size(); i<n; ++i)
208  is_border[ nodes[i] - 1 ] = true;
209 
210  if (b) b->push_back( fid);
211  }
212  }
213 
214 }
const COM::Pane & _pane
Definition: Pane_boundary.h:87
A structure used to represent element faces.
Definition: Pane_boundary.C:60
An adaptor for enumerating node IDs of an element.
j indices k indices k
Definition: Indexing.h:6
#define COM_assertion_msg(EX, msg)
double s
Definition: blastest.C:80
void get_nodes(std::vector< int > &nodes, bool quad_ret)
char lid() const
Local edge ID of the halfedge within its element.
Adaptor for enumerating node IDs of a facet of an element.
int eid() const
Element ID of the halfedge.
static void check_face_unique(const Four_tuple &face_corners, const Facet_ID &fid, std::vector< Corners2Face_Map > &c2f_vec, int &num_external_face, int &counter)
Definition: Pane_boundary.C:79
const int num_nodes
Definition: ex1.C:96
blockLoc i
Definition: read.cpp:79
const NT & n
void int int * nk
Definition: read.cpp:74
const int num_elmts
Definition: ex1.C:97
j indices j
Definition: Indexing.h:6
The ID of a facet (edge in 2D and face in 3D) encodes an element ID and the local facet&#39;s ID internal...
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void int * nj
Definition: read.cpp:74
Optimized version for unstructured meshes.

Here is the call graph for this function:

void determine_borders ( const COM::Attribute *  mesh,
COM::Attribute *  isborder,
int  ghost_level = 0 
)
static

Determine the nodes at pane boundaries of a given mesh.

The argument isborder must be a nodal attribute of integer type. At return, isborder is set to 1 for border nodes, and 0 for others

Definition at line 286 of file Pane_boundary.C.

References COM_assertion_msg, COM_compatible_types(), COM_INT, determine_border_nodes(), i, j, n, and nj.

Referenced by Rocmap::pane_border_nodes().

288  {
289  COM_assertion_msg( mesh, "Unexpected NULL pointer");
290  COM_assertion_msg( isborder, "Unexpected NULL pointer");
291  COM_assertion_msg( COM_compatible_types( isborder->data_type(), COM_INT),
292  "Border-list must have integer type");
293  COM_assertion_msg( isborder->is_nodal() == 1,
294  "Border-list must have integer type");
295 
296  std::vector<COM::Pane*> panes;
297  isborder->window()->panes( panes);
298 
299  for ( int i=0, n=panes.size(); i<n; ++i) {
300  Pane_boundary pb( panes[i]);
301  COM::Attribute *bdl_pane = panes[i]->attribute(isborder->id());
302 
303  std::vector<bool> is_border_bitmap, is_isolated;
304  pb.determine_border_nodes( is_border_bitmap, is_isolated,
305  NULL, ghost_level);
306 
307  int *ptr = (int *)bdl_pane->pointer();
308  int nj=0;
309  if (ghost_level == 0)
310  nj=panes[i]->size_of_real_nodes();
311  else {
312  COM_assertion_msg(ghost_level > 0, "Ghost level must be positive");
313  nj=panes[i]->size_of_nodes();
314  }
315  for ( int j=0; j<nj; ++j) {
316  ptr[j] = is_border_bitmap[j];
317  }
318  }
319 }
#define COM_assertion_msg(EX, msg)
int COM_compatible_types(COM_Type type1, COM_Type type2)
Definition: roccom_c++.h:563
blockLoc i
Definition: read.cpp:79
const NT & n
j indices j
Definition: Indexing.h:6
void int * nj
Definition: read.cpp:74

Here is the call graph for this function:

Here is the caller graph for this function:

void determine_isolated_nodes ( std::vector< bool > &  is_isolated,
int  ghost_level 
)
throw (int
)
protected

Determine the isolated nodes (i.e. not belonging to any element)

Definition at line 217 of file Pane_boundary.C.

References i, j, Element_node_enumerator_uns::next(), and Element_node_enumerator_uns::size_of_nodes().

218  {
219  // Initialize to true
220  is_isolated.clear();
221 
222  int nnodes = ghost_level ?
223  _pane.size_of_nodes() : _pane.size_of_real_nodes();
224 
225  if ( _pane.is_structured()) {
226  // A structured mesh have no isolated nodes.
227  is_isolated.resize( nnodes, false);
228  return;
229  }
230 
231  is_isolated.resize( nnodes, true);
232 
233  // Loop through the connectivity table to mark their nodes as false.
235  int nelems = ghost_level ?
236  _pane.size_of_elements() : _pane.size_of_real_elements();
237  for ( int i=0,size=nelems; i<size; ++i, ene.next()) {
238  for ( int j=ene.size_of_nodes()-1; j>=0; --j)
239  is_isolated[ ene[j]-1] = false;
240  }
241 }
const COM::Pane & _pane
Definition: Pane_boundary.h:87
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
Optimized version for unstructured meshes.

Here is the call graph for this function:

double min_squared_edge_len ( const std::vector< Facet_ID > &  be)
throw (int
)

Compute the minimum squared edge length of given edges.

Definition at line 246 of file Pane_boundary.C.

References COM_NC, d, i, j, min(), Facet_node_enumerator::size_of_corners(), and square().

Referenced by Pane_connectivity::get_local_boundary_nodes().

246  {
247  const COM::Attribute *attr = _pane.attribute( COM::COM_NC);
248 
249  double sql = HUGE_VAL;
250 
251  // Loop through all the edges of border facets to compute the
252  // shortest squared edge length.
253  std::vector<Facet_ID >::const_iterator it;
254  for ( it=be.begin(); it!=be.end(); ++it) {
255  Element_node_enumerator ene( &_pane, it->eid());
256  Facet_node_enumerator fne( &ene, it->lid());
257  int ne = fne.size_of_corners();
258 
259  // Loop through all edges of the facet.
260  for ( int j=0; j<fne.size_of_edges(); ++j) {
261  int n1 = fne[j], n2 = fne[(j+1)%ne];
262  const double *x1 = (const double*)attr->get_addr( n1-1, 0);
263  const double *x2 = (const double*)attr->get_addr( n2-1, 0);
264 
265  double sqdiff;
266  if ( attr->stride() >= 3) {
267  // Contiguous layout of coordinates
268  sqdiff = square(x1[0]-x2[0])+square(x1[1]-x2[1])+square(x1[2]-x2[2]);
269  }
270  else {
271  // This supports R^2 points.
272  sqdiff=square(x1[0]-x2[0]);
273  for ( int i=1, d=attr->size_of_components(); i<d; ++i) {
274  sqdiff += square((const double*)attr->get_addr( n1-1, i)-
275  (const double*)attr->get_addr( n2-1, i));
276  }
277  }
278 
279  sql = std::min( sql, sqdiff);
280  }
281  }
282 
283  return sql;
284 }
const COM::Pane & _pane
Definition: Pane_boundary.h:87
double square(double x)
An adaptor for enumerating node IDs of an element.
const NT & d
Adaptor for enumerating node IDs of a facet of an element.
blockLoc i
Definition: read.cpp:79
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
j indices j
Definition: Indexing.h:6

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

const COM::Pane& _pane
private

Definition at line 87 of file Pane_boundary.h.

const Simple_manifold_2* const _pm
private

Definition at line 88 of file Pane_boundary.h.


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