22 _dimension(dimension),
36 _boundaryNodeGlobalToLocalPtr(),
38 _numOfAssembleMesh(1),
39 _isAssembleMesh(false),
41 _isDoubleShell(false),
42 _isConnectedShell(false),
43 _parentFaceGroupSite(0),
44 _otherFaceGroupSite(0),
54 _dimension(dimension),
68 _boundaryNodeGlobalToLocalPtr(),
70 _numOfAssembleMesh(1),
71 _isAssembleMesh(false),
73 _isDoubleShell(false),
74 _isConnectedShell(false),
75 _parentFaceGroupSite(0),
76 _otherFaceGroupSite(0),
81 int totNodes = faceNodesCoord.
getLength();
84 int totFaces = totNodes / faceNodeCount;
87 assert( (faceNodeCount*totFaces) == totNodes );
97 shared_ptr< Array<VecD3> > coord(
new Array< VecD3 > ( totNodes ) );
98 *coord = faceNodesCoord;
102 shared_ptr<CRConnectivity> faceNodes(
new CRConnectivity(faceSite,
105 faceNodes->initCount();
107 for (
int i = 0; i < totFaces; i++ )
108 faceNodes->addCount(i, faceNodeCount);
110 faceNodes->finishCount();
114 for(
int i = 0; i < totFaces; i++ )
116 for(
int j =0; j < faceNodeCount; j++ )
118 faceNodes->add(face, nodeIndx++);
123 faceNodes->finishAdd();
126 SSPair key(&faceSite,&nodeSite);
140 _dimension(dimension),
148 _interiorFaceGroup(),
154 _boundaryNodeGlobalToLocalPtr(),
156 _numOfAssembleMesh(1),
157 _isAssembleMesh(false),
159 _isDoubleShell(false),
160 _isConnectedShell(false),
161 _parentFaceGroupSite(0),
162 _otherFaceGroupSite(0),
178 int nFaceGroups = faceGroupSize.
getLength();
180 int offset = faceGroupSize[0];
181 int nBoundaryFaces =0;
182 for(
int nfg=1; nfg<nFaceGroups; nfg++)
185 offset += faceGroupSize[nfg];
186 nBoundaryFaces += faceGroupSize[nfg];
189 cellSite.
setCount( nCells, nBoundaryFaces );
192 shared_ptr< Array<VecD3> > coord(
new Array< VecD3 > ( nNodes ) );
198 shared_ptr<CRConnectivity> faceNodes(
new CRConnectivity(faceSite,
201 faceNodes->initCount();
203 shared_ptr<CRConnectivity> faceCells(
new CRConnectivity(faceSite,
206 faceCells->initCount();
210 for (
int f = 0; f < nFaces; f++ )
212 faceNodes->addCount(f, faceNodeCount[f]);
213 faceCells->addCount(f, 2);
217 faceNodes->finishCount();
218 faceCells->finishCount();
224 for(
int f = 0; f < nFaces; f++ )
226 for(
int j =0; j < faceNodeCount[f]; j++ )
228 faceNodes->add(f, faceNodeIndices[nfn++]);
230 faceCells->add(f,faceCellIndices[nfc++]);
231 faceCells->add(f,faceCellIndices[nfc++]);
234 faceNodes->finishAdd();
235 faceCells->finishAdd();
238 SSPair key(&faceSite,&nodeSite);
241 SSPair key2(&faceSite,&cellSite);
270 shared_ptr<FaceGroup> fg(
new FaceGroup(size,offset,
_faces,
id,
"interface"));
280 shared_ptr<FaceGroup> fg(
new FaceGroup(size,offset,
_faces,
id,boundaryType));
287 shared_ptr<Array<int> >
296 int BoundaryNodeCount=0;
307 const int nBFaces = BoundaryFaceNodes.
getRowDim();
308 for(
int i=0;i<nBFaces;i++)
310 for(
int ip=BFArray[i];ip<BFArray[i+1];ip++)
312 const int j = BNArray[ip];
313 if (globalToLocal[j] == -1)
314 globalToLocal[j] = nLocal++;
319 BoundaryNodeCount = nLocal;
331 Array<int>& GlobalToLocal = *GlobalToLocalPtr;
332 int BoundaryNodeCount = 0;
334 for(
int i=0;i<nNodes;i++)
336 if(GlobalToLocal[i] != -1)
339 BoundaryNodeCount = nLocal;
353 shared_ptr<CRConnectivity> conn)
355 SSPair key(&rowSite,&colSite);
362 SSPair key(&rowSite,&colSite);
395 shared_ptr<CRConnectivity> thisFaceCells =
398 return *thisFaceCells;
409 shared_ptr<CRConnectivity> thisFaceNodes =
412 return *thisFaceNodes;
442 shared_ptr<CRConnectivity> cellFaces = faceCells.getTranspose();
443 shared_ptr<CRConnectivity> cellNodes = cellFaces->multiply(faceNodes,
false);
462 shared_ptr<CRConnectivity> cellFaces = faceCells.
getTranspose();
489 shared_ptr<CRConnectivity> cellCells = cellFaces.
multiply(faceCells,
true);
500 if ( MPI::COMM_WORLD.Get_size() > 1 ) {
510 multimap<int,int>::const_iterator it0;
511 multimap<int,int>::const_iterator it1;
513 for (
int n = 0; n < ncells; n++ ){
515 for (
int k = 0; k < cellCells.
getCount(n); k++ ){
516 const int cellID1 = cellCells(n,k);
517 setCells.insert( cellID1 );
518 if ( cellID1 < selfCount ){
519 for (
int i = 0; i < cellCells.
getCount(cellID1); i++ ){
520 const int cellID2 = cellCells(cellID1,i);
521 setCells.insert(cellID2);
525 const int globalCellID2 = it1->second;
528 setCells.insert(localID2);
540 for (
int n = 0; n < ncells; n++ ){
542 for (
int k = 0; k < cellCells.
getCount(n); k++ ){
543 const int cellID1 = cellCells(n,k);
544 setCells.insert( cellID1 );
545 if ( cellID1 < selfCount ){
546 for (
int i = 0; i < cellCells.
getCount(cellID1); i++ ){
547 const int cellID2 = cellCells(cellID1,i);
548 setCells.insert(cellID2);
552 const int globalCellID2 = it1->second;
555 setCells.insert(localID2);
561 foreach (
const set<int>::value_type cellID, setCells ){
570 const int ncount =
_cellCells2->getRowSite().getCountLevel1();
573 for(
int i = 0; i < ncount; i++ ){
574 for (
int j = row[i]; j < row[i+1]; j++ ){
575 const int globalID = (*_localToGlobal)[ col[j] ];
586 for(
int i = 0; i < nfaces; i++ ){
587 for (
int j = row[i]; j < row[i+1]; j++ ){
588 const int globalID = (*_localToGlobal)[ col[j] ];
598 map<int,int>& globalToLocalMapper =
_cellCells2->getGlobalToLocalMapper();
600 globalToLocalMapper[mpos.first] = mpos.second;
606 for (
int i = 0; i < localToGlobal.
getLength(); i++ ){
607 localToGlobal[i] = (*_localToGlobal)[i];
674 for(
int i = 0; i < nfaces; i++ ){
675 for (
int j = row[i]; j < row[i+1]; j++ ){
676 const int globalID = (*_localToGlobal)[ col[j] ];
757 const map<int,int>& globalToLocal = nodes.
getScatterIndex().find(&boundaryNodes)->second;
762 const int globalNodeID = (*_localToGlobalNodes)[node];
763 const int localNodeID = globalToLocal.find(globalNodeID)->second;
764 (*_repeatNodes)[localNodeID] = 1;
783 shared_ptr< ArrayBase >
788 const map<int,int>& globalToLocal = nodes.
getScatterIndex().find(&boundaryNodes)->second;
790 shared_ptr< ArrayBase> returnCoord = geomField.
coordinate[nodes].newSizedClone( boundaryNodes.
getCount() );
795 const int globalNodeID = (*_localToGlobalNodes)[node];
796 const int localNodeID = globalToLocal.find(globalNodeID)->second;
797 coord[localNodeID] = fieldCoord[node] / double( (*
_repeatNodes)[localNodeID] );
815 const map<int,int>& globalToLocal = nodes.
getScatterIndex().find(&boundaryNodes)->second;
819 shared_ptr<CRConnectivity> nodeFacesBMeshPtr = faceNodesBMesh.
getTranspose();
825 const int nFaces = faces.
getCount();
827 for(
int f=0; f<nFaces; f++){
828 const int faceID = f + faces.
getOffset();
829 const int nFaceNodes = faceNodes.
getCount(faceID);
831 vector<int> nodeList(nFaceNodes,0);
832 for(
int nn=0; nn<nFaceNodes; nn++){
834 const int n=faceNodes(faceID,nn);
835 const int globalNodeID = (*_localToGlobalNodes)[n];
836 const int localNodeID = globalToLocal.find(globalNodeID)->second;
837 comp.insert(localNodeID);
838 nodeList[nn] = localNodeID;
842 for(
int i = 0; i < nFaceNodes; i++ ){
843 bool breakUpperLoop =
false;
844 const int nfaces = nodeFacesBMesh.
getCount(nodeList[i]);
846 for (
int j = 0; j < nfaces; j++ ){
847 const int localFaceID = nodeFacesBMesh(nodeList[i],j);
849 const int nnodes = faceNodesBMesh.
getCount(localFaceID);
850 vector<bool> matchingNodes(nFaceNodes,
false);
851 for (
int k = 0; k < nnodes; k++ ){
852 const int nodeID = faceNodesBMesh(localFaceID,j);
853 if ( comp.count(nodeID) == 1 ){
854 matchingNodes[k] =
true;
858 if ( find(matchingNodes.begin(), matchingNodes.end(),
false) == matchingNodes.end() ){
861 breakUpperLoop =
true;
865 if ( breakUpperLoop ){
881 const int nNodes = nodes.
getCount();
882 const int nOtherNodes = otherNodes.
getCount();
900 const int nFaces = faces.
getCount();
902 for(
int f=0; f<nFaces; f++)
904 const int nFaceNodes = faceNodes.
getCount(f);
905 for(
int nn=0; nn<nFaceNodes; nn++)
907 const int n=faceNodes(f,nn);
911 bNodeTree.
insert(coords[n],n);
923 typedef map<int,int> CommonNodesMap;
924 CommonNodesMap commonNodesMap;
937 const int nFaces = faces.
getCount();
940 for(
int f=0; f<nFaces; f++)
942 const int nFaceNodes = faceNodes.
getCount(f);
943 for(
int nn=0; nn<nFaceNodes; nn++)
945 const int n=faceNodes(f,nn);
950 double dist0 =
mag(otherCoords[n] - coords[closest[0]]);
954 double distScale =
mag(coords[closest[0]] - coords[closest[1]]);
960 if (commonNodesMap.find(closest[0]) != commonNodesMap.end())
962 throw CException(
"duplicate nodes on the mesh ?");
964 commonNodesMap.insert(make_pair(closest[0], n));
973 const int nCommon = commonNodesMap.size();
977 cout <<
"found " << nCommon <<
" common nodes " << endl;
979 shared_ptr<IntArray> myCommonNodes(
new IntArray(nCommon));
980 shared_ptr<IntArray> otherCommonNodes(
new IntArray(nCommon));
983 foreach(CommonNodesMap::value_type& pos, commonNodesMap)
985 (*myCommonNodes)[nc] = pos.first;
986 (*otherCommonNodes)[nc] = pos.second;
1000 if (count != otherFaces.
getCount())
1001 throw CException(
"face groups are not of the same length");
1019 shared_ptr<IntArray> myCommonFaces(
new IntArray(count));
1020 shared_ptr<IntArray> otherCommonFaces(
new IntArray(count));
1022 for(
int f=0; f<count; f++)
1024 thisFacesTree.findNeighbors(otherCoords[f],2,closest);
1026 const int closestFace = closest[0];
1027 double dist0 =
mag(otherCoords[f] - coords[closestFace]);
1031 double distScale =
mag(coords[closest[0]] - coords[closest[1]]);
1033 if (dist0 < distScale*
epsilon)
1035 double crossProductMag(
mag2(
cross(otherArea[f],area[closestFace])));
1036 if (crossProductMag >
mag2(otherArea[f])*epsilon)
1037 throw CException(
"cross product is not small");
1039 (*otherCommonFaces)[f] = closestFace;
1040 (*myCommonFaces)[closestFace] = f;
1057 if (count != otherFaces.
getCount())
1082 shared_ptr<IntArray> myCommonFaces(
new IntArray(count));
1083 shared_ptr<IntArray> otherCommonFaces(
new IntArray(count));
1085 for(
int f=0; f<count; f++)
1087 thisFacesTree.findNeighbors(otherCoords[f],neibs,closest);
1089 const int closestFace = closest[0];
1090 double dist0 =
mag(otherCoords[f] - coords[closestFace]);
1096 distScale=
mag(coords[closest[0]] - coords[closest[1]])*
epsilon;
1100 if (dist0 < distScale)
1102 double crossProductMag(
mag2(
cross(otherArea[f],area[closestFace])));
1106 (*otherCommonFaces)[f] = closestFace;
1107 (*myCommonFaces)[closestFace] = f;
1127 const int nodeCount = nodes.
getCount();
1130 globalToLocalNodes = -1;
1131 int bMeshNodeCount=0;
1132 int bMeshFaceCount=0;
1139 const int nFaces = faces.
getCount();
1141 for(
int f=0; f<nFaces; f++)
1143 const int nFaceNodes = faceNodes.
getCount(f);
1144 for(
int nn=0; nn<nFaceNodes; nn++)
1146 const int n=faceNodes(f,nn);
1147 if (globalToLocalNodes[n] == -1)
1149 globalToLocalNodes[n] = bMeshNodeCount++;
1153 bMeshFaceCount += nFaces;
1163 bMeshFaces.
setCount( bMeshFaceCount );
1164 bMeshNodes.
setCount( bMeshNodeCount );
1169 shared_ptr< Array<VecD3> > bMeshCoordPtr(
new Array< VecD3 > ( bMeshNodeCount ) );
1171 shared_ptr<IntArray> myCommonNodes(
new IntArray(bMeshNodeCount));
1172 shared_ptr<IntArray> otherCommonNodes(
new IntArray(bMeshNodeCount));
1174 for(
int n=0; n<nodeCount; n++)
1176 const int nLocal = globalToLocalNodes[n];
1179 (*bMeshCoordPtr)[nLocal] = coords[n];
1180 (*myCommonNodes)[nLocal] = nLocal;
1181 (*otherCommonNodes)[nLocal] = n;
1190 shared_ptr<CRConnectivity> bFaceNodes(
new CRConnectivity(bMeshFaces,
1193 bFaceNodes->initCount();
1203 const int nFaces = faces.
getCount();
1206 shared_ptr<IntArray> myCommonFaces(
new IntArray(nFaces));
1207 shared_ptr<IntArray> otherCommonFaces(
new IntArray(nFaces));
1209 for(
int f=0; f<nFaces; f++)
1211 const int nFaceNodes = faceNodes.
getCount(f);
1212 bFaceNodes->addCount(bMeshFaceCount,nFaceNodes);
1213 (*myCommonFaces)[f] = bMeshFaceCount;
1214 (*otherCommonFaces)[f] = f;
1223 bFaceNodes->finishCount();
1232 const int nFaces = faces.
getCount();
1234 for(
int f=0; f<nFaces; f++)
1236 const int nFaceNodes = faceNodes.
getCount(f);
1237 for(
int nn=0; nn<nFaceNodes; nn++)
1239 const int n=faceNodes(f,nn);
1240 const int nLocal = globalToLocalNodes[n];
1241 bFaceNodes->add(bMeshFaceCount,nLocal);
1248 bFaceNodes->finishAdd();
1250 SSPair key(&bMeshFaces,&bMeshNodes);
1264 throw CException(
"can only extrude two dimensional mesh");
1269 const int myNBoundaryFaces = myNFaces - myNInteriorFaces;
1273 const int eNInteriorFaces_rib = boundaryOnly ? 0 : nz*myNInteriorFaces;
1274 const int eNInteriorFaces_cap = (nz-1)*myNCells;
1276 const int eNInteriorFaces = eNInteriorFaces_rib + eNInteriorFaces_cap;
1277 const int eNBoundaryFaces = nz*myNBoundaryFaces + 2*myNCells;
1278 const int eNFaces = eNInteriorFaces + eNBoundaryFaces;
1279 const int eNInteriorCells = boundaryOnly ? 0 : nz*myNCells;
1280 const int eNBoundaryCells = boundaryOnly ? 0 : eNBoundaryFaces;
1282 const int eNNodes = (nz+1)*myNNodes;
1291 shared_ptr< Array<VecD3> > eMeshCoordPtr(
new Array< VecD3 > ( eNNodes ) );
1293 const double dz = zmax/nz;
1295 const double z0 = -zmax/2.0;
1296 for(
int k=0, en=0; k<=nz; k++)
1298 const double z = z0 + dz*k;
1299 for(
int n=0; n<myNNodes; n++)
1301 eCoords[en][0] = myCoords[n][0];
1302 eCoords[en][1] = myCoords[n][1];
1314 eMeshCells.
setCount( eNInteriorCells, eNBoundaryCells);
1323 shared_ptr<CRConnectivity> eFaceNodes(
new CRConnectivity(eMeshFaces,
1326 shared_ptr<CRConnectivity> eFaceCells(
new CRConnectivity(eMeshFaces,
1332 eFaceNodes->initCount();
1333 eFaceCells->initCount();
1340 for(; f<eNInteriorFaces_rib; f++)
1342 eFaceNodes->addCount(f,4);
1343 eFaceCells->addCount(f,2);
1347 for(
int k=1; k<nz; k++)
1349 for(
int c=0; c<myNCells; c++)
1351 eFaceNodes->addCount(f, myCellNodes.
getCount(c));
1352 eFaceCells->addCount(f, 2);
1363 for(
int c=0; c<myNCells; c++)
1365 eFaceNodes->addCount(f, myCellNodes.
getCount(c));
1366 eFaceCells->addCount(f, 2);
1372 for(
int c=0; c<myNCells; c++)
1374 eFaceNodes->addCount(f, myCellNodes.
getCount(c));
1375 eFaceCells->addCount(f, 2);
1385 const int nBFaces = faces.
getCount();
1389 for(
int k=0; k<nz; k++)
1390 for(
int bf=0; bf<nBFaces; bf++)
1392 eFaceNodes->addCount(f,4);
1393 eFaceCells->addCount(f,2);
1399 eFaceNodes->finishCount();
1400 eFaceCells->finishCount();
1416 for(
int k=0; k<nz; k++)
1418 const int eCellOffset = k*myNCells;
1419 const int eNodeOffset = k*myNNodes;
1421 for(
int myf=0; myf<myNInteriorFaces; myf++)
1423 const int myNode0 = myFaceNodes(myf,0);
1424 const int myNode1 = myFaceNodes(myf,1);
1426 const int myCell0 = myFaceCells(myf,0);
1427 const int myCell1 = myFaceCells(myf,1);
1430 eFaceNodes->add(f, myNode0 + eNodeOffset);
1431 eFaceNodes->add(f, myNode1 + eNodeOffset );
1432 eFaceNodes->add(f, myNode1 + eNodeOffset + myNNodes);
1433 eFaceNodes->add(f, myNode0 + eNodeOffset + myNNodes);
1435 eFaceCells->add(f, myCell0 + eCellOffset);
1436 eFaceCells->add(f, myCell1 + eCellOffset);
1443 for(
int k=1; k<nz; k++)
1445 const int eCellOffset = k*myNCells;
1446 const int eNodeOffset = k*myNNodes;
1448 for(
int c=0; c<myNCells; c++)
1450 const int nCellNodes = myCellNodes.
getCount(c);
1451 for(
int nnc=0; nnc<nCellNodes; nnc++)
1453 eFaceNodes->add(f, myCellNodes(c,nnc) + eNodeOffset);
1456 eFaceCells->add(f, c + eCellOffset - myNCells);
1457 eFaceCells->add(f, c + eCellOffset);
1469 const int eCellOffset = 0;
1470 const int eNodeOffset = 0;
1472 for(
int c=0; c<myNCells; c++)
1474 const int nCellNodes = myCellNodes.
getCount(c);
1477 for(
int nnc=nCellNodes-1; nnc>=0; nnc--)
1479 eFaceNodes->add(f, myCellNodes(c,nnc) + eNodeOffset);
1482 eFaceCells->add(f, c + eCellOffset);
1483 eFaceCells->add(f, ebf + eNInteriorCells);
1492 const int eCellOffset = (nz-1)*myNCells;
1493 const int eNodeOffset = nz*myNNodes;
1495 for(
int c=0; c<myNCells; c++)
1497 const int nCellNodes = myCellNodes.
getCount(c);
1500 for(
int nnc=0; nnc<nCellNodes; nnc++)
1502 eFaceNodes->add(f, myCellNodes(c,nnc) + eNodeOffset);
1505 eFaceCells->add(f, c + eCellOffset);
1506 eFaceCells->add(f, ebf + eNInteriorCells);
1520 const int nBFaces = faces.
getCount();
1525 for(
int k=0; k<nz; k++)
1527 const int eCellOffset = k*myNCells;
1528 const int eNodeOffset = k*myNNodes;
1529 for(
int bf=0; bf<nBFaces; bf++)
1531 const int myNode0 = bFaceNodes(bf,0);
1532 const int myNode1 = bFaceNodes(bf,1);
1534 const int myCell0 = bFaceCells(bf,0);
1537 eFaceNodes->add(f, myNode0 + eNodeOffset);
1538 eFaceNodes->add(f, myNode1 + eNodeOffset);
1539 eFaceNodes->add(f, myNode1 + eNodeOffset + myNNodes);
1540 eFaceNodes->add(f, myNode0 + eNodeOffset + myNNodes);
1542 eFaceCells->add(f, myCell0 + eCellOffset);
1543 eFaceCells->add(f, ebf + eNInteriorCells);
1553 eFaceNodes->finishAdd();
1554 eFaceCells->finishAdd();
1557 SSPair key1(&eMeshFaces,&eMeshNodes);
1562 SSPair key2(&eMeshFaces,&eMeshCells);
1578 throw CException(
"no face group with given id");
1610 sMeshCells.
setCount( count, 2*count);
1618 map<int, int> leftCellsToSCells;
1619 map<int, int> rightCellsToSCells;
1620 for(
int f=0; f<count; f++)
1622 const int lc1 = faceCells(f,1);
1623 const int rc1 = otherFaceCells(f,1);
1624 leftCellsToSCells[lc1] = f;
1625 rightCellsToSCells[rc1] = f;
1637 shared_ptr<IntArray> L2RScatterOrigPtr = lScatterMap[&otherCells];
1638 shared_ptr<IntArray> R2LScatterOrigPtr = rScatterMap[&cells];
1644 shared_ptr<IntArray> R2LGatherOrigPtr = lGatherMap[&otherCells];
1645 shared_ptr<IntArray> L2RGatherOrigPtr = rGatherMap[&cells];
1648 vector<int> L2SScatterVector;
1649 vector<int> R2SScatterVector;
1650 vector<int> S2LScatterVector;
1651 vector<int> S2RScatterVector;
1653 vector<int> L2SGatherVector;
1654 vector<int> R2SGatherVector;
1655 vector<int> S2LGatherVector;
1656 vector<int> S2RGatherVector;
1658 vector<int> L2RScatterNewVector;
1659 vector<int> R2LScatterNewVector;
1660 vector<int> L2RGatherNewVector;
1661 vector<int> R2LGatherNewVector;
1663 for(
int i=0; i<L2RScatterOrigPtr->getLength(); i++)
1665 const int lcs = (*L2RScatterOrigPtr)[i];
1666 const int rcg = (*L2RGatherOrigPtr)[i];
1668 if (rightCellsToSCells.find(rcg) != rightCellsToSCells.end())
1671 const int sCell = rightCellsToSCells[rcg];
1673 L2SScatterVector.push_back(lcs);
1674 L2SGatherVector.push_back(sCell+count);
1676 S2RScatterVector.push_back(sCell);
1677 S2RGatherVector.push_back(rcg);
1681 L2RScatterNewVector.push_back(lcs);
1682 L2RGatherNewVector.push_back(rcg);
1686 for(
int i=0; i<R2LGatherOrigPtr->getLength(); i++)
1688 const int lcg = (*R2LGatherOrigPtr)[i];
1689 const int rcs = (*R2LScatterOrigPtr)[i];
1691 if (leftCellsToSCells.find(lcg) != leftCellsToSCells.end())
1693 const int sCell = leftCellsToSCells[lcg];
1695 S2LGatherVector.push_back(lcg);
1696 S2LScatterVector.push_back(sCell);
1698 R2SGatherVector.push_back(sCell+2*count);
1699 R2SScatterVector.push_back(rcs);
1704 R2LGatherNewVector.push_back(lcg);
1705 R2LScatterNewVector.push_back(rcs);
1719 lScatterMap.erase(&otherCells);
1720 if (L2RScatterNewVector.size() > 0)
1724 lGatherMap.erase(&otherCells);
1725 if (R2LGatherNewVector.size() > 0)
1729 rScatterMap.erase(&cells);
1730 if (R2LScatterNewVector.size() > 0)
1734 rGatherMap.erase(&cells);
1735 if (L2RGatherNewVector.size() > 0)
1740 shared_ptr<CRConnectivity> sCellCells(
new CRConnectivity(sMeshCells,sMeshCells));
1741 sCellCells->initCount();
1744 for(
int i=0; i<count; i++)
1746 sCellCells->addCount(i,2);
1747 sCellCells->addCount(i+count,1);
1748 sCellCells->addCount(i+2*count,1);
1751 sCellCells->finishCount();
1753 for(
int i=0; i<count; i++)
1755 sCellCells->add(i,i+count);
1756 sCellCells->add(i,i+2*count);
1758 sCellCells->add(i+count,i);
1759 sCellCells->add(i+2*count,i);
1762 sCellCells->finishAdd();
1764 SSPair key(&sMeshCells,&sMeshCells);
1805 sMeshCells.
setCount( 2*count, 2*count);
1813 map<int, int> leftCellsToSCells;
1814 map<int, int> rightCellsToSCells;
1831 for(
int f=0; f<count; f++)
1834 const int lc1 = faceCells(f,lDirection);
1835 const int rc1 = otherFaceCells(f,rDirection);
1836 leftCellsToSCells[lc1] = f;
1837 rightCellsToSCells[rc1] = f;
1850 shared_ptr<IntArray> L2RScatterOrigPtr = lScatterMap[&otherCells];
1851 shared_ptr<IntArray> R2LScatterOrigPtr = rScatterMap[&cells];
1857 shared_ptr<IntArray> R2LGatherOrigPtr = lGatherMap[&otherCells];
1858 shared_ptr<IntArray> L2RGatherOrigPtr = rGatherMap[&cells];
1861 vector<int> L2SScatterVector;
1862 vector<int> R2SScatterVector;
1863 vector<int> S2LScatterVector;
1864 vector<int> S2RScatterVector;
1866 vector<int> L2SGatherVector;
1867 vector<int> R2SGatherVector;
1868 vector<int> S2LGatherVector;
1869 vector<int> S2RGatherVector;
1871 vector<int> L2RScatterNewVector;
1872 vector<int> R2LScatterNewVector;
1873 vector<int> L2RGatherNewVector;
1874 vector<int> R2LGatherNewVector;
1876 for(
int i=0; i<L2RScatterOrigPtr->getLength(); i++)
1878 const int lcs = (*L2RScatterOrigPtr)[i];
1879 const int rcg = (*L2RGatherOrigPtr)[i];
1881 if (rightCellsToSCells.find(rcg) != rightCellsToSCells.end())
1884 const int sCell = rightCellsToSCells[rcg];
1886 L2SScatterVector.push_back(lcs);
1887 L2SGatherVector.push_back(sCell+3*count);
1889 S2RScatterVector.push_back(sCell+count);
1890 S2RGatherVector.push_back(rcg);
1894 L2RScatterNewVector.push_back(lcs);
1895 L2RGatherNewVector.push_back(rcg);
1899 for(
int i=0; i<R2LGatherOrigPtr->getLength(); i++)
1901 const int lcg = (*R2LGatherOrigPtr)[i];
1902 const int rcs = (*R2LScatterOrigPtr)[i];
1904 if (leftCellsToSCells.find(lcg) != leftCellsToSCells.end())
1906 const int sCell = leftCellsToSCells[lcg];
1908 S2LGatherVector.push_back(lcg);
1909 S2LScatterVector.push_back(sCell);
1911 R2SGatherVector.push_back(sCell+2*count);
1912 R2SScatterVector.push_back(rcs);
1917 R2LGatherNewVector.push_back(lcg);
1918 R2LScatterNewVector.push_back(rcs);
1932 lScatterMap.erase(&otherCells);
1933 if (L2RScatterNewVector.size() > 0)
1937 lGatherMap.erase(&otherCells);
1938 if (R2LGatherNewVector.size() > 0)
1942 rScatterMap.erase(&cells);
1943 if (R2LScatterNewVector.size() > 0)
1947 rGatherMap.erase(&cells);
1948 if (L2RGatherNewVector.size() > 0)
1953 shared_ptr<CRConnectivity> sCellCells(
new CRConnectivity(sMeshCells,sMeshCells));
1954 sCellCells->initCount();
1958 for(
int i=0; i<count; i++)
1960 sCellCells->addCount(i,3);
1961 sCellCells->addCount(i+count,3);
1962 sCellCells->addCount(i+2*count,2);
1963 sCellCells->addCount(i+3*count,2);
1966 sCellCells->finishCount();
1968 for(
int i=0; i<count; i++)
1971 sCellCells->add(i,i+count);
1972 sCellCells->add(i,i+2*count);
1973 sCellCells->add(i,i+3*count);
1976 sCellCells->add(i+count,i);
1977 sCellCells->add(i+count,i+2*count);
1978 sCellCells->add(i+count,i+3*count);
1981 sCellCells->add(i+2*count,i);
1982 sCellCells->add(i+2*count,i+count);
1985 sCellCells->add(i+3*count,i);
1986 sCellCells->add(i+3*count,i+count);
1989 sCellCells->finishAdd();
1991 SSPair key(&sMeshCells,&sMeshCells);
2018 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
2021 const Array<int>& scatterArray = *mpos.second;
2028 for(
int i = 0; i < scatterArray.
getLength(); i++ ){
2029 const int cellID = scatterArray[i];
2030 sendArray[i] = cellCells.
getCount(cellID);
2037 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2039 const Array<int>& gatherArray = *mpos.second;
2055 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2077 MPI::Request request_send[ request_size ];
2078 MPI::Request request_recv[ request_size ];
2083 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
2091 if ( to_where != -1 ){
2092 int mpi_tag = oSite.
getTag();
2093 request_send[indxSend++] =
2094 MPI::COMM_WORLD.Isend( sendArray.
getData(), sendArray.
getDataSize(), MPI::BYTE, to_where, mpi_tag );
2100 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2106 if ( from_where != -1 ){
2107 int mpi_tag = oSite.
getTag();
2108 request_recv[indxRecv++] =
2109 MPI::COMM_WORLD.Irecv( recvArray.
getData(), recvArray.
getDataSize(), MPI::BYTE, from_where, mpi_tag );
2114 MPI::Request::Waitall( count, request_recv );
2115 MPI::Request::Waitall( count, request_send );
2132 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
2134 const Array<int>& scatterArray = *mpos.second;
2139 for (
int i = 0; i < scatterArray.
getLength(); i++ ){
2140 sendSize += cellCells.
getCount( scatterArray[i] );
2146 for(
int i = 0; i < scatterArray.
getLength(); i++ ){
2147 const int cellID = scatterArray[i];
2148 for (
int j = 0; j < cellCells.
getCount(cellID); j++ ){
2149 sendArray[indx] = localToGlobal[ cellCells(cellID,j) ];
2156 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2161 for (
int i = 0; i < recvCounts.
getLength(); i++ ){
2162 recvSize += recvCounts[i];
2178 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2196 MPI::Request request_send[ request_size ];
2197 MPI::Request request_recv[ request_size ];
2202 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
2209 if ( to_where != -1 ){
2210 int mpi_tag = oSite.
getTag();
2211 request_send[indxSend++] =
2212 MPI::COMM_WORLD.Isend( sendArray.
getData(), sendArray.
getDataSize(), MPI::BYTE, to_where, mpi_tag );
2218 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2223 if ( from_where != -1 ){
2224 int mpi_tag = oSite.
getTag();
2225 request_recv[indxRecv++] =
2226 MPI::COMM_WORLD.Irecv( recvArray.
getData(), recvArray.
getDataSize(), MPI::BYTE, from_where, mpi_tag );
2231 MPI::Request::Waitall( count, request_recv );
2232 MPI::Request::Waitall( count, request_send );
2243 set<int> interfaceCells;
2247 const int originalCount = site.
getCount();
2249 int countLevel0 = 0;
2250 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2259 for (
int i = 0; i < gatherArray.
getLength(); i++ ){
2260 const int nnb = recv_counts[i];
2261 for (
int nb = 0; nb < nnb; nb++ ){
2262 const int localID = globalToLocal.find( recv_indices[indx] )->second;
2263 if ( localID >= originalCount ){
2264 interfaceCells.insert( recv_indices[indx] );
2271 const int countLevel1 = int(interfaceCells.size());
2289 for (
int i = 0; i < ncount; i++ ){
2294 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2300 for (
int i = 0; i < gatherArray.
getLength(); i++ ){
2301 conn.
addCount(gatherArray[i], recv_counts[i] );
2317 for (
int i = 0; i < ncount; i++ ){
2318 for (
int j = 0; j < cellCells.
getCount(i); j++ ){
2319 conn.
add(i, cellCells(i,j));
2328 foreach(
const StorageSite::GatherMap::value_type& mpos, gatherMap){
2336 for (
int i = 0; i < gatherArray.
getLength(); i++ ){
2337 const int ncount = recv_counts[i];
2338 for (
int j = 0; j < ncount; j++ ){
2339 const int addCell = globalToLocal.find( recv_indices[indx] )->second;
2340 conn.
add(gatherArray[i], addCell);
2355 for (
int bounID = 0; bounID < int(boundaryFaceGroups.size()); bounID++){
2356 nBounElm += boundaryFaceGroups.at(bounID)->site.getCount();
2368 foreach(
const StorageSite::ScatterMap::value_type& mpos, scatterMap){
2382 if ( MPI::COMM_WORLD.Get_rank() == procID ){
2383 cout << name <<
" :" << endl;
2386 for (
int i = 0; i < row.
getLength()-1; i++ ){
2387 cout <<
" i = " << i <<
", ";
2388 for (
int j = row[i]; j < row[i+1]; j++ )
2389 cout << col[j] <<
" ";
2400 if ( MPI::COMM_WORLD.Get_rank() == procID ){
2402 stringstream ss(stringstream::in | stringstream::out);
2404 string fname = name + ss.str() +
".dat";
2405 debugFile.open( fname.c_str() );
2408 debugFile << name <<
" :" << endl;
2412 for (
int i = 0; i < row.
getLength()-1; i++ ){
2413 debugFile <<
" i = " << i <<
", ";
2414 for (
int j = row[i]; j < row[i+1]; j++ )
2415 debugFile << col[j] <<
" ";
const CRConnectivity & getAllFaceNodes() const
const FaceGroupList & getBoundaryFaceGroups() const
void setNodeRepeationArrayCoupling(const Mesh &bMesh)
const Array< int > & getCol() const
int getCount(const int i) const
virtual int getDataSize() const =0
const Array< int > & getRow() const
const ArrayBase & getSendCounts(const EntryIndex &e) const
shared_ptr< FaceGroup > FaceGroupPtr
void setFaceNodes(shared_ptr< CRConnectivity > faceNodes)
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
void findCommonFaces(StorageSite &faces, StorageSite &otherFaces, const GeomFields &geomFields)
map< int, int > _globalToLocal
void eraseConnectivity(const StorageSite &rowSite, const StorageSite &colSite) const
void createGhostCellSiteScatter(const PartIDMeshIDPair &id, shared_ptr< StorageSite > site)
const FaceGroupList & getAllFaceGroups() const
shared_ptr< Array< int > > _ibFaceList
void CRConnectivityPrint(const CRConnectivity &conn, int procID, const string &name)
bool COMETfindCommonFaces(StorageSite &faces, StorageSite &otherFaces, const GeomFields &geomFields)
const StorageSite & getNodes() const
FaceGroupList _interfaceGroups
map< int, int > _commonFacesMapOther
const StorageSite & createInteriorFaceGroup(const int size)
const ScatterIndex & getScatterIndex() const
void createGhostCellSiteGatherLevel1(const PartIDMeshIDPair &id, shared_ptr< StorageSite > site)
map< int, int > _commonFacesMap
const Array< int > & getIBFaceList() const
void setCoordinates(shared_ptr< Array< VecD3 > > x)
GhostArrayMap _sendCounts
const FaceGroup & getFaceGroup(const int fgId) const
ConnectivityMap _connectivityMap
const CRConnectivity & getFaceNodes(const StorageSite &site) const
const CommonMap & getCommonMap() const
T mag(const Vector< T, 3 > &a)
void setFaceCells(shared_ptr< CRConnectivity > faceCells)
void setCount(const int selfCount, const int nGhost=0)
shared_ptr< CRConnectivity > _cellCellsGhostExt
Mesh * createShell(const int fgId, Mesh &otherMesh, const int otherFgId)
void createRowColSiteCRConn()
void setConnectivity(const StorageSite &rowSite, const StorageSite &colSite, shared_ptr< CRConnectivity > conn)
map< int, int > & getGlobalToLocal()
GhostCellSiteMap _ghostCellSiteScatterMapLevel1
Mesh * extrude(int nz, double zmax, bool boundaryOnly=false)
const StorageSite & createBoundaryFaceGroup(const int size, const int offset, const int id, const string &boundaryType)
void recvScatterGatherCountsBufferLocal()
GhostCellSiteMap _ghostCellSiteGatherMapLevel1
const ArrayBase & getSendIndices(const EntryIndex &e) const
GhostArrayMap _recvIndices
void setMesh(const Mesh *mesh)
const StorageSite * _otherFaceGroupSite
Mesh(const int dimension)
Tangent sqrt(const Tangent &a)
void orderCellFacesAndNodes(CRConnectivity &cellFaces, CRConnectivity &cellNodes, const CRConnectivity &faceNodes, const CRConnectivity &faceCells, const Array< Vector< double, 3 > > &nodeCoordinates)
pair< const StorageSite *, const StorageSite * > EntryIndex
const CRConnectivity & getAllFaceCells() const
const CRConnectivity & getCellFaces() const
shared_ptr< CRConnectivity > _cellCells2
void createGhostCellSiteGather(const PartIDMeshIDPair &id, shared_ptr< StorageSite > site)
const StorageSite & getBoundaryNodes() const
set< int > _boundaryNodesSet
shared_ptr< Array< int > > _boundaryNodeGlobalToLocalPtr
GhostCellSiteMap _ghostCellSiteScatterMap
const Array< VecD3 > & getNodeCoordinates() const
const StorageSite & createInterfaceGroup(const int size, const int offset, const int id)
Array< int > & getLocalToGlobal()
Mesh * createDoubleShell(const int fgId, Mesh &otherMesh, const int otherFgId, const bool connectedShell)
Mesh * extractBoundaryMesh()
shared_ptr< Array< int > > _cellColorOther
GhostArrayMap _recvCounts
int getGatherProcID() const
void createScatterGatherIndicesBuffer()
GhostCellSiteMap _ghostCellSiteGatherMap
void findCommonNodes(Mesh &other)
void CRConnectivityPrintFile(const CRConnectivity &conn, const string &name, const int procID) const
vector< FaceGroupPtr > FaceGroupList
pair< const StorageSite *, const StorageSite * > SSPair
void findNeighbors(const Vec3D &p, const int k, Array< int > &neighbors)
multiMap _cellCellsGlobal
const Mesh & getMesh() const
shared_ptr< StorageSite > _cellSiteGhostExt
pair< int, int > PartIDMeshIDPair
const StorageSite & getFaces() const
void recvScatterGatherIndicesBufferLocal()
shared_ptr< FaceGroup > _interiorFaceGroup
FaceGroupList _boundaryGroups
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
Vector< T, 3 > cross(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
void createLocalGlobalArray()
int getCountLevel1() const
shared_ptr< CRConnectivity > _faceCells2
const ScatterMap & getScatterMap() const
void InterfaceToBoundary()
const CRConnectivity & getFaceCells(const StorageSite &site) const
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
const CRConnectivity & getFaceCells2() const
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
shared_ptr< Array< int > > _repeatNodes
const GatherMap & getGatherMap() const
shared_ptr< Array< int > > _localToGlobal
shared_ptr< Array< int > > _cellColor
void createGhostCellSiteScatterLevel1(const PartIDMeshIDPair &id, shared_ptr< StorageSite > site)
shared_ptr< CRConnectivity > getTranspose() const
int add(const int index, const int val)
shared_ptr< CRConnectivity > createOffset(const StorageSite &newRowSite, const int offset, const int size) const
const CRConnectivity & getCellCells2() const
virtual void * getData() const =0
shared_ptr< Array< int > > createAndGetBNglobalToLocal() const
void createScatterGatherCountsBuffer()
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
GhostArrayMap _sendIndices
shared_ptr< Array< VecD3 > > _coordinates
shared_ptr< ArrayBase > getUpdatedNodesCoordCoupling(const GeomFields &geomField, const Mesh &bMesh)
void createCellCellsGhostExt()
StorageSite * _boundaryNodes
void setCommonFacesMap(const Mesh &bMesh)
const StorageSite * _parentFaceGroupSite
const StorageSite & getRowSite() const
FaceGroupList _faceGroups
void addCount(const int index, const int count)
const CRConnectivity & getCellNodes() const
const ArrayBase & getBNglobalToLocal() const
void createLocalToGlobalNodesArray()
shared_ptr< Array< T > > arrayFromVector(const vector< T > &v)
shared_ptr< Array< int > > _localToGlobalNodes
void insert(const Vec3D &v, const int n)
T mag2(const Vector< T, 3 > &a)