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

#include <Pane_connectivity.h>

Collaboration diagram for Pane_connectivity:

Public Member Functions

 Pane_connectivity (const COM::Attribute *mesh, MPI_Comm c=MPI_COMM_WORLD)
 Constructors. More...
 
 Pane_connectivity (const Simple_manifold_2 **mani2, MPI_Comm c=MPI_COMM_WORLD)
 Construct from an array of Simple_manifold_2. More...
 
void compute_pconn (COM::Attribute *pconn_n, COM::Attribute *pconn_f=NULL) throw (int)
 Create b2v mapping for nodes and facets (edges or faces) correspondence. More...
 

Static Public Member Functions

static void size_of_cpanes (const COM::Attribute *pconn, const int *pane_id, int *npanes_total, int *npanes_ghost=NULL)
 Get the number of communicating panes. More...
 
static int pconn_nblocks (const COM::Attribute *pconn)
 Determine the number of pconn blocks for all panes. More...
 
static int pconn_offset ()
 Retrieve an offset to avoid the number of communicating panes when reading a pconn attribute. More...
 

Protected Member Functions

void create_b2map (COM::Attribute *pconn, bool for_facet) throw (int)
 Create b2v mapping (pane connectivity) for nodes or edges and store the solution into the given Roccom Attribute. More...
 
void create_b2map (std::vector< std::vector< int > > &b2, bool for_facet) throw (int)
 Create b2v mapping (pane connectivity) for nodes or edges and store the results into a vector of vectors (with the same format as above). More...
 
double get_local_boundary_nodes (std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet) throw (int)
 Obtains the IDs and coordinates of boundary nodes of all local panes. More...
 
double collect_boundary_nodes (std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet) throw (int)
 Collect the boundary nodes of all panes that are coincident with the boundary nodes of local panes. More...
 
void determine_coisolated_nodes (const COM::Pane &pn, std::vector< Point_3 > &pnts, const double tol, std::vector< bool > &is_co, KD_tree_3 *tree=NULL) throw (int)
 

Private Types

typedef std::vector< const
COM::Pane * > 
Pane_set
 
typedef MAP::Point_3< double > Point_3
 

Private Member Functions

void collect_nodes (const std::vector< std::vector< int > > &ns, std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet)
 
void collect_points (const std::vector< std::vector< int > > &ns, std::vector< Point_3 > &pnts)
 

Private Attributes

const COM::Window *const _win
 
const Pane_set _panes
 
const Simple_manifold_2 ** _mani2
 
MPI_Comm _comm
 

Static Private Attributes

static const int _pconn_offset =1
 

Detailed Description

Definition at line 46 of file Pane_connectivity.h.

Member Typedef Documentation

typedef std::vector<const COM::Pane*> Pane_set
private

Definition at line 47 of file Pane_connectivity.h.

typedef MAP::Point_3<double> Point_3
private

Definition at line 48 of file Pane_connectivity.h.

Constructor & Destructor Documentation

Pane_connectivity ( const COM::Attribute *  mesh,
MPI_Comm  c = MPI_COMM_WORLD 
)
explicit

Constructors.

Definition at line 72 of file Pane_connectivity.C.

References _panes, and _win.

73  : _win(mesh->window()), _mani2(NULL),
74  _comm( COMMPI_Initialized()?c:MPI_COMM_NULL)
75 {
76  _win->panes( const_cast<std::vector<const COM::Pane*>&>(_panes));
77 }
const Pane_set _panes
const COM::Window *const _win
int COMMPI_Initialized()
Definition: commpi.h:168
const Simple_manifold_2 ** _mani2
Pane_connectivity ( const Simple_manifold_2 **  mani2,
MPI_Comm  c = MPI_COMM_WORLD 
)
explicit

Construct from an array of Simple_manifold_2.

Definition at line 80 of file Pane_connectivity.C.

References _panes, and _win.

81  : _win( mani2[0]->pane()->window()), _mani2(mani2),
82  _comm( COMMPI_Initialized()?c:MPI_COMM_NULL)
83 {
84  _win->panes( const_cast<std::vector<const COM::Pane*>&>(_panes));
85 }
const Pane_set _panes
const COM::Window *const _win
int COMMPI_Initialized()
Definition: commpi.h:168
const Simple_manifold_2 ** _mani2

Member Function Documentation

double collect_boundary_nodes ( std::vector< int > &  nodes,
std::vector< Point_3 > &  pnts,
bool  for_facet 
)
throw (int
)
protected

Collect the boundary nodes of all panes that are coincident with the boundary nodes of local panes.

Also returns an estimated tolerance for window query.

The output nodes is in the following format: <+/-pane_id> <n=#of nodes> <local_id 1> ... <local_id n>=""> <+/-pane_id 2> .... !repeat the above Note that for remote panes, the negative of pane ids are given. The local nodes are always listed first. For points, they are stored as minx miny minz maxx maxy maxz x1 y1 z1 x2 y2 z2 ... xn yn zn ! then repeats for other panes in consecutive order for all the boundary nodes. It returns an estimated tolerance for window query.

Definition at line 433 of file Pane_connectivity.C.

References collect_coincident_nodes(), i, and make_kd_tree().

435  {
436 
437  double tol = get_local_boundary_nodes( nodes, pnts, for_facet);
438  if ( _comm == MPI_COMM_NULL) return tol;
439 
440  int comm_size, comm_rank;
441  MPI_Comm_size( _comm, &comm_size);
442  MPI_Comm_rank( _comm, &comm_rank);
443 
444  // Gather the size info
445  int ns=nodes.size(); assert( pnts.size()==nodes.size());
446  std::vector<int> nss( comm_size);
447 
448  MPI_Allgather( &ns, 1, MPI_INT, &nss[0], 1, MPI_INT, _comm);
449 
450  std::vector<MPI_Request> reqs; reqs.reserve( (comm_size-1)*2);
451 
452  std::vector<int> l_nodes = nodes;
453  std::vector<Point_3> l_pnts = pnts;
454  // Now have each processor broadcast their
455  for ( int i=1; i<comm_size; ++i) {
456  const int to_rank = (comm_rank+i)%comm_size;
457  MPI_Request req;
458  MPI_Isend( &l_nodes[0], nodes.size(), MPI_INT, to_rank,
459  101, _comm, &req); reqs.push_back(req);
460  MPI_Isend( &l_pnts[0], 3*pnts.size(), MPI_DOUBLE, to_rank,
461  102, _comm, &req); reqs.push_back(req);
462  }
463 
464  KD_tree_pntref_3 local_rtree;
465  std::vector< Point_3> bbox;
466  std::vector< int> r_nodes, r_nodes_pre = nodes;
467  std::vector< Point_3> r_pnts, r_pnts_pre;
468  int from_rank_pre = comm_rank;
469 
470  for ( int i=comm_size-1; i>=1; --i) {
471  MPI_Request l_reqs[2];
472  MPI_Status l_stats[2];
473 
474  const int from_rank = (comm_rank+i)%comm_size;
475  r_nodes.resize( nss[from_rank]);
476  r_pnts.resize( nss[from_rank]);
477  MPI_Irecv( &r_nodes[0], r_nodes.size(), MPI_INT, from_rank,
478  101, _comm, &l_reqs[0]);
479  MPI_Irecv( &r_pnts[0], 3*r_pnts.size(), MPI_DOUBLE, from_rank,
480  102, _comm, &l_reqs[1]);
481 
482  // Overlap computation with communication.
483  if ( i==comm_size-1) {
484  make_kd_tree( r_nodes_pre, pnts, bbox, local_rtree);
485  }
486  else {
487  collect_coincident_nodes( r_nodes_pre, r_pnts_pre, bbox, local_rtree,
488  tol, nodes, pnts);
489  }
490  MPI_Waitall( 2, l_reqs, l_stats);
491  r_nodes_pre.swap( r_nodes); r_pnts_pre.swap( r_pnts);
492  from_rank_pre = from_rank;
493  }
494 
495  collect_coincident_nodes( r_nodes_pre, r_pnts_pre, bbox,
496  local_rtree, tol, nodes, pnts);
497 
498  std::vector<MPI_Status> stat( reqs.size());
499  if (reqs.size())
500  MPI_Waitall( reqs.size(), &reqs[0], &stat[0]);
501 
502  return tol;
503 }
blockLoc i
Definition: read.cpp:79
static void make_kd_tree(const std::vector< int > &nodes, const std::vector< Point_3< Real > > &pnts, std::vector< Point_3< Real > > &bbox, KD_tree_pntref_3 &ktree)
static void collect_coincident_nodes(const std::vector< int > &r_nodes, const std::vector< Point_3< Real > > &r_pnts, const std::vector< Point_3< Real > > &bbox, KD_tree_pntref_3 &ktree, double tol, std::vector< int > &nodes, std::vector< Point_3< Real > > &pnts)
double get_local_boundary_nodes(std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet)
Obtains the IDs and coordinates of boundary nodes of all local panes.

Here is the call graph for this function:

void collect_nodes ( const std::vector< std::vector< int > > &  ns,
std::vector< int > &  nodes,
std::vector< Point_3 > &  pnts,
bool  for_facet 
)
private

Definition at line 96 of file Pane_connectivity.C.

References _panes, COM_NC, d, Facet_ID::eid(), i, iend, j, k, Facet_ID::lid(), max(), min(), and s.

99  {
100  int count=0;
101  for (unsigned int i=0; i<ns.size(); ++i) count+=ns[i].size();
102 
103  // Collect the nodes
104  nodes.clear(); nodes.reserve( count+2*ns.size());
105  pnts.clear(); pnts.reserve( count+2*ns.size());
106 
107  for ( int i=0, s=_panes.size(); i<s; ++i) {
108  nodes.push_back( _panes[i]->id());
109  nodes.push_back( ns[i].size());
110 
111  nodes.insert( nodes.end(), ns[i].begin(), ns[i].end());
112 
113  pnts.push_back( Point_3(HUGE_VAL,HUGE_VAL,HUGE_VAL));
114  Point_3 &bnd_min = pnts.back();
115  pnts.push_back( Point_3(-HUGE_VAL,-HUGE_VAL,-HUGE_VAL));
116  Point_3 &bnd_max = pnts.back();
117 
118  const COM::Attribute *attr = _panes[i]->attribute( COM::COM_NC);
119  const int d = attr->size_of_components();
120 
121  for (std::vector<int>::const_iterator it=ns[i].begin(), iend=ns[i].end();
122  it!=iend;++it) {
123  Point_3 p(0,0,0);
124  if ( !for_facet) {
125  int j=*it-1;
126 
127  for ( int k=0; k<d; ++k)
128  p[k] = *(const double*)attr->get_addr( j, k);
129  }
130  else {
131  Facet_ID eID=(Facet_ID&)(*it);
132  Element_node_enumerator ene( _panes[i], eID.eid());
133  int vdst=(ene[eID.lid()+1==ene.size_of_edges()?0:eID.lid()+1]);
134  int j1=ene[eID.lid()]-1, j2=vdst-1;
135 
136  for ( int k=0; k<d; ++k) {
137  p[k] = 0.5*(*(const double*)attr->get_addr( j1, k) +
138  *(const double*)attr->get_addr( j2, k));
139  }
140  }
141 
142  pnts.push_back( p);
143 
144  for (int k=0; k<3; ++k) {
145  bnd_min[k] = std::min( bnd_min[k], p[k]);
146  bnd_max[k] = std::max( bnd_max[k], p[k]);
147  }
148  }
149  }
150 }
An adaptor for enumerating node IDs of an element.
const NT & d
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
const Pane_set _panes
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
char lid() const
Local edge ID of the halfedge within its element.
int eid() const
Element ID of the halfedge.
MAP::Point_3< double > Point_3
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode iend
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
The ID of a facet (edge in 2D and face in 3D) encodes an element ID and the local facet&#39;s ID internal...

Here is the call graph for this function:

void collect_points ( const std::vector< std::vector< int > > &  ns,
std::vector< Point_3 > &  pnts 
)
private

Definition at line 153 of file Pane_connectivity.C.

References _panes, COM_NC, d, i, iend, j, k, and s.

154  {
155  int count=0;
156  for (unsigned int i=0; i<ns.size(); ++i) count+=ns[i].size();
157  pnts.clear(); pnts.reserve( count);
158 
159  for ( int i=0, s=_panes.size(); i<s; ++i) {
160  const COM::Attribute *attr = _panes[i]->attribute( COM::COM_NC);
161  const int d = attr->size_of_components();
162 
163  for (std::vector<int>::const_iterator it=ns[i].begin(), iend=ns[i].end();
164  it!=iend;++it) {
165  Point_3 p(0,0,0);
166  int j=*it-1;
167  for ( int k=0; k<d; ++k)
168  p[k] = *(const double*)attr->get_addr( j, k);
169 
170  pnts.push_back( p);
171  }
172  }
173 }
const NT & d
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
const Pane_set _panes
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode iend
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
void compute_pconn ( COM::Attribute *  pconn_n,
COM::Attribute *  pconn_f = NULL 
)
throw (int
)

Create b2v mapping for nodes and facets (edges or faces) correspondence.

Definition at line 717 of file Pane_connectivity.C.

Referenced by Rocmap::compute_pconn().

718  {
719  if ( pconn_n) create_b2map( pconn_n, false);
720  if ( pconn_f) create_b2map( pconn_f, true);
721 }
void create_b2map(COM::Attribute *pconn, bool for_facet)
Create b2v mapping (pane connectivity) for nodes or edges and store the solution into the given Rocco...

Here is the caller graph for this function:

void create_b2map ( COM::Attribute *  pconn,
bool  for_facet 
)
throw (int
)
protected

Create b2v mapping (pane connectivity) for nodes or edges and store the solution into the given Roccom Attribute.

Create b2v mapping for nodes.

The output is a vector of b2v mapping for the local panes (b2v[i] for panes[i]). Each mapping has the following format: <remote_pane_id> <n=#of coincident nodes> <local_id 1> ... <local_id n>=""> <remote_pane_id 2> .... !repeat the above

Definition at line 676 of file Pane_connectivity.C.

References COM_assertion_msg, copy, i, j, min(), and n.

678 {
679  std::vector< std::vector<int> > b2v;
680 
681  create_b2map( b2v, for_facet);
682 
683  // Loop through the panes to get the connectivity map for each pane.
684  for ( int i=0, n=b2v.size(); i!=n; ++i) {
685  COM::Attribute *attr;
686  attr = const_cast<COM::Attribute*>(_panes[i]->attribute( pconn->id()));
687 
688  int size = b2v[i].size() + _pconn_offset;
689  attr->set_size( size);
690 
691  int *addr;
692  // If not yet initialized, allocate memory for it.
693  if ( !attr->initialized())
694  addr = (int*)attr->allocate( 1, size, false);
695  else
696  addr = (int*)attr->pointer();
697 
698  int cap = attr->capacity();
699  int cpanes = 0; // number of communicating panes.
700  int j=0,len=b2v[i].size();
701  for(; j+1<len; j+=2+(b2v[i])[j+1]){
702  // Count all the panes in b2v
703  cpanes ++;
704  }
705  COM_assertion_msg(j==len, "Invalid communication map");
706 
707  // Make sure to output pconn in correct format
708  if (_pconn_offset && cap >= 1){
709  addr[0] = cpanes;
710  std::copy(b2v[i].begin(), b2v[i].begin()+std::min(size-1,cap-1), addr+1);
711  }
712  else if (cap >= 1)
713  std::copy( b2v[i].begin(), b2v[i].begin()+std::min(size,cap),addr);
714  }
715 }
void create_b2map(COM::Attribute *pconn, bool for_facet)
Create b2v mapping (pane connectivity) for nodes or edges and store the solution into the given Rocco...
#define COM_assertion_msg(EX, msg)
const Pane_set _panes
static const int _pconn_offset
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
blockLoc i
Definition: read.cpp:79
const NT & n
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:

void create_b2map ( std::vector< std::vector< int > > &  b2v,
bool  for_facet 
)
throw (int
)
protected

Create b2v mapping (pane connectivity) for nodes or edges and store the results into a vector of vectors (with the same format as above).

Create b2v mapping for nodes or edges.

The output is a vector of b2v mapping for the local panes (b2v[i] for panes[i]). Each mapping has the following format: <remote_pane_id> <n=#of coincident nodes> <local_id 1> ... <local_id n>=""> <remote_pane_id 2> .... !repeat the above

Definition at line 513 of file Pane_connectivity.C.

References NTS::abs(), COM_assertion, i, iend, j, jend, k, make_kd_tree(), n, offset(), s, Point_3< T >::x(), Point_3< T >::y(), and Point_3< T >::z().

514  {
515 
516  typedef std::map< int, std::map< int, std::vector<pair_int> > > B2v_map;
517  B2v_map b2v_map;
518 
519  //< This is a mapping for pane_1-->pane_2-->node_1-->node2, where
520  //< <pane_1,node_1> and <pane_2,node_2> are two coincident nodes.
521  //< Furthermore, pane_1 is always <= pane_2; If pane_1<=pane_2, then
522  //< node_1<node_2.
523 
524  try {
525  // Create a mapping in b2v_map
526  std::vector<int> nodes, panes;
527  std::vector<Point_3> pnts;
528 
529  // Obtain the boundary nodes of all panes that are coincident with
530  // the boundary nodes of local panes.
531  double tol = collect_boundary_nodes( nodes, pnts, for_facet);
532 
533  panes.resize( nodes.size());
534  for (unsigned int count=0; count<nodes.size(); count+=nodes[count+1]+2) {
535  std::fill( &panes[count], &panes[count+nodes[count+1]+2], nodes[count]);
536  }
537 
538  std::vector< Point_3> bbox;
539  KD_tree_pntref_3 ktree;
540  make_kd_tree( nodes, pnts, bbox, ktree);
541 
542  std::vector< bool> processed(nodes.size());
543  std::fill_n( processed.begin(), nodes.size(), false);
544 
545  unsigned int count = 0;
546  while (count<nodes.size()) {
547  int paneid = nodes[count++];
548  // If the pane is remote (i.e., paneid<0), we stop processing the
549  // array because the local ones are always before the remote ones.
550  if (paneid<0) break;
551 
552  for ( int i=0, n=nodes[count++]; i<n; ++i, ++count) {
553  if ( processed[count]) continue;
554 
555  const Point_3 &p = pnts[count];
556  Point_3_ref lb(p.x()-tol, p.y()-tol, p.z()-tol);
557  Point_3_ref ub(p.x()+tol, p.y()+tol, p.z()+tol);
558  KD_tree_pntref_3::Box box( lb, ub, 3);
559 
560  std::vector< Point_3_ref> outList; outList.reserve(4);
561  ktree.search( std::back_inserter( outList), box);
562  assert( !outList.empty());
563 
564  std::vector< Node_ID> ids; ids.reserve( outList.size());
565  for ( std::vector< Point_3_ref>::iterator
566  i=outList.begin(); i!=outList.end(); ++i) {
567  int offset=i->offset();
568  processed[ offset] = true;
569  ids.push_back( Node_ID( panes[offset],nodes[offset]));
570  }
571 
572  std::vector< Node_ID >::const_iterator id1=ids.begin();
573  for ( id1=ids.begin(); id1!=ids.end(); ++id1) {
574  std::vector< Node_ID >::const_iterator id2=id1; ++id2;
575 
576  for ( ; id2!=ids.end(); ++id2) {
577  if ( abs(id1->first) < abs(id2->first) ||
578  abs(id1->first) == abs(id2->first) &&
579  id1->second < id2->second)
580  b2v_map[id1->first][id2->first].
581  push_back(pair_int(id1->second, id2->second));
582  else
583  b2v_map[id2->first][id1->first].
584  push_back(pair_int(id2->second, id1->second));
585  }
586  }
587  }
588  }
589  }
590  catch (int ex) {
591  throw ex;
592  }
593 
594  // Now copy from b2v_map into b2v_t
595  std::map<int, std::vector<int> > b2v_t;
596  B2v_map::iterator i, iend;
597  for ( i=b2v_map.begin(), iend=b2v_map.end(); i!=iend; ++i) {
598  // Try to catch branchcut.
599  std::map<int,int> branchcut;
600 
601  B2v_map::mapped_type::iterator j, jend;
602  for ( j=i->second.begin(), jend=i->second.end(); j!=jend; ++j) {
603  // Sort the ids in the group so that the mapping between the local
604  // boundary ids and the node ids is monotonically increasing on process.
605  // with smaller rank. This is useful for correcting correspondence
606  // across processors and is also useful for defining primary node as the
607  // one with the smallest <pane_id,node_id> pair (for Rocface). When they
608  // are ordered incrementally, the primary copy can be detected locally.
609  std::sort( j->second.begin(), j->second.end());
610  if ( i->first == j->first) {
611  COM_assertion( i->first>0);
612 
613  std::vector< int> &b2v_i = b2v_t[i->first];
614  b2v_i.push_back( j->first);
615  b2v_i.push_back( j->second.size()*2);
616 
617  B2v_map::mapped_type::mapped_type::const_iterator k, kend;
618  for ( k=j->second.begin(), kend=j->second.end(); k!=kend; ++k) {
619  b2v_i.push_back( k->first);
620  b2v_i.push_back( k->second);
621  branchcut[k->first] = k->second;
622  }
623  }
624  else {
625  if ( i->first>0) { // First pane is local
626  std::vector< int> &b2v_i = b2v_t[i->first];
627  b2v_i.push_back( std::abs(j->first));
628  b2v_i.push_back( j->second.size());
629 
630  B2v_map::mapped_type::mapped_type::const_iterator k, kend;
631  for ( k=j->second.begin(), kend=j->second.end(); k!=kend; ++k)
632  b2v_i.push_back( k->first);
633  }
634  if ( j->first>0) { // Second pane is local
635  std::vector< int> &b2v_j = b2v_t[j->first];
636  b2v_j.push_back( std::abs(i->first));
637  b2v_j.push_back( j->second.size());
638 
639  B2v_map::mapped_type::mapped_type::const_iterator k, kend;
640  for ( k=j->second.begin(), kend=j->second.end(); k!=kend; ++k)
641  b2v_j.push_back( k->second);
642  }
643  }
644  }
645 
646  if ( !branchcut.empty()) {
647  if ( _win->pane(i->first).is_structured())
648  std::cerr << "\nRocmap Info: Got a branchcut in pane "
649  << i->first << " of window " << _win->name() << std::endl;
650  else {
651  std::cerr << "\nRocmap Warning: Got duplicate nodes within pane "
652  << i->first << " of window " << _win->name() << std::endl;
653  while ( !branchcut.empty()) {
654  std::map<int,int>::iterator it=branchcut.begin();
655 
656  std::cerr << "Rocmap Warning: Duplicate nodes " << it->first
657  << " and " << it->second << std::endl;
658 
659  branchcut.erase(it);
660  }
661  }
662  }
663  }
664 
665  b2v_map.clear();
666 
667  // Copy from b2v_t into b2v
668  b2v.resize(_panes.size());
669  Pane_set::const_iterator it=_panes.begin();
670  for ( int i=0, s=_panes.size(); i<s; ++i, ++it) {
671  b2v[i].swap( b2v_t[(*it)->id()]);
672  }
673 }
std::pair< int, int > Node_ID
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
const Pane_set _panes
KD_tree::Box box
Definition: Overlay_0d.C:47
std::pair< int, int > pair_int
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
double collect_boundary_nodes(std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet)
Collect the boundary nodes of all panes that are coincident with the boundary nodes of local panes...
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode iend
blockLoc i
Definition: read.cpp:79
const NT & n
const COM::Window *const _win
static void make_kd_tree(const std::vector< int > &nodes, const std::vector< Point_3< Real > > &pnts, std::vector< Point_3< Real > > &bbox, KD_tree_pntref_3 &ktree)
FT x() const
Definition: Point_3.h:129
FT y() const
Definition: Point_3.h:132
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode jend
NT abs(const NT &x)
Definition: number_utils.h:130
FT z() const
Definition: Point_3.h:135

Here is the call graph for this function:

void determine_coisolated_nodes ( const COM::Pane &  pn,
std::vector< Point_3 > &  pnts,
const double  tol,
std::vector< bool > &  is_co,
KD_tree_3 tree = NULL 
)
throw (int
)
protected

Definition at line 178 of file Pane_connectivity.C.

References COM_NC, d, j, k, n, q, Point_3< T >::x(), Point_3< T >::y(), and Point_3< T >::z().

182  {
183 
184  int n=pn.size_of_real_nodes();
185  is_co.clear(); is_co.resize( n, false);
186 
187  // Build a kd-tree from the points in pnts if not give at input
188  KD_tree_3 ktree_local;
189 
190  if ( tree == NULL) {
191  ktree_local.build( pnts);
192  tree = &ktree_local;
193  }
194 
195  // Define a temporary buffer for holding the matching points.
196  std::vector< Point_3> outList; outList.reserve(4);
197 
198  // Loop through the nodes in the current pane to determine coisolated nodes
199  const COM::Attribute *attr = pn.attribute( COM::COM_NC);
200  const int d = attr->size_of_components();
201 
202  for ( int j=0; j<n; ++j) {
203  Point_3 q(0,0,0);
204  for ( int k=0; k<d; ++k)
205  q[k] = *(const double*)attr->get_addr( j, k);
206 
207  Point_3 lb(q.x()-tol, q.y()-tol, q.z()-tol);
208  Point_3 ub(q.x()+tol, q.y()+tol, q.z()+tol);
209  KD_tree_3::Box box( lb, ub, 3);
210 
211  // If found match in the tree, then the current node is coisolated.
212  outList.clear();
213 
214  tree->search( std::back_inserter( outList), box);
215 
216  if ( outList.size()) is_co[j]=true;
217  }
218 }
const NT & d
j indices k indices k
Definition: Indexing.h:6
KD_tree::Box box
Definition: Overlay_0d.C:47
const NT & n
j indices j
Definition: Indexing.h:6
NT q

Here is the call graph for this function:

double get_local_boundary_nodes ( std::vector< int > &  nodes,
std::vector< Point_3 > &  pnts,
bool  for_facet 
)
throw (int
)
protected

Obtains the IDs and coordinates of boundary nodes of all local panes.

Also returns a tolerance for window query.

Definition at line 221 of file Pane_connectivity.C.

References convert_nodelist(), Pane_boundary::determine_border_nodes(), i, min(), Pane_boundary::min_squared_edge_len(), MPI_MIN, s, and sqrt().

223  {
224 
225  std::vector< std::vector<int> > ns(_panes.size());
226  std::vector< std::vector<int> > iso_ns(_panes.size());
227 
228  double sql = HUGE_VAL;
229  int iso_local=0;
230  for ( int i=0, s=_panes.size(); i<s; ++i) {
231  std::vector<bool> is_border;
232  std::vector<bool> is_isolated;
233  std::vector<Facet_ID> facets;
234 
235  Pane_boundary pb =
236  _mani2 ? Pane_boundary( _mani2[i]) : Pane_boundary( _panes[i]);
237 
238  pb.determine_border_nodes( is_border, is_isolated, &facets);
239  sql = std::min( sql, pb.min_squared_edge_len( facets));
240 
241  if ( !for_facet) {
242  convert_nodelist( is_border, ns[i]);
243  convert_nodelist( is_isolated, iso_ns[i]);
244 
245  iso_local += iso_ns[i].size();
246  }
247  else {
248  ns[i].clear();
249  ns[i].insert( ns[i].end(), (int*)&*facets.begin(), (int*)&*facets.end());
250  }
251  }
252 
253  // Compute minimum squared edge length.
254  double g_sql=sql;
255  if ( _comm != MPI_COMM_NULL)
256  MPI_Allreduce( &sql, &g_sql, 1, MPI_DOUBLE, MPI_MIN, _comm);
257 
258  if ( g_sql==HUGE_VAL) g_sql=0;
259  double tol = std::sqrt( g_sql)*0.03;
260 
261  if ( !for_facet) {
262  std::vector<int> iso_counts;
263 
264  // Is there any isolated nodes?
265  int comm_size, comm_rank;
266  if ( _comm != MPI_COMM_NULL) {
267  MPI_Comm_size( _comm, &comm_size);
268  MPI_Comm_rank( _comm, &comm_rank);
269 
270  iso_counts.resize(comm_size);
271  MPI_Allgather(&iso_local, 1, MPI_INT, &iso_counts[0], 1, MPI_INT, _comm);
272 
273  iso_local=0;
274  for (int i=0; i<comm_size; ++i) iso_local+=iso_counts[i];
275  }
276  else {
277  comm_size=1;
278  comm_rank=0;
279  }
280 
281  if ( iso_local) { // Determine all nodes incident on isolated nodes.
282  collect_points( iso_ns, pnts);
283 
284  // Collect all isolated nodes onto the processor
285  std::vector< Point_3> pnts_g( iso_local);
286 
287  if ( _comm != MPI_COMM_NULL) {
288  for (int i=0; i<comm_size; ++i)
289  iso_counts[i]*=3;
290 
291  std::vector<int> iso_disps(comm_size, 0);
292  for (int i=1; i<comm_size; ++i)
293  iso_disps[i]=iso_disps[i-1]+iso_counts[i-1];
294 
295  MPI_Allgatherv( &pnts[0], iso_counts[comm_rank], MPI_DOUBLE,
296  &pnts_g[0], &iso_counts[0], &iso_disps[0],
297  MPI_DOUBLE, _comm);
298  }
299  else
300  pnts_g = pnts;
301 
302  if ( pnts_g.size()>0) {
303  // Build a kd-tree from the points in pnts_g
304  KD_tree_3 ktree;
305  ktree.build( pnts_g);
306 
307  for ( int i=0, s=_panes.size(); i<s; ++i) {
308  std::vector<bool> is_co;
309  determine_coisolated_nodes( *_panes[i], pnts_g, tol, is_co, &ktree);
310  convert_nodelist( is_co, iso_ns[i]);
311  }
312  }
313  }
314 
315  // Merge the lists
316  for ( unsigned int i=0; i<ns.size(); ++i) {
317  std::vector<int> &nsi = ns[i];
318  nsi.insert( ns[i].end(), iso_ns[i].begin(), iso_ns[i].end());
319 
320  // sort and unique the entries in ns[i]
321  std::sort(nsi.begin(), nsi.end());
322  std::vector<int>::iterator new_end=std::unique(nsi.begin(), nsi.end());
323  nsi.erase( new_end, nsi.end());
324  }
325  }
326 
327  // Copy the nodes from ns into nodes and pnts
328  collect_nodes( ns, nodes, pnts, for_facet);
329 
330  return tol;
331 }
static void convert_nodelist(const std::vector< bool > &bs, std::vector< int > &nodes)
void determine_coisolated_nodes(const COM::Pane &pn, std::vector< Point_3 > &pnts, const double tol, std::vector< bool > &is_co, KD_tree_3 *tree=NULL)
void collect_nodes(const std::vector< std::vector< int > > &ns, std::vector< int > &nodes, std::vector< Point_3 > &pnts, bool for_facet)
double s
Definition: blastest.C:80
const Pane_set _panes
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MIN
double sqrt(double d)
Definition: double.h:73
void collect_points(const std::vector< std::vector< int > > &ns, std::vector< Point_3 > &pnts)
void determine_border_nodes(std::vector< bool > &is_border, std::vector< bool > &is_isolated, std::vector< Facet_ID > *b=NULL, int ghost_level=0)
Determine the border nodes (excluding isolated nodes)
Definition: Pane_boundary.C:37
blockLoc i
Definition: read.cpp:79
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
double min_squared_edge_len(const std::vector< Facet_ID > &)
Compute the minimum squared edge length of given edges.
const Simple_manifold_2 ** _mani2

Here is the call graph for this function:

int pconn_nblocks ( const COM::Attribute *  pconn)
static

Determine the number of pconn blocks for all panes.

Must be called collectively by all processes of the owner window of pconn. Return 0 if pconn is empty; 1 if has only shared noodes; 2 if with shared nodes and ghost nodes; 3 if with ghost elements as well.

Definition at line 762 of file Pane_connectivity.C.

References _pconn_offset, COMMPI_Initialized(), i, max(), and MPI_MAX.

762  {
763  const COM::Window *win = pconn->window();
764 
765  int nblocks = 0;
766  // Loop through all panes
767  std::vector<const COM::Pane*> panes; win->panes(panes);
768  for ( int p=0, np=panes.size(); p<np; ++p) {
769  const COM::Attribute *pconn_pn = panes[p]->attribute( pconn->id());
770 
771  // Obtain the address and sizes of the map
772  const int *pconn_ptr = (const int *)pconn_pn->pointer();
773 
774  if ( pconn_ptr==NULL) continue;
775 
776  const int len_total = pconn_pn->size_of_items()-_pconn_offset;
777 
778  const int len_ghost = pconn_ptr ? pconn_pn->size_of_ghost_items() : 0;
779  if ( len_ghost == 0) { nblocks = std::max( nblocks, 1); continue; }
780 
781  pconn_ptr += len_total-len_ghost+_pconn_offset;
782 
783  // Skip real nodes
784  int index=1, ncpanes=pconn_ptr[0];
785  for ( int i=1; i<=ncpanes; ++i, index+=pconn_ptr[index+1]+2);
786  // Skip ghost nodes
787  ncpanes=pconn_ptr[index++];
788  for ( int i=1; i<=ncpanes; ++i, index+=pconn_ptr[index+1]+2);
789 
790  nblocks = std::max( nblocks, 2+(index<len_ghost));
791  }
792 
793  // Communicate to get the maximum of nblocks.
794  if ( COMMPI_Initialized()) {
795  int nblocks_local = nblocks;
796  MPI_Allreduce( &nblocks_local, &nblocks, 1, MPI_INT, MPI_MAX,
797  win->get_communicator());
798  }
799 
800  return nblocks;
801 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MAX
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
static const int _pconn_offset
blockLoc i
Definition: read.cpp:79
int COMMPI_Initialized()
Definition: commpi.h:168

Here is the call graph for this function:

static int pconn_offset ( )
inlinestatic

Retrieve an offset to avoid the number of communicating panes when reading a pconn attribute.

Definition at line 74 of file Pane_connectivity.h.

References _pconn_offset.

Referenced by Rocmop::determine_shared_border().

74  {
75  return _pconn_offset;
76  }
static const int _pconn_offset

Here is the caller graph for this function:

void size_of_cpanes ( const COM::Attribute *  pconn,
const int *  pane_id,
int *  npanes_total,
int *  npanes_ghost = NULL 
)
static

Get the number of communicating panes.

Definition at line 723 of file Pane_connectivity.C.

References _pconn_offset, COM_assertion_msg, and i.

Referenced by Rocmap::size_of_cpanes().

725  {
726  const COM::Window *win = pconn->window();
727  const COM::Attribute *pconn_pn;
728  pconn_pn = pconn->window()->pane( *pane_id).attribute( pconn->id());
729 
730  // Obtain the address and sizes of the map
731  const int *tmp_ptr = (const int *)pconn_pn->pointer();
732  const int *ptr_pconn = tmp_ptr ? tmp_ptr+_pconn_offset : tmp_ptr;
733  const int len_real = ptr_pconn ? pconn_pn->size_of_real_items()-_pconn_offset : 0;
734  const int len_total = ptr_pconn ? pconn_pn->size_of_items()-_pconn_offset : 0;
735 
736  COM_assertion_msg( npanes_total,
737  "Invalid NULL pointer for argument npanes_total");
738 
739  *npanes_total = 0;
740  int i=0;
741  for ( ; i+1<len_real; i+=2+ptr_pconn[i+1]) {
742  // Count only the panes existing in the window
743  *npanes_total += win->owner_rank( ptr_pconn[i])>=0;
744  }
745  COM_assertion_msg( i==len_real, "Invalid communication map");
746 
747  for ( ; i+1<len_total; i+=2+ptr_pconn[i+1]) {
748  // Count only the panes existing in the window
749  *npanes_total += win->owner_rank( ptr_pconn[i])>=0;
750  }
751 
752  // Compute the communicating panes that involve ghost nodes
753  if ( npanes_ghost) {
754  *npanes_ghost = 0;
755  for ( i=len_real; i+1<len_total; i+=2+ptr_pconn[i+1])
756  *npanes_ghost += win->owner_rank( ptr_pconn[i])>=0;
757  }
758 
759  COM_assertion_msg( i==len_total, "Invalid communication map");
760 }
#define COM_assertion_msg(EX, msg)
static const int _pconn_offset
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

Member Data Documentation

MPI_Comm _comm
private

Definition at line 129 of file Pane_connectivity.h.

const Simple_manifold_2** _mani2
private

Definition at line 128 of file Pane_connectivity.h.

const Pane_set _panes
private

Definition at line 127 of file Pane_connectivity.h.

Referenced by collect_nodes(), collect_points(), and Pane_connectivity().

const int _pconn_offset =1
staticprivate

Definition at line 130 of file Pane_connectivity.h.

Referenced by pconn_nblocks(), pconn_offset(), and size_of_cpanes().

const COM::Window* const _win
private

Definition at line 126 of file Pane_connectivity.h.

Referenced by Pane_connectivity().


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