51 label patchFaceI = initial;
52 forAll(patchSizes_, patchI)
54 startLst[patchI] = patchFaceI;
55 patchFaceI += patchSizes_[patchI];
62 void Foam::ccm::reader::printSizes()
const 64 Info<<
"nPoints:" << nPoints_
65 <<
" nCells:" << nCells_
66 <<
" nFaces:" << nFaces_
67 <<
" nInternalFaces:" << nInternalFaces_
78 bool Foam::ccm::reader::detectGeometry()
81 if (geometryStatus_ != UNKNOWN)
83 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
97 ccmID verticesNode, topoNode;
104 (globalState_->root),
121 && CCMIOReadProcessor
132 && CCMIOIsFromSameFile((globalState_->root), verticesNode)
133 && CCMIOIsFromSameFile((globalState_->root), topoNode)
134 && CCMIOIsValidEntity(probNode)
137 readProblemDescription(probNode);
138 geometryStatus_ = OKAY;
143 geometryStatus_ = BAD;
146 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
151 void Foam::ccm::reader::readMeshTopology
153 const scalar scaleFactor
156 ccmID verticesNode, topoNode;
171 (globalState_->root),
188 && CCMIOReadProcessor
200 labelList origPointId = readVertices(verticesNode, scaleFactor);
202 readMonitoring(topoNode);
206 label maxId =
max(origPointId);
209 for (face&
f : faces_)
218 label maxId =
max(origCellId_);
238 mergeInplaceInterfaces();
250 const ccmID& verticesNode,
251 const scalar scaleFactor
260 #ifdef DEBUG_CCMIOREAD 267 &(globalState_->error),
275 &(globalState_->error),
284 assertNoError(
"problem finding 'Vertices' node");
289 <<
"can only handle 3-dimensional vertices" 303 List<scalar> vrts(3*nPoints_);
308 &(globalState_->error),
317 assertNoError(
"problem reading 'Vertices' node");
320 points_.setSize(nPoints_);
322 scalar effectiveScale = scale * scaleFactor;
325 points_[i].x() = effectiveScale * vrts[i*3];
326 points_[i].y() = effectiveScale * vrts[i*3+1];
327 points_[i].z() = effectiveScale * vrts[i*3+2];
332 #ifdef DEBUG_CCMIOREAD 333 Info<<
"readVertices: " << nPoints_ <<
endl;
343 void Foam::ccm::reader::readCells
345 const ccmID& topoNode
349 ccmID cellsNode, mapId;
352 #ifdef DEBUG_CCMIOREAD 359 &(globalState_->error),
368 &(globalState_->error),
373 assertNoError(
"cannot get 'Cells' node");
377 #ifdef DEBUG_CCMIOREAD 378 Info<<
"readCells: " << nCells_ <<
endl;
382 origCellId_.setSize(nCells_);
383 cellTableId_.setSize(nCells_);
387 &(globalState_->error),
394 assertNoError(
"Error reading 'Cells' node");
405 &(globalState_->error),
413 &(globalState_->error),
418 nInternalFaces_ = size;
420 nFaces_ = nInternalFaces_;
428 DynamicList<ccmBoundaryInfo> bndInfo;
434 CCMIOGetNumberOfChildren
458 &(globalState_->error),
466 ccmBoundaryInfo info;
472 &(globalState_->error),
478 info.setPatchName(ccmReadOptstr(
"Label", nodeId));
481 auto dictIter = boundaryRegion_.find(info.ccmIndex);
482 if (dictIter.found())
484 dictionary&
dict = dictIter.val();
486 const word patchName(
dict.get<word>(
"Label"));
487 const word patchType(
dict.get<word>(
"BoundaryType"));
489 if (!patchName.empty())
491 info.patchName = patchName;
494 if (!patchType.empty())
496 info.patchType = patchType;
500 dict.add(
"BoundaryIndex", info.ccmIndex);
501 dict.add(
"size", info.size);
504 bndInfo.append(info);
508 faces_.setSize(nFaces_);
509 faceOwner_.setSize(nFaces_);
510 faceNeighbour_.setSize(nFaces_);
511 origFaceId_.setSize(nFaces_);
515 patchSizes_.setSize(bndInfo.size());
516 origBndId_.setSize(bndInfo.size());
521 for (ccmBoundaryInfo& info : bndInfo)
523 if (info.patchId != -1)
526 origBndId_[info.patchId] = info.ccmIndex;
531 origBndId_[info.patchId] = info.ccmIndex;
534 patchSizes_[info.patchId] += info.size;
543 IndirectList<ccmBoundaryInfo> ccmLookupOrder(bndInfo,
labelList());
545 DynamicList<label> addr(bndInfo.size());
546 for (
int patchI = 0; patchI <
nPatches; ++patchI)
550 if (bndInfo[infoI].
patchId == patchI)
557 ccmLookupOrder.addressing() = std::move(addr);
566 &(globalState_->error),
576 &(globalState_->error),
586 List<label> mapData(nInternalFaces_);
587 List<label> faceCells(2*nInternalFaces_);
588 List<label> ccmFaces(size);
592 &(globalState_->error),
604 &(globalState_->error),
611 assertNoError(
"Error reading internal faces");
621 unsigned int pos = 0;
622 for (label faceI = 0; faceI < nInternalFaces_; ++faceI)
624 origFaceId_[faceI] = mapData[faceI];
625 faceOwner_[faceI] = faceCells[2*faceI];
626 faceNeighbour_[faceI] = faceCells[2*faceI+1];
627 face&
f = faces_[faceI];
629 f.setSize(ccmFaces[
pos++]);
632 f[fp] = ccmFaces[
pos++];
638 label patchFaceI = nInternalFaces_;
640 for (
const ccmBoundaryInfo& info : ccmLookupOrder)
642 const unsigned int patchSize = info.size;
648 &(globalState_->error),
658 &(globalState_->error),
668 mapData.setSize(patchSize);
669 faceCells.setSize(patchSize);
670 ccmFaces.setSize(size);
680 &(globalState_->error),
691 &(globalState_->error),
700 "Error reading boundary face cells - index " 706 unsigned int pos = 0;
707 for (
unsigned int i = 0; i < patchSize; ++i, ++patchFaceI)
709 origFaceId_[patchFaceI] = mapData[i];
710 faceOwner_[patchFaceI] = faceCells[i];
711 faceNeighbour_[patchFaceI] = -1;
713 face&
f = faces_[patchFaceI];
715 f.setSize(ccmFaces[
pos++]);
718 f[fp] = ccmFaces[
pos++];
726 "Error reading boundary faces - index " 732 readInterfaces(cellsNode);
740 void Foam::ccm::reader::readInterfaces
742 const ccmID& cellsNode
745 #ifdef DEBUG_CCMIOREAD 749 label nBaffleInterface = 0, nInterfaceTotal = 0;
750 CCMIOIndex size = 0, dims = 0;
752 bafInterfaces_.clear();
753 domInterfaces_.clear();
781 && size > 0 && dims == 2
784 nInterfaceTotal = size;
811 nBaffleInterface = (size - size % 4) / 4;
815 label nDomainInterface = nInterfaceTotal - nBaffleInterface;
818 List<int> mapData(
max(2 * nInterfaceTotal, 4 * nBaffleInterface), -1);
820 bafInterfaces_.setSize(nBaffleInterface);
821 domInterfaces_.setSize(nDomainInterface);
824 label maxId =
max(origFaceId_);
827 if (nBaffleInterface > 0)
833 &(globalState_->error),
840 assertNoError(
"problem reading interface 'ProstarBaffles'");
847 for (label i=0; i < nBaffleInterface; ++i)
849 mapData[i*2] = mapData[i*4+1];
850 mapData[i*2+1] = mapData[i*4+2];
853 for (label i=2*nBaffleInterface; i < 4*nBaffleInterface; ++i)
863 bafInterfaces_[i][0] = mapData[i*2];
864 bafInterfaces_[i][1] = mapData[i*2+1];
869 SubList<label> subMap(mapData, 2*nBaffleInterface);
876 &(globalState_->error),
883 assertNoError(
"problem reading interface 'FaceIds'");
889 nDomainInterface = 0;
890 for (label i=0; i < nInterfaceTotal; ++i)
892 label face0 = mapData[i*2];
893 label face1 = mapData[i*2+1];
897 !hashedFace.found(face0)
898 && !hashedFace.found(face1)
901 domInterfaces_[nDomainInterface][0] = face0;
902 domInterfaces_[nDomainInterface][1] = face1;
904 if (nDomainInterface >= domInterfaces_.size())
912 domInterfaces_.setSize(nDomainInterface);
918 void Foam::ccm::reader::readMonitoring
923 #ifdef DEBUG_CCMIOREAD 927 #ifdef WITH_MONITORING 928 CCMIONode topoNode, monitorParent;
929 CCMIONode monitorNode;
947 "MonitorBoundaryRegions",
959 CCMIOGetNextChildWithLabel
970 #ifdef DEBUG_MONITORING 984 int ccmRegionId = ccmGetEntityIndex(monitorNode);
997 #ifdef DEBUG_MONITORING 998 Info<<
"monitoring mapId " << idVal
999 <<
" with nFaces = " << nMonFaces
1006 (globalState_->root),
1012 List<label> mapData(nMonFaces);
1022 #ifdef DEBUG_MONITORING 1023 Info<<
"map: " << mapData <<
nl 1024 <<
"toFoam: " << toFoamFaces
1032 #ifdef DEBUG_MONITORING 1033 Info<<
"map: " << mapData <<
nl 1034 <<
"ccmRegionId: " << ccmRegionId <<
endl;
1037 auto iter = boundaryRegion_.cfind(ccmRegionId);
1042 iter().readEntry(
"Label", zoneName);
1046 zoneName =
"monitoring_" +
Foam::name(ccmRegionId);
1049 monitoringSets_.insert(zoneName, mapData);
1069 void Foam::ccm::reader::juggleSolids()
1071 if (!option().keepSolid())
1077 label defaultBoundaryRegion = boundaryRegion_.findIndex
1083 label defaultBoundarySolid = boundaryRegion_.findIndex
1085 defaultSolidBoundaryName
1092 defaultBoundaryRegion < 0
1093 || defaultBoundarySolid >= 0
1102 bitSet solidCells(cellTableId_.size(),
false);
1104 Map<word> solidMap = cellTable_.solids();
1106 forAll(cellTableId_, cellI)
1108 if (solidMap.found(cellTableId_[cellI]))
1110 solidCells.set(cellI);
1123 const label patchIndex = origBndId_.find(defaultBoundaryRegion);
1124 const label nPatchFaces = patchSizes_[patchIndex];
1126 labelList patchStarts(patchStartList(nInternalFaces_));
1127 label adjustPatch = 0;
1128 for (label i = 0; i < nPatchFaces; ++i)
1130 label faceI = patchStarts[patchIndex] + i;
1131 label cellI = faceOwner_[faceI];
1133 if (solidCells.test(cellI))
1149 label
nPatches = patchSizes_.size();
1150 patchStarts.setSize(
nPatches+1, 0);
1151 patchSizes_.setSize(
nPatches+1, 0);
1155 for (label i =
nPatches; i > patchIndex; --i)
1157 patchStarts[i] = patchStarts[i-1];
1158 patchSizes_[i] = patchSizes_[i-1];
1159 origBndId_[i] = origBndId_[i-1];
1163 patchSizes_[patchIndex] -= adjustPatch;
1164 patchSizes_[patchIndex+1] = adjustPatch;
1165 patchStarts[patchIndex+1] =
1166 patchStarts[patchIndex] + patchSizes_[patchIndex];
1168 origBndId_[patchIndex+1] = boundaryRegion_.append
1174 "BoundaryType wall;" 1175 "Label " + word(defaultSolidBoundaryName) +
";" 1180 label fluidFace = patchStarts[patchIndex];
1181 label solidFace = patchStarts[patchIndex+1];
1184 for (label i = 0; i < nPatchFaces; ++i)
1186 label faceI = patchStarts[patchIndex] + i;
1187 label cellI = faceOwner_[faceI];
1189 if (solidCells.test(cellI))
1191 oldToNew[faceI] = solidFace++;
1195 oldToNew[faceI] = fluidFace++;
1205 renumberInterfaces(oldToNew);
1211 void Foam::ccm::reader::removeUnwanted()
1216 bitSet removeCells(cellTableId_.size(),
false);
1219 Map<word> fluidMap = cellTable_.fluids();
1220 Map<word> porousMap = selectPorous(cellTable_);
1221 Map<word> solidMap = cellTable_.solids();
1222 Map<word> removeMap;
1224 forAll(cellTableId_, cellI)
1226 label tableId = cellTableId_[cellI];
1230 porousMap.found(tableId)
1231 ? !option().keepPorous()
1232 : fluidMap.found(tableId)
1233 ? !option().keepFluid()
1234 : solidMap.found(tableId)
1235 ? !option().keepSolid()
1239 removeCells.set(cellI);
1241 removeMap.set(tableId, cellTable_.name(tableId));
1251 const label tableId = iter.key();
1252 if (!removeMap.found(tableId))
1254 keepMap.set(tableId, cellTable_.name(tableId));
1258 Info<<
"remove "<< nRemove <<
" cells in " 1259 << removeMap.size() <<
" unwanted cellZone(s)" <<
nl;
1264 << iter.key() <<
" : " << iter.val() <<
nl;
1267 Info<<
"retain "<< (nCells_ - nRemove) <<
" cells in " 1268 << keepMap.size() <<
" cellZone(s)" <<
nl;
1273 << iter.key() <<
" : " << iter.val() <<
nl;
1285 label adjustInternal = 0;
1289 label oldFaceI = nFaces_ - 1;
1291 for (label faceI = 0; faceI < nFaces_; ++faceI)
1293 label cellI = faceOwner_[faceI];
1294 if (removeCells.test(cellI))
1296 if (faceI < nInternalFaces_)
1303 label beg = nInternalFaces_;
1304 forAll(patchSizes_, patchI)
1306 label
end = beg + patchSizes_[patchI];
1308 if (faceI >= beg && faceI <
end)
1310 ++adjustPatchSize[patchI];
1319 oldToNew[faceI] = oldFaceI--;
1323 if (newFaceI != faceI)
1325 faces_[newFaceI] = faces_[faceI];
1326 faceOwner_[newFaceI] = faceOwner_[faceI];
1327 faceNeighbour_[newFaceI] = faceNeighbour_[faceI];
1328 origFaceId_[newFaceI] = origFaceId_[faceI];
1332 oldToNew[faceI] = newFaceI++;
1339 faces_.setSize(nFaces_);
1340 faceOwner_.setSize(nFaces_);
1341 faceNeighbour_.setSize(nFaces_);
1342 origFaceId_.setSize(nFaces_);
1346 nInternalFaces_ -= adjustInternal;
1347 forAll(patchSizes_, patchI)
1349 patchSizes_[patchI] -= adjustPatchSize[patchI];
1352 renumberInterfaces(oldToNew);
1356 oldToNew.setSize(nCells_, -1);
1357 for (label cellI = 0; cellI < nCells_; ++cellI)
1359 if (!removeCells.test(cellI))
1363 origCellId_[nCell] = origCellId_[cellI];
1364 cellTableId_[nCell] = cellTableId_[cellI];
1366 oldToNew[cellI] = nCell;
1376 origCellId_.setSize(nCells_);
1377 cellTableId_.setSize(nCells_);
1381 oldToNew.setSize(nPoints_);
1385 for (
const face&
f : faces_)
1387 for (
const label pointi :
f)
1393 label nPointUsed = 0;
1396 if (oldToNew[ptI] >= 0)
1398 oldToNew[ptI] = nPointUsed;
1399 if (ptI != nPointUsed)
1401 points_[nPointUsed] = points_[ptI];
1407 nPoints_ = nPointUsed;
1408 points_.setSize(nPoints_);
1410 for (face&
f : faces_)
1420 void Foam::ccm::reader::validateInterface
1422 List<labelPair>& lst
1428 label face0 = lst[elemI][0];
1429 label face1 = lst[elemI][1];
1431 if (face0 < nFaces_ && face1 < nFaces_)
1435 lst[nElem][0] = face0;
1436 lst[nElem][1] = face1;
1445 void Foam::ccm::reader::renumberInterfaces
1450 forAll(domInterfaces_, elemI)
1452 domInterfaces_[elemI][0] = oldToNew[domInterfaces_[elemI][0]];
1453 domInterfaces_[elemI][1] = oldToNew[domInterfaces_[elemI][1]];
1456 forAll(bafInterfaces_, elemI)
1458 bafInterfaces_[elemI][0] = oldToNew[bafInterfaces_[elemI][0]];
1459 bafInterfaces_[elemI][1] = oldToNew[bafInterfaces_[elemI][1]];
1462 validateInterface(domInterfaces_);
1463 validateInterface(bafInterfaces_);
1472 void Foam::ccm::reader::cleanupInterfaces()
1474 validateInterface(bafInterfaces_);
1475 validateInterface(domInterfaces_);
1477 if (bafInterfaces_.size() <= 0 && domInterfaces_.size() <= 0)
1479 Info<<
"0 baffle interface pairs" <<
nl 1480 <<
"0 domain interface pairs" <<
endl;
1484 #ifdef DEBUG_BAFFLES 1485 Info<<
"baffle Interfaces " << bafInterfaces_ <<
nl 1486 <<
"domain Interfaces " << domInterfaces_ <<
nl 1487 <<
"nCells:" << nCells_ <<
nl 1488 <<
"nFaces:" << nFaces_ <<
nl 1489 <<
"patchSizes:" << patchSizes_ <<
nl 1490 <<
"nInternalFaces:" << nInternalFaces_ <<
endl;
1492 forAll(domInterfaces_, elemI)
1494 const label face0 = domInterfaces_[elemI][0];
1495 const label face1 = domInterfaces_[elemI][1];
1497 Info<<
"interface [" << elemI <<
"] = " 1498 << face0 <<
" - " << face1 <<
" own/neigh = " 1499 << faceOwner_[face0] <<
"/" << faceNeighbour_[face0] <<
" " 1500 << faceOwner_[face1] <<
"/" << faceNeighbour_[face1] <<
endl;
1509 label begOfList = nInternalFaces_;
1510 label endOfList = nFaces_ - 1;
1513 const labelList origPatchStarts(patchStartList(nInternalFaces_));
1518 nInternalFaces_ += domInterfaces_.
size();
1519 nFaces_ -= domInterfaces_.size();
1521 Info<< domInterfaces_.size() <<
" domain interface pairs";
1522 if (domInterfaces_.size())
1532 forAll(domInterfaces_, elemI)
1534 label face0 = domInterfaces_[elemI][0];
1535 label face1 = domInterfaces_[elemI][1];
1537 oldToNew[face0] = begOfList++;
1538 oldToNew[face1] = endOfList--;
1541 faceNeighbour_[face0] = faceOwner_[face1];
1542 faceOwner_[face1] = -1;
1545 forAll(patchSizes_, patchI)
1547 label beg = origPatchStarts[patchI];
1548 label
end = beg + patchSizes_[patchI];
1550 if (face0 >= beg && face0 <
end)
1552 ++adjustPatchSize[patchI];
1554 if (face1 >= beg && face1 <
end)
1556 ++adjustPatchSize[patchI];
1562 forAll(bafInterfaces_, elemI)
1564 label face0 = bafInterfaces_[elemI][0];
1565 label face1 = bafInterfaces_[elemI][1];
1567 forAll(patchSizes_, patchI)
1569 label beg = origPatchStarts[patchI];
1570 label
end = beg + patchSizes_[patchI];
1572 if (face0 >= beg && face0 <
end)
1574 ++bafflePatchCount[patchI];
1576 if (face1 >= beg && face1 <
end)
1578 ++bafflePatchCount[patchI];
1584 if (option().removeBaffles())
1587 nInternalFaces_ += bafInterfaces_.size();
1588 nFaces_ -= bafInterfaces_.size();
1591 Info<< bafInterfaces_.size() <<
" baffle interface pairs";
1592 if (bafInterfaces_.size())
1594 if (option().removeBaffles())
1609 if (option().removeBaffles())
1611 forAll(bafInterfaces_, elemI)
1613 label face0 = bafInterfaces_[elemI][0];
1614 label face1 = bafInterfaces_[elemI][1];
1616 oldToNew[face0] = begOfList++;
1617 oldToNew[face1] = endOfList--;
1620 faceNeighbour_[face0] = faceOwner_[face1];
1621 faceOwner_[face1] = -1;
1626 label
pos = nInternalFaces_;
1627 forAll(patchSizes_, patchI)
1629 label beg = origPatchStarts[patchI];
1630 label
end = beg + patchSizes_[patchI];
1633 for (label faceI = beg; faceI <
end; ++faceI)
1635 if (oldToNew[faceI] < 0)
1637 oldToNew[faceI] =
pos;
1644 bafInterfaces_.clear();
1649 forAll(bafflePatchCount, patchI)
1651 if (bafflePatchCount[patchI] % 2)
1653 Info<<
"WARNING: patch " << patchI
1654 <<
" has an uneven number of baffles (" 1655 << bafflePatchCount[patchI] <<
") expect strange results" 1662 label
pos = nInternalFaces_;
1663 forAll(patchSizes_, patchI)
1665 const label beg = origPatchStarts[patchI];
1666 const label
end = beg + patchSizes_[patchI];
1668 const label nsize = bafflePatchCount[patchI];
1673 const label nsizeby2 = (nsize - nsize % 2) / 2;
1677 forAll(bafInterfaces_, elemI)
1679 const label face0 = bafInterfaces_[elemI][0];
1680 const label face1 = bafInterfaces_[elemI][1];
1684 (face0 >= beg && face0 <
end)
1685 || (face1 >= beg && face1 <
end)
1688 oldToNew[face0] =
pos + nsorted;
1689 oldToNew[face1] =
pos + nsorted + nsizeby2;
1694 bafInterfaces_[elemI][0] = -oldToNew[face0];
1695 bafInterfaces_[elemI][1] = -oldToNew[face1];
1704 for (label faceI = beg; faceI <
end; ++faceI)
1706 if (oldToNew[faceI] < 0)
1708 oldToNew[faceI] =
pos;
1715 forAll(bafInterfaces_, elemI)
1717 bafInterfaces_[elemI][0] = abs(bafInterfaces_[elemI][0]);
1718 bafInterfaces_[elemI][1] = abs(bafInterfaces_[elemI][1]);
1722 #ifdef DEBUG_BAFFLES 1723 Info<<
"remap with " << oldToNew <<
nl 1724 <<
"owners:" << faceOwner_ <<
nl 1725 <<
"neighbours:" << faceNeighbour_ <<
nl 1735 if (monitoringSets_.size())
1737 #ifdef WITH_MONITORING 1742 forAll(domInterfaces_, elemI)
1744 label face0 = domInterfaces_[elemI][0];
1745 label face1 = domInterfaces_[elemI][1];
1746 oldToNew[face1] = oldToNew[face0];
1757 domInterfaces_.clear();
1760 faces_.setSize(nFaces_);
1761 faceOwner_.setSize(nFaces_);
1762 faceNeighbour_.setSize(nFaces_);
1763 origFaceId_.setSize(nFaces_);
1768 oldToNew.setSize(patchSizes_.size());
1772 forAll(patchSizes_, patchI)
1774 patchSizes_[patchI] -= adjustPatchSize[patchI];
1775 if (option().removeBaffles())
1777 patchSizes_[patchI] -= bafflePatchCount[patchI];
1780 if (patchSizes_[patchI])
1792 #ifdef DEBUG_BAFFLES 1793 Info<<
"nCells:" << nCells_ <<
nl 1794 <<
"nFaces:" << nFaces_ <<
nl 1795 <<
"PatchSizes:" << patchSizes_ <<
nl 1796 <<
"nInternalFaces:" << nInternalFaces_ <<
nl 1805 void Foam::ccm::reader::mergeInplaceInterfaces()
1807 if (interfaceDefinitions_.empty())
1811 if (!option().mergeInterfaces())
1813 Info<< interfaceDefinitions_.size() <<
" interface definitions" 1814 <<
" - leaving unmerged" <<
endl;
1819 DynamicList<labelPair> interfacePatches(interfaceDefinitions_.size());
1825 const interfaceEntry& ifentry = iter.val();
1829 origBndId_.find(ifentry.bnd0),
1830 origBndId_.find(ifentry.bnd1)
1835 patchPair[0] == patchPair[1]
1841 Info<<
"Warning : bad interface " << ifentry.id <<
" " << ifentry
1842 <<
" on patches " << patchPair <<
endl;
1846 patchSizes_[patchPair[0]] != patchSizes_[patchPair[1]]
1847 || patchSizes_[patchPair[0]] == 0
1848 || patchSizes_[patchPair[1]] == 0
1853 Info<<
"Warning: skip interface with zero or different" 1854 <<
" number of faces" <<
nl;
1857 Info<<
" Interface:" << ifentry.id <<
" " << ifentry
1858 <<
" patches " << patchPair
1860 << patchSizes_[patchPair[0]]
1861 <<
" " << patchSizes_[patchPair[1]] <<
")" 1866 interfacePatches.append(patchPair);
1870 if (interfacePatches.empty())
1882 const labelList origPatchStarts(patchStartList(nInternalFaces_));
1884 label nMergedTotal = 0;
1887 bitSet whichPoints(points_.size());
1889 Info<<
"interface merge points (tol=" 1890 << option().mergeTol() <<
"):" <<
endl;
1892 DynamicList<label> interfacesToMerge(interfacePatches.size());
1893 forAll(interfacePatches, interI)
1895 const label patch0 = interfacePatches[interI][0];
1896 const label patch1 = interfacePatches[interI][1];
1897 const label nPatch0Faces = patchSizes_[patch0];
1898 const label nPatch1Faces = patchSizes_[patch1];
1901 whichPoints.reset();
1902 for (label local0FaceI = 0; local0FaceI < nPatch0Faces; ++local0FaceI)
1904 const face&
f = faces_[origPatchStarts[patch0] + local0FaceI];
1906 for (
const label pointi :
f)
1909 whichPoints.set(oldToNew[pointi]);
1912 for (label local1FaceI = 0; local1FaceI < nPatch1Faces; ++local1FaceI)
1914 const face&
f = faces_[origPatchStarts[patch1] + local1FaceI];
1916 for (
const label pointi :
f)
1919 whichPoints.set(oldToNew[pointi]);
1926 const UIndirectList<point> pointsToMerge(points_, addr);
1928 Info<<
" patch " << patch0 <<
',' << patch1 <<
": (" 1929 << nPatch0Faces <<
" and " << nPatch1Faces <<
" faces) " <<
flush;
1934 option().mergeTol(),
1939 Info<< nMerged <<
" from " << pointsToMerge.size() <<
" points" 1948 forAll(mergedPointMap, pti)
1950 const label mergedPti = mergedPointMap[pti];
1957 const label origPointi = oldToNew[addr[pti]];
1962 label dupPti = pti+1;
1963 (dupPti = mergedPointMap.find(mergedPti, dupPti)) != -1;
1967 oldToNew[addr[dupPti]] = origPointi;
1968 mergedPointMap[dupPti] = -1;
1972 interfacesToMerge.append(interI);
1973 nMergedTotal += nMerged;
1987 for (face&
f : faces_)
1993 oldToNew.resize_nocopy(nPoints_);
1997 for (
const face&
f : faces_)
1999 for (
const label pointi :
f)
2005 label nPointUsed = 0;
2008 if (oldToNew[ptI] >= 0)
2010 oldToNew[ptI] = nPointUsed;
2011 if (ptI != nPointUsed)
2013 points_[nPointUsed] = points_[ptI];
2022 nPoints_ = nPointUsed;
2023 points_.resize(nPoints_);
2025 for (face&
f : faces_)
2034 Info<<
"interface merge faces:" <<
endl;
2038 forAll(interfacesToMerge, mergeI)
2040 const label patch0 = interfacePatches[interfacesToMerge[mergeI]][0];
2041 const label patch1 = interfacePatches[interfacesToMerge[mergeI]][1];
2043 labelList faceAddr0(patchSizes_[patch0]);
2044 labelList faceAddr1(patchSizes_[patch1]);
2046 forAll(faceAddr0, localFaceI)
2048 faceAddr0[localFaceI] = origPatchStarts[patch0] + localFaceI;
2050 forAll(faceAddr1, localFaceI)
2052 faceAddr1[localFaceI] = origPatchStarts[patch1] + localFaceI;
2055 if (faceAddr0.size() != faceAddr1.size())
2062 SortableList<scalar> pts0MagSqr
2077 SortableList<scalar> pts1MagSqr
2097 forAll(pts0MagSqr, sortI)
2099 const label face0I = faceAddr0[pts0MagSqr.indices()[sortI]];
2100 const label face1I = faceAddr1[pts1MagSqr.indices()[sortI]];
2108 ++adjustPatchSize[patch0];
2109 ++adjustPatchSize[patch1];
2111 if (faceOwner_[face0I] < faceOwner_[face1I])
2114 faceNeighbour_[face0I] = faceOwner_[face1I];
2115 faceNeighbour_[face1I] = faceOwner_[face1I] = -1;
2120 faceNeighbour_[face1I] = faceOwner_[face0I];
2121 faceNeighbour_[face0I] = faceOwner_[face0I] = -1;
2126 failed0.set(face0I);
2127 failed1.set(face1I);
2137 for (
const label face0I : failed0)
2139 for (
const label face1I : failed1)
2147 ++adjustPatchSize[patch0];
2148 ++adjustPatchSize[patch1];
2150 if (faceOwner_[face0I] < faceOwner_[face1I])
2153 faceNeighbour_[face0I] = faceOwner_[face1I];
2154 faceNeighbour_[face1I] = faceOwner_[face1I] = -1;
2159 faceNeighbour_[face1I] = faceOwner_[face0I];
2160 faceNeighbour_[face0I] = faceOwner_[face0I] = -1;
2163 failed1.
erase(face1I);
2174 Info<<
" patch " << patch0 <<
',' << patch1 <<
": " 2175 << nMerged <<
" from " << faceAddr0.size() <<
" faces";
2179 Info<<
" (" << failed0.size() <<
" merged ad hoc)";
2184 nMergedTotal += nMerged;
2197 oldToNew.setSize(nFaces_);
2201 label extFaceI = nInternalFaces_ + nMergedTotal;
2204 nInternalFaces_ = 0;
2205 label nFaceUsed = 0;
2206 for (label faceI = 0; faceI < nFaces_; ++faceI)
2208 if (faceOwner_[faceI] != -1)
2210 if (faceNeighbour_[faceI] != -1)
2213 oldToNew[faceI] = nInternalFaces_;
2220 oldToNew[faceI] = extFaceI;
2227 if (nFaceUsed != extFaceI)
2230 <<
"coding error: used " << nFaceUsed
2231 <<
" faces, but expected to use " << extFaceI <<
" faces" 2241 nFaces_ = nFaceUsed;
2243 faces_.setSize(nFaces_);
2244 faceOwner_.setSize(nFaces_);
2245 faceNeighbour_.setSize(nFaces_);
2246 origFaceId_.setSize(nFaces_);
2249 oldToNew.setSize(patchSizes_.size());
2253 forAll(patchSizes_, patchI)
2255 patchSizes_[patchI] -= adjustPatchSize[patchI];
2256 if (patchSizes_[patchI])
2280 void Foam::ccm::reader::reorderMesh()
2285 forAll(faceOwner_, faceI)
2287 const label nbr = faceNeighbour_[faceI];
2288 const label own = faceOwner_[faceI];
2290 if (nbr >= cellTableId_.size() || own >= cellTableId_.size())
2296 <<
" nCells:" << cellTableId_.size()
2300 if (nbr >= 0 && nbr < own)
2302 faceOwner_[faceI] = faceNeighbour_[faceI];
2303 faceNeighbour_[faceI] = own;
2304 faces_[faceI].flip();
2308 const face&
f = faces_[faceI];
2310 for (
const label pointi :
f)
2312 if (pointi < 0 || pointi >= points_.size())
2315 <<
"face:" << faceI <<
" f:" <<
f 2323 labelList oldToNew(faceOwner_.size(), -1);
2327 primitiveMesh::calcCells
2336 forAll(cellFaceAddr, cellI)
2338 const labelList& cFaces = cellFaceAddr[cellI];
2339 SortableList<label> nbr(cFaces.size(), -1);
2343 label faceI = cFaces[i];
2344 label nbrCellI = faceNeighbour_[faceI];
2349 if (nbrCellI == cellI)
2351 nbrCellI = faceOwner_[faceI];
2355 if (cellI < nbrCellI)
2368 oldToNew[cFaces[nbr.indices()[i]]] = newFaceI++;
2388 if (lst[i] >= 0 && lst[i] < nInternalFaces_)
2392 lst[nElem] = lst[i];
2404 Info <<
"remove monitor " << iter.key() <<
endl;
2405 monitoringSets_.erase(iter);
2416 void Foam::ccm::reader::addPatches
2425 label meshFaceI = nInternalFaces_;
2430 forAll(newPatches, patchI)
2436 auto citer = boundaryRegion_.cfind(origBndId_[patchI]);
2440 citer().readEntry(
"Label", patchName);
2441 citer().readEntry(
"BoundaryType", patchType);
2445 patchName = fallbackName;
2446 patchType =
"patch";
2451 if (hashedNames.found(patchName))
2453 Info<<
"renamed patch " << patchName <<
" to ";
2454 patchName = fallbackName +
"_" + patchName;
2457 hashedNames.insert(patchName);
2459 Info<<
"patch " << patchI
2460 <<
" (start: " << meshFaceI <<
" size: " << patchSizes_[patchI]
2461 <<
") name: " << patchName
2464 if (patchType ==
"wall")
2472 patchSizes_[patchI],
2475 mesh.boundaryMesh(),
2480 else if (patchType ==
"symmetry")
2485 new symmetryPolyPatch
2488 patchSizes_[patchI],
2491 mesh.boundaryMesh(),
2496 else if (patchType ==
"empty")
2505 patchSizes_[patchI],
2508 mesh.boundaryMesh(),
2523 patchSizes_[patchI],
2526 mesh.boundaryMesh(),
2532 meshFaceI += patchSizes_[patchI];
2535 if (meshFaceI !=
mesh.nFaces())
2538 <<
"meshFaceI:" << meshFaceI <<
" nFaces:" <<
mesh.nFaces()
2542 mesh.addPatches(newPatches);
2548 void Foam::ccm::reader::addFaceZones
2553 label nZone = monitoringSets_.size();
2554 mesh.faceZones().setSize(nZone);
2564 Info<<
"faceZone " << nZone
2565 <<
" (size: " << iter().size() <<
") name: " 2566 << iter.key() <<
endl;
2568 mesh.faceZones().set
2585 warnDuplicates(
"faceZones",
mesh.faceZones().names());
2595 if (geometryStatus_ == OKAY || geometryStatus_ == READ)
2597 geometryStatus_ = UNKNOWN;
2603 faceNeighbour_.clear();
2606 patchSizes_.clear();
2618 if (!readGeometry())
2624 remapMeshInfo(registry, remappingDictName);
2640 std::move(faceOwner_),
2641 std::move(faceNeighbour_)
2649 cellTable_.addCellZones(
mesh, cellTableId_);
2650 warnDuplicates(
"cellZones",
mesh.cellZones().names());
2654 warnDuplicates(
"boundaries",
mesh.boundaryMesh().names());
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
UList< label > labelUList
A UList of labels.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Calculate merge mapping, preserving the original point order. All points closer/equal mergeTol are to...
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
static word defaultRegion
Return the default region name.
void clearGeom()
Clear out some information after obtaining a polyMesh.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
errorManip< error > abort(error &err)
Pair< label > labelPair
A pair of labels.
Internal bits for wrapping libccmio - do not use directly.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Geometric merging of points. See below.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
Ostream & flush(Ostream &os)
Flush stream.
autoPtr< polyMesh > mesh(const objectRegistry ®istry, const fileName &remappingDictName=fileName::null)
Construct the polyMesh from the read geometry.
Automatically write from objectRegistry::writeObject()
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
static int compare(const face &a, const face &b)
Compare faces.
List< label > labelList
A List of labels.
Registry of regIOobjects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Container for holding STARCCM boundary information.
List< cell > cellList
A List of cells.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
forAllConstIters(mixture.phases(), phase)
static constexpr const zero Zero
Global zero (0)