52 label patchFaceI = initial;
53 forAll(patchSizes_, patchI)
55 startLst[patchI] = patchFaceI;
56 patchFaceI += patchSizes_[patchI];
63 void Foam::ccm::reader::printSizes()
const
65 Info<<
"nPoints:" << nPoints_
66 <<
" nCells:" << nCells_
67 <<
" nFaces:" << nFaces_
68 <<
" nInternalFaces:" << nInternalFaces_
79 bool Foam::ccm::reader::detectGeometry()
82 if (geometryStatus_ != UNKNOWN)
84 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
98 ccmID verticesNode, topoNode;
105 (globalState_->root),
122 && CCMIOReadProcessor
133 && CCMIOIsFromSameFile((globalState_->root), verticesNode)
134 && CCMIOIsFromSameFile((globalState_->root), topoNode)
135 && CCMIOIsValidEntity(probNode)
138 readProblemDescription(probNode);
139 geometryStatus_ = OKAY;
144 geometryStatus_ = BAD;
147 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
152 void Foam::ccm::reader::readMeshTopology
154 const scalar scaleFactor
157 ccmID verticesNode, topoNode;
172 (globalState_->root),
189 && CCMIOReadProcessor
201 labelList origPointId = readVertices(verticesNode, scaleFactor);
203 readMonitoring(topoNode);
207 label maxId =
max(origPointId);
219 label maxId =
max(origCellId_);
239 mergeInplaceInterfaces();
251 const ccmID& verticesNode,
252 const scalar scaleFactor
261 #ifdef DEBUG_CCMIOREAD
268 &(globalState_->error),
276 &(globalState_->error),
285 assertNoError(
"problem finding 'Vertices' node");
290 <<
"can only handle 3-dimensional vertices"
304 List<scalar> vrts(3*nPoints_);
309 &(globalState_->error),
318 assertNoError(
"problem reading 'Vertices' node");
321 points_.setSize(nPoints_);
323 scalar effectiveScale = scale * scaleFactor;
326 points_[i].x() = effectiveScale * vrts[i*3];
327 points_[i].y() = effectiveScale * vrts[i*3+1];
328 points_[i].z() = effectiveScale * vrts[i*3+2];
333 #ifdef DEBUG_CCMIOREAD
334 Info<<
"readVertices: " << nPoints_ <<
endl;
344 void Foam::ccm::reader::readCells
346 const ccmID& topoNode
350 ccmID cellsNode, mapId;
353 #ifdef DEBUG_CCMIOREAD
360 &(globalState_->error),
369 &(globalState_->error),
374 assertNoError(
"cannot get 'Cells' node");
378 #ifdef DEBUG_CCMIOREAD
379 Info<<
"readCells: " << nCells_ <<
endl;
383 origCellId_.setSize(nCells_);
384 cellTableId_.setSize(nCells_);
388 &(globalState_->error),
391 cellTableId_.begin(),
395 assertNoError(
"Error reading 'Cells' node");
406 &(globalState_->error),
414 &(globalState_->error),
419 nInternalFaces_ = size;
421 nFaces_ = nInternalFaces_;
429 DynamicList<ccmBoundaryInfo> bndInfo;
435 CCMIOGetNumberOfChildren
459 &(globalState_->error),
467 ccmBoundaryInfo info;
473 &(globalState_->error),
479 info.setPatchName(ccmReadOptstr(
"Label", nodeId));
482 auto dictIter = boundaryRegion_.find(info.ccmIndex);
483 if (dictIter.found())
485 dictionary&
dict = dictIter.val();
487 const word patchName(
dict.get<word>(
"Label"));
488 const word patchType(
dict.get<word>(
"BoundaryType"));
490 if (!patchName.empty())
492 info.patchName = patchName;
495 if (!patchType.empty())
497 info.patchType = patchType;
501 dict.add(
"BoundaryIndex", info.ccmIndex);
502 dict.add(
"size", info.size);
505 bndInfo.append(info);
509 faces_.setSize(nFaces_);
510 faceOwner_.setSize(nFaces_);
511 faceNeighbour_.setSize(nFaces_);
512 origFaceId_.setSize(nFaces_);
516 patchSizes_.setSize(bndInfo.size());
517 origBndId_.setSize(bndInfo.size());
524 ccmBoundaryInfo& info = bndInfo[infoI];
526 if (info.patchId != -1)
529 origBndId_[info.patchId] = info.ccmIndex;
534 origBndId_[info.patchId] = info.ccmIndex;
537 patchSizes_[info.patchId] += info.size;
546 IndirectList<ccmBoundaryInfo> ccmLookupOrder(bndInfo,
labelList());
548 DynamicList<label> addr(bndInfo.size());
549 for (
int patchI = 0; patchI <
nPatches; ++patchI)
553 if (bndInfo[infoI].
patchId == patchI)
560 ccmLookupOrder.addressing() = std::move(addr);
569 &(globalState_->error),
579 &(globalState_->error),
589 List<label> mapData(nInternalFaces_);
590 List<label> faceCells(2*nInternalFaces_);
591 List<label> ccmFaces(size);
595 &(globalState_->error),
607 &(globalState_->error),
614 assertNoError(
"Error reading internal faces");
624 unsigned int pos = 0;
625 for (label faceI = 0; faceI < nInternalFaces_; ++faceI)
627 origFaceId_[faceI] = mapData[faceI];
628 faceOwner_[faceI] = faceCells[2*faceI];
629 faceNeighbour_[faceI] = faceCells[2*faceI+1];
630 face&
f = faces_[faceI];
632 f.setSize(ccmFaces[
pos++]);
635 f[fp] = ccmFaces[
pos++];
641 label patchFaceI = nInternalFaces_;
643 forAll(ccmLookupOrder, lookupI)
645 const ccmBoundaryInfo& info = ccmLookupOrder[lookupI];
646 const unsigned int patchSize = info.size;
652 &(globalState_->error),
662 &(globalState_->error),
672 mapData.setSize(patchSize);
673 faceCells.setSize(patchSize);
674 ccmFaces.setSize(size);
684 &(globalState_->error),
695 &(globalState_->error),
704 "Error reading boundary face cells - index "
710 unsigned int pos = 0;
711 for (
unsigned int i = 0; i < patchSize; ++i, ++patchFaceI)
713 origFaceId_[patchFaceI] = mapData[i];
714 faceOwner_[patchFaceI] = faceCells[i];
715 faceNeighbour_[patchFaceI] = -1;
717 face&
f = faces_[patchFaceI];
719 f.setSize(ccmFaces[
pos++]);
722 f[fp] = ccmFaces[
pos++];
730 "Error reading boundary faces - index "
736 readInterfaces(cellsNode);
744 void Foam::ccm::reader::readInterfaces
746 const ccmID& cellsNode
749 #ifdef DEBUG_CCMIOREAD
753 label nBaffleInterface = 0, nInterfaceTotal = 0;
754 CCMIOIndex size = 0, dims = 0;
756 bafInterfaces_.clear();
757 domInterfaces_.clear();
785 && size > 0 && dims == 2
788 nInterfaceTotal = size;
815 nBaffleInterface = (size - size % 4) / 4;
819 label nDomainInterface = nInterfaceTotal - nBaffleInterface;
822 List<int> mapData(
max(2 * nInterfaceTotal, 4 * nBaffleInterface), -1);
824 bafInterfaces_.setSize(nBaffleInterface);
825 domInterfaces_.setSize(nDomainInterface);
828 label maxId =
max(origFaceId_);
831 if (nBaffleInterface > 0)
837 &(globalState_->error),
844 assertNoError(
"problem reading interface 'ProstarBaffles'");
851 for (label i=0; i < nBaffleInterface; ++i)
853 mapData[i*2] = mapData[i*4+1];
854 mapData[i*2+1] = mapData[i*4+2];
857 for (label i=2*nBaffleInterface; i < 4*nBaffleInterface; ++i)
867 bafInterfaces_[i][0] = mapData[i*2];
868 bafInterfaces_[i][1] = mapData[i*2+1];
873 SubList<label> subMap(mapData, 2*nBaffleInterface);
880 &(globalState_->error),
887 assertNoError(
"problem reading interface 'FaceIds'");
893 nDomainInterface = 0;
894 for (label i=0; i < nInterfaceTotal; ++i)
896 label face0 = mapData[i*2];
897 label face1 = mapData[i*2+1];
901 !hashedFace.found(face0)
902 && !hashedFace.found(face1)
905 domInterfaces_[nDomainInterface][0] = face0;
906 domInterfaces_[nDomainInterface][1] = face1;
908 if (nDomainInterface >= domInterfaces_.size())
916 domInterfaces_.setSize(nDomainInterface);
922 void Foam::ccm::reader::readMonitoring
927 #ifdef DEBUG_CCMIOREAD
931 #ifdef WITH_MONITORING
932 CCMIONode topoNode, monitorParent;
933 CCMIONode monitorNode;
951 "MonitorBoundaryRegions",
963 CCMIOGetNextChildWithLabel
974 #ifdef DEBUG_MONITORING
988 int ccmRegionId = ccmGetEntityIndex(monitorNode);
1001 #ifdef DEBUG_MONITORING
1002 Info<<
"monitoring mapId " << idVal
1003 <<
" with nFaces = " << nMonFaces
1010 (globalState_->root),
1016 List<label> mapData(nMonFaces);
1026 #ifdef DEBUG_MONITORING
1027 Info<<
"map: " << mapData <<
nl
1028 <<
"toFoam: " << toFoamFaces
1036 #ifdef DEBUG_MONITORING
1037 Info<<
"map: " << mapData <<
nl
1038 <<
"ccmRegionId: " << ccmRegionId <<
endl;
1041 auto iter = boundaryRegion_.cfind(ccmRegionId);
1046 iter().readEntry(
"Label", zoneName);
1050 zoneName =
"monitoring_" +
Foam::name(ccmRegionId);
1053 monitoringSets_.insert(zoneName, mapData);
1073 void Foam::ccm::reader::juggleSolids()
1075 if (!option().keepSolid())
1081 label defaultBoundaryRegion = boundaryRegion_.findIndex
1087 label defaultBoundarySolid = boundaryRegion_.findIndex
1089 defaultSolidBoundaryName
1096 defaultBoundaryRegion < 0
1097 || defaultBoundarySolid >= 0
1106 bitSet solidCells(cellTableId_.size(),
false);
1108 Map<word> solidMap = cellTable_.solids();
1110 forAll(cellTableId_, cellI)
1112 if (solidMap.found(cellTableId_[cellI]))
1114 solidCells.set(cellI);
1127 const label patchIndex = origBndId_.find(defaultBoundaryRegion);
1128 const label nPatchFaces = patchSizes_[patchIndex];
1130 labelList patchStarts(patchStartList(nInternalFaces_));
1131 label adjustPatch = 0;
1132 for (label i = 0; i < nPatchFaces; ++i)
1134 label faceI = patchStarts[patchIndex] + i;
1135 label cellI = faceOwner_[faceI];
1137 if (solidCells.test(cellI))
1153 label
nPatches = patchSizes_.size();
1154 patchStarts.setSize(
nPatches+1, 0);
1155 patchSizes_.setSize(
nPatches+1, 0);
1159 for (label i =
nPatches; i > patchIndex; --i)
1161 patchStarts[i] = patchStarts[i-1];
1162 patchSizes_[i] = patchSizes_[i-1];
1163 origBndId_[i] = origBndId_[i-1];
1167 patchSizes_[patchIndex] -= adjustPatch;
1168 patchSizes_[patchIndex+1] = adjustPatch;
1169 patchStarts[patchIndex+1] =
1170 patchStarts[patchIndex] + patchSizes_[patchIndex];
1172 origBndId_[patchIndex+1] = boundaryRegion_.append
1178 "BoundaryType wall;"
1179 "Label " + word(defaultSolidBoundaryName) +
";"
1184 label fluidFace = patchStarts[patchIndex];
1185 label solidFace = patchStarts[patchIndex+1];
1188 for (label i = 0; i < nPatchFaces; ++i)
1190 label faceI = patchStarts[patchIndex] + i;
1191 label cellI = faceOwner_[faceI];
1193 if (solidCells.test(cellI))
1195 oldToNew[faceI] = solidFace++;
1199 oldToNew[faceI] = fluidFace++;
1209 renumberInterfaces(oldToNew);
1215 void Foam::ccm::reader::removeUnwanted()
1220 bitSet removeCells(cellTableId_.size(),
false);
1223 Map<word> fluidMap = cellTable_.fluids();
1224 Map<word> porousMap = selectPorous(cellTable_);
1225 Map<word> solidMap = cellTable_.solids();
1226 Map<word> removeMap;
1228 forAll(cellTableId_, cellI)
1230 label tableId = cellTableId_[cellI];
1234 porousMap.found(tableId)
1235 ? !option().keepPorous()
1236 : fluidMap.found(tableId)
1237 ? !option().keepFluid()
1238 : solidMap.found(tableId)
1239 ? !option().keepSolid()
1243 removeCells.set(cellI);
1245 removeMap.set(tableId, cellTable_.name(tableId));
1255 const label tableId = iter.key();
1256 if (!removeMap.found(tableId))
1258 keepMap.set(tableId, cellTable_.name(tableId));
1262 Info<<
"remove "<< nRemove <<
" cells in "
1263 << removeMap.size() <<
" unwanted cellZone(s)" <<
nl;
1268 << iter.key() <<
" : " << iter.val() <<
nl;
1271 Info<<
"retain "<< (nCells_ - nRemove) <<
" cells in "
1272 << keepMap.size() <<
" cellZone(s)" <<
nl;
1277 << iter.key() <<
" : " << iter.val() <<
nl;
1289 label adjustInternal = 0;
1293 label oldFaceI = nFaces_ - 1;
1295 for (label faceI = 0; faceI < nFaces_; ++faceI)
1297 label cellI = faceOwner_[faceI];
1298 if (removeCells.test(cellI))
1300 if (faceI < nInternalFaces_)
1307 label beg = nInternalFaces_;
1308 forAll(patchSizes_, patchI)
1310 label
end = beg + patchSizes_[patchI];
1312 if (faceI >= beg && faceI <
end)
1314 ++adjustPatchSize[patchI];
1323 oldToNew[faceI] = oldFaceI--;
1327 if (newFaceI != faceI)
1329 faces_[newFaceI] = faces_[faceI];
1330 faceOwner_[newFaceI] = faceOwner_[faceI];
1331 faceNeighbour_[newFaceI] = faceNeighbour_[faceI];
1332 origFaceId_[newFaceI] = origFaceId_[faceI];
1336 oldToNew[faceI] = newFaceI++;
1343 faces_.setSize(nFaces_);
1344 faceOwner_.setSize(nFaces_);
1345 faceNeighbour_.setSize(nFaces_);
1346 origFaceId_.setSize(nFaces_);
1350 nInternalFaces_ -= adjustInternal;
1351 forAll(patchSizes_, patchI)
1353 patchSizes_[patchI] -= adjustPatchSize[patchI];
1356 renumberInterfaces(oldToNew);
1360 oldToNew.setSize(nCells_, -1);
1361 for (label cellI = 0; cellI < nCells_; ++cellI)
1363 if (!removeCells.test(cellI))
1367 origCellId_[nCell] = origCellId_[cellI];
1368 cellTableId_[nCell] = cellTableId_[cellI];
1370 oldToNew[cellI] = nCell;
1380 origCellId_.setSize(nCells_);
1381 cellTableId_.setSize(nCells_);
1385 oldToNew.setSize(nPoints_);
1391 const labelList& facePoints = faces_[faceI];
1395 ++oldToNew[facePoints[ptI]];
1399 label nPointUsed = 0;
1402 if (oldToNew[ptI] >= 0)
1404 oldToNew[ptI] = nPointUsed;
1405 if (ptI != nPointUsed)
1407 points_[nPointUsed] = points_[ptI];
1413 nPoints_ = nPointUsed;
1414 points_.setSize(nPoints_);
1426 void Foam::ccm::reader::validateInterface
1428 List<labelPair>& lst
1434 label face0 = lst[elemI][0];
1435 label face1 = lst[elemI][1];
1437 if (face0 < nFaces_ && face1 < nFaces_)
1441 lst[nElem][0] = face0;
1442 lst[nElem][1] = face1;
1451 void Foam::ccm::reader::renumberInterfaces
1456 forAll(domInterfaces_, elemI)
1458 domInterfaces_[elemI][0] = oldToNew[domInterfaces_[elemI][0]];
1459 domInterfaces_[elemI][1] = oldToNew[domInterfaces_[elemI][1]];
1462 forAll(bafInterfaces_, elemI)
1464 bafInterfaces_[elemI][0] = oldToNew[bafInterfaces_[elemI][0]];
1465 bafInterfaces_[elemI][1] = oldToNew[bafInterfaces_[elemI][1]];
1468 validateInterface(domInterfaces_);
1469 validateInterface(bafInterfaces_);
1478 void Foam::ccm::reader::cleanupInterfaces()
1480 validateInterface(bafInterfaces_);
1481 validateInterface(domInterfaces_);
1483 if (bafInterfaces_.size() <= 0 && domInterfaces_.size() <= 0)
1485 Info<<
"0 baffle interface pairs" <<
nl
1486 <<
"0 domain interface pairs" <<
endl;
1490 #ifdef DEBUG_BAFFLES
1491 Info<<
"baffle Interfaces " << bafInterfaces_ <<
nl
1492 <<
"domain Interfaces " << domInterfaces_ <<
nl
1493 <<
"nCells:" << nCells_ <<
nl
1494 <<
"nFaces:" << nFaces_ <<
nl
1495 <<
"patchSizes:" << patchSizes_ <<
nl
1496 <<
"nInternalFaces:" << nInternalFaces_ <<
endl;
1498 forAll(domInterfaces_, elemI)
1500 const label face0 = domInterfaces_[elemI][0];
1501 const label face1 = domInterfaces_[elemI][1];
1503 Info<<
"interface [" << elemI <<
"] = "
1504 << face0 <<
" - " << face1 <<
" own/neigh = "
1505 << faceOwner_[face0] <<
"/" << faceNeighbour_[face0] <<
" "
1506 << faceOwner_[face1] <<
"/" << faceNeighbour_[face1] <<
endl;
1515 label begOfList = nInternalFaces_;
1516 label endOfList = nFaces_ - 1;
1519 const labelList origPatchStarts(patchStartList(nInternalFaces_));
1524 nInternalFaces_ += domInterfaces_.size();
1525 nFaces_ -= domInterfaces_.size();
1527 Info<< domInterfaces_.size() <<
" domain interface pairs";
1528 if (domInterfaces_.size())
1538 forAll(domInterfaces_, elemI)
1540 label face0 = domInterfaces_[elemI][0];
1541 label face1 = domInterfaces_[elemI][1];
1543 oldToNew[face0] = begOfList++;
1544 oldToNew[face1] = endOfList--;
1547 faceNeighbour_[face0] = faceOwner_[face1];
1548 faceOwner_[face1] = -1;
1551 forAll(patchSizes_, patchI)
1553 label beg = origPatchStarts[patchI];
1554 label
end = beg + patchSizes_[patchI];
1556 if (face0 >= beg && face0 <
end)
1558 ++adjustPatchSize[patchI];
1560 if (face1 >= beg && face1 <
end)
1562 ++adjustPatchSize[patchI];
1568 forAll(bafInterfaces_, elemI)
1570 label face0 = bafInterfaces_[elemI][0];
1571 label face1 = bafInterfaces_[elemI][1];
1573 forAll(patchSizes_, patchI)
1575 label beg = origPatchStarts[patchI];
1576 label
end = beg + patchSizes_[patchI];
1578 if (face0 >= beg && face0 <
end)
1580 ++bafflePatchCount[patchI];
1582 if (face1 >= beg && face1 <
end)
1584 ++bafflePatchCount[patchI];
1590 if (option().removeBaffles())
1593 nInternalFaces_ += bafInterfaces_.size();
1594 nFaces_ -= bafInterfaces_.size();
1597 Info<< bafInterfaces_.size() <<
" baffle interface pairs";
1598 if (bafInterfaces_.size())
1600 if (option().removeBaffles())
1615 if (option().removeBaffles())
1617 forAll(bafInterfaces_, elemI)
1619 label face0 = bafInterfaces_[elemI][0];
1620 label face1 = bafInterfaces_[elemI][1];
1622 oldToNew[face0] = begOfList++;
1623 oldToNew[face1] = endOfList--;
1626 faceNeighbour_[face0] = faceOwner_[face1];
1627 faceOwner_[face1] = -1;
1632 label
pos = nInternalFaces_;
1633 forAll(patchSizes_, patchI)
1635 label beg = origPatchStarts[patchI];
1636 label
end = beg + patchSizes_[patchI];
1639 for (label faceI = beg; faceI <
end; ++faceI)
1641 if (oldToNew[faceI] < 0)
1643 oldToNew[faceI] =
pos;
1650 bafInterfaces_.clear();
1655 forAll(bafflePatchCount, patchI)
1657 if (bafflePatchCount[patchI] % 2)
1659 Info<<
"WARNING: patch " << patchI
1660 <<
" has an uneven number of baffles ("
1661 << bafflePatchCount[patchI] <<
") expect strange results"
1668 label
pos = nInternalFaces_;
1669 forAll(patchSizes_, patchI)
1671 const label beg = origPatchStarts[patchI];
1672 const label
end = beg + patchSizes_[patchI];
1674 const label nsize = bafflePatchCount[patchI];
1679 const label nsizeby2 = (nsize - nsize % 2) / 2;
1683 forAll(bafInterfaces_, elemI)
1685 const label face0 = bafInterfaces_[elemI][0];
1686 const label face1 = bafInterfaces_[elemI][1];
1690 (face0 >= beg && face0 <
end)
1691 || (face1 >= beg && face1 <
end)
1694 oldToNew[face0] =
pos + nsorted;
1695 oldToNew[face1] =
pos + nsorted + nsizeby2;
1700 bafInterfaces_[elemI][0] = -oldToNew[face0];
1701 bafInterfaces_[elemI][1] = -oldToNew[face1];
1710 for (label faceI = beg; faceI <
end; ++faceI)
1712 if (oldToNew[faceI] < 0)
1714 oldToNew[faceI] =
pos;
1721 forAll(bafInterfaces_, elemI)
1723 bafInterfaces_[elemI][0] = abs(bafInterfaces_[elemI][0]);
1724 bafInterfaces_[elemI][1] = abs(bafInterfaces_[elemI][1]);
1728 #ifdef DEBUG_BAFFLES
1729 Info<<
"remap with " << oldToNew <<
nl
1730 <<
"owners:" << faceOwner_ <<
nl
1731 <<
"neighbours:" << faceNeighbour_ <<
nl
1741 if (monitoringSets_.size())
1743 #ifdef WITH_MONITORING
1748 forAll(domInterfaces_, elemI)
1750 label face0 = domInterfaces_[elemI][0];
1751 label face1 = domInterfaces_[elemI][1];
1752 oldToNew[face1] = oldToNew[face0];
1763 domInterfaces_.clear();
1766 faces_.setSize(nFaces_);
1767 faceOwner_.setSize(nFaces_);
1768 faceNeighbour_.setSize(nFaces_);
1769 origFaceId_.setSize(nFaces_);
1774 oldToNew.setSize(patchSizes_.size());
1778 forAll(patchSizes_, patchI)
1780 patchSizes_[patchI] -= adjustPatchSize[patchI];
1781 if (option().removeBaffles())
1783 patchSizes_[patchI] -= bafflePatchCount[patchI];
1786 if (patchSizes_[patchI])
1798 #ifdef DEBUG_BAFFLES
1799 Info<<
"nCells:" << nCells_ <<
nl
1800 <<
"nFaces:" << nFaces_ <<
nl
1801 <<
"PatchSizes:" << patchSizes_ <<
nl
1802 <<
"nInternalFaces:" << nInternalFaces_ <<
nl
1811 void Foam::ccm::reader::mergeInplaceInterfaces()
1813 if (interfaceDefinitions_.empty())
1817 if (!option().mergeInterfaces())
1819 Info<< interfaceDefinitions_.size() <<
" interface definitions"
1820 <<
" - leaving unmerged" <<
endl;
1825 DynamicList<labelPair> interfacePatches(interfaceDefinitions_.size());
1831 const interfaceEntry& ifentry = iter.val();
1835 origBndId_.find(ifentry.bnd0),
1836 origBndId_.find(ifentry.bnd1)
1841 patchPair[0] == patchPair[1]
1847 Info<<
"Warning : bad interface " << ifentry.id <<
" " << ifentry
1848 <<
" on patches " << patchPair <<
endl;
1852 patchSizes_[patchPair[0]] != patchSizes_[patchPair[1]]
1853 || patchSizes_[patchPair[0]] == 0
1854 || patchSizes_[patchPair[1]] == 0
1859 Info<<
"Warning: skip interface with zero or different"
1860 <<
" number of faces" <<
nl;
1863 Info<<
" Interface:" << ifentry.id <<
" " << ifentry
1864 <<
" patches " << patchPair
1866 << patchSizes_[patchPair[0]]
1867 <<
" " << patchSizes_[patchPair[1]] <<
")"
1872 interfacePatches.append(patchPair);
1876 if (interfacePatches.empty())
1888 const labelList origPatchStarts(patchStartList(nInternalFaces_));
1890 label nMergedTotal = 0;
1893 bitSet whichPoints(points_.size());
1895 Info<<
"interface merge points (tol="
1896 << option().mergeTol() <<
"):" <<
endl;
1898 DynamicList<label> interfacesToMerge(interfacePatches.size());
1899 forAll(interfacePatches, interI)
1901 const label patch0 = interfacePatches[interI][0];
1902 const label patch1 = interfacePatches[interI][1];
1903 const label nPatch0Faces = patchSizes_[patch0];
1904 const label nPatch1Faces = patchSizes_[patch1];
1907 whichPoints.reset();
1908 for (label local0FaceI = 0; local0FaceI < nPatch0Faces; ++local0FaceI)
1910 const face&
f = faces_[origPatchStarts[patch0] + local0FaceI];
1915 whichPoints.set(oldToNew[
f[fp]]);
1918 for (label local1FaceI = 0; local1FaceI < nPatch1Faces; ++local1FaceI)
1920 const face&
f = faces_[origPatchStarts[patch1] + local1FaceI];
1925 whichPoints.set(oldToNew[
f[fp]]);
1932 const UIndirectList<point> pointsToMerge(points_, addr);
1934 Info<<
" patch " << patch0 <<
"," << patch1 <<
": ("
1935 << nPatch0Faces <<
" and " << nPatch1Faces <<
" faces) " <<
flush;
1940 option().mergeTol(),
1945 Info<< nMerged <<
" from " << pointsToMerge.size() <<
" points"
1951 forAll(mergedPointMap, i)
1953 oldToNew[addr[i]] = addr[mergedPointMap[i]];
1956 interfacesToMerge.append(interI);
1957 nMergedTotal += nMerged;
1977 oldToNew.setSize(nPoints_);
1983 const labelList& facePoints = faces_[faceI];
1987 ++oldToNew[facePoints[ptI]];
1991 label nPointUsed = 0;
1994 if (oldToNew[ptI] >= 0)
1996 oldToNew[ptI] = nPointUsed;
1997 if (ptI != nPointUsed)
1999 points_[nPointUsed] = points_[ptI];
2008 nPoints_ = nPointUsed;
2009 points_.setSize(nPoints_);
2020 Info<<
"interface merge faces:" <<
endl;
2024 forAll(interfacesToMerge, mergeI)
2026 const label patch0 = interfacePatches[interfacesToMerge[mergeI]][0];
2027 const label patch1 = interfacePatches[interfacesToMerge[mergeI]][1];
2029 labelList faceAddr0(patchSizes_[patch0]);
2030 labelList faceAddr1(patchSizes_[patch1]);
2032 forAll(faceAddr0, localFaceI)
2034 faceAddr0[localFaceI] = origPatchStarts[patch0] + localFaceI;
2036 forAll(faceAddr1, localFaceI)
2038 faceAddr1[localFaceI] = origPatchStarts[patch1] + localFaceI;
2041 if (faceAddr0.size() != faceAddr1.size())
2048 SortableList<scalar> pts0MagSqr
2063 SortableList<scalar> pts1MagSqr
2083 forAll(pts0MagSqr, sortI)
2085 const label face0I = faceAddr0[pts0MagSqr.indices()[sortI]];
2086 const label face1I = faceAddr1[pts1MagSqr.indices()[sortI]];
2094 ++adjustPatchSize[patch0];
2095 ++adjustPatchSize[patch1];
2097 if (faceOwner_[face0I] < faceOwner_[face1I])
2100 faceNeighbour_[face0I] = faceOwner_[face1I];
2101 faceNeighbour_[face1I] = faceOwner_[face1I] = -1;
2106 faceNeighbour_[face1I] = faceOwner_[face0I];
2107 faceNeighbour_[face0I] = faceOwner_[face0I] = -1;
2112 failed0.set(face0I);
2113 failed1.set(face1I);
2125 const label face0I = iter0.key();
2129 const label face1I = iter1.key();
2137 ++adjustPatchSize[patch0];
2138 ++adjustPatchSize[patch1];
2140 if (faceOwner_[face0I] < faceOwner_[face1I])
2143 faceNeighbour_[face0I] = faceOwner_[face1I];
2144 faceNeighbour_[face1I] = faceOwner_[face1I] = -1;
2149 faceNeighbour_[face1I] = faceOwner_[face0I];
2150 faceNeighbour_[face0I] = faceOwner_[face0I] = -1;
2153 failed1.erase(face1I);
2164 Info<<
" patch " << patch0 <<
", " << patch1 <<
": "
2165 << nMerged <<
" from " << faceAddr0.size() <<
" faces";
2169 Info<<
" (" << failed0.size() <<
" merged ad hoc)";
2174 nMergedTotal += nMerged;
2187 oldToNew.setSize(nFaces_);
2191 label extFaceI = nInternalFaces_ + nMergedTotal;
2194 nInternalFaces_ = 0;
2195 label nFaceUsed = 0;
2196 for (label faceI = 0; faceI < nFaces_; ++faceI)
2198 if (faceOwner_[faceI] != -1)
2200 if (faceNeighbour_[faceI] != -1)
2203 oldToNew[faceI] = nInternalFaces_;
2210 oldToNew[faceI] = extFaceI;
2217 if (nFaceUsed != extFaceI)
2220 <<
"coding error: used " << nFaceUsed
2221 <<
" faces, but expected to use " << extFaceI <<
" faces"
2231 nFaces_ = nFaceUsed;
2233 faces_.setSize(nFaces_);
2234 faceOwner_.setSize(nFaces_);
2235 faceNeighbour_.setSize(nFaces_);
2236 origFaceId_.setSize(nFaces_);
2239 oldToNew.setSize(patchSizes_.size());
2243 forAll(patchSizes_, patchI)
2245 patchSizes_[patchI] -= adjustPatchSize[patchI];
2246 if (patchSizes_[patchI])
2270 void Foam::ccm::reader::reorderMesh()
2275 forAll(faceOwner_, faceI)
2277 label nbr = faceNeighbour_[faceI];
2278 label own = faceOwner_[faceI];
2280 if (nbr >= cellTableId_.size() || own >= cellTableId_.size())
2286 <<
" nCells:" << cellTableId_.size()
2290 if (nbr >= 0 && nbr < own)
2292 faceOwner_[faceI] = faceNeighbour_[faceI];
2293 faceNeighbour_[faceI] = own;
2294 faces_[faceI] = faces_[faceI].reverseFace();
2298 const face&
f = faces_[faceI];
2302 if (
f[fp] < 0 ||
f[fp] >= points_.size())
2305 <<
"face:" << faceI <<
" f:" <<
f
2313 labelList oldToNew(faceOwner_.size(), -1);
2317 primitiveMesh::calcCells
2326 forAll(cellFaceAddr, cellI)
2328 const labelList& cFaces = cellFaceAddr[cellI];
2329 SortableList<label> nbr(cFaces.size(), -1);
2333 label faceI = cFaces[i];
2334 label nbrCellI = faceNeighbour_[faceI];
2339 if (nbrCellI == cellI)
2341 nbrCellI = faceOwner_[faceI];
2345 if (cellI < nbrCellI)
2358 oldToNew[cFaces[nbr.indices()[i]]] = newFaceI++;
2378 if (lst[i] >= 0 && lst[i] < nInternalFaces_)
2382 lst[nElem] = lst[i];
2394 Info <<
"remove monitor " << iter.key() <<
endl;
2395 monitoringSets_.erase(iter);
2406 void Foam::ccm::reader::addPatches
2413 List<polyPatch*> newPatches(origBndId_.size());
2415 label meshFaceI = nInternalFaces_;
2420 forAll(newPatches, patchI)
2426 auto citer = boundaryRegion_.cfind(origBndId_[patchI]);
2430 citer().readEntry(
"Label", patchName);
2431 citer().readEntry(
"BoundaryType", patchType);
2435 patchName = fallbackName;
2436 patchType =
"patch";
2441 if (hashedNames.found(patchName))
2443 Info<<
"renamed patch " << patchName <<
" to ";
2444 patchName = fallbackName +
"_" + patchName;
2447 hashedNames.insert(patchName);
2449 Info<<
"patch " << patchI
2450 <<
" (start: " << meshFaceI <<
" size: " << patchSizes_[patchI]
2451 <<
") name: " << patchName
2454 if (patchType ==
"wall")
2456 newPatches[patchI] =
2460 patchSizes_[patchI],
2463 mesh.boundaryMesh(),
2467 else if (patchType ==
"symmetry")
2469 newPatches[patchI] =
2470 new symmetryPolyPatch
2473 patchSizes_[patchI],
2476 mesh.boundaryMesh(),
2480 else if (patchType ==
"empty")
2483 newPatches[patchI] =
2487 patchSizes_[patchI],
2490 mesh.boundaryMesh(),
2498 newPatches[patchI] =
2502 patchSizes_[patchI],
2505 mesh.boundaryMesh(),
2510 meshFaceI += patchSizes_[patchI];
2513 if (meshFaceI !=
mesh.nFaces())
2516 <<
"meshFaceI:" << meshFaceI <<
" nFaces:" <<
mesh.nFaces()
2520 mesh.addPatches(newPatches);
2526 void Foam::ccm::reader::addFaceZones
2531 label nZone = monitoringSets_.size();
2532 mesh.faceZones().setSize(nZone);
2542 Info<<
"faceZone " << nZone
2543 <<
" (size: " << iter().size() <<
") name: "
2544 << iter.key() <<
endl;
2546 mesh.faceZones().set
2563 warnDuplicates(
"faceZones",
mesh.faceZones().names());
2573 if (geometryStatus_ == OKAY || geometryStatus_ == READ)
2575 geometryStatus_ = UNKNOWN;
2581 faceNeighbour_.clear();
2584 patchSizes_.clear();
2596 if (!readGeometry())
2602 remapMeshInfo(registry, remappingDictName);
2618 std::move(faceOwner_),
2619 std::move(faceNeighbour_)
2627 cellTable_.addCellZones(
mesh, cellTableId_);
2628 warnDuplicates(
"cellZones",
mesh.cellZones().names());
2632 warnDuplicates(
"boundaries",
mesh.boundaryMesh().names());