23 vector< Mesh* >::iterator it_mesh;
24 for ( it_mesh =
_mesh.begin(); it_mesh !=
_mesh.end(); it_mesh++)
32 int dim =
_meshList.at(0)->getDimension();
60 int siteSelfCount = 0;
61 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
65 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
66 const Array<int>& fromIndices = *(mpos.second);
69 siteCount += site.
getCount() - nghost;
82 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
87 int sharedFaceCount = 0;
88 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
90 for (
int n = 0; n <
_meshList[id]->getInterfaceGroupCount(); n++ ){
96 assert( sharedFaceCount%2 == 0 );
105 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
112 int id = faceGroupList[i]->id;
117 int jend = jstart + site.
getCount();
118 for (
int face = jstart; face < jend; face++ ){
120 for (
int node = 0; node < faceNodes.
getCount(face); node++ ){
121 nodes.insert( faceNodes(face,node) );
138 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
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);
150 for (
unsigned int i = 0; i <
_meshList.size(); i++ ){
153 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
155 const Array<int>& fromIndices = *(mpos.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;
184 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
192 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
199 localToGlobal[n] = glblIndx;
207 shared_ptr<MultiField> cellMultiField = shared_ptr<MultiField>(
new MultiField() );
208 shared_ptr<Field> cellField = shared_ptr<Field> (
new Field(
"cellID") );
210 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
215 cellMultiField->addArray(ai,cIndex);
219 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
225 localCell[i] =localToGlobal[i];
228 cellMultiField->sync();
231 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
236 for (
int i = 0; i < site->
getCount(); i++ )
237 localToGlobal[i] = localCell[i];
267 const int cellCount = 2;
268 for (
int i = 0; i <
_faceSite->getCount(); i++ )
275 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
281 int cell1 = faceCells(i,0);
282 int cell2 = faceCells(i,1);
283 _faceCells->add( face, localToGlobal[ cell1 ] );
284 _faceCells->add( face, localToGlobal[ cell2 ] );
290 set<int> faceGroupSet;
291 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
298 int faceGroupID = faceGroupList[i]->id;
300 if ( faceGroupSet.count( faceGroupID) == 0 ){
301 faceGroupSet.insert( faceGroupID );
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 ] );
317 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
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);
333 _faceCells->add( face, localToGlobal[ cell1 ] );
335 _faceCells->add( face, localToGlobal[ cell2 ] );
359 for (
int i = 0; i <
_faceSite->getCount(); i++ )
365 for (
unsigned int n = 0; n <
_meshList.size(); 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] );
381 set<int> faceGroupSet;
382 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
388 int faceGroupID = faceGroupList[i]->id;
390 if ( faceGroupSet.count( faceGroupID) == 0 ){
391 faceGroupSet.insert( faceGroupID );
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] );
410 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
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] );
438 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
446 for (
int i = 0; i < nface; i++ )
448 for (
int node = 0; node < faceNodes.
getCount(i); node++ )
449 nodeArray[ faceNodes(i,node) ] = 1;
454 int id = faceGroupList[i]->id;
456 foreach (
const set<int>::value_type node, nodes )
457 nodeArray[ node] = -1;
460 for (
int i = 0; i < nodeArray.
getLength(); i++ )
461 if ( nodeArray[i] != -1 ) nodeCount++;
472 int nInterfaceNodes = 0;
473 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
478 int id = faceGroupList[i]->id;
480 nInterfaceNodes += nodes.size();
483 return nInterfaceNodes;
499 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
505 int id = faceGroupList[i]->id;
507 foreach (
const set<int>::value_type node, nodes ){
508 interfaceNodeValues[indx] = coord[node];
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;
539 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
544 int id = faceGroupList[i]->id;
546 foreach (
const set<int>::value_type node, nodes ){
562 cout <<
" glbIndx = " << glblIndx << endl;
563 for (
unsigned int id = 0;
id <
_meshList.size();
id++ ){
569 isVisitedNodes =
false;
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);
578 if ( !isVisitedNodes[nodeID]){
579 if ( localInterfaceNodesToGlobalMap.count( nodeID ) == 0 )
580 localToGlobal[nodeID] = glblIndx++;
582 localToGlobal[nodeID] = localInterfaceNodesToGlobalMap.find(nodeID)->second;
583 isVisitedNodes[nodeID] =
true;
600 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
606 int size = bounGroupList[i]->site.getCount();
608 int id = bounGroupList[i]->id;
609 string boundaryType = bounGroupList[i]->groupType;
612 _mesh.at(0)->createBoundaryFaceGroup( size, offset,
id, boundaryType );
623 for (
unsigned n = 0; n <
_meshList.size(); n++ ){
629 for (
int i = 0; i < nodeSite.
getCount(); i++ ){
630 if ( localToGlobal[i] != -1 )
631 (*_coord)[ localToGlobal[i] ] = coordLocal[i];
671 _mesh.at(0)->createCellColor();
675 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
681 int cell1 = faceCells(i,0);
682 int cell2 = faceCells(i,1);
683 cellColor[ localToGlobal[ cell1 ] ] = n;
684 cellColor[ localToGlobal[ cell2 ] ] = n;
690 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
696 int ibeg = bounGroupList[i]->site.getOffset();
697 int iend = ibeg + bounGroupList[i]->site.getCount();
698 for (
int i = ibeg; i < iend; i++ ){
727 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
730 for (
int i = 0; i < localToGlobal.
getLength(); i++ )
731 _debugFile <<
" localCellToGlobal[" << i <<
"] = " << localToGlobal[i] << endl;
759 _debugFile <<
" localCellToGlobal after sync() opeartion " << endl;
760 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
763 for (
int i = 0; i < localToGlobal.
getLength(); i++ )
764 _debugFile <<
" localToGlobal[" << i <<
"] = " << localToGlobal[i] << endl;
776 _debugFile <<
" faceCells Connectivity " << endl;
777 for (
int i = 0; i <
_faceSite->getCount(); i++ ) {
779 for (
int j = 0; j < ncells; j++ ){
780 _debugFile <<
" faceCells(" << i <<
"," << j <<
") = " << (*_faceCells)(i,j);
793 for (
unsigned int n = 0; n <
_meshList.size(); n++ ){
795 for (
int i = 0; i < localToGlobal.
getLength(); i++ )
796 _debugFile <<
" localToGlobal[" << i <<
"] = " << localToGlobal[i] << endl;
819 string fname =
"MESHASSEMBLER_"+fname_+
".dat";
const CRConnectivity & getAllFaceNodes() const
const FaceGroupList & getBoundaryFaceGroups() const
int getCount(const int i) const
const Array< int > & getRow() const
const FaceGroup & getInteriorFaceGroup() const
int getBoundaryGroupCount() const
int getInterfaceNodesDuplicatedCount()
shared_ptr< Array< Mesh::VecD3 > > ArrayVecD3Ptr
const StorageSite & getNodes() const
vector< int > _globalCellToLocal
void debug_globalCellToMeshID_mappers()
void setCount(const int selfCount, const int nGhost=0)
shared_ptr< Array< int > > ArrayIntPtr
int getInterfaceGroupCount() const
shared_ptr< StorageSite > StorageSitePtr
void debug_localNodeToGlobal()
const CRConnectivity & getAllFaceCells() const
const CRConnectivity & getCellFaces() const
void debug_sync_localToGlobal_mappers()
CRConnectivityPtr _faceNodes
MeshAssembler(const MeshList &meshList)
const Array< VecD3 > & getNodeCoordinates() const
pair< const Field *, const StorageSite * > ArrayIndex
void debug_file_open(const string &fname)
vector< FaceGroupPtr > FaceGroupList
vector< int > _globalCellToMeshID
CRConnectivityPtr _faceCells
void countInterfaceNodes()
const StorageSite & getFaces() const
const StorageSite & getCells() const
int getInterfaceNodesCount()
map< int, ArrayIntPtr > _localNodeToGlobal
const ScatterMap & getScatterMap() const
void debug_localToGlobal_mappers()
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
shared_ptr< CRConnectivity > CRConnectivityPtr
void setBoundaryFaceGroup()
const GatherMap & getGatherMap() const
map< int, ArrayIntPtr > _localCellToGlobal
vector< map< int, int > > _localInterfaceNodesToGlobalMap
VecMap _interfaceNodesSet
const FaceGroupList & getInterfaceGroups() const
vector< Mesh * > MeshList