634 const bitSet& selectedCells,
640 const auto* basePointMeshPtr =
641 baseMesh_.thisDb().cfindObject<pointMesh>(pointMesh::typeName);
642 if (basePointMeshPtr)
644 DebugPout<<
"fvMeshSubset::reset(const bitSet&) :"
645 <<
" Detected pointMesh" <<
endl;
652 const cellList& oldCells = baseMesh().cells();
653 const faceList& oldFaces = baseMesh().faces();
654 const pointField& oldPoints = baseMesh().points();
655 const labelList& oldOwner = baseMesh().faceOwner();
656 const labelList& oldNeighbour = baseMesh().faceNeighbour();
658 const label oldNInternalFaces = baseMesh().nInternalFaces();
664 if (wantedPatchID == -1)
668 wantedPatchID = oldPatches.findPatchID(exposedPatchName);
670 else if (wantedPatchID < 0 || wantedPatchID >= oldPatches.size())
673 <<
"Non-existing patch index " << wantedPatchID <<
endl
674 <<
"Should be between 0 and " << oldPatches.size()-1
679 cellMap_ = selectedCells.sortedToc();
684 label len = cellMap_.size();
688 i >= 0 && (cellMap_[i] >= oldCells.size());
694 cellMap_.resize(len);
710 label nFacesInSet = 0;
712 forAll(oldFaces, oldFacei)
714 bool faceUsed =
false;
716 if (selectedCells.test(oldOwner[oldFacei]))
718 ++nCellsUsingFace[oldFacei];
724 baseMesh().isInternalFace(oldFacei)
725 && selectedCells.test(oldNeighbour[oldFacei])
728 ++nCellsUsingFace[oldFacei];
737 faceMap_.resize(nFacesInSet);
740 doCoupledPatches(syncPar, nCellsUsingFace);
744 label oldInternalPatchID = 0;
747 label nextPatchID = oldPatches.size();
750 labelList globalPatchMap(oldPatches.size());
753 label nbSize = oldPatches.size();
755 if (wantedPatchID == -1)
761 forAll(oldPatches, patchi)
765 nextPatchID = patchi;
768 ++oldInternalPatchID;
774 for (label oldPatchi = 0; oldPatchi < nextPatchID; oldPatchi++)
776 globalPatchMap[oldPatchi] = oldPatchi;
780 label oldPatchi = nextPatchID;
781 oldPatchi < oldPatches.size();
785 globalPatchMap[oldPatchi] = oldPatchi+1;
790 oldInternalPatchID = wantedPatchID;
791 nextPatchID = wantedPatchID+1;
794 globalPatchMap =
identity(oldPatches.size());
801 labelList globalPointMap(oldPoints.size(), -1);
802 labelList globalFaceMap(oldFaces.size(), -1);
807 for (label oldFacei = 0; oldFacei < oldNInternalFaces; ++oldFacei)
809 if (nCellsUsingFace[oldFacei] == 2)
811 globalFaceMap[oldFacei] = facei;
812 faceMap_[facei++] = oldFacei;
815 markUsed(oldFaces[oldFacei], globalPointMap);
820 const label nInternalFaces = facei;
826 oldPatchi < oldPatches.size()
827 && oldPatchi < nextPatchID;
831 const polyPatch& oldPatch = oldPatches[oldPatchi];
833 label oldFacei = oldPatch.
start();
837 if (nCellsUsingFace[oldFacei] == 1)
842 globalFaceMap[oldFacei] = facei;
843 faceMap_[facei++] = oldFacei;
846 markUsed(oldFaces[oldFacei], globalPointMap);
849 ++boundaryPatchSizes[globalPatchMap[oldPatchi]];
856 for (label oldFacei = 0; oldFacei < oldNInternalFaces; ++oldFacei)
858 if (nCellsUsingFace[oldFacei] == 1)
860 globalFaceMap[oldFacei] = facei;
861 faceMap_[facei++] = oldFacei;
864 markUsed(oldFaces[oldFacei], globalPointMap);
867 ++boundaryPatchSizes[oldInternalPatchID];
874 label oldFacei = oldNInternalFaces;
875 oldFacei < oldFaces.size();
879 if (nCellsUsingFace[oldFacei] == 3)
881 globalFaceMap[oldFacei] = facei;
882 faceMap_[facei++] = oldFacei;
885 markUsed(oldFaces[oldFacei], globalPointMap);
888 ++boundaryPatchSizes[oldInternalPatchID];
895 label oldPatchi = nextPatchID;
896 oldPatchi < oldPatches.size();
900 const polyPatch& oldPatch = oldPatches[oldPatchi];
902 label oldFacei = oldPatch.
start();
906 if (nCellsUsingFace[oldFacei] == 1)
911 globalFaceMap[oldFacei] = facei;
912 faceMap_[facei++] = oldFacei;
915 markUsed(oldFaces[oldFacei], globalPointMap);
918 ++boundaryPatchSizes[globalPatchMap[oldPatchi]];
924 if (facei != nFacesInSet)
932 label nPointsInSet = 0;
934 forAll(globalPointMap, pointi)
936 if (globalPointMap[pointi] != -1)
941 pointMap_.setSize(nPointsInSet);
945 forAll(globalPointMap, pointi)
947 if (globalPointMap[pointi] != -1)
949 pointMap_[nPointsInSet] = pointi;
950 globalPointMap[pointi] = nPointsInSet;
976 auto iter = newFaces.begin();
977 const auto& renumbering = globalPointMap;
980 for (label facei = 0; facei < nInternalFaces; ++facei)
982 face& newItem = *iter;
985 const face& oldItem = oldFaces[faceMap_[facei]];
988 newItem.
resize(oldItem.size());
992 newItem[i] = renumbering[oldItem[i]];
997 for (label facei = nInternalFaces; facei < faceMap_.size(); ++facei)
999 const label oldFacei = faceMap_[facei];
1001 face& newItem = *iter;
1004 const face oldItem =
1007 baseMesh().isInternalFace(oldFacei)
1008 && selectedCells.test(oldNeighbour[oldFacei])
1009 && !selectedCells.test(oldOwner[oldFacei])
1012 ? oldFaces[oldFacei].reverseFace()
1013 : oldFaces[oldFacei]
1017 newItem.
resize(oldItem.size());
1021 newItem[i] = renumbering[oldItem[i]];
1031 cellList newCells(cellMap_.size());
1033 auto iter = newCells.begin();
1034 const auto& renumbering = globalFaceMap;
1036 for (
const label oldCelli : cellMap_)
1038 cell& newItem = *iter;
1041 const labelList& oldItem = oldCells[oldCelli];
1044 newItem.resize(oldItem.size());
1048 newItem[i] = renumbering[oldItem[i]];
1066 baseMesh_.time().timeName(),
1072 std::move(newPoints),
1073 std::move(newFaces),
1074 std::move(newCells),
1081 patchMap_.resize(nbSize);
1082 label nNewPatches = 0;
1083 label patchStart = nInternalFaces;
1091 labelList globalPatchSizes(boundaryPatchSizes);
1092 globalPatchSizes.setSize(nextPatchID);
1110 bool samePatches =
true;
1116 samePatches =
false;
1134 label oldPatchi = 0;
1135 oldPatchi < oldPatches.size()
1136 && oldPatchi < nextPatchID;
1140 const label newSize = boundaryPatchSizes[globalPatchMap[oldPatchi]];
1142 if (oldInternalPatchID != oldPatchi)
1147 for (label patchFacei = 0; patchFacei < newSize; patchFacei++)
1149 const label facei = patchStart+patchFacei;
1150 const label oldFacei = faceMap_[facei];
1151 map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
1157 oldPatches[oldPatchi].clone
1172 oldPatches[oldPatchi].clone
1182 patchStart += newSize;
1183 patchMap_[nNewPatches] = oldPatchi;
1189 label newInternalPatchID = -1;
1191 if (wantedPatchID == -1)
1193 label oldInternalSize = boundaryPatchSizes[oldInternalPatchID];
1201 if (oldInternalSize > 0)
1209 boundaryPatchSizes[oldInternalPatchID],
1213 emptyPolyPatch::typeName
1222 patchStart += boundaryPatchSizes[oldInternalPatchID];
1223 patchMap_[nNewPatches] = -1;
1224 newInternalPatchID = nNewPatches;
1233 label oldPatchi = nextPatchID;
1234 oldPatchi < oldPatches.size();
1238 const label newSize = boundaryPatchSizes[globalPatchMap[oldPatchi]];
1240 if (oldInternalPatchID != oldPatchi)
1245 for (label patchFacei = 0; patchFacei < newSize; patchFacei++)
1247 const label facei = patchStart+patchFacei;
1248 const label oldFacei = faceMap_[facei];
1249 map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
1255 oldPatches[oldPatchi].clone
1270 oldPatches[oldPatchi].clone
1283 patchStart += newSize;
1284 patchMap_[nNewPatches] = oldPatchi;
1290 newBoundary.resize(nNewPatches);
1291 patchMap_.resize(nNewPatches);
1295 subMeshPtr_().addFvPatches(newBoundary, syncPar);
1301 if (basePointMeshPtr)
1304 const auto& basePointMesh = *basePointMeshPtr;
1305 const auto& oldPointBoundary = basePointMesh.boundary();
1311 pointPatchMap_ = patchMap_;
1318 labelList oldToNewPoints(baseMesh_.nPoints(), -1);
1321 oldToNewPoints[pointMap_[i]] = i;
1326 pointPatchMap_.setSize(newBoundary.size(), -1);
1328 for (
const auto& oldPointPatch : oldPointBoundary)
1331 if (mppPtr && (newBoundary.findPatchID(mppPtr->name()) == -1))
1333 const auto&
mp = mppPtr->meshPoints();
1340 subPointMap.append(i);
1344 pointPatchMap_.push_back(mppPtr->index());
1346 newBoundary.push_back
1365 label newPatchi = 0;
1366 forAll(newBoundary, patchi)
1370 patchi != newInternalPatchID
1374 oldToNew[patchi] = newPatchi++;
1377 if (newInternalPatchID != -1)
1379 oldToNew[newInternalPatchID] = newPatchi++;
1381 forAll(newBoundary, patchi)