15 _rowDim(_rowSite->getCountLevel1()),
16 _colDim(_colSite->getCountLevel1()),
31 for(map<const CRConnectivity*,PairToColMapping*>::iterator p
54 const int colSize = (_rowDim == 0) ? 0 : row[_rowDim-1];
56 for(
int i=_rowDim; i>0; i--)
73 shared_ptr<CRConnectivity>
84 for(
int j=myRow[i]; j<myRow[i+1]; j++)
90 for(
int j=myRow[i]; j<myRow[i+1]; j++)
100 shared_ptr<CRConnectivity>
116 for(
int ndr=0; ndr<varSize; ndr++)
118 const int nfr = i*varSize + ndr;
122 for(
int jp=myRow[i]; jp<myRow[i+1]; jp++)
124 const int j = myCol[jp];
126 for(
int ndr=0; ndr<varSize; ndr++)
127 for(
int ndc=0; ndc<varSize; ndc++)
130 const int nfc = j*varSize + ndc;
140 for(
int ndr=0; ndr<varSize; ndr++)
141 for(
int ndc=0; ndc<varSize; ndc++)
143 const int nfr = i*varSize + ndr;
144 const int nfc = i*varSize + ndc;
148 for(
int jp=myRow[i]; jp<myRow[i+1]; jp++)
150 const int j = myCol[jp];
152 for(
int ndr=0; ndr<varSize; ndr++)
153 for(
int ndc=0; ndc<varSize; ndc++)
155 const int nfr = i*varSize + ndr;
156 const int nfc = j*varSize + ndc;
167 shared_ptr<CRConnectivity>
170 const bool isSquared = (&b ==
this);
173 cerr <<
"invalid connectivity multiplication" << endl;
198 for(
int ir = myRow[i]; ir<myRow[i+1]; ir++)
200 const int ja = myCol[ir];
207 if (ja != i || !implicitDiagonal)
209 marked[nMarked++] = ja;
214 for (
int rb = bRow[ja]; rb<bRow[ja+1]; rb++)
216 const int jb = bCol[rb];
220 if (jb != i || !implicitDiagonal)
222 marked[nMarked++] = jb;
226 for(
int n=0; n<nMarked; n++)
227 marker[marked[n]] =
false;
238 for(
int ir = myRow[i]; ir<myRow[i+1]; ir++)
240 const int ja = myCol[ir];
246 if (ja != i || !implicitDiagonal)
248 marked[nMarked++] = ja;
252 for (
int rb = bRow[ja]; rb<bRow[ja+1]; rb++)
254 const int jb = bCol[rb];
258 if (jb != i || !implicitDiagonal)
260 marked[nMarked++] = jb;
264 for(
int n=0; n<nMarked; n++)
265 marker[marked[n]] =
false;
273 shared_ptr<CRConnectivity>
285 for(
int ii=0;ii<indices.
getLength();ii++)
287 const int i = indices[ii];
292 for(
int ii=0;ii<indices.
getLength();ii++)
294 const int i = indices[ii];
295 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
297 const int j = myCol[ip];
310 shared_ptr<CRConnectivity>
317 map<int, int> localToGlobalMap;
318 map<int, vector<int> > faceToGlobalCellsMap;
319 map<int, vector<int> > faceToLocalCellsMap;
323 Array<int>& globalToLocal = *globalToLocalPtr;
327 int max_sur_cells = 0;
328 for (
int elem = 0; elem < cellCells.
getRowDim(); elem++ )
334 for(
int ii=0;ii<indices.
getLength();ii++)
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 );
341 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
343 const int j = myCol[ip];
345 globalConn.at(indx) = j;
347 if ( cellCells.
getCount(local_elem) != max_sur_cells )
350 if ( cellCells.
getCount(local_elem) == max_sur_cells ){
351 if( globalToLocal[j] == -1 ){
352 localToGlobalMap.insert( pair<int,int>(nLocal, j) );
353 localConn.at(indx) = nLocal;
354 globalToLocal[j] = nLocal++;
356 localConn.at(indx) = globalToLocal[j];
364 faceToGlobalCellsMap[ii] = globalConn;
365 faceToLocalCellsMap[ii] = localConn;
371 for(
int ii=0;ii<indices.
getLength();ii++)
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 );
378 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
380 const int j = myCol[ip];
382 globalConn.at(indx) = j;
384 if ( cellCells.
getCount(local_elem) != max_sur_cells )
387 if ( cellCells.
getCount(local_elem) != max_sur_cells ){
388 localToGlobalMap.insert( pair<int,int>(nLocal, j) );
389 localConn.at(indx) = nLocal;
390 globalToLocal[j] = nLocal++;
392 assert( globalToLocal[j] != -1 );
393 localConn.at(indx) = globalToLocal[j];
400 faceToGlobalCellsMap[ii] = globalConn;
401 faceToLocalCellsMap[ii] = localConn;
406 shared_ptr<Array<int> > localToGlobalPtr(
new Array<int>(nLocal));
408 Array<int>& localToGlobal = *localToGlobalPtr;
411 shared_ptr<CRConnectivity> subPtr(
new CRConnectivity(newRowSite,newColSite));
416 for(
int ii=0;ii<indices.
getLength();ii++)
418 const int i = indices[ii];
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;
432 for(
int ii=0;ii<indices.
getLength();ii++)
434 const int i = indices[ii];
436 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
438 const int jLocal = faceToLocalCellsMap[ii].at(indx);
456 shared_ptr<CRConnectivity>
463 map<int, int> localToGlobalMap;
464 map<int, vector<int> > faceToLocalCellsMap;
468 const int cellCount = rowSite.
getCount();
469 shared_ptr<Array<int> > globalToLocalPtr(
new Array<int>(cellCount));
470 Array<int>& globalToLocal = *globalToLocalPtr;
476 for(
int ii=0;ii<indices.
getLength();ii++)
478 bool inner_face =
true;
479 const int i = indices[ii];
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 )
489 for(
int ip=myRow[i];ip<myRow[i+1]; ip++){
490 const int j = myCol[ip];
491 if ( j >= cellSelfCount )
495 vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
499 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
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++;
507 localConn.at(indx) = globalToLocal[j];
513 faceToLocalCellsMap[ii] = localConn;
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];
524 if ( j < cellSelfCount && globalToLocal[j] == -1 && cellParts(j,0) == partID ){
525 localToGlobalMap.insert( pair<int,int>(nLocal, j) );
526 globalToLocal[j] = nLocal++;
533 for(
int ii=0;ii<indices.
getLength();ii++)
535 bool outer_face =
false;
536 const int i = indices[ii];
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 )
546 for(
int ip=myRow[i];ip<myRow[i+1]; ip++){
547 const int j = myCol[ip];
548 if ( j >= cellSelfCount )
551 vector<int> localConn ( myRow[i+1] - myRow[i], -1 );
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++;
560 localConn.at(indx) = globalToLocal[j];
567 faceToLocalCellsMap[ii] = localConn;
572 shared_ptr<Array<int> > localToGlobalPtr(
new Array<int>(nLocal));
574 Array<int>& localToGlobal = *localToGlobalPtr;
577 shared_ptr<CRConnectivity> subPtr(
new CRConnectivity(newRowSite,newColSite));
582 for(
int ii=0;ii<indices.
getLength();ii++)
584 const int i = indices[ii];
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;
598 for(
int ii=0;ii<indices.
getLength();ii++)
600 const int i = indices[ii];
602 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
604 const int jLocal = faceToLocalCellsMap[ii].at(indx);
620 shared_ptr<CRConnectivity>
630 Array<int>& globalToLocal = *globalToLocalPtr;
635 for(
int ii=0;ii<indices.
getLength();ii++)
637 const int i = indices[ii];
638 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
640 const int j = myCol[ip];
641 if (globalToLocal[j] == -1)
642 globalToLocal[j] = nLocal++;
646 shared_ptr<Array<int> > localToGlobalPtr(
new Array<int>(nLocal));
648 Array<int>& localToGlobal = *localToGlobalPtr;
651 shared_ptr<CRConnectivity> subPtr(
new CRConnectivity(newRowSite,newColSite));
656 for(
int ii=0;ii<indices.
getLength();ii++)
658 const int i = indices[ii];
663 for(
int ii=0;ii<indices.
getLength();ii++)
665 const int i = indices[ii];
666 for(
int ip=myRow[i];ip<myRow[i+1]; ip++)
668 const int j = myCol[ip];
669 const int jLocal = globalToLocal[j];
675 if (globalToLocal[i] != -1)
676 localToGlobal[globalToLocal[i]] = i;
691 for (
int i = 0; i < myCol.
getLength(); i++ )
692 myCol[i] = indices[ myCol[i] ];
700 const int newColDim = newColSite.
getCount();
705 e <<
"global to local mapping is of wrong size (" <<
713 const int localIndex = globalToLocal[myCol[i]];
714 if (localIndex >=0 && localIndex < newColDim)
715 myCol[i] = localIndex;
719 e <<
"invalid global to local mapping at index " <<
743 for(
int np=0; np<pairCount; np++)
747 int n0 = pairs(np,0);
748 int n1 = pairs(np,1);
751 for(
int r0=crRow[n0]; r0<crRow[n0+1]; r0++)
754 (*pairToCol)[np][0] = r0;
762 e <<
"did not find col pos for ( " << n0 <<
"," << n1 <<
")";
767 for(
int r1=crRow[n1]; r1<crRow[n1+1]; r1++)
770 (*pairToCol)[np][1] = r1;
777 e <<
"did not find col pos for ( " << n1 <<
"," << n0 <<
")";
785 e <<
"invalid count for pairs connectivity" << endl;
795 shared_ptr<CRConnectivity>
797 const int offset,
const int size)
const
800 shared_ptr<ArrayBase> rowOffset(
_row->createOffsetArray(offset,size+1));
801 offPtr->_row = dynamic_pointer_cast<
Array<int> >(rowOffset);
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
const Array< int > & getGlobalToLocalMap() const
StorageSite const * _colSite
#define logCtorVerbose(str,...)
void reorder(const Array< int > &indices)
shared_ptr< Array< int > > _globalToLocalMap
double max(double x, double y)
void setCount(const int selfCount, const int nGhost=0)
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
const StorageSite & getRowSite() const
void addCount(const int index, const int count)
#define logDtorVerbose(str,...)
const PairToColMapping & getPairToColMapping(const CRConnectivity &pairs) const