Memosa-FVM  0.2
CRConnectivity Class Reference

#include <CRConnectivity.h>

Collaboration diagram for CRConnectivity:

Public Types

enum  CRTYPE { CELLCELL1 = 1, CELLCELL2 = 2 }
 
typedef Array< Vector< int, 2 > > PairToColMapping
 

Public Member Functions

 CRConnectivity (const StorageSite &rowSite, const StorageSite &colSite)
 
 ~CRConnectivity ()
 
 DEFINE_TYPENAME ("CRConnectivity")
 
int getRowDim () const
 
int getColDim () const
 
const StorageSitegetRowSite () const
 
const StorageSitegetColSite () const
 
shared_ptr< CRConnectivitygetTranspose () const
 
shared_ptr< CRConnectivitygetMultiTranspose (const int varSize) const
 
shared_ptr< CRConnectivitymultiply (const CRConnectivity &b, const bool implicitDiagonal) const
 
shared_ptr< CRConnectivitycreateOffset (const StorageSite &newRowSite, const int offset, const int size) const
 
shared_ptr< CRConnectivitygetSubset (const StorageSite &site, const Array< int > &indices) const
 
void reorder (const Array< int > &indices)
 
shared_ptr< CRConnectivitygetLocalizedSubset (const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices) const
 
shared_ptr< CRConnectivitygetLocalizedSubsetOfFaceCells (const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices, const CRConnectivity &faceCells, const CRConnectivity &cellCells) const
 
shared_ptr< CRConnectivitygetLocalizedSubsetOfFaceCells (const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices, const CRConnectivity &cellParts, const int partID) const
 
void localize (const Array< int > &globalToLocal, const StorageSite &newColSite)
 
int operator() (const int i, const int j) const
 
int & operator() (const int i, const int j)
 
int getCoeffPosition (const int i, const int j) const
 
int getCount (const int i) const
 
const Array< int > & getGlobalToLocalMap () const
 
const Array< int > & getLocalToGlobalMap () const
 
const map< int, int > & getGlobalToLocalMapper () const
 
map< int, int > & getGlobalToLocalMapper ()
 
shared_ptr< Array< int > > getGlobalToLocalMapPtr ()
 
shared_ptr< Array< int > > getLocalToGlobalMapPtr ()
 
const PairToColMappinggetPairToColMapping (const CRConnectivity &pairs) const
 
void clearPairToColMapping (const CRConnectivity &pairs) const
 
void setConnType (CRTYPE type)
 
const CRTYPEgetConnType () const
 
void initCount ()
 
void addCount (const int index, const int count)
 
void finishCount ()
 
int add (const int index, const int val)
 
void finishAdd ()
 
void resizeLocalToGlobalMap (int size)
 
const Array< int > & getRow () const
 
const Array< int > & getCol () const
 
Array< int > & getCol ()
 

Private Member Functions

 CRConnectivity (const CRConnectivity &)
 

Private Attributes

StorageSite const * _rowSite
 
StorageSite const * _colSite
 
int _rowDim
 
int _colDim
 
shared_ptr< Array< int > > _row
 
shared_ptr< Array< int > > _col
 
shared_ptr< Array< int > > _globalToLocalMap
 
map< int, int > _globalToLocalMapper
 
shared_ptr< Array< int > > _localToGlobalMap
 
map< const CRConnectivity
*, PairToColMapping * > 
_pairToColMappings
 
CRTYPE _connType
 

Detailed Description

Stores connectivity information using a compressed row format. Basically this means that we have a (integer) row array that stores the indices into col array (also integer) where the non zero entries for a particular row begin. Thus col[row[i]] through col[row[i+1]] store the column indices j where a sparse matrix based on this connectivity would have non zero entries.

Objects of this class can be used to store connectivities between mesh elements such as the faces of a cell or the cells surrounding a node etc. It can also be used to represent the fill pattern of an arbitrary sparse matrix (see CRMatrix).

This class provides support for constructing the connectivity in a two step fashion but is not usable for dynamically changing the connectivity. Typical usage is

– construct by specifying rowSite and colSite. Thus the dimensions are known but not the number of nonzero entries

– call initCount to start the process of counting non zeros

– call addCount to specify the number of non zeros for each row i (this can be in any order and multiple calls for same row are allowed)

– call finishCount - this allocates the col array and resets row array so that it is ready for entries to be added

– call add to specify the nonzero location j for each row i (this can also be in any order but each i,j must be specified only once)

Since we treat this connectivity as a matrix we can perform operations like transpose (to get node - cell connectvity from cell

  • node connectivity, for example) and multiplication (multiplying cell - faces with face - nodes to get cell nodes, for example)

Definition at line 52 of file CRConnectivity.h.

Member Typedef Documentation

Definition at line 55 of file CRConnectivity.h.

Member Enumeration Documentation

Enumerator
CELLCELL1 
CELLCELL2 

Definition at line 57 of file CRConnectivity.h.

Constructor & Destructor Documentation

CRConnectivity::CRConnectivity ( const StorageSite rowSite,
const StorageSite colSite 
)

Definition at line 11 of file CRConnectivity.cpp.

References _colDim, _rowDim, and logCtorVerbose.

Referenced by createOffset(), getLocalizedSubset(), getLocalizedSubsetOfFaceCells(), getMultiTranspose(), getSubset(), getTranspose(), and multiply().

12  :
13  _rowSite(&rowSite),
14  _colSite(&colSite),
17  _row(),
18  _col(),
23 {
24  logCtorVerbose("from rowSite and colSite of dimensions (%dx%d)" ,
26 }
StorageSite const * _colSite
#define logCtorVerbose(str,...)
Definition: RLogInterface.h:29
shared_ptr< Array< int > > _globalToLocalMap
shared_ptr< Array< int > > _row
StorageSite const * _rowSite
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
shared_ptr< Array< int > > _col
int getCountLevel1() const
Definition: StorageSite.h:72
shared_ptr< Array< int > > _localToGlobalMap
CRConnectivity::~CRConnectivity ( )

Definition at line 29 of file CRConnectivity.cpp.

References _colDim, _pairToColMappings, _rowDim, and logDtorVerbose.

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 }
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
#define logDtorVerbose(str,...)
Definition: RLogInterface.h:36
CRConnectivity::CRConnectivity ( const CRConnectivity )
private

Member Function Documentation

int CRConnectivity::add ( const int  index,
const int  val 
)
inline

Definition at line 123 of file CRConnectivity.h.

Referenced by Mesh::addCRConn(), KSConnectivity< T >::addOther(), KSConnectivity< T >::addSelf(), CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0(), getLocalizedSubset(), getLocalizedSubsetOfFaceCells(), getMultiTranspose(), getSubset(), getTranspose(), multiply(), and FluentReader::readFaces().

124  {
125  int pos = (*_row)[index];
126  (*_col)[pos] = val;
127  (*_row)[index]++;
128  return pos;
129  }
void CRConnectivity::addCount ( const int  index,
const int  count 
)
inline
void CRConnectivity::clearPairToColMapping ( const CRConnectivity pairs) const

Definition at line 807 of file CRConnectivity.cpp.

References _pairToColMappings.

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 }
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
Definition: Array.h:14
shared_ptr< CRConnectivity > CRConnectivity::createOffset ( const StorageSite newRowSite,
const int  offset,
const int  size 
) const

Definition at line 796 of file CRConnectivity.cpp.

References _col, _colSite, _row, and CRConnectivity().

Referenced by Mesh::getFaceCells(), and Mesh::getFaceNodes().

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 }
StorageSite const * _colSite
shared_ptr< Array< int > > _row
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
CRConnectivity::DEFINE_TYPENAME ( "CRConnectivity"  )
void CRConnectivity::finishAdd ( )
void CRConnectivity::finishCount ( )

Definition at line 47 of file CRConnectivity.cpp.

References _col, _row, and _rowDim.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0(), Mesh::countCRConn(), KSConnectivity< T >::finishCountOther(), KSConnectivity< T >::finishCountSelf(), getLocalizedSubset(), getLocalizedSubsetOfFaceCells(), getMultiTranspose(), getSubset(), getTranspose(), and multiply().

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 }
shared_ptr< Array< int > > _row
shared_ptr< Array< int > > _col
int CRConnectivity::getCoeffPosition ( const int  i,
const int  j 
) const
inline

Definition at line 150 of file CRConnectivity.h.

References _col, and _row.

Referenced by setFlatCoeffs().

151  {
152  for (int nnb = (*_row)[i]; nnb<(*_row)[i+1]; nnb++)
153  {
154  if ((*_col)[nnb] == j)
155  return nnb;
156  }
157  throw CException("invalid indices");
158  }
shared_ptr< Array< int > > _row
shared_ptr< Array< int > > _col
const Array<int>& CRConnectivity::getCol ( ) const
inline

Definition at line 183 of file CRConnectivity.h.

References _col.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0(), KineticModel< T >::computeIBFaceDsf(), COMETModel< T >::computeIBFaceDsf(), MeshMetricsCalculator< T >::computeIBInterpolationMatrices(), MeshMetricsCalculator< T >::computeIBInterpolationMatricesCells(), KineticModel< T >::computeSolidFaceDsf(), COMETModel< T >::computeSolidFaceDsf(), MeshMetricsCalculator< T >::computeSolidInterpolationMatrices(), ElectricModel< T >::Impl::computeSolidSurfaceForce(), FlowModel< T >::Impl::computeSolidSurfaceForce(), KineticModel< T >::computeSurfaceForce(), COMETModel< T >::computeSurfaceForce(), NcDataWriter::connectivities(), MeshPartitioner::CRConnectivityPrint(), Mesh::CRConnectivityPrint(), IBManager::CRConnectivityPrintFile(), MeshPartitioner::CRConnectivityPrintFile(), Mesh::CRConnectivityPrintFile(), Mesh::createAndGetBNglobalToLocal(), CRMatrixRect< T_Coeff, X, B >::createCoarseMatrix(), CRMatrix< T_Diag, T_OffDiag, X >::createCoarseMatrix(), FluentReader::createMesh(), debug_mesh(), IbmDiscretization< X, Diag, OffDiag >::discretize(), StructureSourceDiscretization< T, Diag, OffDiag >::discretizeFaces(), StructurePlasticDiscretization< T, Diag, OffDiag >::discretizeFaces(), PlateSourceDiscretization< T, Diag, OffDiag >::discretizeFaces(), FlowModel< T >::Impl::dumpContinuityMatrix(), ThermalModel< T >::Impl::dumpMatrix(), VacancyModel< T >::Impl::dumpMatrix(), PlateModel< T >::Impl::dumpMatrix(), KSConnectivity< T >::expandMySelfOther(), KSConnectivity< T >::expandMySelfSelf(), Mesh::getCellCells2(), KSConnectivity< T >::getOtherCol(), getPairToColMapping(), KSConnectivity< T >::getSelfCol(), KSConnectivity< T >::multiplyOther(), KSConnectivity< T >::multiplySelf(), setFlatCoeffs(), SpikeMatrix< T_Diag, T_OffDiag, X >::setMatrix(), SpikeStorage::setOffDiagPtr(), and Mesh::uniqueFaceCells().

183 {return *_col;}
shared_ptr< Array< int > > _col
Array<int>& CRConnectivity::getCol ( )
inline

Definition at line 184 of file CRConnectivity.h.

References _col.

184 {return *_col;}
shared_ptr< Array< int > > _col
int CRConnectivity::getColDim ( ) const
inline

Definition at line 69 of file CRConnectivity.h.

References _colDim.

Referenced by debug_mesh().

69 {return _colDim;}
const StorageSite& CRConnectivity::getColSite ( ) const
inline

Definition at line 72 of file CRConnectivity.h.

References _colSite.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0().

72 {return *_colSite;}
StorageSite const * _colSite
const CRTYPE& CRConnectivity::getConnType ( ) const
inline

Definition at line 208 of file CRConnectivity.h.

References _connType.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::eliminateBoundaryEquations().

208  {
209  return _connType;
210  }
int CRConnectivity::getCount ( const int  i) const
inline

returns the number of non zeroes for row i

Definition at line 165 of file CRConnectivity.h.

References _row.

Referenced by AABB::AABB(), Mesh::addCRConn(), addFluidNeighbors(), MovingMeshModel< T >::advance(), COMETBoundaryConditions< X, Diag, OffDiag >::applyPressureInletBC(), COMETBoundaryConditions< X, Diag, OffDiag >::applyRealWallBC(), COMETBoundary< T >::applyTemperatureWallFine(), COMETBoundaryConditions< X, Diag, OffDiag >::applyZeroGradientBC(), MeshMetricsCalculator< T >::calculateBoundaryNodeNormal(), MeshMetricsCalculator< T >::calculateCellCentroids(), MeshMetricsCalculator< T >::calculateFaceAreas(), MeshMetricsCalculator< T >::calculateFaceCentroids(), StructureDeformationModel< T >::calculateNodeDisplacement(), PlateDeformationModel< T >::calculateNodeDisplacement(), MeshPartitioner::cellcells_global_extension(), CellMark_Impl(), COMETModel< T >::coarsenInterfaceCells(), COMETModel< T >::coarsenInterior(), COMETESBGKDiscretizer< T >::COMETConvection(), COMETDiscretizer< T >::COMETConvection(), COMETDiscretizer< T >::COMETConvectionCoarse(), COMETESBGKDiscretizer< T >::COMETConvectionFine(), COMETDiscretizer< T >::COMETConvectionFine(), COMETDiscretizer< T >::correctInterface(), COMETModel< T >::correctSolution(), Mesh::countCRConn(), MeshAssembler::countInterfaceNodes(), CRMatrixRect< T_Coeff, X, B >::createCoarseConnectivity(), CRMatrix< T_Diag, T_OffDiag, X >::createCoarseConnectivity(), DiagonalMatrix< Diag, X >::createCoarseMatrix(), CRMatrixRect< T_Coeff, X, B >::createCoarseMatrix(), CRMatrix< T_Diag, T_OffDiag, X >::createCoarseMatrix(), IBManager::createIBInterpolationStencil(), Mesh::createScatterGatherCountsBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherCountsBuffer(), Mesh::createScatterGatherIndicesBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherIndicesBuffer(), GradientMatrix< T_Scalar >::createScatterGatherValuesBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherValuesCRMtrxBuffer(), IBManager::createSolidInterpolationStencil(), MeshDismantler::debug_face_cells(), MeshDismantler::debug_face_nodes(), TrapBandTunnelingDiscretization< X, Diag, OffDiag >::discretize(), LinearizeDielectric< X, Diag, OffDiag >::discretize(), InjectionDiscretization< X, Diag, OffDiag >::discretize(), TunnelingDiscretization< X, Diag, OffDiag >::discretize(), PartMesh::dumpTecplot(), MeshPartitioner::extractBoundaryMesh(), Mesh::extractBoundaryMesh(), Mesh::extrude(), MeshDismantler::faceNodesAddBoundaryInterfaces(), MeshDismantler::faceNodesAddInteriorFaces(), MeshDismantler::faceNodesAddMeshInterfaces(), MeshDismantler::faceNodesAddPartitionInterfaces(), MeshDismantler::faceNodesInit(), Mesh::findCommonNodes(), Grid::findNeighborsByCells(), MeshPartitioner::get_local_nodes(), Mesh::getCellCells2(), MeshAssembler::getInnerNodesCount(), getLocalizedSubset(), getLocalizedSubsetOfFaceCells(), KSConnectivity< T >::getOtherCount(), getPairToColMapping(), KSConnectivity< T >::getSelfCount(), getSubset(), MeshPartitioner::globalCellID_procID_map(), inCell(), COMETModel< T >::injectResid(), MeshPartitioner::level1_scatter_gather_cells(), PartMesh::local_nodes(), COMETModel< T >::makeCellColors(), COMETModel< T >::MakeCoarseMesh1(), COMETModel< T >::MakeInteriorCoarseMesh(), markCell(), IBManager::markFluid(), IBManager::markIntersections(), PartMesh::mesh_tecplot(), MeshPartitioner::mesh_tecplot(), PartMesh::mesh_xdmfplot(), MeshPartitioner::mesh_xdmfplot(), AABB::meshIntersections(), Cell< CellTrait >::orderCellFacesAndNodes(), orderCellFacesAndNodes(), COMETDiscretizer< T >::ScatterPhonons(), MeshPartitioner::set_cellcells_global(), PartMesh::set_eptr_eind(), MeshPartitioner::set_eptr_eind(), MeshDismantler::set_local_global(), MeshPartitioner::set_local_global(), COMETESBGKDiscretizer< T >::setBoundaryValFine(), Mesh::setCommonFacesMap(), MeshAssembler::setFaceNodes(), setibFaceCells(), setibFaceParticles(), MeshAssembler::setInterfaceNodes(), MeshAssembler::setNodesMapper(), MeshDismantler::setNodesMapper(), MeshDismantler::setNodesSite(), FVMParticles::setParticles(), StructureDeformationModel< T >::updateBoundaryMesh(), PlateDeformationModel< T >::updateBoundaryMesh(), COMETDiscretizer< T >::updateGhostCoarse(), COMETDiscretizer< T >::updateGhostFine(), MovingMeshModel< T >::volChange(), and VTKWriter< T >::VTKWriter().

166  {
167  return ((*_row)[i+1] - (*_row)[i]);
168  }
shared_ptr< Array< int > > _row
const Array<int>& CRConnectivity::getGlobalToLocalMap ( ) const
inline

Definition at line 189 of file CRConnectivity.h.

References _globalToLocalMap.

Referenced by getLocalizedSubsetOfFaceCells(), and MeshPartitioner::preserve_cell_order().

189 {return *_globalToLocalMap;}
shared_ptr< Array< int > > _globalToLocalMap
const map<int,int>& CRConnectivity::getGlobalToLocalMapper ( ) const
inline

Definition at line 192 of file CRConnectivity.h.

References _globalToLocalMapper.

192 {return _globalToLocalMapper;}
map< int, int > _globalToLocalMapper
map<int,int>& CRConnectivity::getGlobalToLocalMapper ( )
inline

Definition at line 193 of file CRConnectivity.h.

References _globalToLocalMapper.

193 {return _globalToLocalMapper;}
map< int, int > _globalToLocalMapper
shared_ptr<Array<int> > CRConnectivity::getGlobalToLocalMapPtr ( )
inline

Definition at line 195 of file CRConnectivity.h.

References _globalToLocalMap.

195 {return _globalToLocalMap;}
shared_ptr< Array< int > > _globalToLocalMap
shared_ptr< CRConnectivity > CRConnectivity::getLocalizedSubset ( const StorageSite newRowSite,
StorageSite newColSite,
const Array< int > &  indices 
) const

Definition at line 621 of file CRConnectivity.cpp.

References _col, _colDim, _globalToLocalMap, _localToGlobalMap, _row, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), getCount(), Array< T >::getLength(), initCount(), and StorageSite::setCount().

Referenced by debug_mesh().

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 }
int getCount(const int i) const
shared_ptr< Array< int > > _globalToLocalMap
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
shared_ptr< Array< int > > _row
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
shared_ptr< Array< int > > _localToGlobalMap
int add(const int index, const int val)
void addCount(const int index, const int count)
int getLength() const
Definition: Array.h:87
shared_ptr< CRConnectivity > CRConnectivity::getLocalizedSubsetOfFaceCells ( const StorageSite newRowSite,
StorageSite newColSite,
const Array< int > &  indices,
const CRConnectivity faceCells,
const CRConnectivity cellCells 
) const

Definition at line 311 of file CRConnectivity.cpp.

References _col, _colDim, _globalToLocalMap, _localToGlobalMap, _row, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), getCount(), getGlobalToLocalMap(), Array< T >::getLength(), getRowDim(), initCount(), max(), and StorageSite::setCount().

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 }
int getCount(const int i) const
const Array< int > & getGlobalToLocalMap() const
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
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
shared_ptr< Array< int > > _localToGlobalMap
int add(const int index, const int val)
int getRowDim() const
void addCount(const int index, const int count)
int getLength() const
Definition: Array.h:87
shared_ptr< CRConnectivity > CRConnectivity::getLocalizedSubsetOfFaceCells ( const StorageSite newRowSite,
StorageSite newColSite,
const Array< int > &  indices,
const CRConnectivity cellParts,
const int  partID 
) const

Definition at line 457 of file CRConnectivity.cpp.

References _col, _globalToLocalMap, _localToGlobalMap, _row, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), StorageSite::getCount(), getCount(), Array< T >::getLength(), getRowSite(), StorageSite::getSelfCount(), initCount(), and StorageSite::setCount().

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 }
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
shared_ptr< Array< int > > _globalToLocalMap
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
shared_ptr< Array< int > > _row
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
shared_ptr< Array< int > > _localToGlobalMap
int add(const int index, const int val)
int getCount() const
Definition: StorageSite.h:39
const StorageSite & getRowSite() const
void addCount(const int index, const int count)
int getLength() const
Definition: Array.h:87
const Array<int>& CRConnectivity::getLocalToGlobalMap ( ) const
inline
shared_ptr<Array<int> > CRConnectivity::getLocalToGlobalMapPtr ( )
inline

Definition at line 196 of file CRConnectivity.h.

References _localToGlobalMap.

196 {return _localToGlobalMap;}
shared_ptr< Array< int > > _localToGlobalMap
shared_ptr< CRConnectivity > CRConnectivity::getMultiTranspose ( const int  varSize) const

Definition at line 101 of file CRConnectivity.cpp.

References _col, _colDim, _colSite, _row, _rowDim, _rowSite, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), and initCount().

Referenced by DirectSolver::solve().

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 }
StorageSite const * _colSite
shared_ptr< Array< int > > _row
StorageSite const * _rowSite
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
int add(const int index, const int val)
void addCount(const int index, const int count)
const Array< Vector< int, 2 > > & CRConnectivity::getPairToColMapping ( const CRConnectivity pairs) const

Definition at line 730 of file CRConnectivity.cpp.

References _pairToColMappings, getCol(), getCount(), getRow(), and getRowDim().

Referenced by CRMatrixRect< T_Coeff, X, B >::getPairWiseAssembler(), and CRMatrix< T_Diag, T_OffDiag, X >::getPairWiseAssembler().

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 }
const Array< int > & getCol() const
int getCount(const int i) const
const Array< int > & getRow() const
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
int getRowDim() const
const Array<int>& CRConnectivity::getRow ( ) const
inline

Definition at line 182 of file CRConnectivity.h.

References _row.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0(), KineticModel< T >::computeIBFaceDsf(), COMETModel< T >::computeIBFaceDsf(), MeshMetricsCalculator< T >::computeIBInterpolationMatrices(), MeshMetricsCalculator< T >::computeIBInterpolationMatricesCells(), KineticModel< T >::computeSolidFaceDsf(), COMETModel< T >::computeSolidFaceDsf(), MeshMetricsCalculator< T >::computeSolidInterpolationMatrices(), ElectricModel< T >::Impl::computeSolidSurfaceForce(), FlowModel< T >::Impl::computeSolidSurfaceForce(), KineticModel< T >::computeSurfaceForce(), COMETModel< T >::computeSurfaceForce(), NcDataWriter::connectivities(), MeshPartitioner::CRConnectivityPrint(), Mesh::CRConnectivityPrint(), IBManager::CRConnectivityPrintFile(), MeshPartitioner::CRConnectivityPrintFile(), Mesh::CRConnectivityPrintFile(), Mesh::createAndGetBNglobalToLocal(), CRMatrixRect< T_Coeff, X, B >::createCoarseMatrix(), CRMatrix< T_Diag, T_OffDiag, X >::createCoarseMatrix(), FluentReader::createMesh(), debug_mesh(), IbmDiscretization< X, Diag, OffDiag >::discretize(), MomentumPressureGradientDiscretization< X >::discretize(), StructureSourceDiscretization< T, Diag, OffDiag >::discretizeFaces(), StructurePlasticDiscretization< T, Diag, OffDiag >::discretizeFaces(), PlateSourceDiscretization< T, Diag, OffDiag >::discretizeFaces(), FlowModel< T >::Impl::dumpContinuityMatrix(), VacancyModel< T >::Impl::dumpMatrix(), ThermalModel< T >::Impl::dumpMatrix(), PlateModel< T >::Impl::dumpMatrix(), KSConnectivity< T >::expandMySelfOther(), KSConnectivity< T >::expandMySelfSelf(), Mesh::getCellCells2(), GradientModel< Vector< T, 3 > >::getLeastSquaresGradientMatrix2D(), GradientModel< Vector< T, 3 > >::getLeastSquaresGradientMatrix3D(), KSConnectivity< T >::getOtherRow(), getPairToColMapping(), KSConnectivity< T >::getSelfRow(), KSConnectivity< T >::multiplyOther(), KSConnectivity< T >::multiplySelf(), FlowModel< T >::Impl::setDirichlet(), MeshAssembler::setFaceNodes(), setFlatCoeffs(), SpikeMatrix< T_Diag, T_OffDiag, X >::setMatrix(), SpikeStorage::setOffDiagPtr(), and Mesh::uniqueFaceCells().

182 {return *_row;}
shared_ptr< Array< int > > _row
const StorageSite& CRConnectivity::getRowSite ( ) const
inline

Definition at line 71 of file CRConnectivity.h.

References _rowSite.

Referenced by CRMatrix< T_Diag, T_OffDiag, X >::compute_ILU0(), CRMatrix< T_Diag, T_OffDiag, X >::computeResidual(), CRMatrix< T_Diag, T_OffDiag, X >::createCoarsening(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherCountsBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherIndicesBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherValuesBBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::createScatterGatherValuesCRMtrxBuffer(), CRMatrix< T_Diag, T_OffDiag, X >::eliminateBoundaryEquations(), CRMatrix< T_Diag, T_OffDiag, X >::eliminateRow(), CRMatrix< T_Diag, T_OffDiag, X >::eliminateRowGhost(), CRMatrix< T_Diag, T_OffDiag, X >::forwardGS(), SpikeStorage::gatherCellSizes(), CRMatrix< T_Diag, T_OffDiag, X >::get_request_size(), Mesh::getCellCells2(), GradientMatrix< T_Scalar >::getGradient(), getLocalizedSubsetOfFaceCells(), SpikeStorage::init(), CRMatrix< T_Diag, T_OffDiag, X >::Jacobi(), CRMatrix< T_Diag, T_OffDiag, X >::lowerSolve(), CRMatrixRect< T_Coeff, X, B >::multiply(), CRMatrix< T_Diag, T_OffDiag, X >::multiply(), CRMatrixTranspose< T_Coeff, X, B >::multiplyAndAdd(), CRMatrixRect< T_Coeff, X, B >::multiplyAndAdd(), CRMatrix< T_Diag, T_OffDiag, X >::multiplyAndAdd(), orderCellFacesAndNodes(), CRMatrix< T_Diag, T_OffDiag, X >::quadProduct(), CRMatrix< T_Diag, T_OffDiag, X >::reverseGS(), SpikeStorage::setGlobalIndices(), CRMatrix< T_Diag, T_OffDiag, X >::solveBoundary(), SpikeStorage::syncCellIDs(), CRMatrix< T_Diag, T_OffDiag, X >::syncCounts(), CRMatrix< T_Diag, T_OffDiag, X >::syncIndices(), CRMatrix< T_Diag, T_OffDiag, X >::syncValuesB(), CRMatrix< T_Diag, T_OffDiag, X >::syncValuesCRMtrx(), CRMatrix< T_Diag, T_OffDiag, X >::transpose(), Mesh::uniqueFaceCells(), and CRMatrix< T_Diag, T_OffDiag, X >::upperSolve().

71 {return *_rowSite;}
StorageSite const * _rowSite
shared_ptr< CRConnectivity > CRConnectivity::getSubset ( const StorageSite site,
const Array< int > &  indices 
) const

Definition at line 274 of file CRConnectivity.cpp.

References _col, _colSite, _row, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), getCount(), Array< T >::getLength(), and initCount().

Referenced by debug_mesh().

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 }
int getCount(const int i) const
StorageSite const * _colSite
shared_ptr< Array< int > > _row
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
int add(const int index, const int val)
void addCount(const int index, const int count)
int getLength() const
Definition: Array.h:87
shared_ptr< CRConnectivity > CRConnectivity::getTranspose ( ) const

Definition at line 74 of file CRConnectivity.cpp.

References _col, _colSite, _row, _rowDim, _rowSite, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), and initCount().

Referenced by StructureDeformationModel< T >::calculateNodeDisplacement(), PlateDeformationModel< T >::calculateNodeDisplacement(), COMETModel< T >::coarsenInterfaceCells(), Mesh::getCellFaces(), FluentReader::getNodeCells(), MeshDismantler::init(), COMETModel< T >::makeFinestToCoarseConn(), COMETModel< T >::MakeInteriorCoarseMesh(), and Mesh::setCommonFacesMap().

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 }
StorageSite const * _colSite
shared_ptr< Array< int > > _row
StorageSite const * _rowSite
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
int add(const int index, const int val)
void addCount(const int index, const int count)
void CRConnectivity::initCount ( )
void CRConnectivity::localize ( const Array< int > &  globalToLocal,
const StorageSite newColSite 
)

Definition at line 697 of file CRConnectivity.cpp.

References _col, _colDim, _colSite, StorageSite::getCount(), and Array< T >::getLength().

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 }
StorageSite const * _colSite
shared_ptr< Array< int > > _col
int getCount() const
Definition: StorageSite.h:39
int getLength() const
Definition: Array.h:87
shared_ptr< CRConnectivity > CRConnectivity::multiply ( const CRConnectivity b,
const bool  implicitDiagonal 
) const

Definition at line 168 of file CRConnectivity.cpp.

References _col, _colDim, _colSite, _row, _rowDim, _rowSite, add(), addCount(), CRConnectivity(), finishAdd(), finishCount(), and initCount().

Referenced by COMETModel< T >::coarsenInterfaceCells(), Mesh::getCellCells(), Mesh::getCellCells2(), FluentReader::getCellNodes(), Mesh::getFaceCells2(), and COMETModel< T >::MakeInteriorCoarseMesh().

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 }
StorageSite const * _colSite
shared_ptr< Array< int > > _row
StorageSite const * _rowSite
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
shared_ptr< Array< int > > _col
int add(const int index, const int val)
void addCount(const int index, const int count)
int CRConnectivity::operator() ( const int  i,
const int  j 
) const
inline

Definition at line 135 of file CRConnectivity.h.

References _col.

136  {
137  return (*_col)[(*_row)[i]+j];
138  }
shared_ptr< Array< int > > _col
int& CRConnectivity::operator() ( const int  i,
const int  j 
)
inline

returns the index of the j'th non zero column for row i

Definition at line 145 of file CRConnectivity.h.

References _col.

146  {
147  return (*_col)[(*_row)[i]+j];
148  }
shared_ptr< Array< int > > _col
void CRConnectivity::reorder ( const Array< int > &  indices)

Definition at line 687 of file CRConnectivity.cpp.

References _col, and Array< T >::getLength().

Referenced by MeshPartitioner::fiedler_partition().

688 {
689  Array<int>& myCol = *_col;
690 
691  for ( int i = 0; i < myCol.getLength(); i++ )
692  myCol[i] = indices[ myCol[i] ];
693 }
shared_ptr< Array< int > > _col
int getLength() const
Definition: Array.h:87
void CRConnectivity::resizeLocalToGlobalMap ( int  size)
inline

direct access to row and col array

Definition at line 177 of file CRConnectivity.h.

References _localToGlobalMap.

178  {
179  _localToGlobalMap = shared_ptr< Array<int> > ( new Array<int>(size) );
180  }
shared_ptr< Array< int > > _localToGlobalMap
void CRConnectivity::setConnType ( CRTYPE  type)
inline

Definition at line 204 of file CRConnectivity.h.

References _connType.

204  {
205  _connType = type;
206  }

Member Data Documentation

int CRConnectivity::_colDim
mutableprivate
StorageSite const* CRConnectivity::_colSite
mutableprivate
CRTYPE CRConnectivity::_connType
private

Definition at line 225 of file CRConnectivity.h.

Referenced by getConnType(), and setConnType().

shared_ptr<Array<int> > CRConnectivity::_globalToLocalMap
private
map<int,int> CRConnectivity::_globalToLocalMapper
private

Definition at line 222 of file CRConnectivity.h.

Referenced by getGlobalToLocalMapper().

shared_ptr<Array<int> > CRConnectivity::_localToGlobalMap
private
map<const CRConnectivity*, PairToColMapping*> CRConnectivity::_pairToColMappings
mutableprivate

Definition at line 224 of file CRConnectivity.h.

Referenced by clearPairToColMapping(), getPairToColMapping(), and ~CRConnectivity().

int CRConnectivity::_rowDim
mutableprivate
StorageSite const* CRConnectivity::_rowSite
mutableprivate

Definition at line 215 of file CRConnectivity.h.

Referenced by getMultiTranspose(), getRowSite(), getTranspose(), and multiply().


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