Memosa-FVM  0.2
MeshAssembler Class Reference

#include <MeshAssembler.h>

Public Types

typedef shared_ptr< Array
< double > > 
ArrayDblePtr
 
typedef shared_ptr< Array< int > > ArrayIntPtr
 
typedef map< int, ArrayIntPtrArrayIntPtrMap
 
typedef shared_ptr< StorageSiteStorageSitePtr
 
typedef shared_ptr
< CRConnectivity
CRConnectivityPtr
 
typedef shared_ptr< Array
< Mesh::VecD3 > > 
ArrayVecD3Ptr
 
typedef vector< map< int, set
< int > > > 
VecMap
 

Public Member Functions

 MeshAssembler (const MeshList &meshList)
 
 ~MeshAssembler ()
 
const MeshListmeshList () const
 
void debug_print ()
 
void debug_sites ()
 
void debug_localToGlobal_mappers ()
 
void debug_globalCellToMeshID_mappers ()
 
void debug_sync_localToGlobal_mappers ()
 
void debug_faceCells ()
 
void debug_localNodeToGlobal ()
 

Private Member Functions

 MeshAssembler (const MeshAssembler &)
 
void init ()
 
void setCellsSite ()
 
void setFacesSite ()
 
void setInterfaceNodes ()
 
void setNodesSite ()
 
void setCellsMapper ()
 
void setNodesMapper ()
 
void setBoundaryFaceGroup ()
 
void setCoord ()
 
void setSites ()
 
void setMeshCellColor ()
 
void setFaceCells ()
 
void setFaceNodes ()
 
void setMesh ()
 
void countInterfaceNodes ()
 
int getInnerNodesCount ()
 
int getInterfaceNodesDuplicatedCount ()
 
int getInterfaceNodesCount ()
 
void debug_file_open (const string &fname)
 
void debug_file_close ()
 

Private Attributes

const MeshList _meshList
 
StorageSitePtr _cellSite
 
StorageSitePtr _faceSite
 
StorageSitePtr _nodeSite
 
VecMap _interfaceNodesSet
 
map< int, ArrayIntPtr_localCellToGlobal
 
vector< int > _globalCellToMeshID
 
vector< int > _globalCellToLocal
 
vector< map< int, int > > _localInterfaceNodesToGlobalMap
 
map< int, ArrayIntPtr_localNodeToGlobal
 
set< Mesh::VecD3_interfaceNodeCoord
 
CRConnectivityPtr _faceCells
 
CRConnectivityPtr _faceNodes
 
ArrayVecD3Ptr _coord
 
ofstream _debugFile
 
int _nInterfaceNodes
 
int _interiorFaceSize
 
MeshList _mesh
 

Detailed Description

Definition at line 15 of file MeshAssembler.h.

Member Typedef Documentation

typedef shared_ptr< Array<double> > MeshAssembler::ArrayDblePtr

Definition at line 19 of file MeshAssembler.h.

typedef shared_ptr< Array<int> > MeshAssembler::ArrayIntPtr

Definition at line 20 of file MeshAssembler.h.

Definition at line 21 of file MeshAssembler.h.

Definition at line 25 of file MeshAssembler.h.

Definition at line 23 of file MeshAssembler.h.

Definition at line 22 of file MeshAssembler.h.

typedef vector< map<int, set<int> > > MeshAssembler::VecMap

Definition at line 26 of file MeshAssembler.h.

Constructor & Destructor Documentation

MeshAssembler::MeshAssembler ( const MeshList meshList)

Definition at line 15 of file MeshAssembler.cpp.

References init().

16 {
17 
18  init();
19 }
const MeshList & meshList() const
Definition: MeshAssembler.h:34
const MeshList _meshList
Definition: MeshAssembler.h:76
MeshAssembler::~MeshAssembler ( )

Definition at line 21 of file MeshAssembler.cpp.

References _mesh.

22 {
23  vector< Mesh* >::iterator it_mesh;
24  for ( it_mesh = _mesh.begin(); it_mesh != _mesh.end(); it_mesh++)
25  delete *it_mesh;
26 }
MeshList _mesh
MeshAssembler::MeshAssembler ( const MeshAssembler )
private

Member Function Documentation

void MeshAssembler::countInterfaceNodes ( )
private

Definition at line 135 of file MeshAssembler.cpp.

References _meshList, Mesh::getCellFaces(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getFaces(), StorageSite::getGatherMap(), Array< T >::getLength(), and StorageSite::getScatterMap().

136 {
137 
138  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
139  const Mesh& mesh = *(_meshList.at(n));
140  const StorageSite& faceSite = mesh.getFaces();
141  const CRConnectivity& cellFaces = mesh.getCellFaces();
142  for ( int i = 0; i < faceSite.getCount(); i++ ){
143  cout << " cellFaces[" << i << " ] = ";
144  for ( int j = 0; j < cellFaces.getCount(i); j++ )
145  cout << " " << cellFaces(i,j);
146  cout << endl;
147  }
148  }
149  //writing mapping
150  for ( unsigned int i = 0; i < _meshList.size(); i++ ){
151  const StorageSite& thisSite = _meshList[i]->getCells();
152  const StorageSite::ScatterMap& scatterMap = thisSite.getScatterMap();
153  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
154  const StorageSite& oSite = *(mpos.first);
155  const Array<int>& fromIndices = *(mpos.second);
156  const Array<int>& toIndices = *(oSite.getGatherMap().find(&thisSite)->second);
157  cout << " fromIndices.getLength() = " << fromIndices.getLength() << endl;
158  cout << " scatterArray " << endl;
159  for ( int n = 0; n < fromIndices.getLength(); n++){
160  cout << " fromIndices[" << n << "] = " << fromIndices[n] << " toIndices[" << n << "] = " << toIndices[n] << endl;
161  }
162  }
163  }
164 
165 }
int getCount(const int i) const
Definition: Mesh.h:49
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
const StorageSite & getFaces() const
Definition: Mesh.h:108
const MeshList _meshList
Definition: MeshAssembler.h:76
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
int getCount() const
Definition: StorageSite.h:39
int getLength() const
Definition: Array.h:87
void MeshAssembler::debug_faceCells ( )

Definition at line 772 of file MeshAssembler.cpp.

References _debugFile, _faceCells, _faceSite, debug_file_close(), and debug_file_open().

Referenced by debug_print().

773 {
774  debug_file_open("faceCells");
775  //faceCells
776  _debugFile << " faceCells Connectivity " << endl;
777  for ( int i = 0; i < _faceSite->getCount(); i++ ) {
778  int ncells = _faceCells->getCount(i);
779  for ( int j = 0; j < ncells; j++ ){
780  _debugFile << " faceCells(" << i << "," << j << ") = " << (*_faceCells)(i,j);
781  }
782  _debugFile << endl;
783  }
785 }
ofstream _debugFile
Definition: MeshAssembler.h:97
void debug_file_open(const string &fname)
CRConnectivityPtr _faceCells
Definition: MeshAssembler.h:93
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79
void debug_file_close()
void MeshAssembler::debug_file_close ( )
private
void MeshAssembler::debug_file_open ( const string &  fname)
private

Definition at line 817 of file MeshAssembler.cpp.

References _debugFile.

Referenced by debug_faceCells(), debug_globalCellToMeshID_mappers(), debug_localNodeToGlobal(), debug_localToGlobal_mappers(), debug_sites(), and debug_sync_localToGlobal_mappers().

818 {
819  string fname = "MESHASSEMBLER_"+fname_+".dat";
820  _debugFile.open( fname.c_str() );
821 }
ofstream _debugFile
Definition: MeshAssembler.h:97
void MeshAssembler::debug_globalCellToMeshID_mappers ( )

Definition at line 738 of file MeshAssembler.cpp.

References _debugFile, _globalCellToLocal, _globalCellToMeshID, debug_file_close(), and debug_file_open().

Referenced by debug_print().

739 {
740  debug_file_open("globalCellToMeshID");
741  //globalCellToMeshID
742  for ( unsigned int i = 0; i < _globalCellToMeshID.size(); i++ )
743  _debugFile << " globalCellToMeshID[" << i << "] = " << _globalCellToMeshID[i] << endl;
744 
745  _debugFile << endl;
746  //globalCellToLocal
747  for ( unsigned int i = 0; i < _globalCellToLocal.size(); i++ )
748  _debugFile << " globalCellToLocal[" << i << "] = " << _globalCellToLocal[i] << endl;
749 
751 }
ofstream _debugFile
Definition: MeshAssembler.h:97
vector< int > _globalCellToLocal
Definition: MeshAssembler.h:86
void debug_file_open(const string &fname)
vector< int > _globalCellToMeshID
Definition: MeshAssembler.h:85
void debug_file_close()
void MeshAssembler::debug_localNodeToGlobal ( )

Definition at line 788 of file MeshAssembler.cpp.

References _debugFile, _localNodeToGlobal, _meshList, debug_file_close(), debug_file_open(), and Array< T >::getLength().

Referenced by debug_print().

789 {
790  debug_file_open("localNodeToGlobal");
791  //localNodeToGlobal
792  _debugFile << " localNodeToGlobal " << endl;
793  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
794  const Array<int>& localToGlobal = *_localNodeToGlobal[n];
795  for ( int i = 0; i < localToGlobal.getLength(); i++ )
796  _debugFile << " localToGlobal[" << i << "] = " << localToGlobal[i] << endl;
797  _debugFile << endl;
798  }
800 }
ofstream _debugFile
Definition: MeshAssembler.h:97
void debug_file_open(const string &fname)
map< int, ArrayIntPtr > _localNodeToGlobal
Definition: MeshAssembler.h:89
const MeshList _meshList
Definition: MeshAssembler.h:76
void debug_file_close()
int getLength() const
Definition: Array.h:87
void MeshAssembler::debug_localToGlobal_mappers ( )

Definition at line 723 of file MeshAssembler.cpp.

References _debugFile, _localCellToGlobal, _meshList, debug_file_close(), debug_file_open(), and Array< T >::getLength().

Referenced by debug_print().

724 {
725  debug_file_open("localToGlobal");
726  //mapLocalToGlobal
727  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
728  _debugFile << " mesh = " << n << endl;
729  const Array<int>& localToGlobal = *_localCellToGlobal[n];
730  for ( int i = 0; i < localToGlobal.getLength(); i++ )
731  _debugFile << " localCellToGlobal[" << i << "] = " << localToGlobal[i] << endl;
732  _debugFile << endl;
733  }
735 }
ofstream _debugFile
Definition: MeshAssembler.h:97
void debug_file_open(const string &fname)
const MeshList _meshList
Definition: MeshAssembler.h:76
map< int, ArrayIntPtr > _localCellToGlobal
Definition: MeshAssembler.h:84
void debug_file_close()
int getLength() const
Definition: Array.h:87
void MeshAssembler::debug_sites ( )

Definition at line 712 of file MeshAssembler.cpp.

References _cellSite, _debugFile, _faceSite, _nodeSite, debug_file_close(), and debug_file_open().

Referenced by debug_print().

713 {
714  debug_file_open("sites");
715  _debugFile << " cells.getSelfCount() = " << _cellSite->getSelfCount() << " cells.selfCount() = " << _cellSite->getCount() << endl;
716  _debugFile << " faces.getSelfCount() = " << _faceSite->getSelfCount() << " faces.selfCount() = " << _faceSite->getCount() << endl;
717  _debugFile << " nodes.getSelfCount() = " << _nodeSite->getSelfCount() << " nodes.selfCount() = " << _nodeSite->getCount() << endl;
719 }
ofstream _debugFile
Definition: MeshAssembler.h:97
StorageSitePtr _cellSite
Definition: MeshAssembler.h:78
void debug_file_open(const string &fname)
StorageSitePtr _nodeSite
Definition: MeshAssembler.h:80
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79
void debug_file_close()
void MeshAssembler::debug_sync_localToGlobal_mappers ( )

Definition at line 755 of file MeshAssembler.cpp.

References _debugFile, _localCellToGlobal, _meshList, debug_file_close(), debug_file_open(), and Array< T >::getLength().

Referenced by debug_print().

756 {
757  debug_file_open("syncLocalToGlobal");
758  //printing things
759  _debugFile << " localCellToGlobal after sync() opeartion " << endl;
760  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
761  const Array<int>& localToGlobal = *_localCellToGlobal[n];
762  _debugFile << " mesh = " << n << endl;
763  for ( int i = 0; i < localToGlobal.getLength(); i++ )
764  _debugFile << " localToGlobal[" << i << "] = " << localToGlobal[i] << endl;
765  _debugFile << endl;
766  }
768 }
ofstream _debugFile
Definition: MeshAssembler.h:97
void debug_file_open(const string &fname)
const MeshList _meshList
Definition: MeshAssembler.h:76
map< int, ArrayIntPtr > _localCellToGlobal
Definition: MeshAssembler.h:84
void debug_file_close()
int getLength() const
Definition: Array.h:87
int MeshAssembler::getInnerNodesCount ( )
private

Definition at line 436 of file MeshAssembler.cpp.

References _interfaceNodesSet, _meshList, Mesh::getAllFaceNodes(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getFaces(), Mesh::getInterfaceGroupCount(), Mesh::getInterfaceGroups(), and Array< T >::getLength().

Referenced by setNodesSite().

436  {
437  int nodeCount = 0;
438  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
439  const Mesh& mesh = *(_meshList.at(n));
440  const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
441  const StorageSite& site = _meshList[n]->getNodes();
442  Array<int> nodeArray( site.getCount() );
443  nodeArray = -1;
444  //looop over interior faces
445  int nface = mesh.getFaces().getCount();
446  for ( int i = 0; i < nface; i++ )
447  //loop over face surronding nodes
448  for ( int node = 0; node < faceNodes.getCount(i); node++ )
449  nodeArray[ faceNodes(i,node) ] = 1;
450 
451  //loop over interface faces to reset
452  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
453  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
454  int id = faceGroupList[i]->id;
455  set<int>& nodes = _interfaceNodesSet[n][id];
456  foreach ( const set<int>::value_type node, nodes )
457  nodeArray[ node] = -1; //reseting again, we want to seperate inner/boundary nodes than interface nodes
458  }
459  //node count
460  for ( int i = 0; i < nodeArray.getLength(); i++ )
461  if ( nodeArray[i] != -1 ) nodeCount++;
462  }
463 
464  return nodeCount;
465 }
const CRConnectivity & getAllFaceNodes() const
Definition: Mesh.cpp:368
int getCount(const int i) const
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const StorageSite & getFaces() const
Definition: Mesh.h:108
const MeshList _meshList
Definition: MeshAssembler.h:76
int getCount() const
Definition: StorageSite.h:39
VecMap _interfaceNodesSet
Definition: MeshAssembler.h:82
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
int getLength() const
Definition: Array.h:87
int MeshAssembler::getInterfaceNodesCount ( )
private

Definition at line 488 of file MeshAssembler.cpp.

References _interfaceNodesSet, _localInterfaceNodesToGlobalMap, _meshList, _nInterfaceNodes, Mesh::getInterfaceGroupCount(), Mesh::getInterfaceGroups(), getInterfaceNodesDuplicatedCount(), and Mesh::getNodeCoordinates().

Referenced by setNodesSite().

489 {
490  //count nodes on shared interfaces (duplicated)
491  int nInterfaceNodes = getInterfaceNodesDuplicatedCount();
492 
493  Array< Mesh::VecD3 > interfaceNodeValues ( nInterfaceNodes );
494  Array< int > globalIndx ( nInterfaceNodes );
495  globalIndx = -1;
496 
497  //filing interfaceNodeValues
498  int indx = 0;
499  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
500  const Mesh& mesh = *(_meshList.at(n));
501  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
502  const Array<Mesh::VecD3>& coord = mesh.getNodeCoordinates();
503  //looop over interfaces
504  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
505  int id = faceGroupList[i]->id;
506  const set<int>& nodes = _interfaceNodesSet[n][id];
507  foreach ( const set<int>::value_type node, nodes ){
508  interfaceNodeValues[indx] = coord[node];
509  indx++;
510  }
511  }
512  }
513 
514  //greedy algorithm to fill interfaceNodeCount
515  indx =0;
516  for ( int i = 0; i < nInterfaceNodes; i++ ){
517  if ( globalIndx[i] == -1 ){
518  globalIndx[i] = indx;
519  double x = interfaceNodeValues[i][0];
520  double y = interfaceNodeValues[i][1];
521  double z = interfaceNodeValues[i][2];
522  for ( int j = i+1; j < nInterfaceNodes; j++ ){
523  if ( globalIndx[j] == -1 ){
524  double xOther = interfaceNodeValues[j][0];
525  double yOther = interfaceNodeValues[j][1];
526  double zOther = interfaceNodeValues[j][2];
527  if ( x == xOther && y == yOther && z == zOther )
528  globalIndx[j] = indx;
529  }
530  }
531  indx++;
532  }
533  }
534 
535 
536  _nInterfaceNodes = indx;
537  //filling localInterfaceNodes to GlobalNodes data structure
538  indx = 0;
539  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
540  const Mesh& mesh = *(_meshList.at(n));
541  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
542  //looop over interfaces
543  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
544  int id = faceGroupList[i]->id;
545  const set<int>& nodes = _interfaceNodesSet[n][id];
546  foreach ( const set<int>::value_type node, nodes ){
547  _localInterfaceNodesToGlobalMap[n][node] = globalIndx[indx];
548  indx++;
549  }
550  }
551  }
552 
553  return _nInterfaceNodes;
554 }
int getInterfaceNodesDuplicatedCount()
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
const Array< VecD3 > & getNodeCoordinates() const
Definition: Mesh.h:218
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
Definition: Array.h:14
vector< map< int, int > > _localInterfaceNodesToGlobalMap
Definition: MeshAssembler.h:88
VecMap _interfaceNodesSet
Definition: MeshAssembler.h:82
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
int MeshAssembler::getInterfaceNodesDuplicatedCount ( )
private

Definition at line 469 of file MeshAssembler.cpp.

References _interfaceNodesSet, _meshList, Mesh::getInterfaceGroupCount(), and Mesh::getInterfaceGroups().

Referenced by getInterfaceNodesCount().

470 {
471  //loop over meshes
472  int nInterfaceNodes = 0;
473  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
474  const Mesh& mesh = *(_meshList.at(n));
475  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
476  //looop over interfaces
477  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
478  int id = faceGroupList[i]->id;
479  const set<int>& nodes = _interfaceNodesSet[n][id];
480  nInterfaceNodes += nodes.size();
481  }
482  }
483  return nInterfaceNodes;
484 }
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
VecMap _interfaceNodesSet
Definition: MeshAssembler.h:82
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
void MeshAssembler::init ( )
private

Definition at line 30 of file MeshAssembler.cpp.

References _interfaceNodesSet, _localInterfaceNodesToGlobalMap, _mesh, _meshList, setCellsMapper(), setCellsSite(), setCoord(), setFaceCells(), setFaceNodes(), setFacesSite(), setInterfaceNodes(), setMesh(), setMeshCellColor(), setNodesMapper(), and setNodesSite().

Referenced by MeshAssembler().

31 {
32  int dim = _meshList.at(0)->getDimension();
33  //construct merged Linearsystem
34  _mesh.push_back( new Mesh( dim) );
35 
36 
37  _interfaceNodesSet.resize( _meshList.size() );
39 
40  setCellsSite();
41  setFacesSite();
43  //countInterfaceNodes();
44  setNodesSite();
46  setFaceCells();
48  setFaceNodes();
49  setCoord();
50  setMesh();
52 
53 }
Definition: Mesh.h:49
MeshList _mesh
void setMeshCellColor()
void setInterfaceNodes()
const MeshList _meshList
Definition: MeshAssembler.h:76
vector< map< int, int > > _localInterfaceNodesToGlobalMap
Definition: MeshAssembler.h:88
VecMap _interfaceNodesSet
Definition: MeshAssembler.h:82
const MeshList& MeshAssembler::meshList ( ) const
inline

Definition at line 34 of file MeshAssembler.h.

References _mesh.

34 { return _mesh;}
MeshList _mesh
void MeshAssembler::setBoundaryFaceGroup ( )
private

Definition at line 595 of file MeshAssembler.cpp.

References _interiorFaceSize, _mesh, _meshList, Mesh::getBoundaryFaceGroups(), and Mesh::getBoundaryGroupCount().

Referenced by setMesh().

596 {
597  //interior face size stored
598  int face = _interiorFaceSize;
599  //now add boundary faces
600  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
601  const Mesh& mesh = *(_meshList[n]);
602  const FaceGroupList& bounGroupList = mesh.getBoundaryFaceGroups();
603  //loop over interfaces
604  for ( int i = 0; i <mesh.getBoundaryGroupCount(); i++ ){
605  //sweep interfaces for add up operation
606  int size = bounGroupList[i]->site.getCount();
607  int offset = face;
608  int id = bounGroupList[i]->id;
609  string boundaryType = bounGroupList[i]->groupType;
610  //update face for offset
611  face += size;
612  _mesh.at(0)->createBoundaryFaceGroup( size, offset, id, boundaryType );
613  }
614  }
615 
616 }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
int getBoundaryGroupCount() const
Definition: Mesh.h:184
Definition: Mesh.h:49
MeshList _mesh
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
void MeshAssembler::setCellsMapper ( )
private

Definition at line 180 of file MeshAssembler.cpp.

References _globalCellToLocal, _globalCellToMeshID, _localCellToGlobal, _meshList, StorageSite::getCount(), and StorageSite::getSelfCount().

Referenced by init().

181 {
182  //count cells
183  int selfCount = 0;
184  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
185  const StorageSite& cellSite = _meshList[id]->getCells();
186  selfCount += cellSite.getSelfCount();
187  }
188  _globalCellToMeshID.resize( selfCount );
189  _globalCellToLocal.resize ( selfCount );
190  //loop over meshes
191  int glblIndx = 0;
192  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
193  const StorageSite& cellSite = _meshList[id]->getCells();
194  _localCellToGlobal[id] = ArrayIntPtr( new Array<int>( cellSite.getCount() ) );
195  Array<int>& localToGlobal = *_localCellToGlobal[id];
196  localToGlobal = -1; //initializer
197  //loop over inner cells
198  for ( int n = 0; n < cellSite.getSelfCount(); n++ ){
199  localToGlobal[n] = glblIndx;
200  _globalCellToMeshID[glblIndx] = id; //belongs to which mesh from global Cell ID
201  _globalCellToLocal [glblIndx] = n; //gives local Cell ID from Global ID but which mesh comes from mapGlobalCellToMeshID
202  glblIndx++;
203  }
204  }
205 
206  //creating cellID MultiField to use sync() operation
207  shared_ptr<MultiField> cellMultiField = shared_ptr<MultiField>( new MultiField() );
208  shared_ptr<Field> cellField = shared_ptr<Field> ( new Field("cellID") );
209 
210  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
211  const StorageSite* site = &_meshList[n]->getCells();
212  MultiField::ArrayIndex ai( cellField.get(), site );
213  shared_ptr<Array<int> > cIndex(new Array<int>(site->getCount()));
214  *cIndex = -1;
215  cellMultiField->addArray(ai,cIndex);
216  }
217 
218  //fill local mesh with global Indx
219  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
220  const StorageSite* site = &_meshList[n]->getCells();
221  MultiField::ArrayIndex ai( cellField.get(), site );
222  Array<int>& localCell = dynamic_cast< Array<int>& >( (*cellMultiField)[ai] );
223  const Array<int>& localToGlobal = *_localCellToGlobal[n];
224  for ( int i = 0; i < site->getSelfCount(); i++ )
225  localCell[i] =localToGlobal[i];
226  }
227  //sync opeartion
228  cellMultiField->sync();
229 
230  //fill local mesh with global Indx after sync
231  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
232  const StorageSite* site = &_meshList[n]->getCells();
233  MultiField::ArrayIndex ai( cellField.get(), site );
234  const Array<int>& localCell = dynamic_cast< const Array<int>& >( (*cellMultiField)[ai] );
235  Array<int>& localToGlobal = *_localCellToGlobal[n];
236  for ( int i = 0; i < site->getCount(); i++ )
237  localToGlobal[i] = localCell[i];
238  }
239 
240 
241 // //above algorithm fill localCellToGlobal for only inner cells but we will do ghost cells for interfaces
242 // for ( unsigned int i = 0; i < _meshList.size(); i++ ){
243 // const StorageSite& thisSite = _meshList[i]->getCells();
244 // const StorageSite::ScatterMap& scatterMap = thisSite.getScatterMap();
245 // foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
246 // const StorageSite& oSite = *(mpos.first);
247 // const Array<int>& fromIndices = *(mpos.second);
248 // const Array<int>& toIndices = *(oSite.getGatherMap().find(&thisSite)->second);
249 // cout << " fromIndices.getLength() = " << fromIndices.getLength() << endl;
250 // cout << " scatterArray " << endl;
251 // for ( int n = 0; n < fromIndices.getLength(); n++){
252 // cout << " fromIndices[" << n << "] = " << fromIndices[n] << " toIndices[" << n << "] = " << toIndices[n] << endl;
253 // }
254 // }
255 // }
256 
257 }
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Field.h:14
vector< int > _globalCellToLocal
Definition: MeshAssembler.h:86
shared_ptr< Array< int > > ArrayIntPtr
Definition: MeshAssembler.h:20
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
vector< int > _globalCellToMeshID
Definition: MeshAssembler.h:85
const MeshList _meshList
Definition: MeshAssembler.h:76
map< int, ArrayIntPtr > _localCellToGlobal
Definition: MeshAssembler.h:84
int getCount() const
Definition: StorageSite.h:39
void MeshAssembler::setCellsSite ( )
private

Definition at line 57 of file MeshAssembler.cpp.

References _cellSite, _meshList, StorageSite::getCount(), Array< T >::getLength(), StorageSite::getScatterMap(), and StorageSite::getSelfCount().

Referenced by init().

58 {
59  int siteCount = 0;
60  int siteSelfCount = 0;
61  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
62  const StorageSite& site = _meshList[id]->getCells();
63  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
64  int nghost = 0;
65  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
66  const Array<int>& fromIndices = *(mpos.second);
67  nghost += fromIndices.getLength();
68  }
69  siteCount += site.getCount() - nghost;
70  siteSelfCount += site.getSelfCount();
71  }
72 
73  _cellSite = StorageSitePtr( new StorageSite(siteSelfCount, siteCount-siteSelfCount) );
74 
75 }
int getSelfCount() const
Definition: StorageSite.h:40
shared_ptr< StorageSite > StorageSitePtr
Definition: MeshAssembler.h:22
StorageSitePtr _cellSite
Definition: MeshAssembler.h:78
const MeshList _meshList
Definition: MeshAssembler.h:76
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
int getCount() const
Definition: StorageSite.h:39
int getLength() const
Definition: Array.h:87
void MeshAssembler::setCoord ( )
private

Definition at line 620 of file MeshAssembler.cpp.

References _coord, _localNodeToGlobal, _meshList, _nodeSite, StorageSite::getCount(), Mesh::getNodeCoordinates(), and Mesh::getNodes().

Referenced by init().

621 {
622  _coord = ArrayVecD3Ptr(new Array<Mesh::VecD3>(_nodeSite->getCount()));
623  for ( unsigned n = 0; n < _meshList.size(); n++ ){
624  const Mesh& mesh = *(_meshList[n]);
625  const StorageSite& nodeSite = mesh.getNodes();
626  const Array<int>& localToGlobal = *_localNodeToGlobal[n];
627  const Array<Mesh::VecD3>& coordLocal = mesh.getNodeCoordinates();
628  //loop over local mesh nodes
629  for ( int i = 0; i < nodeSite.getCount(); i++ ){
630  if ( localToGlobal[i] != -1 ) //so mapping is well defined
631  (*_coord)[ localToGlobal[i] ] = coordLocal[i];
632  }
633  }
634 }
shared_ptr< Array< Mesh::VecD3 > > ArrayVecD3Ptr
Definition: MeshAssembler.h:25
const StorageSite & getNodes() const
Definition: Mesh.h:110
Definition: Mesh.h:49
const Array< VecD3 > & getNodeCoordinates() const
Definition: Mesh.h:218
StorageSitePtr _nodeSite
Definition: MeshAssembler.h:80
ArrayVecD3Ptr _coord
Definition: MeshAssembler.h:95
map< int, ArrayIntPtr > _localNodeToGlobal
Definition: MeshAssembler.h:89
const MeshList _meshList
Definition: MeshAssembler.h:76
Definition: Array.h:14
int getCount() const
Definition: StorageSite.h:39
void MeshAssembler::setFaceCells ( )
private

Definition at line 261 of file MeshAssembler.cpp.

References _cellSite, _faceCells, _faceSite, _localCellToGlobal, _meshList, Mesh::getAllFaceCells(), Mesh::getBoundaryFaceGroups(), Mesh::getBoundaryGroupCount(), Mesh::getCells(), StorageSite::getCount(), Mesh::getInterfaceGroupCount(), Mesh::getInterfaceGroups(), Mesh::getInteriorFaceGroup(), StorageSite::getSelfCount(), and FaceGroup::site.

Referenced by init().

262 {
264  _faceCells->initCount();
265 
266  //addCount
267  const int cellCount = 2;
268  for ( int i = 0; i < _faceSite->getCount(); i++ )
269  _faceCells->addCount(i, cellCount); // face has always two cells
270  //finish count
271  _faceCells->finishCount();
272 
273  //first interior faces
274  int face = 0;
275  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
276  const Mesh& mesh = *(_meshList[n]);
277  const CRConnectivity& faceCells = mesh.getAllFaceCells();
278  const FaceGroup& faceGroup = mesh.getInteriorFaceGroup();
279  const Array<int>& localToGlobal = *_localCellToGlobal[n];
280  for ( int i = 0; i < faceGroup.site.getCount(); i++ ){
281  int cell1 = faceCells(i,0);
282  int cell2 = faceCells(i,1);
283  _faceCells->add( face, localToGlobal[ cell1 ] );
284  _faceCells->add( face, localToGlobal[ cell2 ] );
285  face++;
286  }
287  }
288 
289  //now add interfaces
290  set<int> faceGroupSet; // this set make sure that no duplication in sweep
291  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
292  const Mesh& mesh = *(_meshList[n]);
293  const CRConnectivity& faceCells = mesh.getAllFaceCells();
294  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
295  const Array<int>& localToGlobal = *_localCellToGlobal[n];
296  //loop over interfaces
297  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
298  int faceGroupID = faceGroupList[i]->id;
299  //pass only if it is not in faceGroupSet
300  if ( faceGroupSet.count( faceGroupID) == 0 ){
301  faceGroupSet.insert( faceGroupID );
302  //sweep interfaces for add up operation
303  int ibeg = faceGroupList[i]->site.getOffset();
304  int iend = ibeg + faceGroupList[i]->site.getCount();
305  for ( int i = ibeg; i < iend; i++ ){
306  int cell1 = faceCells(i,0);
307  int cell2 = faceCells(i,1);
308  _faceCells->add( face, localToGlobal[ cell1 ] );
309  _faceCells->add( face, localToGlobal[ cell2 ] );
310  face++;
311  }
312  }
313  }
314  }
315  //now add boundary faces
316  int indx = _cellSite->getSelfCount();
317  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
318  const Mesh& mesh = *(_meshList[n]);
319  const StorageSite& cellSite = mesh.getCells();
320  const CRConnectivity& faceCells = mesh.getAllFaceCells();
321  const FaceGroupList& bounGroupList = mesh.getBoundaryFaceGroups();
322  const Array<int>& localToGlobal = *_localCellToGlobal[n];
323  //loop over interfaces
324  for ( int i = 0; i <mesh.getBoundaryGroupCount(); i++ ){
325  //sweep interfaces for add up operation
326  int ibeg = bounGroupList[i]->site.getOffset();
327  int iend = ibeg + bounGroupList[i]->site.getCount();
328  for ( int i = ibeg; i < iend; i++ ){
329  int cell1 = faceCells(i,0);
330  int cell2 = faceCells(i,1);
331  //cell1
332  if ( cell1 < cellSite.getSelfCount() )
333  _faceCells->add( face, localToGlobal[ cell1 ] );
334  else
335  _faceCells->add( face, localToGlobal[ cell2 ] );
336  //adding boundary cells
337  _faceCells->add( face, indx );
338  indx++;
339  face++;
340  }
341  }
342  }
343 
344  //finishAdd
345  _faceCells->finishAdd();
346 
347 
348 }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
const FaceGroup & getInteriorFaceGroup() const
Definition: Mesh.h:181
int getBoundaryGroupCount() const
Definition: Mesh.h:184
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Mesh.h:28
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
StorageSitePtr _cellSite
Definition: MeshAssembler.h:78
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
CRConnectivityPtr _faceCells
Definition: MeshAssembler.h:93
const StorageSite & getCells() const
Definition: Mesh.h:109
const MeshList _meshList
Definition: MeshAssembler.h:76
shared_ptr< CRConnectivity > CRConnectivityPtr
Definition: MeshAssembler.h:23
map< int, ArrayIntPtr > _localCellToGlobal
Definition: MeshAssembler.h:84
int getCount() const
Definition: StorageSite.h:39
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79
StorageSite site
Definition: Mesh.h:40
void MeshAssembler::setFaceNodes ( )
private

Definition at line 352 of file MeshAssembler.cpp.

References _faceNodes, _faceSite, _interiorFaceSize, _localNodeToGlobal, _meshList, _nodeSite, Mesh::getAllFaceNodes(), Mesh::getBoundaryFaceGroups(), Mesh::getBoundaryGroupCount(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getInterfaceGroupCount(), Mesh::getInterfaceGroups(), Mesh::getInteriorFaceGroup(), CRConnectivity::getRow(), and FaceGroup::site.

Referenced by init().

353 {
355  _faceNodes->initCount();
356  //addCount
357  const Mesh& mesh0 = *_meshList[0];
358  const int nodeCount = mesh0.getAllFaceNodes().getRow()[1] - mesh0.getAllFaceNodes().getRow()[0];
359  for ( int i = 0; i < _faceSite->getCount(); i++ )
360  _faceNodes->addCount(i, nodeCount);
361  //finish count
362  _faceNodes->finishCount();
363  //first interior faces
364  int face = 0;
365  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
366  const Mesh& mesh = *(_meshList[n]);
367  const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
368  const FaceGroup& faceGroup = mesh.getInteriorFaceGroup();
369  const StorageSite& faceGroupSite = faceGroup.site;
370  const Array<int>& localToGlobal = *_localNodeToGlobal[n];
371  for ( int i = 0; i < faceGroupSite.getCount(); i++ ){
372  for ( int j = 0; j < faceNodes.getCount(i); j++ ){
373  int nodeID = faceNodes(i,j);
374  _faceNodes->add( face, localToGlobal[nodeID] );
375  }
376  face++;
377  }
378  }
379 
380  //interfaces (mesh)
381  set<int> faceGroupSet;
382  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
383  const Mesh& mesh = *(_meshList[n]);
384  const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
385  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
386  const Array<int>& localToGlobal = *_localNodeToGlobal[n];
387  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
388  int faceGroupID = faceGroupList[i]->id;
389  //pass only if it is not in faceGroupSet
390  if ( faceGroupSet.count( faceGroupID) == 0 ){
391  faceGroupSet.insert( faceGroupID );
392  //sweep interfaces for add up operation
393  int ibeg = faceGroupList[i]->site.getOffset();
394  int iend = ibeg + faceGroupList[i]->site.getCount();
395  for ( int i = ibeg; i < iend; i++ ){
396  for ( int j = 0; j < faceNodes.getCount(i); j++ ){
397  int nodeID = faceNodes(i,j);
398  _faceNodes->add( face, localToGlobal[nodeID] );
399  }
400  face++;
401  }
402  }
403  }
404  }
405  //interior face size stored
406  _interiorFaceSize = face;
407 
408 
409  //now add boundary faces
410  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
411  const Mesh& mesh = *(_meshList[n]);
412  const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
413  const FaceGroupList& bounGroupList = mesh.getBoundaryFaceGroups();
414  const Array<int>& localToGlobal = *_localNodeToGlobal[n];
415  //loop over interfaces
416  for ( int i = 0; i <mesh.getBoundaryGroupCount(); i++ ){
417  //sweep interfaces for add up operation
418  int ibeg = bounGroupList[i]->site.getOffset();
419  int iend = ibeg + bounGroupList[i]->site.getCount();
420  for ( int i = ibeg; i < iend; i++ ){
421  for ( int j = 0; j < faceNodes.getCount(i); j++ ){
422  int nodeID = faceNodes(i,j);
423  _faceNodes->add( face, localToGlobal[nodeID] );
424  }
425  face++;
426  }
427  }
428  }
429 
430  //finishAdd
431  _faceNodes->finishAdd();
432 }
const CRConnectivity & getAllFaceNodes() const
Definition: Mesh.cpp:368
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
int getCount(const int i) const
const Array< int > & getRow() const
const FaceGroup & getInteriorFaceGroup() const
Definition: Mesh.h:181
int getBoundaryGroupCount() const
Definition: Mesh.h:184
Definition: Mesh.h:28
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
CRConnectivityPtr _faceNodes
Definition: MeshAssembler.h:94
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
StorageSitePtr _nodeSite
Definition: MeshAssembler.h:80
map< int, ArrayIntPtr > _localNodeToGlobal
Definition: MeshAssembler.h:89
const MeshList _meshList
Definition: MeshAssembler.h:76
shared_ptr< CRConnectivity > CRConnectivityPtr
Definition: MeshAssembler.h:23
int getCount() const
Definition: StorageSite.h:39
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79
StorageSite site
Definition: Mesh.h:40
void MeshAssembler::setFacesSite ( )
private

Definition at line 79 of file MeshAssembler.cpp.

References _faceSite, _meshList, and StorageSite::getCount().

Referenced by init().

80 {
81  int faceCount = 0;
82  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
83  const StorageSite& site = _meshList[id]->getFaces();
84  faceCount += site.getCount();
85  }
86 
87  int sharedFaceCount = 0;
88  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
89  const FaceGroupList & faceGroupList = _meshList[id]->getInterfaceGroups();
90  for ( int n = 0; n < _meshList[id]->getInterfaceGroupCount(); n++ ){
91  const StorageSite& site = faceGroupList[n]->site;
92  sharedFaceCount += site.getCount();
93  }
94  }
95  _faceSite = StorageSitePtr( new StorageSite(faceCount - sharedFaceCount / 2 ) );
96  assert( sharedFaceCount%2 == 0 );
97 
98 }
shared_ptr< StorageSite > StorageSitePtr
Definition: MeshAssembler.h:22
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
int getCount() const
Definition: StorageSite.h:39
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79
void MeshAssembler::setInterfaceNodes ( )
private

Definition at line 102 of file MeshAssembler.cpp.

References _interfaceNodesSet, _meshList, Mesh::getAllFaceNodes(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getInterfaceGroupCount(), Mesh::getInterfaceGroups(), and StorageSite::getOffset().

Referenced by init().

103 {
104  //loop over meshes
105  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
106  const Mesh& mesh = *(_meshList.at(n));
107  const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
108  //const CRConnectivity& faceCells = mesh.getAllFaceCells();
109  const FaceGroupList& faceGroupList = mesh.getInterfaceGroups();
110  //looop over interfaces
111  for ( int i = 0; i < mesh.getInterfaceGroupCount(); i++ ){
112  int id = faceGroupList[i]->id;
113  set<int>& nodes = _interfaceNodesSet[n][id];
114  //loop over faces to fill nodes
115  const StorageSite& site = faceGroupList[i]->site;
116  int jstart = site.getOffset();
117  int jend = jstart + site.getCount();
118  for ( int face = jstart; face < jend; face++ ){
119  //loop over face surronding nodes
120  for ( int node = 0; node < faceNodes.getCount(face); node++ ){
121  nodes.insert( faceNodes(face,node) );
122 /* cout << " nemsh = " << n << "faceNodes(" << face << "," << node << ") = " << faceNodes(face,node) <<
123  " faceCells(" << face << "," << "0) = " << faceCells(face,0) <<
124  " faceCells(" << face << "," << "1) = " << faceCells(face,1) << endl;*/
125  }
126  }
127  }
128  }
129 
130 }
const CRConnectivity & getAllFaceNodes() const
Definition: Mesh.cpp:368
int getCount(const int i) const
Definition: Mesh.h:49
int getInterfaceGroupCount() const
Definition: Mesh.h:185
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
VecMap _interfaceNodesSet
Definition: MeshAssembler.h:82
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
void MeshAssembler::setMesh ( )
private

Definition at line 649 of file MeshAssembler.cpp.

References _coord, _faceCells, _faceNodes, _interiorFaceSize, _mesh, setBoundaryFaceGroup(), and setSites().

Referenced by init().

650 {
651  //set sites
652  setSites();
653  //interior face group
654  _mesh.at(0)->createInteriorFaceGroup( _interiorFaceSize );
655  //boundary face group
657  //setting coordinates
658  _mesh.at(0)->setCoordinates( _coord );
659  //setting faceNodes CRConnecitivty
660  _mesh.at(0)->setFaceNodes ( _faceNodes );
661  //setting faceCells CRConnectivity
662  _mesh.at(0)->setFaceCells ( _faceCells );
663 
664 }
MeshList _mesh
CRConnectivityPtr _faceNodes
Definition: MeshAssembler.h:94
CRConnectivityPtr _faceCells
Definition: MeshAssembler.h:93
ArrayVecD3Ptr _coord
Definition: MeshAssembler.h:95
void setBoundaryFaceGroup()
void MeshAssembler::setMeshCellColor ( )
private

Definition at line 668 of file MeshAssembler.cpp.

References _cellSite, _localCellToGlobal, _mesh, _meshList, Mesh::getAllFaceCells(), Mesh::getBoundaryFaceGroups(), Mesh::getBoundaryGroupCount(), StorageSite::getCount(), Mesh::getInteriorFaceGroup(), and FaceGroup::site.

Referenced by init().

669 {
670  //allocate Mesh::_cellColor
671  _mesh.at(0)->createCellColor();
672 
673  Array<int>& cellColor = _mesh.at(0)->getCellColors();
674  //first interior faces of local meshes
675  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
676  const Mesh& mesh = *(_meshList[n]);
677  const CRConnectivity& faceCells = mesh.getAllFaceCells();
678  const FaceGroup& faceGroup = mesh.getInteriorFaceGroup();
679  const Array<int>& localToGlobal = *_localCellToGlobal[n];
680  for ( int i = 0; i < faceGroup.site.getCount(); i++ ){
681  int cell1 = faceCells(i,0);
682  int cell2 = faceCells(i,1);
683  cellColor[ localToGlobal[ cell1 ] ] = n;
684  cellColor[ localToGlobal[ cell2 ] ] = n;
685  }
686  }
687 
688  //now color only boundary cells
689  int indx = _cellSite->getSelfCount();
690  for ( unsigned int n = 0; n < _meshList.size(); n++ ){
691  const Mesh& mesh = *(_meshList[n]);
692  const FaceGroupList& bounGroupList = mesh.getBoundaryFaceGroups();
693  //loop over interfaces
694  for ( int i = 0; i <mesh.getBoundaryGroupCount(); i++ ){
695  //sweep interfaces for add up operation
696  int ibeg = bounGroupList[i]->site.getOffset();
697  int iend = ibeg + bounGroupList[i]->site.getCount();
698  for ( int i = ibeg; i < iend; i++ ){
699  cellColor[indx] = n;
700  //adding boundary cells
701  indx++;
702  }
703  }
704  }
705  //assigning Mesh::numOfAssembleMesh
706  _mesh[0]->setNumOfAssembleMesh( int(_meshList.size()) );
707 
708 }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
const FaceGroup & getInteriorFaceGroup() const
Definition: Mesh.h:181
int getBoundaryGroupCount() const
Definition: Mesh.h:184
Definition: Mesh.h:28
Definition: Mesh.h:49
StorageSitePtr _cellSite
Definition: MeshAssembler.h:78
MeshList _mesh
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
vector< FaceGroupPtr > FaceGroupList
Definition: Mesh.h:47
const MeshList _meshList
Definition: MeshAssembler.h:76
map< int, ArrayIntPtr > _localCellToGlobal
Definition: MeshAssembler.h:84
int getCount() const
Definition: StorageSite.h:39
StorageSite site
Definition: Mesh.h:40
void MeshAssembler::setNodesMapper ( )
private

Definition at line 558 of file MeshAssembler.cpp.

References _localInterfaceNodesToGlobalMap, _localNodeToGlobal, _meshList, _nInterfaceNodes, StorageSite::getCount(), and CRConnectivity::getCount().

Referenced by init().

559 {
560 
561  int glblIndx = _nInterfaceNodes; // node numbering first from interfaces
562  cout << " glbIndx = " << glblIndx << endl;
563  for ( unsigned int id = 0; id < _meshList.size(); id++ ){
564  const StorageSite& nodeSite = _meshList[id]->getNodes();
565  const StorageSite& faceSite = _meshList[id]->getFaces();
566  const CRConnectivity& faceNodes = _meshList[id]->getAllFaceNodes();
567  _localNodeToGlobal[id] = ArrayIntPtr( new Array<int>( nodeSite.getCount() ) );
568  Array<bool> isVisitedNodes( nodeSite.getCount() );
569  isVisitedNodes = false;
570  Array<int>& localToGlobal = *_localNodeToGlobal[id];
571  localToGlobal = -1; //initializer
572  const map<int,int>& localInterfaceNodesToGlobalMap = _localInterfaceNodesToGlobalMap[id];
573  //loop over faces then connecting nodes
574  for ( int face = 0; face < faceSite.getCount(); face++ ){
575  for ( int n = 0; n < faceNodes.getCount(face); n++ ){
576  int nodeID = faceNodes(face,n);
577  //cout << " nodeID = " << nodeID << " isVisitedNodes = " << isVisitedNodes[nodeID] << endl;
578  if ( !isVisitedNodes[nodeID]){ //if it is not visited, we renumber it
579  if ( localInterfaceNodesToGlobalMap.count( nodeID ) == 0 )
580  localToGlobal[nodeID] = glblIndx++;
581  else
582  localToGlobal[nodeID] = localInterfaceNodesToGlobalMap.find(nodeID)->second;
583  isVisitedNodes[nodeID] = true;
584  }
585  }
586  }
587  }
588 
589 
590 
591 }
int getCount(const int i) const
shared_ptr< Array< int > > ArrayIntPtr
Definition: MeshAssembler.h:20
map< int, ArrayIntPtr > _localNodeToGlobal
Definition: MeshAssembler.h:89
const MeshList _meshList
Definition: MeshAssembler.h:76
int getCount() const
Definition: StorageSite.h:39
vector< map< int, int > > _localInterfaceNodesToGlobalMap
Definition: MeshAssembler.h:88
void MeshAssembler::setNodesSite ( )
private

Definition at line 169 of file MeshAssembler.cpp.

References _nodeSite, getInnerNodesCount(), and getInterfaceNodesCount().

Referenced by init().

170 {
171  //count inner nodes for assembly
172  int nodeCount = getInnerNodesCount();
173  int nInterfaceNodes = getInterfaceNodesCount();
174  _nodeSite = StorageSitePtr( new StorageSite(nodeCount + nInterfaceNodes) );
175 
176 }
shared_ptr< StorageSite > StorageSitePtr
Definition: MeshAssembler.h:22
StorageSitePtr _nodeSite
Definition: MeshAssembler.h:80
int getInterfaceNodesCount()
int getInnerNodesCount()
void MeshAssembler::setSites ( )
private

Definition at line 638 of file MeshAssembler.cpp.

References _cellSite, _faceSite, _mesh, _nodeSite, and StorageSite::setCount().

Referenced by setMesh().

639 {
640  StorageSite& faceSite = _mesh.at(0)->getFaces();
641  StorageSite& cellSite = _mesh.at(0)->getCells();
642  StorageSite& nodeSite = _mesh.at(0)->getNodes();
643  faceSite.setCount( _faceSite->getCount() );
644  cellSite.setCount( _cellSite->getSelfCount(), _cellSite->getCount()-_cellSite->getSelfCount() );
645  nodeSite.setCount( _nodeSite->getCount() );
646 }
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
StorageSitePtr _cellSite
Definition: MeshAssembler.h:78
MeshList _mesh
StorageSitePtr _nodeSite
Definition: MeshAssembler.h:80
StorageSitePtr _faceSite
Definition: MeshAssembler.h:79

Member Data Documentation

StorageSitePtr MeshAssembler::_cellSite
private

Definition at line 78 of file MeshAssembler.h.

Referenced by debug_sites(), setCellsSite(), setFaceCells(), setMeshCellColor(), and setSites().

ArrayVecD3Ptr MeshAssembler::_coord
private

Definition at line 95 of file MeshAssembler.h.

Referenced by setCoord(), and setMesh().

CRConnectivityPtr MeshAssembler::_faceCells
private

Definition at line 93 of file MeshAssembler.h.

Referenced by debug_faceCells(), setFaceCells(), and setMesh().

CRConnectivityPtr MeshAssembler::_faceNodes
private

Definition at line 94 of file MeshAssembler.h.

Referenced by setFaceNodes(), and setMesh().

StorageSitePtr MeshAssembler::_faceSite
private
vector<int> MeshAssembler::_globalCellToLocal
private

Definition at line 86 of file MeshAssembler.h.

Referenced by debug_globalCellToMeshID_mappers(), and setCellsMapper().

vector<int> MeshAssembler::_globalCellToMeshID
private

Definition at line 85 of file MeshAssembler.h.

Referenced by debug_globalCellToMeshID_mappers(), and setCellsMapper().

set<Mesh::VecD3> MeshAssembler::_interfaceNodeCoord
private

Definition at line 91 of file MeshAssembler.h.

VecMap MeshAssembler::_interfaceNodesSet
private
int MeshAssembler::_interiorFaceSize
private

Definition at line 100 of file MeshAssembler.h.

Referenced by setBoundaryFaceGroup(), setFaceNodes(), and setMesh().

map<int, ArrayIntPtr > MeshAssembler::_localCellToGlobal
private
vector< map<int,int> > MeshAssembler::_localInterfaceNodesToGlobalMap
private

Definition at line 88 of file MeshAssembler.h.

Referenced by getInterfaceNodesCount(), init(), and setNodesMapper().

map<int, ArrayIntPtr > MeshAssembler::_localNodeToGlobal
private

Definition at line 89 of file MeshAssembler.h.

Referenced by debug_localNodeToGlobal(), setCoord(), setFaceNodes(), and setNodesMapper().

MeshList MeshAssembler::_mesh
private
int MeshAssembler::_nInterfaceNodes
private

Definition at line 99 of file MeshAssembler.h.

Referenced by getInterfaceNodesCount(), and setNodesMapper().

StorageSitePtr MeshAssembler::_nodeSite
private

Definition at line 80 of file MeshAssembler.h.

Referenced by debug_sites(), setCoord(), setFaceNodes(), setNodesSite(), and setSites().


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