Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Partition.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 #include <iostream>
24 #include <vector>
25 #include <fstream>
26 #include <string>
27 #include <sstream>
28 #include <list>
29 #include <cassert>
30 #include <cstdlib>
31 #include <algorithm>
32 #include <iomanip>
33 #include <map>
34 
35 using namespace std;
36 
37 #include "GEM.H"
38 #include "Partition.H"
39 
40 
41 bool
43 {
44  int buf[3];
45  Inf.read(reinterpret_cast<char *>(buf),12);
46  _id = -buf[0];
47  _nfaces = buf[1];
48  _ngfaces = buf[2];
49  // _faceconn.resize(4*_nfaces);
50  // Inf.read(reinterpret_cast<char *>(&_faceconn[0]),4 * nfaces);
51  // skip the face connectivity until Bill tell us whats up with it
52  Inf.seekg(16 * _nfaces,ios::cur);
53  return(true);
54 }
55 
56 bool
58 {
59  _ngtri = 0;
60  _ngquad = 0;
61  Inf >> _id >> _nfaces >> _ngfaces;
62  unsigned int nfaces_accum = 0;
63  nfaces_accum += _nfaces;
64  _ngtri = _ngfaces;
65  _id *= -1;
66  _triconn.resize(3*_nfaces);
67  unsigned int face = 0;
68  while(face < _nfaces){
69  unsigned int node1,node2,node3;
70  Inf >> node1 >> node2 >> node3;
71  _triconn[face*3] = node1;
72  _triconn[face*3+1] = node2;
73  _triconn[face*3+2] = node3;
74  face++;
75  }
76  Inf >> _nfaces >> _ngfaces;
77  nfaces_accum += _nfaces;
78  _ngquad = _ngfaces;
79  _quadconn.resize(4*_nfaces);
80  face = 0;
81  while(face < _nfaces){
82  unsigned int node1,node2,node3,node4;
83  Inf >> node1 >> node2 >> node3 >> node4;
84  _quadconn[face*4] = (node1);
85  _quadconn[face*4+1] = (node2);
86  _quadconn[face*4+2] = (node3);
87  _quadconn[face*4+3] = (node4);
88  face++;
89  }
90  _nfaces = nfaces_accum;
91  _ngfaces = _ngquad + _ngtri;
92  return(true);
93 }
94 
95 bool
97 {
98  unsigned int nfaces = _triconn.size()/3;
99  unsigned int face = 0;
100  Ouf << setw(12) << (_id < 0 ? _id : -1*_id) << endl
101  << setw(12) << nfaces << endl
102  << setw(12) << _ngtri << endl;
103  while(face < nfaces){
104  Ouf << setw(12) << _triconn[face*3]
105  << setw(12) << _triconn[face*3+1]
106  << setw(12) << _triconn[face*3+2] << endl;
107  face++;
108  }
109  nfaces = _quadconn.size()/4;
110  face = 0;
111  Ouf << setw(12) << nfaces << endl
112  << setw(12) << _ngquad << endl;
113  while(face < nfaces){
114  Ouf << setw(12) << _quadconn[face*4]
115  << setw(12) << _quadconn[face*4+1]
116  << setw(12) << _quadconn[face*4+2]
117  << setw(12) << _quadconn[face*4+3] << endl;
118  face++;
119  }
120  return(true);
121 }
122 
123 
124 bool
126 {
127  // map<unsigned int, unsigned int> patch_mapping;
128  // if(!build_patch_mapping(pre,patch_mapping))
129  // return false;
130  int nlocal_patches;
131  Inf.read(reinterpret_cast<char *>(&nlocal_patches),4);
132  _patches.resize(nlocal_patches);
133  int bound = 0;
134  while(bound < nlocal_patches){
135  PartitionPatch *pp = &_patches[bound++];
136  if(!pp->ReadPartitionPatch(Inf))
137  return(false);
138  }
139  return(true);
140 }
141 
142 bool
144 {
145  int nlocal_patches;
146  Inf >> nlocal_patches;
147  _patches.resize(nlocal_patches);
148  int bound = 0;
149  while(bound < nlocal_patches){
150  PartitionPatch *pp = &_patches[bound++];
151  if(!pp->ReadPartitionPatchASCII(Inf))
152  return(false);
153  }
154  return(true);
155 }
156 
157 
158 bool
160 {
161  Ouf << setw(12) << _patches.size() << endl;
162  unsigned int bound = 0;
163  while(bound < _patches.size()){
164  PartitionPatch *pp = &_patches[bound++];
165  if(!pp->WritePartitionPatchASCII(Ouf))
166  return(false);
167  }
168  return(true);
169 }
170 
171 bool
173 {
174  int buf[4];
175  Inf.read(reinterpret_cast<char *>(buf),16);
176  _rpart = buf[0];
177  _rbid = buf[1];
178  int nnodes = buf[2];
179  _ngnodes = buf[3];
180 
181  _bnodes.resize(nnodes);
182  int *nbuf = new int [2 * nnodes];
183  Inf.read(reinterpret_cast<char *>(nbuf),8*nnodes);
184 
185  int node = 0;
186  while(node < nnodes){
187  _bnodes[node] = make_pair(nbuf[2*node],nbuf[2*node+1]);
188  node++;
189  }
190  delete [] nbuf;
191 
192  Inf.read(reinterpret_cast<char *>(buf),8);
193  int nelem = buf[0];
194  _ngtets = buf[1];
195  _btets.resize(nelem);
196  nbuf = new int [2*nelem];
197  Inf.read(reinterpret_cast<char *>(nbuf),nelem*8);
198  int elem = 0;
199  while(elem < nelem){
200  _btets[elem] = make_pair(nbuf[2*elem],nbuf[2*elem+1]);
201  elem++;
202  }
203  delete [] nbuf;
204 
205  Inf.read(reinterpret_cast<char *>(buf),8);
206  nelem = buf[0];
207  _ngpyr = buf[1];
208  _bpyr.resize(nelem);
209  nbuf = new int [2*nelem];
210  Inf.read(reinterpret_cast<char *>(nbuf),nelem*8);
211  elem = 0;
212  while(elem < nelem){
213  _bpyr[elem] = make_pair(nbuf[2*elem],nbuf[2*elem+1]);
214  elem++;
215  }
216  delete [] nbuf;
217 
218  Inf.read(reinterpret_cast<char *>(buf),8);
219  nelem = buf[0];
220  _ngpris = buf[1];
221  _bpris.resize(nelem);
222  nbuf = new int [2*nelem];
223  Inf.read(reinterpret_cast<char *>(nbuf),nelem*8);
224  elem = 0;
225  while(elem < nelem){
226  _bpris[elem] = make_pair(nbuf[2*elem],nbuf[2*elem+1]);
227  elem++;
228  }
229  delete [] nbuf;
230 
231  Inf.read(reinterpret_cast<char *>(buf),8);
232  nelem = buf[0];
233  _nghex = buf[1];
234  _bhex.resize(nelem);
235  nbuf = new int [2*nelem];
236  Inf.read(reinterpret_cast<char *>(nbuf),nelem*8);
237  elem = 0;
238  while(elem < nelem){
239  _bhex[elem] = make_pair(nbuf[2*elem],nbuf[2*elem+1]);
240  elem++;
241  }
242  delete [] nbuf;
243 
244  return(true);
245 }
246 
247 bool
249 {
250  int nnodes = 0;
251  Inf >> _rpart >> _rbid >> nnodes >> _ngnodes;
252  _rpart += 1; // This converts to the required 1-based id's
253  _bnodes.resize(nnodes);
254  int node = 0;
255  int l,r;
256  while(node < nnodes){
257  Inf >> l >> r;
258  _bnodes[node++] = make_pair(l,r);
259  }
260 
261  int nelem = 0;
262  Inf >> nelem >> _ngtets;
263  _btets.resize(nelem);
264  int elem = 0;
265  while(elem < nelem){
266  Inf >> l >> r;
267  _btets[elem++] = make_pair(l,r);
268  }
269 
270  nelem = 0;
271  Inf >> nelem >> _ngpyr;
272  _bpyr.resize(nelem);
273  elem = 0;
274  while(elem < nelem){
275  Inf >> l >> r;
276  _bpyr[elem++] = make_pair(l,r);
277  }
278 
279  nelem = 0;
280  Inf >> nelem >> _ngpris;
281  _bpris.resize(nelem);
282  elem = 0;
283  while(elem < nelem){
284  Inf >> l >> r;
285  _bpris[elem++] = make_pair(l,r);
286  }
287 
288  nelem = 0;
289  Inf >> nelem >> _nghex;
290  _bhex.resize(nelem);
291  elem = 0;
292  while(elem < nelem){
293  Inf >> l >> r;
294  _bhex[elem++] = make_pair(l,r);
295  }
296 
297  return(true);
298 }
299 
300 bool
302 {
303  unsigned int nelem = _bnodes.size();
304  Ouf << setw(12) << _rpart-1 << endl
305  << setw(12) << _rbid << endl
306  << setw(12) << nelem << endl
307  << setw(12) << _ngnodes << endl;
308  unsigned int node = 0;
309  while(node < nelem){
310  Ouf << setw(12) << _bnodes[node].first
311  << setw(12) << _bnodes[node].second
312  << endl;
313  node++;
314  }
315  nelem = _btets.size();
316  Ouf << setw(12) << nelem << endl
317  << setw(12) << _ngtets << endl;
318  unsigned int elem = 0;
319  while(elem < nelem){
320  Ouf << setw(12) << _btets[elem].first
321  << setw(12) << _btets[elem].second
322  << endl;
323  elem++;
324  }
325 
326  nelem = _bpyr.size();
327  Ouf << setw(12) << nelem << endl
328  << setw(12) << _ngpyr << endl;
329  elem = 0;
330  while(elem < nelem){
331  Ouf << setw(12) << _bpyr[elem].first
332  << setw(12) << _bpyr[elem].second
333  << endl;
334  elem++;
335  }
336  nelem = _bpris.size();
337  Ouf << setw(12) << nelem << endl
338  << setw(12) << _ngpris << endl;
339  elem = 0;
340  while(elem < nelem){
341  Ouf << setw(12) << _bpris[elem].first
342  << setw(12) << _bpris[elem].second
343  << endl;
344  elem++;
345  }
346  nelem = _bhex.size();
347  Ouf << setw(12) << nelem << endl
348  << setw(12) << _nghex << endl;
349  elem = 0;
350  while(elem < nelem){
351  Ouf << setw(12) << _bhex[elem].first
352  << setw(12) << _bhex[elem].second
353  << endl;
354  elem++;
355  }
356  return(true);
357 }
358 
359 bool
361 {
362  int nbound = _boundaries.size();
363  int bound = 0;
364  while(bound < nbound){
365  PartitionBoundary *pb = &_boundaries[bound++];
366  if(!pb->ReadPartitionBoundaryASCII(Inf))
367  return(false);
368  // pb->MyRank(_rank);
369  }
370  return(true);
371 }
372 
373 bool
375 {
376  int nbound = _boundaries.size();
377  int bound = 0;
378  while(bound < nbound){
379  PartitionBoundary *pb = &_boundaries[bound++];
380  if(!pb->WritePartitionBoundaryASCII(Ouf))
381  return(false);
382  }
383  return(true);
384 }
385 
386 bool
388 {
389  int nbound = _boundaries.size();
390  int bound = 0;
391  while(bound < nbound){
392  PartitionBoundary *pb = &_boundaries[bound++];
393  if(!pb->ReadPartitionBoundary(Inf))
394  return(false);
395  pb->MyRank(_id);
396  }
397  return(true);
398 }
399 
400 
401 bool
402 Partition::ReadPartition(const string &pre,unsigned int rank)
403 {
404  ifstream Inf;
405  ostringstream Ostr;
406 
407  Ostr << pre << "." << rank;
408  Inf.open(Ostr.str().c_str());
409  if(!Inf) return(false);
410 
411  long buf[2];
412  this->_id = rank;
413  Inf.read(reinterpret_cast<char *>(&buf[0]),8);
414  this->_nnodes = buf[0];
415  cout << "buf[0] = " << buf[0] << endl;
416  this->_ngnodes = buf[1];
417  // skip over coordinates 3 of 4 bytes for each node
418  Inf.seekg(this->_nnodes * 3 * 4,ios::cur);
419  Inf.read(reinterpret_cast<char *>(buf),8);
420  this->_ntet = buf[0];
421  this->_ngtet = buf[1];
422  // skip over connectivity 4 of 4 bytes for each tet
423  Inf.seekg(this->_ntet * 4 * 4,ios::cur);
424  Inf.read(reinterpret_cast<char *>(buf),8);
425  this->_npyr = buf[0];
426  this->_ngpyr = buf[1];
427  // skip over connectivity 5 of 4 bytes for each pyr
428  Inf.seekg(this->_npyr * 5 * 4,ios::cur);
429  Inf.read(reinterpret_cast<char *>(buf),8);
430  this->_npris = buf[0];
431  this->_ngpris = buf[1];
432  // skip over connectivity 6 of 4 bytes for each pris
433  Inf.seekg(this->_npris * 6 * 4,ios::cur);
434  Inf.read(reinterpret_cast<char *>(buf),8);
435  this->_nhex = buf[0];
436  this->_nghex = buf[1];
437  // skip over connectivity 8 of 4 bytes for each hex
438  Inf.seekg(this->_nhex * 8 * 4,ios::cur);
439  this->_nelem = this->_nhex + this->_ntet + this->_npyr + this->_npris;
440  int nbound = 0;
441  Inf.read(reinterpret_cast<char *>(&nbound),4);
442  _boundaries.resize(nbound);
443  if(!ReadPartitionBoundaries(Inf))
444  return(false);
445  if(!ReadPartitionPatches(Inf))
446  return(false);
447  Inf.close();
448  return(true);
449 }
450 
451 bool
452 Partition::ReadPartitionASCII(const string &pre,unsigned int rank)
453 {
454  ifstream Inf;
455  ostringstream Ostr;
456 
457  Ostr << pre << "." << rank << ".asc";
458  Inf.open(Ostr.str().c_str());
459  if(!Inf){
460  cerr << "Cannot open " << Ostr.str() << "." << endl;
461  return(false);
462  }
463 
464  _id = rank + 1;
465  unsigned int nvfaces,nbfaces;
466  Inf >> nvfaces >> nbfaces >> _nnodes >> _ngnodes;
467  _nvface = nvfaces + nbfaces;
468  unsigned int node = 0;
469  _nc.resize(3*_nnodes);
470  while(node < _nnodes){
471  Inf >> _nc[3*node] >> _nc[3*node+1] >> _nc[3*node+2];
472  node++;
473  }
474  Inf >> _ntet >> _ngtet;
475  unsigned int tet = 0;
476  _tetconn.resize(4*_ntet);
477  while(tet < _ntet){
478  Inf >> _tetconn[4*tet] >> _tetconn[4*tet+1] >> _tetconn[4*tet+2]
479  >> _tetconn[4*tet+3];
480  tet++;
481  }
482  Inf >> _npyr >> _ngpyr;
483  unsigned int pyr = 0;
484  _pyrconn.resize(5*_npyr);
485  while(pyr < _npyr){
486  Inf >> _pyrconn[5*pyr] >> _pyrconn[5*pyr+1] >> _pyrconn[5*pyr+2]
487  >> _pyrconn[5*pyr+3] >> _pyrconn[5*pyr+4];
488  pyr++;
489  }
490 
491  Inf >> _npris >> _ngpris;
492  unsigned int pris = 0;
493  _prisconn.resize(6*_npris);
494  while(pris < _npris){
495  Inf >> _prisconn[6*pris] >> _prisconn[6*pris+1] >> _prisconn[6*pris+2]
496  >> _prisconn[6*pris+3] >> _prisconn[6*pris+4]
497  >> _prisconn[6*pris+5];
498  pris++;
499  }
500 
501  Inf >> _nhex >> _nghex;
502  unsigned int hex = 0;
503  _hexconn.resize(8*_nhex);
504  while(hex < _nhex){
505  Inf >> _hexconn[8*hex] >> _hexconn[8*hex+1] >> _hexconn[8*hex+2]
506  >> _hexconn[8*hex+3] >> _hexconn[8*hex+4]
507  >> _hexconn[8*hex+5] >> _hexconn[8*hex+6] >> _hexconn[8*hex+7];
508  hex++;
509  }
510  _nelem = _nhex + _ntet + _npyr + _npris;
511  unsigned int nbound = 0;
512  Inf >> nbound;
513  _boundaries.resize(nbound);
514  if(!ReadPartitionBoundariesASCII(Inf))
515  return(false);
516  if(!ReadPartitionPatchesASCII(Inf))
517  return(false);
518  Inf.close();
519  return(true);
520 }
521 
522 bool
523 Partition::BuildPartitionBoundaries(const vector<int> &Pconn)
524 {
525  unsigned int index = 0;
526  unsigned int npb = Pconn[index++];
527  _boundaries.clear();
528  _boundaries.resize(npb);
529 
530  // Shared Nodes
531  unsigned int pb_index = 0;
532  while(pb_index < npb){
533  PartitionBoundary &pb = _boundaries[pb_index++];
534  unsigned int pane_id = Pconn[index++];
535  pb._rpart = pane_id/100;
536  // pb._mypart = _part;
537  // pb._rbid = pane_id%100;
538  unsigned int nshared = Pconn[index++];
539  pb._sharenodes.resize(nshared);
540  unsigned int node = 0;
541  while(node < nshared)
542  pb._sharenodes[node++] = Pconn[index++];
543  }
544  index++;
545 
546  // Send Nodes
547  pb_index = 0;
548  while(pb_index < npb){
549  PartitionBoundary &pb = _boundaries[pb_index++];
550  unsigned int pane_id = Pconn[index++];
551  assert(pb._rpart == pane_id/100);
552  unsigned int nsend = Pconn[index++];
553  pb._sendnodes.resize(nsend);
554  unsigned int node = 0;
555  while(node < nsend)
556  pb._sendnodes[node++] = Pconn[index++];
557  }
558  index++;
559 
560  // Recv Nodes
561  pb_index = 0;
562  while(pb_index < npb){
563  PartitionBoundary &pb = _boundaries[pb_index++];
564  unsigned int pane_id = Pconn[index++];
565  assert(pb._rpart == pane_id/100);
566  unsigned int nrecv = Pconn[index++];
567  pb._recvnodes.resize(nrecv);
568  unsigned int node = 0;
569  while(node < nrecv)
570  pb._recvnodes[node++] = Pconn[index++];
571  }
572  index++;
573 
574  // Send Elems - first, we have to populate a temprorary array
575  // then, we have to sort through the array and determine how
576  // many of each element type there are.
577  pb_index = 0;
578  while(pb_index < npb){
579  PartitionBoundary &pb = _boundaries[pb_index++];
580  unsigned int pane_id = Pconn[index++];
581  assert(pb._rpart == pane_id/100);
582  unsigned int nsend = Pconn[index++];
583  pb._sendcells.resize(nsend);
584  unsigned int node = 0;
585  while(node < nsend)
586  pb._sendcells[node++] = Pconn[index++];
587  // Now temp_id contains the mapped element id
588  // We need to know whether each element is a
589  // tet, pyr, pris, or hex and keep a count.
590  node = 0;
591  unsigned int ntet = 0;
592  unsigned int npyr = 0;
593  unsigned int npris = 0;
594  unsigned int nhex = 0;
595  while(node < nsend){
596  if(pb._sendcells[node] <= _ntet)
597  ntet++;
598  else if (pb._sendcells[node] <= (_ntet+_npyr))
599  npyr++;
600  else if (pb._sendcells[node] <= (_ntet+_npyr+_npris))
601  npris++;
602  else if (pb._sendcells[node] <= (_ntet+_npyr+_npris+_nhex))
603  nhex++;
604  else
605  assert(pb._sendcells[node] <= (_ntet+_npyr+_npris+_nhex));
606  node++;
607  }
608  pb._belem_send[0].resize(ntet);
609  pb._belem_send[1].resize(npyr);
610  pb._belem_send[2].resize(npris);
611  pb._belem_send[3].resize(nhex);
612  node = 0;
613  ntet = 0;
614  npyr = 0;
615  npris = 0;
616  nhex = 0;
617  while(node < nsend){
618  if(pb._sendcells[node] <= _ntet)
619  pb._belem_send[0][ntet++] = pb._sendcells[node];
620  else if (pb._sendcells[node] <= (_ntet+_npyr))
621  pb._belem_send[1][npyr++] = pb._sendcells[node] - _ntet;
622  else if (pb._sendcells[node] <= (_ntet+_npyr+_npris))
623  pb._belem_send[2][npris++] = pb._sendcells[node] - (_ntet+_npyr);
624  else
625  pb._belem_send[3][nhex++] = pb._sendcells[node] - (_ntet+_npyr+_npris);
626  node++;
627  }
628  }
629  index++;
630 
631  // Recv Elems - first, we have to populate a temprorary array
632  // then, we have to sort through the array and determine how
633  // many of each element type there are. Then we populate the
634  // array
635  pb_index = 0;
636  while(pb_index < npb){
637  PartitionBoundary &pb = _boundaries[pb_index++];
638  unsigned int pane_id = Pconn[index++];
639  assert(pb._rpart == pane_id/100);
640  unsigned int nrecv = Pconn[index++];
641  pb._recvcells.resize(nrecv);
642  unsigned int node = 0;
643  while(node < nrecv)
644  pb._recvcells[node++] = Pconn[index++];
645  // Now pb._recvcells contains the mapped element id
646  // We need to know whether each element is a
647  // tet, pyr, pris, or hex and keep a count.
648  node = 0;
649  unsigned int ntet = 0;
650  unsigned int npyr = 0;
651  unsigned int npris = 0;
652  unsigned int nhex = 0;
653  while(node < nrecv){
654  if(pb._recvcells[node] <= _ntet)
655  ntet++;
656  else if (pb._recvcells[node] <= (_ntet+_npyr))
657  npyr++;
658  else if (pb._recvcells[node] <= (_ntet+_npyr+_npris))
659  npris++;
660  else if (pb._recvcells[node] <= (_ntet+_npyr+_npris+_nhex))
661  nhex++;
662  else
663  assert(pb._recvcells[node] <= (_ntet+_npyr+_npris+_nhex));
664  node++;
665  }
666  pb._belem_recv[0].resize(ntet);
667  pb._belem_recv[1].resize(npyr);
668  pb._belem_recv[2].resize(npris);
669  pb._belem_recv[3].resize(nhex);
670  node = 0;
671  ntet = 0;
672  npyr = 0;
673  npris = 0;
674  nhex = 0;
675  while(node < nrecv){
676  if(pb._recvcells[node] <= _ntet)
677  pb._belem_recv[0][ntet++] = pb._recvcells[node];
678  else if (pb._recvcells[node] <= (_ntet+_npyr))
679  pb._belem_recv[1][npyr++] = pb._recvcells[node] - _ntet;
680  else if (pb._recvcells[node] <= (_ntet+_npyr+_npris))
681  pb._belem_recv[2][npris++] = pb._recvcells[node] - (_ntet+_npyr);
682  else
683  pb._belem_recv[3][nhex++] = pb._recvcells[node] - (_ntet+_npyr+_npris);
684  node++;
685  }
686  }
687  return(true);
688 }
689 
690 bool
692 {
693  ofstream Ouf;
694  ostringstream Ostr;
695 
696  Ostr << pre << "." << _id-1 << ".asc";
697  Ouf.open(Ostr.str().c_str());
698  if(!Ouf){
699  cerr << "Cannot open " << Ostr.str() << "." << endl;
700  return(false);
701  }
702 
703 
704  Ouf << setw(12) << _nvface
705  << setw(12) << 0
706  << setw(12) << _nnodes
707  << setw(12) << _ngnodes
708  << endl;
709  unsigned int node = 0;
710  while(node < _nnodes){
711  Ouf << setw(20) << _nc[3*node]
712  << setw(20) << _nc[3*node+1]
713  << setw(20) << _nc[3*node+2]
714  << endl;
715  node++;
716  }
717  Ouf << setw(12) << _ntet
718  << setw(12) << _ngtet
719  << endl;
720  unsigned int tet = 0;
721  while(tet < _ntet){
722  Ouf << setw(12) << _tetconn[4*tet]
723  << setw(12) << _tetconn[4*tet+1]
724  << setw(12) << _tetconn[4*tet+2]
725  << setw(12) << _tetconn[4*tet+3]
726  << endl;
727  tet++;
728  }
729  Ouf << setw(12) << _npyr
730  << setw(12) << _ngpyr
731  << endl;
732  unsigned int pyr = 0;
733  while(pyr < _npyr){
734  Ouf << setw(12) << _pyrconn[5*pyr]
735  << setw(12) << _pyrconn[5*pyr+1]
736  << setw(12) << _pyrconn[5*pyr+2]
737  << setw(12) << _pyrconn[5*pyr+3]
738  << setw(12) << _pyrconn[5*pyr+4]
739  << endl;
740  pyr++;
741  }
742 
743  Ouf << setw(12) << _npris
744  << setw(12) << _ngpris
745  << endl;
746  unsigned int pris = 0;
747  while(pris < _npris){
748  Ouf << setw(12) << _prisconn[6*pris]
749  << setw(12) << _prisconn[6*pris+1]
750  << setw(12) << _prisconn[6*pris+2]
751  << setw(12) << _prisconn[6*pris+3]
752  << setw(12) << _prisconn[6*pris+4]
753  << setw(12) << _prisconn[6*pris+5]
754  << endl;
755  pris++;
756  }
757 
758  Ouf << setw(12) << _nhex
759  << setw(12) << _nghex
760  << endl;
761  unsigned int hex = 0;
762  while(hex < _nhex){
763  Ouf << setw(12) << _hexconn[8*hex]
764  << setw(12) << _hexconn[8*hex+1]
765  << setw(12) << _hexconn[8*hex+2]
766  << setw(12) << _hexconn[8*hex+3]
767  << setw(12) << _hexconn[8*hex+4]
768  << setw(12) << _hexconn[8*hex+5]
769  << setw(12) << _hexconn[8*hex+6]
770  << setw(12) << _hexconn[8*hex+7]
771  << endl;
772  hex++;
773  }
774  Ouf << _boundaries.size() << endl;
775  if(!WritePartitionBoundariesASCII(Ouf))
776  return(false);
777  if(!WritePartitionPatchesASCII(Ouf))
778  return(false);
779  Ouf.close();
780  return(true);
781 }
782 
783 void
784 report_border_array(const vector<pair<unsigned int,unsigned int> > &v)
785 {
786  vector<pair<unsigned int,unsigned int> >::const_iterator vi = v.begin();
787  while(vi != v.end()){
788  cerr << vi->first << " " << vi->second << endl;
789  vi++;
790  }
791 }
792 
793 void
795  GEM_Partition &gp)
796 {
797  bool debug = gp._debug;
798  if(debug)
799  cerr << "PartitionBoundary::populate_local_arrays entry" << endl;
800  // Total number of nodes on this boundary (shared+send+recv)
801  unsigned int nnodes = _bnodes.size();
802  // Number of local reals is local total minus local ghosts
803  unsigned int nreal = _bnodes.size() - _ngnodes;
804  // Number of remote recv'd nodes
805  unsigned int nremote_gnodes = rpb._ngnodes;
806  // Number of local shared is local real - remote ghosts
807  unsigned int nshared = nreal - nremote_gnodes;
808  // Num remote real is remote total minus remote ghosts
809  unsigned int nremote_rnodes = rpb._bnodes.size() - nremote_gnodes;
810  // Num local send nodes must equal num remote ghosts
811  unsigned int nsend = nreal - nshared;
812  assert(nsend == nremote_gnodes);
813  _recvnodes.resize(_ngnodes);
814  _sharenodes.resize(nshared);
815  _sendnodes.resize(nsend);
816  //
817  // We always let the sender determine the node ordering,
818  // so the recv arrays need to be re-ordered so that they
819  // match the remote border's node ordering. Also, we
820  // let the lesser of the two partition_id's determine the
821  // shared node order.
822  //
823  // The format for the data in _bnodes[] at this point is:
824  //
825  // vector<pair<LocalNodeIndex,RemoteBoundaryNodeIndex> >
826  //
827  // And we want to populate the send, recv, and shared
828  // node arrays in the correct order. For those that need
829  // the remote ordering, we swap the pairs above and sort
830  // the array based on the RemoteBoundaryNodeIndex (which
831  // indexes into the remote partition's boundary node
832  // array). Then we take a second pass to populate the
833  // local indices in that ordering.
834  //
835  // These hold the inverted local<-->remote node indices
836  vector<pair<unsigned int,unsigned int> > recv_iindex;
837  vector<pair<unsigned int,unsigned int> > shared_iindex;
838  recv_iindex.resize(_ngnodes);
839  shared_iindex.resize(nshared);
840  unsigned int node = 0;
841  unsigned int shnode = 0;
842  unsigned int snode = 0;
843  unsigned int rnode = 0;
844  while(node < nnodes){
845  // All ghost nodes are processed here
846  if(node >= nreal)
847  recv_iindex[rnode++] = make_pair(_bnodes[node].second,
848  _bnodes[node].first);
849  // recv_iindex[rnode++] = _bnodes[node];
850  else {
851  if(_bnodes[node].second > nremote_rnodes)
852  _sendnodes[snode++] = _bnodes[node].first;
853  else {
854  if(_mypart < _rpart)
855  _sharenodes[shnode++] = _bnodes[node].first;
856  else
857  shared_iindex[shnode++] = make_pair(_bnodes[node].second,
858  _bnodes[node].first);
859  }
860  }
861  node++;
862  }
863  sort(recv_iindex.begin(),recv_iindex.end());
864  node = 0;
865  while(node < rnode){
866  _recvnodes[node] = recv_iindex[node].second;
867  node++;
868  }
869  // Check partition_id (encoded as _myrank and _rrank) and order shared
870  // nodes if needed.
871  if(_mypart > _rpart){
872  node = 0;
873  sort(shared_iindex.begin(),shared_iindex.end());
874  while(node < shnode){
875  _sharenodes[node] = shared_iindex[node].second;
876  node++;
877  }
878  }
879  if(debug)
880  cerr << "PartitionBoundary::populate_local_arrays: Beginning elements."
881  << endl;
882  // Nodes are done. Now we need send and recv element arrays. These will be
883  // done independently for each element type.
884  unsigned int ntets = _btets.size();
885  unsigned int nhex = _bhex.size();
886  unsigned int npyr = _bpyr.size();
887  unsigned int npris = _bpris.size();
888  unsigned int nreal_tets = ntets - _ngtets;
889  unsigned int nreal_hex = nhex - _nghex;
890  unsigned int nreal_pyr = npyr - _ngpyr;
891  unsigned int nreal_pris = npris - _ngpris;
892  _belem_send[0].resize(nreal_tets);
893  _belem_send[1].resize(nreal_pyr);
894  _belem_send[2].resize(nreal_pris);
895  _belem_send[3].resize(nreal_hex);
896  _belem_recv[0].resize(_ngtets);
897  _belem_recv[1].resize(_ngpyr);
898  _belem_recv[2].resize(_ngpris);
899  _belem_recv[3].resize(_nghex);
900  _sendcells.resize(nreal_tets+nreal_pyr+nreal_pris+nreal_hex);
901  _recvcells.resize(_ngtets+_ngpyr+_ngpris+_nghex);
902  unsigned int elem = 0;
903  unsigned int selem = 0;
904  unsigned int relem = 0;
905  unsigned int scell = 0;
906  unsigned int rcell = 0;
907  recv_iindex.resize(_ngtets);
908  while(elem < ntets){
909  if(elem < nreal_tets){
910  _belem_send[0][selem++] = _btets[elem].first;
911  _sendcells[scell++] = gp.Elem2Cell(make_pair((unsigned int)1,
912  _btets[elem].first));
913  }
914  else
915  recv_iindex[relem++] = make_pair(_btets[elem].second,
916  _btets[elem].first);
917  elem++;
918  }
919  elem = 0;
920  sort(recv_iindex.begin(),recv_iindex.end());
921  while(elem < relem){
922  _belem_recv[0][elem] = recv_iindex[elem].second;
923  _recvcells[rcell++] = gp.Elem2Cell(make_pair((unsigned int)1,
924  recv_iindex[elem].second));
925  elem++;
926  }
927  assert((relem == _ngtets) && (selem == nreal_tets));
928  elem = 0;
929  selem = 0;
930  relem = 0;
931  recv_iindex.resize(_ngpyr);
932  while(elem < npyr){
933  if(elem < nreal_pyr){
934  _belem_send[1][selem++] = _bpyr[elem].first;
935  _sendcells[scell++] = gp.Elem2Cell(make_pair((unsigned int)2,
936  _bpyr[elem].first));
937  }
938  else
939  recv_iindex[relem++] = make_pair(_bpyr[elem].second,
940  _bpyr[elem].first);
941  elem++;
942  }
943  elem = 0;
944  sort(recv_iindex.begin(),recv_iindex.end());
945  while(elem < relem){
946  _belem_recv[1][elem] = recv_iindex[elem].second;
947  _recvcells[rcell++] = gp.Elem2Cell(make_pair((unsigned int)2,
948  recv_iindex[elem].second));
949  elem++;
950  }
951  assert((relem == _ngpyr) && (selem == nreal_pyr));
952  elem = 0;
953  selem = 0;
954  relem = 0;
955  recv_iindex.resize(_ngpris);
956  while(elem < npris){
957  if(elem < nreal_pris){
958  _belem_send[2][selem++] = _bpris[elem].first;
959  _sendcells[scell++] = gp.Elem2Cell(make_pair((unsigned int)3,
960  _bpris[elem].first));
961  }
962  else
963  recv_iindex[relem++] = make_pair(_bpris[elem].second,
964  _bpris[elem].first);
965  elem++;
966  }
967  elem = 0;
968  sort(recv_iindex.begin(),recv_iindex.end());
969  while(elem < relem){
970  _belem_recv[2][elem] = recv_iindex[elem].second;
971  _recvcells[rcell++] = gp.Elem2Cell(make_pair((unsigned int)3,
972  recv_iindex[elem].second));
973  elem++;
974  }
975  assert((relem == _ngpris) && (selem == nreal_pris));
976  elem = 0;
977  selem = 0;
978  relem = 0;
979  recv_iindex.resize(_nghex);
980  while(elem < nhex){
981  if(elem < nreal_hex){
982  _belem_send[3][selem++] = _bhex[elem].first;
983  _sendcells[scell++] = gp.Elem2Cell(make_pair((unsigned int)4,
984  _bhex[elem].first));
985  }
986  else
987  recv_iindex[relem++] = make_pair(_bhex[elem].second,
988  _bhex[elem].first);
989  elem++;
990  }
991  elem = 0;
992  sort(recv_iindex.begin(),recv_iindex.end());
993  while(elem < relem){
994  _belem_recv[3][elem] = recv_iindex[elem].second;
995  _recvcells[rcell++] = gp.Elem2Cell(make_pair((unsigned int)4,
996  recv_iindex[elem].second));
997  elem++;
998  }
999  assert((relem == _nghex) && (selem == nreal_hex));
1000 }
1001 
1002 
1003 void
1005 {
1006  // Total number of nodes on this boundary (shared+send+recv)
1007  unsigned int nnodes = _bnodes.size();
1008  // Number of local reals is local total minus local ghosts
1009  unsigned int nreal = _bnodes.size() - _ngnodes;
1010  // Number of remote recv'd nodes
1011  unsigned int nremote_gnodes = rpb._ngnodes;
1012  // Number of local shared is local real - remote ghosts
1013  unsigned int nshared = nreal - nremote_gnodes;
1014  // Num remote real is remote total minus remote ghosts
1015  unsigned int nremote_rnodes = rpb._bnodes.size() - nremote_gnodes;
1016  // Num local send nodes must equal num remote ghosts
1017  unsigned int nsend = nreal - nshared;
1018  assert(nsend == nremote_gnodes);
1019  _recvnodes.resize(_ngnodes);
1020  _sharenodes.resize(nshared);
1021  _sendnodes.resize(nsend);
1022  //
1023  // We always let the sender determine the node ordering,
1024  // so the recv arrays need to be re-ordered so that they
1025  // match the remote border's node ordering. Also, we
1026  // let the lesser of the two partition_id's determine the
1027  // shared node order.
1028  //
1029  // The format for the data in _bnodes[] at this point is:
1030  //
1031  // vector<pair<LocalNodeIndex,RemoteBoundaryNodeIndex> >
1032  //
1033  // And we want to populate the send, recv, and shared
1034  // node arrays in the correct order. For those that need
1035  // the remote ordering, we swap the pairs above and sort
1036  // the array based on the RemoteBoundaryNodeIndex (which
1037  // indexes into the remote partition's boundary node
1038  // array). Then we take a second pass to populate the
1039  // local indices in that ordering.
1040  //
1041  // These hold the inverted local<-->remote node indices
1042  vector<pair<unsigned int,unsigned int> > recv_iindex;
1043  vector<pair<unsigned int,unsigned int> > shared_iindex;
1044  recv_iindex.resize(_ngnodes);
1045  shared_iindex.resize(nshared);
1046  unsigned int node = 0;
1047  unsigned int shnode = 0;
1048  unsigned int snode = 0;
1049  unsigned int rnode = 0;
1050  while(node < nnodes){
1051  // All ghost nodes are processed here
1052  if(node >= nreal)
1053  recv_iindex[rnode++] = make_pair(_bnodes[node].second,
1054  _bnodes[node].first);
1055  // recv_iindex[rnode++] = _bnodes[node];
1056  else {
1057  if(_bnodes[node].second > nremote_rnodes)
1058  _sendnodes[snode++] = _bnodes[node].first;
1059  else {
1060  if(_mypart < _rpart)
1061  _sharenodes[shnode++] = _bnodes[node].first;
1062  else
1063  shared_iindex[shnode++] = make_pair(_bnodes[node].second,
1064  _bnodes[node].first);
1065  }
1066  }
1067  node++;
1068  }
1069  sort(recv_iindex.begin(),recv_iindex.end());
1070  node = 0;
1071  while(node < rnode){
1072  _recvnodes[node] = recv_iindex[node].second;
1073  node++;
1074  }
1075  // Check partition_id (encoded as _myrank and _rrank) and order shared
1076  // nodes if needed.
1077  if(_mypart > _rpart){
1078  node = 0;
1079  sort(shared_iindex.begin(),shared_iindex.end());
1080  while(node < shnode){
1081  _sharenodes[node] = shared_iindex[node].second;
1082  node++;
1083  }
1084  }
1085 
1086  // Nodes are done. Now we need send and recv element arrays. These will be
1087  // done independently for each element type.
1088  unsigned int ntets = _btets.size();
1089  unsigned int nhex = _bhex.size();
1090  unsigned int npyr = _bpyr.size();
1091  unsigned int npris = _bpris.size();
1092  unsigned int nreal_tets = ntets - _ngtets;
1093  unsigned int nreal_hex = nhex - _nghex;
1094  unsigned int nreal_pyr = npyr - _ngpyr;
1095  unsigned int nreal_pris = npris - _ngpris;
1096  _belem_send[0].resize(nreal_tets);
1097  _belem_send[1].resize(nreal_pyr);
1098  _belem_send[2].resize(nreal_pris);
1099  _belem_send[3].resize(nreal_hex);
1100  _belem_recv[0].resize(_ngtets);
1101  _belem_recv[1].resize(_ngpyr);
1102  _belem_recv[2].resize(_ngpris);
1103  _belem_recv[3].resize(_nghex);
1104  _sendcells.resize(nreal_tets+nreal_pyr+nreal_pris+nreal_hex);
1105  _recvcells.resize(_ngtets+_ngpyr+_ngpris+_nghex);
1106  unsigned int elem = 0;
1107  unsigned int selem = 0;
1108  unsigned int relem = 0;
1109  unsigned int scell = 0;
1110  unsigned int rcell = 0;
1111  recv_iindex.resize(_ngtets);
1112  while(elem < ntets){
1113  if(elem < nreal_tets){
1114  _belem_send[0][selem++] = _btets[elem].first;
1115  _sendcells[scell++] = _btets[elem].first;
1116  }
1117  else
1118  recv_iindex[relem++] = make_pair(_btets[elem].second,
1119  _btets[elem].first);
1120  elem++;
1121  }
1122  elem = 0;
1123  sort(recv_iindex.begin(),recv_iindex.end());
1124  while(elem < relem){
1125  _belem_recv[0][elem] = recv_iindex[elem].second;
1126  _recvcells[rcell++] = recv_iindex[elem].second;
1127  elem++;
1128  }
1129  assert((relem == _ngtets) && (selem == nreal_tets));
1130  elem = 0;
1131  selem = 0;
1132  relem = 0;
1133  recv_iindex.resize(_ngpyr);
1134  while(elem < npyr){
1135  if(elem < nreal_pyr){
1136  _belem_send[1][selem++] = _bpyr[elem].first;
1137  _sendcells[scell++] = _bpyr[elem].first + ntets;
1138  }
1139  else
1140  recv_iindex[relem++] = make_pair(_bpyr[elem].second,
1141  _bpyr[elem].first);
1142  elem++;
1143  }
1144  elem = 0;
1145  sort(recv_iindex.begin(),recv_iindex.end());
1146  while(elem < relem){
1147  _belem_recv[1][elem] = recv_iindex[elem].second;
1148  _recvcells[rcell++] = recv_iindex[elem].second + ntets;
1149  elem++;
1150  }
1151  assert((relem == _ngpyr) && (selem == nreal_pyr));
1152  elem = 0;
1153  selem = 0;
1154  relem = 0;
1155  recv_iindex.resize(_ngpris);
1156  while(elem < npris){
1157  if(elem < nreal_pris){
1158  _belem_send[2][selem++] = _bpris[elem].first;
1159  _sendcells[scell++] = _bpris[elem].first + ntets + npyr;
1160  }
1161  else
1162  recv_iindex[relem++] = make_pair(_bpris[elem].second,
1163  _bpris[elem].first);
1164  elem++;
1165  }
1166  elem = 0;
1167  sort(recv_iindex.begin(),recv_iindex.end());
1168  while(elem < relem){
1169  _belem_recv[2][elem] = recv_iindex[elem].second;
1170  _recvcells[rcell++] = recv_iindex[elem].second + ntets + npyr;
1171  elem++;
1172  }
1173  assert((relem == _ngpris) && (selem == nreal_pris));
1174  elem = 0;
1175  selem = 0;
1176  relem = 0;
1177  recv_iindex.resize(_nghex);
1178  while(elem < nhex){
1179  if(elem < nreal_hex){
1180  _belem_send[3][selem++] = _bhex[elem].first;
1181  _sendcells[scell++] = _bhex[elem].first+ntets+npyr+npris;
1182  }
1183  else
1184  recv_iindex[relem++] = make_pair(_bhex[elem].second,
1185  _bhex[elem].first);
1186  elem++;
1187  }
1188  elem = 0;
1189  sort(recv_iindex.begin(),recv_iindex.end());
1190  while(elem < relem){
1191  _belem_recv[3][elem] = recv_iindex[elem].second;
1192  _recvcells[rcell++] = recv_iindex[elem].second+ntets+npyr+npris;
1193  elem++;
1194  }
1195  assert((relem == _nghex) && (selem == nreal_hex));
1196 }
1197 
1198 
1199 #if 0
1201  : GEM_Partition(reg)
1202 {
1203  // _part = _id;
1204  // reg._id = part._rank+1;
1205  // reg._ngnodes = part._ngnodes;
1206  // reg._ngtet = part._ngtet;
1207  // reg._nghex = part._nghex;
1208  // reg._ngpyr = part._ngpyr;
1209  // reg._ngpris = part._ngpris;
1210  _patches.resize(_com
1211  reg._domain_b.resize(part._patches.size());
1212  reg._part_b.resize(part._boundaries.size());
1213  reg._nc = part._nc;
1214  reg._tetconn = part._tetconn;
1215  reg._hexconn = part._hexconn;
1216  reg._pyrconn = part._pyrconn;
1217  reg._prisconn = part._prisconn;
1218 
1219  // Populate all the partition boundary structures. Lots of index juggling here to
1220  // to match the mapping CELLS[0:NELEM-1]. NELEM = NTETS+NPYR+NPRIS+NHEX, in that
1221  // exact order. The Partitioner output has an array for each element type.
1222  unsigned int nbord = reg._part_b.size();
1223  unsigned int bord = 0;
1224  while(bord < nbord){
1225 
1226  // Nodes are straightforward copy of the data
1227  reg._part_b[bord]._rpbindex = part._boundaries[bord]._rbid;
1228  reg._part_b[bord]._rpart = part._boundaries[bord]._rrank + 1;
1229  reg._part_b[bord]._sendnodes = part._boundaries[bord]._sendnodes;
1230  reg._part_b[bord]._recvnodes = part._boundaries[bord]._recvnodes;
1231  reg._part_b[bord]._sharenodes = part._boundaries[bord]._sharenodes;
1232 
1233  // Cells must be re-arranged to the above described ordering
1234  unsigned int nsend = 0;
1235  unsigned int nrecv = 0;
1236 
1237  unsigned int ntets = part._boundaries[bord]._btets.size();
1238  unsigned int nreal_tets = ntets - part._boundaries[bord]._ngtets;
1239  unsigned int npyrs = part._boundaries[bord]._bpyr.size();
1240  unsigned int nreal_pyrs = npyrs - part._boundaries[bord]._ngpyr;
1241  unsigned int npriss = part._boundaries[bord]._bpris.size();
1242  unsigned int nreal_priss = npriss - part._boundaries[bord]._ngpris;
1243  unsigned int nhexs = part._boundaries[bord]._bhex.size();
1244  unsigned int nreal_hexs = nhexs - part._boundaries[bord]._nghex;
1245 
1246  nsend = nreal_tets + nreal_pyrs + nreal_priss + nreal_hexs;
1247  nrecv = ntets - nreal_tets + npyrs - nreal_pyrs + npriss - nreal_priss
1248  + nhexs - nreal_hexs;
1249  reg._part_b[bord]._sendcells.resize(nsend);
1250  reg._part_b[bord]._recvcells.resize(nrecv);
1251 
1252  vector<unsigned int> &sendv = part._boundaries[bord]._belem_send[0];
1253  vector<unsigned int> &recvv = part._boundaries[bord]._belem_recv[0];
1254  vector<unsigned int> &regsend = reg._part_b[bord]._sendcells;
1255  vector<unsigned int> &regrecv = reg._part_b[bord]._recvcells;
1256 
1257  unsigned int sendi = 0;
1258  unsigned int nerecv = ntets - nreal_tets;
1259  unsigned int nesend = nreal_tets;
1260  unsigned int curr_recv_pos = sendi;
1261  unsigned int curr_send_pos = sendi;
1262 
1263  while(sendi < nesend)
1264  regsend[curr_send_pos++] = sendv[sendi++];
1265  sendi = 0;
1266  while(sendi < nerecv)
1267  regrecv[curr_recv_pos++] = recvv[sendi++];
1268 
1269  sendv = part._boundaries[bord]._belem_send[1];
1270  recvv = part._boundaries[bord]._belem_recv[1];
1271  sendi = 0;
1272  nerecv = npyrs - nreal_pyrs;
1273  nesend = nreal_pyrs;
1274  while(sendi < nesend)
1275  regsend[curr_send_pos++] = sendv[sendi++];
1276  sendi = 0;
1277  while(sendi < nerecv)
1278  regrecv[curr_recv_pos++] = recvv[sendi++];
1279 
1280  sendv = part._boundaries[bord]._belem_send[2];
1281  recvv = part._boundaries[bord]._belem_recv[2];
1282  sendi = 0;
1283  nerecv = npriss - nreal_priss;
1284  nesend = nreal_priss;
1285  while(sendi < nesend)
1286  regsend[curr_send_pos++] = sendv[sendi++];
1287  sendi = 0;
1288  while(sendi < nerecv)
1289  regrecv[curr_recv_pos++] = recvv[sendi++];
1290 
1291  sendv = part._boundaries[bord]._belem_send[3];
1292  recvv = part._boundaries[bord]._belem_recv[3];
1293  sendi = 0;
1294  nerecv = nhexs - nreal_hexs;
1295  nesend = nreal_hexs;
1296  while(sendi < nesend)
1297  regsend[curr_send_pos++] = sendv[sendi++];
1298  sendi = 0;
1299  while(sendi < nerecv)
1300  regrecv[curr_recv_pos++] = recvv[sendi++];
1301 
1302  assert(curr_recv_pos == regrecv.size() && curr_send_pos == regsend.size());
1303  bord++;
1304  }
1305 
1306  // Populate the domain boundaries - straightforward data copy
1307  unsigned int local_patch = 0;
1308  unsigned int nlocal_patches = reg._domain_b.size();
1309  while(local_patch < nlocal_patches){
1310  PartitionPatch *pp = &part._patches[local_patch];
1311  reg._domain_b[local_patch]._id = (pp->_id < 0 ? (-1*pp->_id) : pp->_id);
1312  reg._domain_b[local_patch]._ngtri = pp->_ngtri;
1313  reg._domain_b[local_patch]._ngquad = pp->_ngquad;
1314  reg._domain_b[local_patch]._triconn = pp->_triconn;
1315  reg._domain_b[local_patch]._quadconn = pp->_quadconn;
1316  local_patch++;
1317  }
1318  return;
1319 }
1320 #endif
1321 
1322 
1323 
1324 
1325 
1326 
1327 
1328 
1329 
bool WritePartitionPatchASCII(ofstream &Ouf)
Definition: Partition.C:96
Definition: face.h:90
std::vector< unsigned int > _tetconn
Definition: GEM.H:295
bool ReadPartitionPatches(ifstream &Inf)
Definition: Partition.C:125
std::vector< unsigned int > _recvnodes
Definition: GEM.H:230
std::vector< unsigned int > _sendcells
Definition: GEM.H:227
vector< pair< unsigned int, unsigned int > > _bnodes
Definition: Partition.H:33
void report_border_array(const vector< pair< unsigned int, unsigned int > > &v)
Definition: Partition.C:784
bool WritePartitionPatchesASCII(ofstream &Ouf)
Definition: Partition.C:159
std::vector< unsigned int > _quadconn
Definition: GEM.H:132
Definition: adj.h:150
bool WritePartitionBoundariesASCII(ofstream &Ouf)
Definition: Partition.C:374
std::vector< unsigned int > _sharenodes
Definition: GEM.H:231
*********************************************************************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 and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS 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 v
Definition: roccomf90.h:20
bool ReadPartitionBoundaryASCII(ifstream &Inf)
Definition: Partition.C:248
std::vector< unsigned int > _recvcells
Definition: GEM.H:228
std::vector< unsigned int > _sendnodes
Definition: GEM.H:229
unsigned int Elem2Cell(std::pair< unsigned int, unsigned int >)
Definition: GEM.C:956
unsigned int MyRank(void) const
Definition: Partition.H:58
unsigned int _id
Definition: GEM.H:127
bool ReadPartitionPatchesASCII(ifstream &Inf)
Definition: Partition.C:143
std::vector< unsigned int > _triconn
Definition: GEM.H:131
unsigned int _id
Definition: GEM.H:284
unsigned int _ngquad
Definition: GEM.H:129
bool BuildPartitionBoundaries(const vector< int > &Pconn)
Definition: Partition.C:523
bool ReadPartitionBoundariesASCII(ifstream &Inf)
Definition: Partition.C:360
std::vector< unsigned int > _pyrconn
Definition: GEM.H:297
bool ReadPartitionPatchASCII(ifstream &Inf)
Definition: Partition.C:57
std::vector< unsigned int > _hexconn
Definition: GEM.H:301
bool ReadPartitionBoundaries(ifstream &Inf)
Definition: Partition.C:387
bool ReadPartitionPatch(ifstream &Inf)
Definition: Partition.C:42
vector< unsigned int > _belem_recv[4]
Definition: Partition.H:44
bool ReadPartition(const string &pre, unsigned int rank)
Definition: Partition.C:402
unsigned int _ngnodes
Definition: Partition.H:34
bool WritePartitionBoundaryASCII(ofstream &Ouf)
Definition: Partition.C:301
void populate_local_arrays(const PartitionBoundary &)
Definition: Partition.C:1004
bool ReadPartitionASCII(const string &pre, unsigned int rank)
Definition: Partition.C:452
vector< unsigned int > _belem_send[4]
Definition: Partition.H:43
bool _debug
Definition: GEM.H:310
static int rank
Definition: advectest.C:66
bool WritePartitionASCII(const string &pre)
Definition: Partition.C:691
std::vector< double > _nc
Definition: GEM.H:293
std::vector< unsigned int > _prisconn
Definition: GEM.H:299
unsigned int _rpart
Definition: GEM.H:226
unsigned int _ngpyr
Definition: GEM.H:289
bool ReadPartitionBoundary(ifstream &Inf)
Definition: Partition.C:172
unsigned int _ngtri
Definition: GEM.H:128