53 namespace cellCellStencils
68 return (ijk[0]*nDivs[1] + ijk[1])*nDivs[2] + ijk[2];
78 label ij = boxI/nDivs[2];
79 label
k = boxI-ij*nDivs[2];
80 label i = ij/nDivs[1];
81 label j = ij-i*nDivs[1];
99 floor(relPt[0]/d[0]*nDivs[0]),
100 floor(relPt[1]/d[1]*nDivs[1]),
101 floor(relPt[2]/d[2]*nDivs[2])
117 const vector sz(d[0]/nDivs[0], d[1]/nDivs[1], d[2]/nDivs[2]);
119 return bb.
min()+0.5*sz+
vector(sz[0]*ids[0], sz[1]*ids[1], sz[2]*ids[2]);
129 const unsigned int val
135 for (
direction cmpt = 0; cmpt < 3; cmpt++)
137 if (maxIds[cmpt] < 0 || minIds[cmpt] > nDivs[cmpt])
145 maxIds =
min(maxIndex, maxIds);
147 for (label i = minIds[0]; i <= maxIds[0]; i++)
149 for (label j = minIds[1]; j <= maxIds[1]; j++)
151 for (label
k = minIds[2];
k <= maxIds[2];
k++)
176 const fvBoundaryMesh& pbm =
mesh.boundary();
183 const fvPatch& fvp = pbm[patchI];
190 const polyPatch& pp = fvp.patch();
197 boundBox faceBb(pp.points(), pp[i],
false);
198 faceBb.grow(smallVec);
200 if (bb.overlaps(faceBb))
211 const fvPatch& fvp = pbm[patchI];
214 if (isA<oversetFvPatch>(fvp))
217 const polyPatch& pp = fvp.patch();
221 patchCellTypes[cellMap[fc[i]]] = patchCellType::OVERSET;
224 boundBox faceBb(pp.points(), pp[i],
false);
225 faceBb.grow(smallVec);
227 if (bb.overlaps(faceBb))
229 fill(
patchTypes, bb, nDivs, faceBb, patchCellType::OVERSET);
241 const PackedList<2>& vals,
242 const treeBoundBox& subBb,
243 const unsigned int val
248 labelVector minIds(index3(bb, nDivs, subBb.min()));
249 labelVector maxIds(index3(bb, nDivs, subBb.max()));
251 for (
direction cmpt = 0; cmpt < 3; cmpt++)
253 if (maxIds[cmpt] < 0 || minIds[cmpt] > nDivs[cmpt])
261 maxIds =
min(maxIndex, maxIds);
263 for (label i = minIds[0]; i <= maxIds[0]; i++)
265 for (label j = minIds[1]; j <= maxIds[1]; j++)
267 for (label
k = minIds[2];
k <= maxIds[2];
k++)
283 PstreamBuffers& pBufs,
285 const PtrList<fvMeshSubset>& meshParts,
287 const List<treeBoundBoxList>& patchBb,
288 const List<labelVector>& patchDivisions,
289 const PtrList<PackedList<2>>& patchParts,
298 const labelList& tgtCellMap = meshParts[tgtI].cellMap();
305 if (srcPatchBb.overlaps(tgtPatchBb))
307 const PackedList<2>& srcPatchTypes = patchParts[srcI];
308 const labelVector& zoneDivs = patchDivisions[srcI];
310 forAll(tgtCellMap, tgtCelli)
312 label celli = tgtCellMap[tgtCelli];
313 treeBoundBox cBb(mesh_.cellBb(celli));
328 allCellTypes[celli] = HOLE;
342 const treeBoundBox& tgtPatchBb = tgtPatchBbs[procI];
344 if (srcPatchBb.overlaps(tgtPatchBb))
348 UOPstream
os(procI, pBufs);
349 os << srcPatchBb << patchDivisions[srcI] << patchParts[srcI];
353 pBufs.finishedSends();
359 const treeBoundBox& srcPatchBb = srcPatchBbs[procI];
362 if (srcPatchBb.overlaps(tgtPatchBb))
364 UIPstream is(procI, pBufs);
366 treeBoundBox receivedBb(is);
367 if (srcPatchBb != receivedBb)
371 <<
" srcPatchBb:" << srcPatchBb
372 <<
" receivedBb:" << receivedBb
377 const PackedList<2> srcPatchTypes(is);
379 forAll(tgtCellMap, tgtCelli)
381 label celli = tgtCellMap[tgtCelli];
382 treeBoundBox cBb(mesh_.cellBb(celli));
397 allCellTypes[celli] = HOLE;
408 const label destMesh,
409 const label currentDonorMesh,
410 const label newDonorMesh
423 if (currentDonorMesh == -1)
429 const label currentDist =
mag(currentDonorMesh-destMesh);
430 const label newDist =
mag(newDonorMesh-destMesh);
432 if (newDist < currentDist)
436 else if (newDist == currentDist && newDonorMesh > currentDonorMesh)
450 const globalIndex& globalCells,
451 PstreamBuffers& pBufs,
452 const PtrList<fvMeshSubset>& meshParts,
453 const List<treeBoundBoxList>&
meshBb,
466 const fvMesh& srcMesh = meshParts[srcI].subMesh();
467 const labelList& srcCellMap = meshParts[srcI].cellMap();
468 const fvMesh& tgtMesh = meshParts[tgtI].subMesh();
469 const pointField& tgtCc = tgtMesh.cellCentres();
470 const labelList& tgtCellMap = meshParts[tgtI].cellMap();
476 forAll(tgtCellMap, tgtCelli)
478 const label srcCelli = tgtToSrcAddr[tgtCelli];
482 && allCellTypes[tgtCellMap[tgtCelli]] != HOLE
485 label celli = tgtCellMap[tgtCelli];
489 if (betterDonor(tgtI, allDonor[celli], srcI))
492 globalCells.toGlobal(srcCellMap[srcCelli]);
493 allStencil[celli].setSize(1);
494 allStencil[celli][0] = globalDonor;
495 allDonor[celli] = srcI;
516 tgtOverlapProcs.append(procI);
520 srcOverlapProcs.append(procI);
528 forAll(srcOverlapProcs, i)
530 label procI = srcOverlapProcs[i];
531 tgtSendCells[procI].reserve(tgtMesh.nCells()/srcOverlapProcs.size());
535 forAll(tgtCellMap, tgtCelli)
537 label celli = tgtCellMap[tgtCelli];
538 if (srcOverlapProcs.size())
540 treeBoundBox subBb(mesh_.cellBb(celli));
541 subBb.grow(smallVec_);
543 forAll(srcOverlapProcs, i)
545 const label procI = srcOverlapProcs[i];
546 if (subBb.overlaps(srcBbs[procI]))
548 tgtSendCells[procI].append(tgtCelli);
557 forAll(srcOverlapProcs, i)
559 label procI = srcOverlapProcs[i];
562 UOPstream
os(procI, pBufs);
563 os << UIndirectList<point>(tgtCc,
cellIDs);
565 pBufs.finishedSends();
568 (void)srcMesh.tetBasePtIs();
569 forAll(tgtOverlapProcs, i)
571 label procI = tgtOverlapProcs[i];
573 UIPstream is(procI, pBufs);
583 donors[sampleI] = globalCells.toGlobal(srcCellMap[srcCelli]);
588 UOPstream
os(procI, pBufs);
591 pBufs.finishedSends();
593 forAll(srcOverlapProcs, i)
595 label procI = srcOverlapProcs[i];
598 UIPstream is(procI, pBufs);
601 if (donors.size() !=
cellIDs.size())
609 label globalDonor = donors[donorI];
611 if (globalDonor != -1)
613 label celli = tgtCellMap[
cellIDs[donorI]];
617 if (betterDonor(tgtI, allDonor[celli], srcI))
619 allStencil[celli].setSize(1);
620 allStencil[celli][0] = globalDonor;
621 allDonor[celli] = srcI;
933 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
939 (ownType == HOLE && neiType != HOLE)
940 || (ownType != HOLE && neiType == HOLE)
943 isBlockedFace[faceI] =
true;
954 for (label faceI =
mesh.nInternalFaces(); faceI <
mesh.nFaces(); faceI++)
957 label neiType = nbrCellTypes[faceI-
mesh.nInternalFaces()];
961 (ownType == HOLE && neiType != HOLE)
962 || (ownType != HOLE && neiType == HOLE)
965 isBlockedFace[faceI] =
true;
975 const label nRegions = cellRegion.
nRegions();
1003 << nRegions <<
endl;
1024 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
1026 if (isBlockedFace[faceI])
1028 label ownRegion = cellRegion[own[faceI]];
1032 if (regionType[ownRegion] == 0)
1034 regionType[ownRegion] = 1;
1038 label neiRegion = cellRegion[nei[faceI]];
1042 if (regionType[neiRegion] == 0)
1044 regionType[neiRegion] = 1;
1051 label faceI =
mesh.nInternalFaces();
1052 faceI <
mesh.nFaces();
1056 if (isBlockedFace[faceI])
1058 label ownRegion = cellRegion[own[faceI]];
1060 if (regionType[ownRegion] == 0)
1062 regionType[ownRegion] = 1;
1072 const fvPatch& fvp = pbm[patchI];
1074 if (isA<oversetFvPatch>(fvp))
1081 label regionI = cellRegion[fc[i]];
1083 if (
cellTypes[fc[i]] != HOLE && regionType[regionI] != 2)
1085 regionType[regionI] = 2;
1126 const fvPatch& fvp = pbm[patchI];
1128 if (isA<oversetFvPatch>(fvp))
1133 label cellI = fc[i];
1134 label regionI = cellRegion[cellI];
1136 if (regionType[regionI] != 2)
1138 const labelList& slots = compactStencil[cellI];
1141 label otherType = cellRegionType[slots[i]];
1148 regionType[regionI] = 2;
1160 << nChanged <<
endl;
1171 forAll(cellRegion, cellI)
1173 label
type = regionType[cellRegion[cellI]];
1185 const point& sample,
1192 weights.setSize(donorCcs.size());
1196 const scalar d =
mag(sample-donorCcs[i]);
1200 weights[i] = scalar(1)/d;
1206 weights = scalar(0);
1207 weights[i] = scalar(1);
1227 const labelList& owner = mesh_.faceOwner();
1228 const labelList& neighbour = mesh_.faceNeighbour();
1232 boolList isDonor(cellInterpolationMap().constructSize(),
false);
1233 label nHoleDonors = 0;
1235 for (
const label celli : interpolationCells_)
1237 const labelList& slots = cellStencil_[celli];
1241 mapDistributeBase::distribute<bool, orEqOp<bool>, flipOp>
1246 cellInterpolationMap().constructMap(),
1248 cellInterpolationMap().subMap(),
1258 forAll(cellTypes_, celli)
1265 reduce(nHoleDonors, sumOp<label>());
1268 Pout<<
"Detected " << nHoleDonors
1269 <<
" hole cells that are used as donors" <<
endl;
1282 cellInterpolationMap().distribute(globalCellIDs);
1284 forAll(interpolationCells_, i)
1286 label cellI = interpolationCells_[i];
1287 const labelList& slots = cellStencil_[cellI];
1288 cellStencil_[cellI] = UIndirectList<label>(globalCellIDs, slots)();
1295 label nSpecialNear = 0;
1296 label nSpecialFar = 0;
1303 List<pointList> donorCcs(mesh_.nCells());
1306 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
1308 const label own = owner[facei];
1310 const label nbr = neighbour[facei];
1313 if (isDonor[own] && ownHole && !nbrHole)
1316 donorCcs[own].
append(mesh_.cellCentres()[nbr]);
1318 else if (isDonor[nbr] && nbrHole && !ownHole)
1320 donorCells[nbr].append(globalCells.
toGlobal(own));
1321 donorCcs[nbr].
append(mesh_.cellCentres()[own]);
1332 const label facei = bFacei+mesh_.nInternalFaces();
1333 const label own = owner[facei];
1337 if (isDonor[own] && ownHole && !nbrHole)
1339 donorCells[own].
append(nbrCells[bFacei]);
1340 donorCcs[own].
append(nbrCc[bFacei]);
1346 if (donorCcs[celli].size())
1348 cellStencil_[celli] = std::move(donorCells[celli]);
1351 mesh_.cellCentres()[celli],
1353 cellInterpolationWeights_[celli]
1355 cellTypes_[celli] = SPECIAL;
1356 interpolationCells_.append(celli);
1357 cellInterpolationWeight_[celli] = scalar(1);
1371 List<topoDistanceData<int>> cellData(mesh_.nCells());
1372 List<topoDistanceData<int>> faceData(mesh_.nFaces());
1374 int dummyTrackData(0);
1378 forAll(cellTypes_, celli)
1380 label cType = cellTypes_[celli];
1387 cellData[celli] = topoDistanceData<int>(
labelMin, 0);
1391 DynamicList<label> seedFaces(nHoleDonors);
1392 DynamicList<topoDistanceData<int>> seedData(nHoleDonors);
1394 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
1396 const label own = owner[facei];
1397 const bool ownLive =
1403 const label nbr = neighbour[facei];
1404 const bool nbrLive =
1410 if (ownLive && !nbrLive)
1413 const label globalOwn = globalCells.
toGlobal(own);
1414 seedData.append(topoDistanceData<int>(globalOwn, 0));
1416 else if (!ownLive && nbrLive)
1418 seedFaces.append(facei);
1419 const label globalNbr = globalCells.
toGlobal(nbr);
1420 seedData.append(topoDistanceData<int>(globalNbr, 0));
1426 const label facei = bFacei+mesh_.nInternalFaces();
1427 const label own = owner[facei];
1428 const bool ownLive =
1433 const bool nbrLive =
1439 if (ownLive && !nbrLive)
1442 const label globalOwn = globalCells.
toGlobal(own);
1443 seedData.append(topoDistanceData<int>(globalOwn, 0));
1448 FaceCellWave<topoDistanceData<int>> distanceCalc
1455 mesh_.globalData().nTotalCells()+1,
1468 && cellData[celli].valid(dummyTrackData)
1471 cellStencil_[celli].setSize(1);
1472 cellStencil_[celli] = cellData[celli].data();
1473 cellInterpolationWeights_[celli].setSize(1);
1474 cellInterpolationWeights_[celli] = 1.0;
1475 cellTypes_[celli] = SPECIAL;
1476 interpolationCells_.append(celli);
1477 cellInterpolationWeight_[celli] = 1.0;
1484 reduce(nSpecialNear, sumOp<label>());
1485 reduce(nSpecialFar, sumOp<label>());
1487 Pout<<
"Detected " << nHoleDonors
1488 <<
" hole cells that are used as donors of which" <<
nl 1489 <<
" next to live cells : " << nSpecialNear <<
nl 1490 <<
" other : " << nSpecialFar <<
nl 1496 List<Map<label>> compactMap;
1497 cellInterpolationMap_.reset
1513 const bool allowHoleDonors
1531 const vector greatPoint(GREAT, GREAT, GREAT);
1533 boolList isValidDonor(mesh_.nCells(),
true);
1534 if (!allowHoleDonors)
1536 forAll(cellTypes_, celli)
1538 if (cellTypes_[celli] == HOLE)
1540 isValidDonor[celli] =
false;
1546 bitSet doneAcceptor(interpolationCells_.size());
1555 forAll(interpolationCells_, i)
1557 if (!doneAcceptor[i])
1559 label cellI = interpolationCells_[i];
1560 const point& cc = mesh_.cellCentres()[cellI];
1561 const labelList& slots = cellStencil_[cellI];
1565 if (slots.size() > 1)
1570 else if (slots.size())
1574 const label elemi = slots[sloti];
1579 minMagSqrEqOp<point>()(
samples[elemi], cc);
1593 mapDistributeBase::distribute<point, minMagSqrEqOp<point>, flipOp>
1598 cellInterpolationMap().constructMap(),
1600 cellInterpolationMap().subMap(),
1604 minMagSqrEqOp<point>(),
1607 cellInterpolationMap().comm()
1613 DynamicList<label> donorCells(mesh_.nCells());
1616 if (
samples[cellI] != greatPoint)
1618 donorCells.append(cellI);
1640 label cellI = donorCells[i];
1641 const pointList& donorCentres = donorCellCentres[cellI];
1653 cellInterpolationMap().distribute(donorCellCells);
1654 cellInterpolationMap().distribute(donorWeights);
1655 cellInterpolationMap().distribute(
samples);
1658 forAll(interpolationCells_, i)
1660 if (!doneAcceptor[i])
1662 label cellI = interpolationCells_[i];
1663 const labelList& slots = cellStencil_[cellI];
1665 if (slots.size() > 1)
1670 else if (slots.size() == 1)
1672 const label sloti = slots[0];
1675 if (
samples[sloti] == mesh_.cellCentres()[cellI])
1677 cellStencil_[cellI].transfer(donorCellCells[sloti]);
1678 cellInterpolationWeights_[cellI].transfer
1684 doneAcceptor.set(i);
1692 List<Map<label>> compactMap;
1693 cellInterpolationMap_.reset
1707 Foam::cellCellStencils::inverseDistance::inverseDistance
1716 allowHoleDonors_(
dict.getOrDefault(
"allowHoleDonors", false)),
1717 allowInterpolatedDonors_
1719 dict.getOrDefault(
"allowInterpolatedDonors", true)
1723 interpolationCells_(0),
1724 cellInterpolationMap_(),
1726 cellInterpolationWeights_(0),
1727 cellInterpolationWeight_
1731 "cellInterpolationWeight",
1732 mesh_.facesInstance(),
1740 zeroGradientFvPatchScalarField::typeName
1751 const word w(
"snGradCorr(cellDisplacement)");
1752 const word d(
"((viscosity*faceDiffusivity)*magSf)");
1777 forAll(volCellTypes, celli)
1801 label layerRelax(dict_.getOrDefault(
"layerRelax", 1));
1803 scalar tol = dict_.getOrDefault(
"tolerance", 1
e-10);
1804 smallVec_ = mesh_.bounds().span()*tol;
1808 label nZones =
gMax(zoneID)+1;
1812 nCellsPerZone[zoneID[cellI]]++;
1816 const boundBox& allBb = mesh_.bounds();
1834 const fvMesh& subMesh = meshParts[zonei].subMesh();
1867 bbs[procI] = procBb[procI][zoneI];
1879 labelList allPatchTypes(mesh_.nCells(), OTHER);
1883 if (dict_.readIfPresent(
"searchBox", globalPatchBb))
1897 if (dict_.readIfPresent(
"searchBoxDivisions", globalDivs))
1899 patchDivisions = globalDivs;
1905 if (mesh_.nGeometricD() == 1)
1907 nDivs = mesh_.nCells();
1909 else if (mesh_.nGeometricD() == 2)
1911 nDivs = label(
Foam::sqrt(scalar(mesh_.nCells())));
1915 nDivs = label(
Foam::cbrt(scalar(mesh_.nCells())));
1930 forAll(patchParts, zoneI)
1937 patchDivisions[zoneI][0]
1938 *patchDivisions[zoneI][1]
1939 *patchDivisions[zoneI][2]
1944 meshParts[zoneI].subMesh(),
1948 patchDivisions[zoneI],
1951 meshParts[zoneI].cellMap(),
1959 Info<<
type() <<
" : detected " << nZones
1960 <<
" mesh regions" <<
endl;
1962 forAll(nCellsPerZone, zoneI)
1965 <<
" nCells:" << nCellsPerZone[zoneI]
1966 <<
" voxels:" << patchDivisions[zoneI]
1976 labelList allCellTypes(mesh_.nCells(), CALCULATED);
1979 labelList allDonorID(mesh_.nCells(), -1);
1986 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
1988 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
2022 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
2024 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
2055 if ((
debug&2)&& (mesh_.time().outputTime()))
2059 createField(mesh_,
"allCellTypes", allCellTypes)
2065 createField(mesh_,
"allDonorID", allDonorID)
2067 tallDonorID().write();
2071 forAll(allPatchTypes, cellI)
2073 if (allCellTypes[cellI] != HOLE)
2075 switch (allPatchTypes[cellI])
2080 if (allStencil[cellI].size())
2082 allCellTypes[cellI] = INTERPOLATED;
2086 allCellTypes[cellI] = HOLE;
2093 if ((
debug&2) && (mesh_.time().outputTime()))
2097 createField(mesh_,
"allCellTypes_patch", allCellTypes)
2103 createField(mesh_,
"allCellTypes_old", cellTypes_)
2109 findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
2112 if ((
debug&2) && (mesh_.time().outputTime()))
2116 createField(mesh_,
"allCellTypes_hole", allCellTypes)
2120 if ((
debug&2) && (mesh_.time().outputTime()))
2123 forAll(allStencil, celli)
2125 stencilSize[celli] = allStencil[celli].size();
2129 createField(mesh_,
"allStencil_hole", stencilSize)
2135 forAll(allCellTypes, celli)
2137 if (allCellTypes[celli] == HOLE && allStencil[celli].size())
2139 allStencil[celli].clear();
2176 if ((
debug&2) && (mesh_.time().outputTime()))
2180 createField(mesh_,
"allCellTypes_pre_front", allCellTypes)
2189 mapDistribute map(globalCells, compactStencil, compactStencilMap);
2195 label useLayer = dict_.getOrDefault(
"useLayer", -1);
2201 "oversetInterpolation" 2216 dict_.getOrDefault(
"holeLayers", 1),
2220 if ((
debug&2) && (mesh_.time().outputTime()))
2224 createField(mesh_,
"allCellTypes_front", allCellTypes)
2234 label nCalculated = 0;
2236 forAll(cellTypes_, celli)
2238 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
2240 if (allStencil[celli].size() == 0)
2243 allCellTypes[celli] = HOLE;
2244 allStencil[celli].clear();
2248 allCellTypes[celli] = INTERPOLATED;
2256 Pout<<
"Detected " << nCalculated <<
" cells changing from hole" 2257 <<
" to calculated. Changed to interpolated" 2269 cellTypes_.transfer(allCellTypes);
2270 cellStencil_.setSize(mesh_.nCells());
2271 cellInterpolationWeights_.setSize(mesh_.nCells());
2307 label nInterpolatedDonors = 0;
2308 forAll(cellTypes_, celli)
2310 if (cellTypes_[celli] == INTERPOLATED)
2312 const labelList& slots = compactStencil[celli];
2317 compactCellTypes[slots[0]] == HOLE
2320 !allowInterpolatedDonors_
2321 && compactCellTypes[slots[0]] == INTERPOLATED
2325 cellTypes_[celli] = POROUS;
2326 cellStencil_[celli].
clear();
2327 cellInterpolationWeights_[celli].clear();
2328 nInterpolatedDonors++;
2332 cellStencil_[celli].transfer(allStencil[celli]);
2333 cellInterpolationWeights_[celli].setSize(1);
2334 cellInterpolationWeights_[celli][0] = 1.0;
2335 interpolationCells.
append(celli);
2341 cellStencil_[celli].clear();
2342 cellInterpolationWeights_[celli].clear();
2349 <<
"interpolate Donors : " 2350 << nInterpolatedDonors <<
endl;
2354 cellInterpolationMap_.reset
2359 interpolationCells_.
transfer(interpolationCells);
2361 cellInterpolationWeight_.transfer(allWeight);
2366 >(cellInterpolationWeight_.boundaryFieldRef(),
false);
2369 if ((
debug&2) && (mesh_.time().outputTime()))
2372 mesh_.time().
write();
2375 mkDir(mesh_.time().timePath());
2376 OBJstream str(mesh_.time().timePath()/
"injectionStencil.obj");
2377 Pout<<
type() <<
" : dumping injectionStencil to " 2378 << str.name() <<
endl;
2380 cellInterpolationMap().distribute(cc);
2382 forAll(cellStencil_, celli)
2384 const labelList& slots = cellStencil_[celli];
2387 const point& accCc = mesh_.cellCentres()[celli];
2390 const point& donorCc = cc[slots[i]];
2391 str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
2399 createStencil(globalCells, allowHoleDonors_);
2403 if (allowHoleDonors_)
2405 holeExtrapolationStencil(globalCells);
2408 if ((
debug&2) && (mesh_.time().outputTime()))
2412 cellInterpolationWeight_.instance() = mesh_.time().timeName();
2413 cellInterpolationWeight_.write();
2418 forAll(cellStencil_, celli)
2420 const scalarList& wghts = cellInterpolationWeights_[celli];
2423 if (
mag(wghts[i]) >
mag(maxMagWeight[celli]))
2425 maxMagWeight[celli] = wghts[i];
2428 if (
mag(maxMagWeight[celli]) > 1)
2431 Pout<<
"cell:" << celli
2432 <<
" at:" << cc[celli]
2433 <<
" zone:" << zoneID[celli]
2434 <<
" donors:" << cellStencil_[celli]
2435 <<
" weights:" << wghts
2445 createField(mesh_,
"maxMagWeight", maxMagWeight)
2451 >(tfld.
ref().boundaryFieldRef(),
false);
2459 createField(mesh_,
"cellTypes", cellTypes_)
2466 >(tfld.
ref().boundaryFieldRef(),
false);
2472 mkDir(mesh_.time().timePath());
2474 cellInterpolationMap().distribute(cc);
2479 mesh_.time().timePath()
2480 +
"/stencil_" +
name(zonei) +
".obj" 2482 Pout<<
type() <<
" : dumping to " << str.name() <<
endl;
2484 const labelList& subMeshCellMap = meshParts[zonei].cellMap();
2486 forAll(subMeshCellMap, subcelli)
2488 const label celli = subMeshCellMap[subcelli];
2489 const labelList& slots = cellStencil_[celli];
2490 const point& accCc = mesh_.cellCentres()[celli];
2493 const point& donorCc = cc[slots[i]];
2494 str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
2507 forAll(interpolationCells_, i)
2509 label celli = interpolationCells_[i];
2510 const labelList& slots = cellStencil_[celli];
2512 bool hasLocal =
false;
2513 bool hasRemote =
false;
2517 if (slots[sloti] >= mesh_.nCells())
2544 Info<<
"Overset analysis : nCells : " 2547 <<
indent <<
"calculated : " << nCells[CALCULATED] <<
nl 2548 <<
indent <<
"interpolated : " << nCells[INTERPOLATED]
2552 <<
indent <<
"hole : " << nCells[HOLE] <<
nl static point position(const boundBox &bb, const labelVector &nDivs, const label boxI)
Convert index back into coordinate.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Inverse-distance-weighted interpolation stencil.
List< labelList > labelListList
A List of labelList.
void size(const label n)
Older name for setAddressableSize.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static labelVector index3(const labelVector &nDivs, const label)
Convert single index into ijk.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
void findHoles(const globalIndex &globalCells, const fvMesh &mesh, const labelList &zoneID, const labelListList &stencil, labelList &cellTypes) const
Do flood filling to detect unreachable (from patches) sections.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
static void calculate(const polyMesh &src, const polyMesh &tgt, labelList &srcToTgtAddr)
Calculate addressing.
bool betterDonor(const label destMesh, const label currentDonorMesh, const label newDonorMesh) const
If multiple donors meshes: decide which is best.
scalarField samples(nIntervals, Zero)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void markBoundaries(const fvMesh &mesh, const vector &smallVec, const boundBox &bb, const labelVector &nDivs, PackedList< 2 > &patchTypes, const labelList &cellMap, labelList &patchCellTypes)
Mark voxels of patchTypes with type of patch face.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
defineTypeNameAndDebug(cellVolumeWeight, 0)
static void fill(PackedList< 2 > &elems, const boundBox &bb, const labelVector &nDivs, const boundBox &subBb, const unsigned int val)
Fill all elements overlapping subBb with value val.
A bounding box defined in terms of min/max extrema points.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
static int & msgType() noexcept
Message tag of standard messages.
List< treeBoundBox > treeBoundBoxList
A List of treeBoundBox.
label k
Boltzmann constant.
Ignore writing from objectRegistry::writeObject()
const point & min() const noexcept
Minimum describing the bounding box.
const dimensionSet dimless
Dimensionless.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
static const List< T > & null()
Return a null List.
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
List< point > pointList
A List of points.
const Time & time() const
Return the top-level database.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
virtual ~inverseDistance()
Destructor.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
Macros for easy insertion into run-time selection tables.
wordHashSet nonInterpolatedFields_
Set of fields that should not be interpolated.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
void markDonors(const globalIndex &globalCells, PstreamBuffers &pBufs, const PtrList< fvMeshSubset > &meshParts, const List< treeBoundBoxList > &meshBb, const labelList &allCellTypes, const label srcI, const label tgtI, labelListList &allStencil, labelList &allDonor) const
Determine donors for all tgt cells.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static void allGatherList(List< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses linear/tree communication. ...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const point & max() const noexcept
Maximum describing the bounding box.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Calculation of interpolation stencils.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
virtual void stencilWeights(const point &sample, const pointList &donorCcs, scalarList &weights) const
Calculate inverse distance weights for a single acceptor.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
void markPatchesAsHoles(PstreamBuffers &pBufs, const PtrList< fvMeshSubset > &meshParts, const List< treeBoundBoxList > &patchBb, const List< labelVector > &patchDivisions, const PtrList< PackedList< 2 >> &patchParts, const label srcI, const label tgtI, labelList &allCellTypes) const
Mark all cells overlapping (a voxel covered by) a src patch.
virtual const labelUList & faceCells() const
Return faceCells.
const label nSamples(pdfDictionary.get< label >("nSamples"))
label size() const noexcept
The number of elements in the list.
List< scalar > scalarList
A List of scalars.
dimensionedScalar cbrt(const dimensionedScalar &ds)
const dictionary & schemesDict() const
The current schemes dictionary, respects the "select" keyword.
void append(const T &val)
Copy append an element to the end of this list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
const fvMesh & mesh_
Reference to the mesh.
const labelList & cellTypes
virtual void createStencil(const globalIndex &, const bool allowHoleDonors)
Create stencil starting from the donor containing the acceptor allowHoleDonors : allow donors of type...
#define DebugInfo
Report an information message using Foam::Info.
static void correctBoundaryConditions(typename GeoField::Boundary &bfld, const bool typeOnly)
Correct boundary conditions of certain type (typeOnly = true)
virtual bool update()
Update stencils. Return false if nothing changed.
addToRunTimeSelectionTable(cellCellStencil, cellVolumeWeight, mesh)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
List< pointList > pointListList
A List of pointList.
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
labelList cellTypes_
Per cell the cell type.
static label index(const labelVector &nDivs, const labelVector &)
Convert ijk indices into single index.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
label toGlobal(const label i) const
From local to global index.
const labelIOList & zoneID() const
Helper: get reference to registered zoneID. Loads volScalarField.
UIndirectList< label > labelUIndList
UIndirectList of labels.
Class containing processor-to-processor mapping information.
List< scalarList > scalarListList
A List of scalarList.
vector point
Point is a vector.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Selector class for finite volume differencing schemes. fvMesh is derived from fvSchemes so that all f...
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
label nRegions() const
Return total number of regions.
vector span() const
The bounding box span (from minimum to maximum)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Standard boundBox with extra functionality for use in octree.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Vector< label > labelVector
Vector of labels.
virtual void write(Ostream &os) const
Write.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
A class for managing temporary objects.
static bool overlaps(const boundBox &bb, const labelVector &nDivs, const PackedList< 2 > &voxels, const treeBoundBox &subBb, const unsigned int val)
Is any voxel inside subBb set to val.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Defines the attributes of an object for which implicit objectRegistry management is supported...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void holeExtrapolationStencil(const globalIndex &globalCells)
Make holes next to live ones type SPECIAL and include in interpolation stencil.
static const Vector< label > zero
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
static constexpr const zero Zero
Global zero (0)