Memosa-FVM  0.2
CRConnectivity.cpp
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #include "CRConnectivity.h"
6 #include "CException.h"
7 #include "StorageSite.h"
8 #include <map>
9 #include <set>
10 
12  const StorageSite& colSite) :
13  _rowSite(&rowSite),
14  _colSite(&colSite),
15  _rowDim(_rowSite->getCountLevel1()),
16  _colDim(_colSite->getCountLevel1()),
17  _row(),
18  _col(),
19  _globalToLocalMap(),
20  _localToGlobalMap(),
21  _pairToColMappings(),
22  _connType(CELLCELL1)
23 {
24  logCtorVerbose("from rowSite and colSite of dimensions (%dx%d)" ,
26 }
27 
28 
30 {
31  for(map<const CRConnectivity*,PairToColMapping*>::iterator p
32  = _pairToColMappings.begin();
33  p != _pairToColMappings.end();
34  ++p)
35  delete p->second;
36 
37  logDtorVerbose("of dimensions (%dx%d)" , _rowDim,_colDim);
38 }
39 
40 
42 {
43  _row = shared_ptr<Array<int> >(new Array<int>(_rowDim+1));
44  *_row = 0;
45 }
46 
48 {
49  Array<int>& row = *_row;
50 
51  for(int i=0; i<_rowDim; i++)
52  row[i+1] += row[i];
53 
54  const int colSize = (_rowDim == 0) ? 0 : row[_rowDim-1];
55 
56  for(int i=_rowDim; i>0; i--)
57  row[i] = row[i-1];
58  row[0] = 0;
59 
60  _col = shared_ptr<Array<int> >(new Array<int>(colSize));
61 }
62 
63 
65 {
66  Array<int>& row = *_row;
67  for(int i=_rowDim; i>0; i--)
68  row[i] = row[i-1];
69  row[0] = 0;
70 }
71 
72 
73 shared_ptr<CRConnectivity>
75 {
76  shared_ptr<CRConnectivity> trPtr(new CRConnectivity(*_colSite,*_rowSite));
77  CRConnectivity& tr = *trPtr;
78 
79  tr.initCount();
80 
81  const Array<int>& myRow = *_row;
82  const Array<int>& myCol = *_col;
83  for(int i=0; i<_rowDim; i++){
84  for(int j=myRow[i]; j<myRow[i+1]; j++)
85  tr.addCount(myCol[j],1);
86  }
87  tr.finishCount();
88 
89  for(int i=0; i<_rowDim; i++)
90  for(int j=myRow[i]; j<myRow[i+1]; j++)
91  tr.add(myCol[j],i);
92  tr.finishAdd();
93  return trPtr;
94 }
95 
96 // returns a transpose connectivity for a "flattened" matrix, ie. a
97 // connectivity matrix where each row is made of varSize number of
98 // separate rows
99 
100 shared_ptr<CRConnectivity>
101 CRConnectivity::getMultiTranspose(const int varSize) const
102 {
103  shared_ptr<CRConnectivity> trPtr(new CRConnectivity(*_colSite,*_rowSite));
104  CRConnectivity& tr = *trPtr;
105 
106  tr._rowDim *= varSize;
107  tr._colDim *= varSize;
108 
109  tr.initCount();
110 
111  const Array<int>& myRow = *_row;
112  const Array<int>& myCol = *_col;
113 
114  for(int i=0; i<_rowDim; i++)
115  {
116  for(int ndr=0; ndr<varSize; ndr++)
117  {
118  const int nfr = i*varSize + ndr;
119  tr.addCount(nfr, varSize);
120  }
121 
122  for(int jp=myRow[i]; jp<myRow[i+1]; jp++)
123  {
124  const int j = myCol[jp];
125 
126  for(int ndr=0; ndr<varSize; ndr++)
127  for(int ndc=0; ndc<varSize; ndc++)
128  {
129  //const int nfr = i*varSize + ndr;
130  const int nfc = j*varSize + ndc;
131  tr.addCount(nfc, 1);
132  }
133  }
134  }
135 
136  tr.finishCount();
137 
138  for(int i=0; i<_rowDim; i++)
139  {
140  for(int ndr=0; ndr<varSize; ndr++)
141  for(int ndc=0; ndc<varSize; ndc++)
142  {
143  const int nfr = i*varSize + ndr;
144  const int nfc = i*varSize + ndc;
145  tr.add(nfc, nfr);
146  }
147 
148  for(int jp=myRow[i]; jp<myRow[i+1]; jp++)
149  {
150  const int j = myCol[jp];
151 
152  for(int ndr=0; ndr<varSize; ndr++)
153  for(int ndc=0; ndc<varSize; ndc++)
154  {
155  const int nfr = i*varSize + ndr;
156  const int nfc = j*varSize + ndc;
157  tr.add(nfc, nfr);
158  }
159  }
160  }
161 
162  tr.finishAdd();
163  return trPtr;
164 }
165 
166 
167 shared_ptr<CRConnectivity>
168 CRConnectivity::multiply(const CRConnectivity& b, const bool implicitDiagonal) const
169 {
170  const bool isSquared = (&b == this);
171 
172  if (_colDim != b._rowDim)
173  cerr << "invalid connectivity multiplication" << endl;
174 
175  shared_ptr<CRConnectivity> prPtr(new CRConnectivity(*_rowSite,*b._colSite));
176  CRConnectivity& pr = *prPtr;
177 
178  pr.initCount();
179 
180  const Array<int>& myRow = *_row;
181  const Array<int>& myCol = *_col;
182 
183 
184  const Array<int>& bRow = *b._row;
185  const Array<int>& bCol = *b._col;
186 
187  Array<bool> marker(b._colDim);
188  Array<int> marked(b._colDim);
189 
190  for(int i=0; i<b._colDim; i++)
191  {
192  marker[i] = false;
193  marked[i] = 0;
194  }
195  for(int i=0; i<_rowDim; i++)
196  {
197  int nMarked = 0;
198  for(int ir = myRow[i]; ir<myRow[i+1]; ir++)
199  {
200  const int ja = myCol[ir];
201 
202  if (isSquared)
203  {
204  if (!marker[ja])
205  {
206  marker[ja] = true;
207  if (ja != i || !implicitDiagonal)
208  pr.addCount(i,1);
209  marked[nMarked++] = ja;
210  }
211 
212  }
213 
214  for (int rb = bRow[ja]; rb<bRow[ja+1]; rb++)
215  {
216  const int jb = bCol[rb];
217  if (!marker[jb])
218  {
219  marker[jb] = true;
220  if (jb != i || !implicitDiagonal)
221  pr.addCount(i,1);
222  marked[nMarked++] = jb;
223  }
224  }
225  }
226  for(int n=0; n<nMarked; n++)
227  marker[marked[n]] = false;
228  }
229 
230  // for(int i=0; i<pr._rowDim;i++)
231  // cerr << i << " " << (*pr._row)[i] << endl;
232 
233  pr.finishCount();
234 
235  for(int i=0; i<_rowDim; i++)
236  {
237  int nMarked = 0;
238  for(int ir = myRow[i]; ir<myRow[i+1]; ir++)
239  {
240  const int ja = myCol[ir];
241  if (isSquared)
242  {
243  if (!marker[ja])
244  {
245  marker[ja] = true;
246  if (ja != i || !implicitDiagonal)
247  pr.add(i,ja);
248  marked[nMarked++] = ja;
249  }
250  }
251 
252  for (int rb = bRow[ja]; rb<bRow[ja+1]; rb++)
253  {
254  const int jb = bCol[rb];
255  if (!marker[jb])
256  {
257  marker[jb] = true;
258  if (jb != i || !implicitDiagonal)
259  pr.add(i,jb);
260  marked[nMarked++] = jb;
261  }
262  }
263  }
264  for(int n=0; n<nMarked; n++)
265  marker[marked[n]] = false;
266  }
267 
268  pr.finishAdd();
269  return prPtr;
270 }
271 
272 
273 shared_ptr<CRConnectivity>
275  const Array<int>& indices) const
276 {
277  shared_ptr<CRConnectivity> subPtr(new CRConnectivity(site,*_colSite));
278 
279  CRConnectivity& sub = *subPtr;
280  const Array<int>& myRow = *_row;
281  const Array<int>& myCol = *_col;
282 
283  sub.initCount();
284 
285  for(int ii=0;ii<indices.getLength();ii++)
286  {
287  const int i = indices[ii];
288  sub.addCount(ii,getCount(i));
289  }
290 
291  sub.finishCount();
292  for(int ii=0;ii<indices.getLength();ii++)
293  {
294  const int i = indices[ii];
295  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
296  {
297  const int j = myCol[ip];
298  sub.add(ii,j);
299  }
300  }
301 
302  sub.finishAdd();
303  return subPtr;
304 }
305 
306 
307 
308 //this is specialized subset for PartMesh class, V type faceCells siutation for interface ghost cells sharing common global cell result
309 //in wrong number of local element counts and mapping (Gazi).
310 shared_ptr<CRConnectivity>
312  const Array<int>& indices, const CRConnectivity& faceCells, const CRConnectivity& cellCells ) const
313 {
314  const Array<int>& myRow = *_row;
315  const Array<int>& myCol = *_col;
316 
317  map<int, int> localToGlobalMap;
318  map<int, vector<int> > faceToGlobalCellsMap;
319  map<int, vector<int> > faceToLocalCellsMap;
320 
321  shared_ptr<Array<int> > globalToLocalPtr(new Array<int>(_colDim));
322 
323  Array<int>& globalToLocal = *globalToLocalPtr;
324 
325  globalToLocal = -1;
326 
327  int max_sur_cells = 0;
328  for ( int elem = 0; elem < cellCells.getRowDim(); elem++ )
329  max_sur_cells = std::max( max_sur_cells, cellCells.getCount(elem) );
330 
331 
332  int nLocal=0;
333 //loop over inner elements
334  for(int ii=0;ii<indices.getLength();ii++)
335  {
336  bool inner_face = true;
337  const int i = indices[ii];
338  vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
339  vector<int> globalConn( myRow[i+1] - myRow[i], -1 );
340  int indx = 0;
341  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
342  {
343  const int j = myCol[ip];
344  const int local_elem = faceCells.getGlobalToLocalMap()[j];
345  globalConn.at(indx) = j;
346 
347  if ( cellCells.getCount(local_elem) != max_sur_cells )
348  inner_face = false;
349 
350  if ( cellCells.getCount(local_elem) == max_sur_cells ){ //if it is a inner element
351  if( globalToLocal[j] == -1 ){
352  localToGlobalMap.insert( pair<int,int>(nLocal, j) );
353  localConn.at(indx) = nLocal;
354  globalToLocal[j] = nLocal++;
355  } else {
356  localConn.at(indx) = globalToLocal[j];
357  }
358  }
359  indx++;
360 
361  }
362 
363  if ( inner_face ){
364  faceToGlobalCellsMap[ii] = globalConn;
365  faceToLocalCellsMap[ii] = localConn;
366  }
367  }
368 
369 
370  //outer faces (interface + boundary)
371  for(int ii=0;ii<indices.getLength();ii++)
372  {
373  bool outer_face = false;
374  const int i = indices[ii];
375  vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
376  vector<int> globalConn( myRow[i+1] - myRow[i], -1 );
377  int indx = 0;
378  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
379  {
380  const int j = myCol[ip];
381  const int local_elem = faceCells.getGlobalToLocalMap()[j];
382  globalConn.at(indx) = j;
383 
384  if ( cellCells.getCount(local_elem) != max_sur_cells )
385  outer_face = true;
386 
387  if ( cellCells.getCount(local_elem) != max_sur_cells ){ //if it is a boundary or interface cells
388  localToGlobalMap.insert( pair<int,int>(nLocal, j) );
389  localConn.at(indx) = nLocal;
390  globalToLocal[j] = nLocal++; //we still use globalToLocal for only inner and boundary (one-to-one mapping)
391  } else {
392  assert( globalToLocal[j] != -1 );
393  localConn.at(indx) = globalToLocal[j];
394  }
395  indx++;
396 
397  }
398 
399  if ( outer_face ){
400  faceToGlobalCellsMap[ii] = globalConn;
401  faceToLocalCellsMap[ii] = localConn;
402  }
403 
404  }
405 
406  shared_ptr<Array<int> > localToGlobalPtr(new Array<int>(nLocal));
407 
408  Array<int>& localToGlobal = *localToGlobalPtr;
409 
410  newColSite.setCount(nLocal);
411  shared_ptr<CRConnectivity> subPtr(new CRConnectivity(newRowSite,newColSite));
412  CRConnectivity& sub = *subPtr;
413 
414  sub.initCount();
415 
416  for(int ii=0;ii<indices.getLength();ii++)
417  {
418  const int i = indices[ii];
419  sub.addCount(ii,getCount(i));
420  }
421 
422  sub.finishCount();
423 
424 
425  map<int,int>::const_iterator it;
426  for ( it = localToGlobalMap.begin(); it != localToGlobalMap.end(); it++ ){
427  int local_id = it->first;
428  int global_id = it->second;
429  localToGlobal[ local_id ] = global_id;
430  }
431 
432  for(int ii=0;ii<indices.getLength();ii++)
433  {
434  const int i = indices[ii];
435  int indx = 0;
436  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
437  {
438  const int jLocal = faceToLocalCellsMap[ii].at(indx);
439  sub.add(ii,jLocal);
440  indx++;
441  }
442  }
443 
444 
445  sub.finishAdd();
446  sub._globalToLocalMap=globalToLocalPtr;
447  sub._localToGlobalMap=localToGlobalPtr;
448 
449  return subPtr;
450 }
451 
452 
453 //this is specialized subset for PartMesh class, V type faceCells siutation for interface ghost cells sharing common global cell result
454 //in wrong number of local element counts and mapping (Gazi). This is more robust version then
455 //above implementation
456 shared_ptr<CRConnectivity>
458  const Array<int>& indices, const CRConnectivity& cellParts, const int partID ) const
459 {
460  const Array<int>& myRow = *_row;
461  const Array<int>& myCol = *_col;
462 
463  map<int, int> localToGlobalMap;
464  map<int, vector<int> > faceToLocalCellsMap;
465 
466  const StorageSite& rowSite = cellParts.getRowSite();
467  const int cellSelfCount = rowSite.getSelfCount();
468  const int cellCount = rowSite.getCount();
469  shared_ptr<Array<int> > globalToLocalPtr(new Array<int>(cellCount));
470  Array<int>& globalToLocal = *globalToLocalPtr;
471 
472  globalToLocal = -1;
473 
474  int nLocal=0;
475 //loop over faces (sub)
476  for(int ii=0;ii<indices.getLength();ii++)
477  {
478  bool inner_face = true;
479  const int i = indices[ii];
480  //check if it is interface, pick one cell partition id, then compare connected cells if they are anot equal
481  const int compID = cellParts( myCol[myRow[i]], 0 );
482  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
483  const int j = myCol[ip];
484  if ( cellParts(j,0) != compID ) //interface if it is true
485  inner_face = false;
486  }
487 
488  //first check if it is boundary cell, then it is boundary interface
489  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
490  const int j = myCol[ip];
491  if ( j >= cellSelfCount ) //either interface or boundary
492  inner_face = false;
493  }
494 
495  vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
496  //looping over cell around faces
497  if ( inner_face ){ //if it is a inner element
498  int indx = 0;
499  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
500  {
501  const int j = myCol[ip];
502  if( globalToLocal[j] == -1 ){
503  localToGlobalMap.insert( pair<int,int>(nLocal, j) );
504  localConn.at(indx) = nLocal;
505  globalToLocal[j] = nLocal++;
506  } else {
507  localConn.at(indx) = globalToLocal[j];
508  }
509  indx++;
510  }
511  }
512  if ( inner_face ){
513  faceToLocalCellsMap[ii] = localConn;
514  }
515  }
516 
517 
518  //now there might be cells which is inner cell but surrounded by all boundary/interfaces faces, we have to renumber it before ghost cells
519  for(int ii=0;ii<indices.getLength();ii++){
520  const int i = indices[ii];
521  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
522  const int j = myCol[ip];
523  // these cells should be inner cell (j<..), never visited (glb..=-1), and staying in current partition (cellParts... == partID)
524  if ( j < cellSelfCount && globalToLocal[j] == -1 && cellParts(j,0) == partID ){
525  localToGlobalMap.insert( pair<int,int>(nLocal, j) );
526  globalToLocal[j] = nLocal++;
527  }
528  }
529  }
530 
531 
532  //outer faces (interface + boundary)
533  for(int ii=0;ii<indices.getLength();ii++)
534  {
535  bool outer_face = false;
536  const int i = indices[ii];
537  //check if it is interface, pick one cell partition id, then compare connected cells if they are anot equal
538  const int compID = cellParts( myCol[myRow[i]], 0 );
539  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
540  const int j = myCol[ip];
541  if ( cellParts(j,0) != compID ) //either interface or boundary
542  outer_face = true;
543  }
544 
545  //first check if it is boundary cell, then it is boundary interface
546  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
547  const int j = myCol[ip];
548  if ( j >= cellSelfCount ) //either interface or boundary
549  outer_face = true;
550  }
551  vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
552  if ( outer_face ){ //if it is a boundary or interface cells
553  int indx = 0;
554  for(int ip=myRow[i];ip<myRow[i+1]; ip++){
555  const int j = myCol[ip];
556  if ( globalToLocal[j] == -1 ){
557  localToGlobalMap.insert( pair<int,int>(nLocal, j) );
558  localConn.at(indx) = nLocal++;
559  } else {
560  localConn.at(indx) = globalToLocal[j];
561  }
562  indx++;
563  }
564  }
565 
566  if ( outer_face ){
567  faceToLocalCellsMap[ii] = localConn;
568  }
569 
570  }
571 
572  shared_ptr<Array<int> > localToGlobalPtr(new Array<int>(nLocal));
573 
574  Array<int>& localToGlobal = *localToGlobalPtr;
575 
576  newColSite.setCount(nLocal);
577  shared_ptr<CRConnectivity> subPtr(new CRConnectivity(newRowSite,newColSite));
578  CRConnectivity& sub = *subPtr;
579 
580  sub.initCount();
581 
582  for(int ii=0;ii<indices.getLength();ii++)
583  {
584  const int i = indices[ii];
585  sub.addCount(ii,getCount(i));
586  }
587 
588  sub.finishCount();
589 
590 
591  map<int,int>::const_iterator it;
592  for ( it = localToGlobalMap.begin(); it != localToGlobalMap.end(); it++ ){
593  int local_id = it->first;
594  int global_id = it->second;
595  localToGlobal[ local_id ] = global_id;
596  }
597 
598  for(int ii=0;ii<indices.getLength();ii++)
599  {
600  const int i = indices[ii];
601  int indx = 0;
602  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
603  {
604  const int jLocal = faceToLocalCellsMap[ii].at(indx);
605  sub.add(ii,jLocal);
606  indx++;
607  }
608  }
609 
610  sub.finishAdd();
611  sub._globalToLocalMap=globalToLocalPtr;
612  sub._localToGlobalMap=localToGlobalPtr;
613  return subPtr;
614 }
615 
616 
617 
618 
619 
620 shared_ptr<CRConnectivity>
622  StorageSite& newColSite,
623  const Array<int>& indices) const
624 {
625  const Array<int>& myRow = *_row;
626  const Array<int>& myCol = *_col;
627 
628  shared_ptr<Array<int> > globalToLocalPtr(new Array<int>(_colDim));
629 
630  Array<int>& globalToLocal = *globalToLocalPtr;
631 
632  globalToLocal = -1;
633 
634  int nLocal=0;
635  for(int ii=0;ii<indices.getLength();ii++)
636  {
637  const int i = indices[ii];
638  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
639  {
640  const int j = myCol[ip];
641  if (globalToLocal[j] == -1)
642  globalToLocal[j] = nLocal++;
643  }
644  }
645 
646  shared_ptr<Array<int> > localToGlobalPtr(new Array<int>(nLocal));
647 
648  Array<int>& localToGlobal = *localToGlobalPtr;
649 
650  newColSite.setCount(nLocal);
651  shared_ptr<CRConnectivity> subPtr(new CRConnectivity(newRowSite,newColSite));
652  CRConnectivity& sub = *subPtr;
653 
654  sub.initCount();
655 
656  for(int ii=0;ii<indices.getLength();ii++)
657  {
658  const int i = indices[ii];
659  sub.addCount(ii,getCount(i));
660  }
661 
662  sub.finishCount();
663  for(int ii=0;ii<indices.getLength();ii++)
664  {
665  const int i = indices[ii];
666  for(int ip=myRow[i];ip<myRow[i+1]; ip++)
667  {
668  const int j = myCol[ip];
669  const int jLocal = globalToLocal[j];
670  sub.add(ii,jLocal);
671  }
672  }
673 
674  for(int i=0; i<_colDim; i++)
675  if (globalToLocal[i] != -1)
676  localToGlobal[globalToLocal[i]] = i;
677 
678  sub.finishAdd();
679  sub._globalToLocalMap=globalToLocalPtr;
680  sub._localToGlobalMap=localToGlobalPtr;
681 
682  return subPtr;
683 }
684 
685 
686 void
688 {
689  Array<int>& myCol = *_col;
690 
691  for ( int i = 0; i < myCol.getLength(); i++ )
692  myCol[i] = indices[ myCol[i] ];
693 }
694 
695 
696 void
697 CRConnectivity::localize( const Array<int>& globalToLocal,
698  const StorageSite& newColSite)
699 {
700  const int newColDim = newColSite.getCount();
701 
702  if (globalToLocal.getLength() != _colDim)
703  {
704  ostringstream e;
705  e << "global to local mapping is of wrong size (" <<
706  globalToLocal.getLength() << "); should be " << _colDim;
707  throw CException(e.str());
708  }
709 
710  Array<int>& myCol = *_col;
711  for(int i=0; i<myCol.getLength(); i++)
712  {
713  const int localIndex = globalToLocal[myCol[i]];
714  if (localIndex >=0 && localIndex < newColDim)
715  myCol[i] = localIndex;
716  else
717  {
718  ostringstream e;
719  e << "invalid global to local mapping at index " <<
720  myCol[i];
721  throw CException(e.str());
722  }
723  }
724  _colDim = newColDim;
725  _colSite = &newColSite;
726 }
727 
728 
729 const Array<Vector<int,2> >&
731 {
732  if (_pairToColMappings.find(&pairs) == _pairToColMappings.end())
733  {
734  const Array<int>& crRow = getRow();
735  const Array<int>& crCol = getCol();
736 
737  const int pairCount = pairs.getRowDim();
738 
739  Array<Vector<int,2> > *pairToCol = new Array<Vector<int,2> >(pairCount);
740 
741  _pairToColMappings[&pairs] = pairToCol;
742 
743  for(int np=0; np<pairCount; np++)
744  {
745  if (pairs.getCount(np) == 2)
746  {
747  int n0 = pairs(np,0);
748  int n1 = pairs(np,1);
749 
750  bool found = false;
751  for(int r0=crRow[n0]; r0<crRow[n0+1]; r0++)
752  if (crCol[r0] == n1)
753  {
754  (*pairToCol)[np][0] = r0;
755  found = true;
756  break;
757  }
758 
759  ostringstream e;
760  if (!found)
761  {
762  e << "did not find col pos for ( " << n0 << "," << n1 << ")";
763  throw CException(e.str());
764  }
765 
766  found = false;
767  for(int r1=crRow[n1]; r1<crRow[n1+1]; r1++)
768  if (crCol[r1] == n0)
769  {
770  (*pairToCol)[np][1] = r1;
771  found = true;
772  break;
773  }
774 
775  if (!found)
776  {
777  e << "did not find col pos for ( " << n1 << "," << n0 << ")";
778  throw CException(e.str());
779  }
780 
781  }
782  else
783  {
784  ostringstream e;
785  e << "invalid count for pairs connectivity" << endl;
786  throw CException(e.str());
787  }
788  }
789  }
790 
791  return *_pairToColMappings[&pairs];
792 }
793 
794 
795 shared_ptr<CRConnectivity>
797  const int offset, const int size) const
798 {
799  shared_ptr<CRConnectivity> offPtr(new CRConnectivity(newRowSite,*_colSite));
800  shared_ptr<ArrayBase> rowOffset(_row->createOffsetArray(offset,size+1));
801  offPtr->_row = dynamic_pointer_cast<Array<int> >(rowOffset);
802  offPtr->_col = _col;
803  return offPtr;
804 }
805 
806 void
808 {
809  if (_pairToColMappings.find(&pairs) != _pairToColMappings.end())
810  {
811  Array<Vector<int,2> > *pairToCol = _pairToColMappings[&pairs];
812  delete pairToCol;
813 
814  _pairToColMappings.erase(&pairs);
815  }
816 }
shared_ptr< CRConnectivity > getMultiTranspose(const int varSize) const
const Array< int > & getCol() const
int getCount(const int i) const
const Array< int > & getRow() const
shared_ptr< CRConnectivity > getSubset(const StorageSite &site, const Array< int > &indices) const
int getSelfCount() const
Definition: StorageSite.h:40
const Array< int > & getGlobalToLocalMap() const
StorageSite const * _colSite
#define logCtorVerbose(str,...)
Definition: RLogInterface.h:29
void reorder(const Array< int > &indices)
shared_ptr< Array< int > > _globalToLocalMap
double max(double x, double y)
Definition: Octree.cpp:18
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
shared_ptr< Array< int > > _row
StorageSite const * _rowSite
void clearPairToColMapping(const CRConnectivity &pairs) const
shared_ptr< CRConnectivity > getLocalizedSubset(const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices) const
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
void localize(const Array< int > &globalToLocal, const StorageSite &newColSite)
shared_ptr< Array< int > > _col
shared_ptr< CRConnectivity > getLocalizedSubsetOfFaceCells(const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices, const CRConnectivity &faceCells, const CRConnectivity &cellCells) const
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
shared_ptr< Array< int > > _localToGlobalMap
shared_ptr< CRConnectivity > getTranspose() const
int add(const int index, const int val)
shared_ptr< CRConnectivity > createOffset(const StorageSite &newRowSite, const int offset, const int size) const
int getCount() const
Definition: StorageSite.h:39
const StorageSite & getRowSite() const
int getRowDim() const
void addCount(const int index, const int count)
#define logDtorVerbose(str,...)
Definition: RLogInterface.h:36
const PairToColMapping & getPairToColMapping(const CRConnectivity &pairs) const
int getLength() const
Definition: Array.h:87