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();
358 const treeBoundBox& srcPatchBb = srcPatchBbs[procI];
361 if (srcPatchBb.overlaps(tgtPatchBb))
363 UIPstream is(procI, pBufs);
364 const treeBoundBox receivedBb(is);
366 const PackedList<2> srcPatchTypes(is);
369 if (srcPatchBb != receivedBb)
373 <<
" srcPatchBb:" << srcPatchBb
374 <<
" receivedBb:" << receivedBb
378 forAll(tgtCellMap, tgtCelli)
380 label celli = tgtCellMap[tgtCelli];
381 treeBoundBox cBb(mesh_.cellBb(celli));
396 allCellTypes[celli] = HOLE;
407 const label destMesh,
408 const label currentDonorMesh,
409 const label newDonorMesh
422 if (currentDonorMesh == -1)
428 const label currentDist =
mag(currentDonorMesh-destMesh);
429 const label newDist =
mag(newDonorMesh-destMesh);
431 if (newDist < currentDist)
435 else if (newDist == currentDist && newDonorMesh > currentDonorMesh)
449 const globalIndex& globalCells,
450 PstreamBuffers& pBufs,
451 const PtrList<fvMeshSubset>& meshParts,
452 const List<treeBoundBoxList>&
meshBb,
465 const fvMesh& srcMesh = meshParts[srcI].subMesh();
466 const labelList& srcCellMap = meshParts[srcI].cellMap();
467 const fvMesh& tgtMesh = meshParts[tgtI].subMesh();
468 const pointField& tgtCc = tgtMesh.cellCentres();
469 const labelList& tgtCellMap = meshParts[tgtI].cellMap();
475 forAll(tgtCellMap, tgtCelli)
477 const label srcCelli = tgtToSrcAddr[tgtCelli];
481 && allCellTypes[tgtCellMap[tgtCelli]] != HOLE
484 label celli = tgtCellMap[tgtCelli];
488 if (betterDonor(tgtI, allDonor[celli], srcI))
491 globalCells.toGlobal(srcCellMap[srcCelli]);
492 allStencil[celli].setSize(1);
493 allStencil[celli][0] = globalDonor;
494 allDonor[celli] = srcI;
515 tgtOverlapProcs.append(procI);
519 srcOverlapProcs.append(procI);
527 forAll(srcOverlapProcs, i)
529 label procI = srcOverlapProcs[i];
530 tgtSendCells[procI].reserve(tgtMesh.nCells()/srcOverlapProcs.size());
534 forAll(tgtCellMap, tgtCelli)
536 label celli = tgtCellMap[tgtCelli];
537 if (srcOverlapProcs.size())
539 treeBoundBox subBb(mesh_.cellBb(celli));
540 subBb.grow(smallVec_);
542 forAll(srcOverlapProcs, i)
544 const label procI = srcOverlapProcs[i];
545 if (subBb.overlaps(srcBbs[procI]))
547 tgtSendCells[procI].append(tgtCelli);
556 forAll(srcOverlapProcs, i)
558 label procI = srcOverlapProcs[i];
561 UOPstream
os(procI, pBufs);
562 os << UIndirectList<point>(tgtCc,
cellIDs);
564 pBufs.finishedSends();
567 (void)srcMesh.tetBasePtIs();
568 forAll(tgtOverlapProcs, i)
570 label procI = tgtOverlapProcs[i];
572 UIPstream is(procI, pBufs);
582 donors[sampleI] = globalCells.toGlobal(srcCellMap[srcCelli]);
587 UOPstream
os(procI, pBufs);
590 pBufs.finishedSends();
592 forAll(srcOverlapProcs, i)
594 label procI = srcOverlapProcs[i];
597 UIPstream is(procI, pBufs);
600 if (donors.size() !=
cellIDs.size())
608 label globalDonor = donors[donorI];
610 if (globalDonor != -1)
612 label celli = tgtCellMap[
cellIDs[donorI]];
616 if (betterDonor(tgtI, allDonor[celli], srcI))
618 allStencil[celli].setSize(1);
619 allStencil[celli][0] = globalDonor;
620 allDonor[celli] = srcI;
932 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
938 (ownType == HOLE && neiType != HOLE)
939 || (ownType != HOLE && neiType == HOLE)
942 isBlockedFace[faceI] =
true;
953 for (label faceI =
mesh.nInternalFaces(); faceI <
mesh.nFaces(); faceI++)
956 label neiType = nbrCellTypes[faceI-
mesh.nInternalFaces()];
960 (ownType == HOLE && neiType != HOLE)
961 || (ownType != HOLE && neiType == HOLE)
964 isBlockedFace[faceI] =
true;
974 const label nRegions = cellRegion.
nRegions();
1002 << nRegions <<
endl;
1023 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
1025 if (isBlockedFace[faceI])
1027 label ownRegion = cellRegion[own[faceI]];
1031 if (regionType[ownRegion] == 0)
1033 regionType[ownRegion] = 1;
1037 label neiRegion = cellRegion[nei[faceI]];
1041 if (regionType[neiRegion] == 0)
1043 regionType[neiRegion] = 1;
1050 label faceI =
mesh.nInternalFaces();
1051 faceI <
mesh.nFaces();
1055 if (isBlockedFace[faceI])
1057 label ownRegion = cellRegion[own[faceI]];
1059 if (regionType[ownRegion] == 0)
1061 regionType[ownRegion] = 1;
1073 if (isA<oversetFvPatch>(fvp))
1080 label regionI = cellRegion[fc[i]];
1082 if (
cellTypes[fc[i]] != HOLE && regionType[regionI] != 2)
1084 regionType[regionI] = 2;
1127 if (isA<oversetFvPatch>(fvp))
1132 label cellI = fc[i];
1133 label regionI = cellRegion[cellI];
1135 if (regionType[regionI] != 2)
1137 const labelList& slots = compactStencil[cellI];
1140 label otherType = cellRegionType[slots[i]];
1147 regionType[regionI] = 2;
1159 << nChanged <<
endl;
1170 forAll(cellRegion, cellI)
1172 label
type = regionType[cellRegion[cellI]];
1184 const point& sample,
1191 weights.setSize(donorCcs.size());
1195 const scalar d =
mag(sample-donorCcs[i]);
1199 weights[i] = scalar(1)/d;
1205 weights = scalar(0);
1206 weights[i] = scalar(1);
1226 const labelList& owner = mesh_.faceOwner();
1227 const labelList& neighbour = mesh_.faceNeighbour();
1231 boolList isDonor(cellInterpolationMap().constructSize(),
false);
1232 label nHoleDonors = 0;
1234 for (
const label celli : interpolationCells_)
1236 const labelList& slots = cellStencil_[celli];
1240 mapDistributeBase::distribute<bool, orEqOp<bool>, flipOp>
1245 cellInterpolationMap().constructMap(),
1247 cellInterpolationMap().subMap(),
1257 forAll(cellTypes_, celli)
1264 reduce(nHoleDonors, sumOp<label>());
1267 Pout<<
"Detected " << nHoleDonors
1268 <<
" hole cells that are used as donors" <<
endl;
1281 cellInterpolationMap().distribute(globalCellIDs);
1283 forAll(interpolationCells_, i)
1285 label cellI = interpolationCells_[i];
1286 const labelList& slots = cellStencil_[cellI];
1287 cellStencil_[cellI] = UIndirectList<label>(globalCellIDs, slots)();
1294 label nSpecialNear = 0;
1295 label nSpecialFar = 0;
1302 List<pointList> donorCcs(mesh_.nCells());
1305 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
1307 const label own = owner[facei];
1309 const label nbr = neighbour[facei];
1312 if (isDonor[own] && ownHole && !nbrHole)
1315 donorCcs[own].
append(mesh_.cellCentres()[nbr]);
1317 else if (isDonor[nbr] && nbrHole && !ownHole)
1319 donorCells[nbr].append(globalCells.
toGlobal(own));
1320 donorCcs[nbr].
append(mesh_.cellCentres()[own]);
1331 const label facei = bFacei+mesh_.nInternalFaces();
1332 const label own = owner[facei];
1336 if (isDonor[own] && ownHole && !nbrHole)
1338 donorCells[own].
append(nbrCells[bFacei]);
1339 donorCcs[own].
append(nbrCc[bFacei]);
1345 if (donorCcs[celli].size())
1347 cellStencil_[celli] = std::move(donorCells[celli]);
1350 mesh_.cellCentres()[celli],
1352 cellInterpolationWeights_[celli]
1354 cellTypes_[celli] = SPECIAL;
1355 interpolationCells_.append(celli);
1356 cellInterpolationWeight_[celli] = scalar(1);
1370 List<topoDistanceData<int>> cellData(mesh_.nCells());
1371 List<topoDistanceData<int>> faceData(mesh_.nFaces());
1373 int dummyTrackData(0);
1377 forAll(cellTypes_, celli)
1379 label cType = cellTypes_[celli];
1386 cellData[celli] = topoDistanceData<int>(
labelMin, 0);
1390 DynamicList<label> seedFaces(nHoleDonors);
1391 DynamicList<topoDistanceData<int>> seedData(nHoleDonors);
1393 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
1395 const label own = owner[facei];
1396 const bool ownLive =
1402 const label nbr = neighbour[facei];
1403 const bool nbrLive =
1409 if (ownLive && !nbrLive)
1412 const label globalOwn = globalCells.
toGlobal(own);
1413 seedData.append(topoDistanceData<int>(globalOwn, 0));
1415 else if (!ownLive && nbrLive)
1417 seedFaces.append(facei);
1418 const label globalNbr = globalCells.
toGlobal(nbr);
1419 seedData.append(topoDistanceData<int>(globalNbr, 0));
1425 const label facei = bFacei+mesh_.nInternalFaces();
1426 const label own = owner[facei];
1427 const bool ownLive =
1432 const bool nbrLive =
1438 if (ownLive && !nbrLive)
1441 const label globalOwn = globalCells.
toGlobal(own);
1442 seedData.append(topoDistanceData<int>(globalOwn, 0));
1447 FaceCellWave<topoDistanceData<int>> distanceCalc
1454 mesh_.globalData().nTotalCells()+1,
1467 && cellData[celli].valid(dummyTrackData)
1470 cellStencil_[celli].setSize(1);
1471 cellStencil_[celli] = cellData[celli].data();
1472 cellInterpolationWeights_[celli].setSize(1);
1473 cellInterpolationWeights_[celli] = 1.0;
1474 cellTypes_[celli] = SPECIAL;
1475 interpolationCells_.append(celli);
1476 cellInterpolationWeight_[celli] = 1.0;
1483 reduce(nSpecialNear, sumOp<label>());
1484 reduce(nSpecialFar, sumOp<label>());
1486 Pout<<
"Detected " << nHoleDonors
1487 <<
" hole cells that are used as donors of which" <<
nl 1488 <<
" next to live cells : " << nSpecialNear <<
nl 1489 <<
" other : " << nSpecialFar <<
nl 1495 List<Map<label>> compactMap;
1496 cellInterpolationMap_.reset
1512 const bool allowHoleDonors
1530 const vector greatPoint(GREAT, GREAT, GREAT);
1532 boolList isValidDonor(mesh_.nCells(),
true);
1533 if (!allowHoleDonors)
1535 forAll(cellTypes_, celli)
1537 if (cellTypes_[celli] == HOLE)
1539 isValidDonor[celli] =
false;
1545 bitSet doneAcceptor(interpolationCells_.size());
1554 forAll(interpolationCells_, i)
1556 if (!doneAcceptor[i])
1558 label cellI = interpolationCells_[i];
1559 const point& cc = mesh_.cellCentres()[cellI];
1560 const labelList& slots = cellStencil_[cellI];
1564 if (slots.size() > 1)
1569 else if (slots.size())
1573 const label elemi = slots[sloti];
1578 minMagSqrEqOp<point>()(
samples[elemi], cc);
1592 mapDistributeBase::distribute<point, minMagSqrEqOp<point>, flipOp>
1597 cellInterpolationMap().constructMap(),
1599 cellInterpolationMap().subMap(),
1603 minMagSqrEqOp<point>(),
1606 cellInterpolationMap().comm()
1612 DynamicList<label> donorCells(mesh_.nCells());
1615 if (
samples[cellI] != greatPoint)
1617 donorCells.append(cellI);
1639 label cellI = donorCells[i];
1640 const pointList& donorCentres = donorCellCentres[cellI];
1652 cellInterpolationMap().distribute(donorCellCells);
1653 cellInterpolationMap().distribute(donorWeights);
1654 cellInterpolationMap().distribute(
samples);
1657 forAll(interpolationCells_, i)
1659 if (!doneAcceptor[i])
1661 label cellI = interpolationCells_[i];
1662 const labelList& slots = cellStencil_[cellI];
1664 if (slots.size() > 1)
1669 else if (slots.size() == 1)
1671 const label sloti = slots[0];
1674 if (
samples[sloti] == mesh_.cellCentres()[cellI])
1676 cellStencil_[cellI].transfer(donorCellCells[sloti]);
1677 cellInterpolationWeights_[cellI].transfer
1683 doneAcceptor.set(i);
1691 List<Map<label>> compactMap;
1692 cellInterpolationMap_.reset
1706 Foam::cellCellStencils::inverseDistance::inverseDistance
1715 allowHoleDonors_(
dict.getOrDefault(
"allowHoleDonors", false)),
1716 allowInterpolatedDonors_
1718 dict.getOrDefault(
"allowInterpolatedDonors", true)
1722 interpolationCells_(0),
1723 cellInterpolationMap_(),
1725 cellInterpolationWeights_(0),
1726 cellInterpolationWeight_
1730 "cellInterpolationWeight",
1731 mesh_.facesInstance(),
1750 const word w(
"snGradCorr(cellDisplacement)");
1751 const word d(
"((viscosity*faceDiffusivity)*magSf)");
1776 forAll(volCellTypes, celli)
1800 scalar layerRelax(dict_.getOrDefault(
"layerRelax", 1.0));
1802 scalar tol = dict_.getOrDefault(
"tolerance", 1
e-10);
1803 smallVec_ = mesh_.bounds().span()*tol;
1807 label nZones =
gMax(zoneID)+1;
1811 nCellsPerZone[zoneID[cellI]]++;
1815 const boundBox& allBb = mesh_.bounds();
1833 const fvMesh& subMesh = meshParts[zonei].subMesh();
1866 bbs[procI] = procBb[procI][zoneI];
1878 labelList allPatchTypes(mesh_.nCells(), OTHER);
1882 if (dict_.readIfPresent(
"searchBox", globalPatchBb))
1896 if (dict_.readIfPresent(
"searchBoxDivisions", globalDivs))
1898 patchDivisions = globalDivs;
1904 if (mesh_.nGeometricD() == 1)
1906 nDivs = mesh_.nCells();
1908 else if (mesh_.nGeometricD() == 2)
1910 nDivs = label(
Foam::sqrt(scalar(mesh_.nCells())));
1914 nDivs = label(
Foam::cbrt(scalar(mesh_.nCells())));
1929 forAll(patchParts, zoneI)
1936 patchDivisions[zoneI][0]
1937 *patchDivisions[zoneI][1]
1938 *patchDivisions[zoneI][2]
1943 meshParts[zoneI].subMesh(),
1947 patchDivisions[zoneI],
1950 meshParts[zoneI].cellMap(),
1958 Info<<
type() <<
" : detected " << nZones
1959 <<
" mesh regions" <<
endl;
1961 forAll(nCellsPerZone, zoneI)
1964 <<
" nCells:" << nCellsPerZone[zoneI]
1965 <<
" voxels:" << patchDivisions[zoneI]
1975 labelList allCellTypes(mesh_.nCells(), CALCULATED);
1978 labelList allDonorID(mesh_.nCells(), -1);
1985 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
1987 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
2021 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
2023 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
2054 if ((
debug&2)&& (mesh_.time().outputTime()))
2058 createField(mesh_,
"allCellTypes", allCellTypes)
2064 createField(mesh_,
"allDonorID", allDonorID)
2066 tallDonorID().write();
2070 forAll(allPatchTypes, cellI)
2072 if (allCellTypes[cellI] != HOLE)
2074 switch (allPatchTypes[cellI])
2079 if (allStencil[cellI].size())
2081 allCellTypes[cellI] = INTERPOLATED;
2085 allCellTypes[cellI] = HOLE;
2092 if ((
debug&2) && (mesh_.time().outputTime()))
2096 createField(mesh_,
"allCellTypes_patch", allCellTypes)
2102 createField(mesh_,
"allCellTypes_old", cellTypes_)
2108 findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
2111 if ((
debug&2) && (mesh_.time().outputTime()))
2115 createField(mesh_,
"allCellTypes_hole", allCellTypes)
2119 if ((
debug&2) && (mesh_.time().outputTime()))
2122 forAll(allStencil, celli)
2124 stencilSize[celli] = allStencil[celli].size();
2128 createField(mesh_,
"allStencil_hole", stencilSize)
2134 forAll(allCellTypes, celli)
2136 if (allCellTypes[celli] == HOLE && allStencil[celli].size())
2138 allStencil[celli].clear();
2175 if ((
debug&2) && (mesh_.time().outputTime()))
2179 createField(mesh_,
"allCellTypes_pre_front", allCellTypes)
2188 mapDistribute map(globalCells, compactStencil, compactStencilMap);
2194 label useLayer = dict_.getOrDefault(
"useLayer", -1);
2200 "oversetInterpolation" 2215 dict_.getOrDefault(
"holeLayers", 1),
2219 if ((
debug&2) && (mesh_.time().outputTime()))
2223 createField(mesh_,
"allCellTypes_front", allCellTypes)
2233 label nCalculated = 0;
2235 forAll(cellTypes_, celli)
2237 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
2239 if (allStencil[celli].size() == 0)
2242 allCellTypes[celli] = HOLE;
2243 allStencil[celli].clear();
2247 allCellTypes[celli] = INTERPOLATED;
2255 Pout<<
"Detected " << nCalculated <<
" cells changing from hole" 2256 <<
" to calculated. Changed to interpolated" 2268 cellTypes_.transfer(allCellTypes);
2269 cellStencil_.setSize(mesh_.nCells());
2270 cellInterpolationWeights_.setSize(mesh_.nCells());
2306 label nInterpolatedDonors = 0;
2307 forAll(cellTypes_, celli)
2309 if (cellTypes_[celli] == INTERPOLATED)
2311 const labelList& slots = compactStencil[celli];
2316 compactCellTypes[slots[0]] == HOLE
2319 !allowInterpolatedDonors_
2320 && compactCellTypes[slots[0]] == INTERPOLATED
2324 cellTypes_[celli] = POROUS;
2325 cellStencil_[celli].
clear();
2326 cellInterpolationWeights_[celli].clear();
2327 nInterpolatedDonors++;
2331 cellStencil_[celli].transfer(allStencil[celli]);
2332 cellInterpolationWeights_[celli].setSize(1);
2333 cellInterpolationWeights_[celli][0] = 1.0;
2334 interpolationCells.
append(celli);
2340 cellStencil_[celli].clear();
2341 cellInterpolationWeights_[celli].clear();
2348 <<
"interpolate Donors : " 2349 << nInterpolatedDonors <<
endl;
2353 cellInterpolationMap_.reset
2358 interpolationCells_.
transfer(interpolationCells);
2360 cellInterpolationWeight_.transfer(allWeight);
2365 >(cellInterpolationWeight_.boundaryFieldRef(),
false);
2368 if ((
debug&2) && (mesh_.time().outputTime()))
2371 mesh_.time().
write();
2374 mkDir(mesh_.time().timePath());
2375 OBJstream str(mesh_.time().timePath()/
"injectionStencil.obj");
2376 Pout<<
type() <<
" : dumping injectionStencil to " 2377 << str.name() <<
endl;
2379 cellInterpolationMap().distribute(cc);
2381 forAll(cellStencil_, celli)
2383 const labelList& slots = cellStencil_[celli];
2386 const point& accCc = mesh_.cellCentres()[celli];
2389 const point& donorCc = cc[slots[i]];
2390 str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
2398 createStencil(globalCells, allowHoleDonors_);
2402 if (allowHoleDonors_)
2404 holeExtrapolationStencil(globalCells);
2407 if ((
debug&2) && (mesh_.time().outputTime()))
2411 cellInterpolationWeight_.instance() = mesh_.time().timeName();
2412 cellInterpolationWeight_.write();
2417 forAll(cellStencil_, celli)
2419 const scalarList& wghts = cellInterpolationWeights_[celli];
2422 if (
mag(wghts[i]) >
mag(maxMagWeight[celli]))
2424 maxMagWeight[celli] = wghts[i];
2427 if (
mag(maxMagWeight[celli]) > 1)
2430 Pout<<
"cell:" << celli
2431 <<
" at:" << cc[celli]
2432 <<
" zone:" << zoneID[celli]
2433 <<
" donors:" << cellStencil_[celli]
2434 <<
" weights:" << wghts
2444 createField(mesh_,
"maxMagWeight", maxMagWeight)
2450 >(tfld.
ref().boundaryFieldRef(),
false);
2458 createField(mesh_,
"cellTypes", cellTypes_)
2465 >(tfld.
ref().boundaryFieldRef(),
false);
2471 mkDir(mesh_.time().timePath());
2473 cellInterpolationMap().distribute(cc);
2478 mesh_.time().timePath()
2479 +
"/stencil_" +
name(zonei) +
".obj" 2481 Pout<<
type() <<
" : dumping to " << str.name() <<
endl;
2483 const labelList& subMeshCellMap = meshParts[zonei].cellMap();
2485 forAll(subMeshCellMap, subcelli)
2487 const label celli = subMeshCellMap[subcelli];
2488 const labelList& slots = cellStencil_[celli];
2489 const point& accCc = mesh_.cellCentres()[celli];
2492 const point& donorCc = cc[slots[i]];
2493 str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
2506 forAll(interpolationCells_, i)
2508 label celli = interpolationCells_[i];
2509 const labelList& slots = cellStencil_[celli];
2511 bool hasLocal =
false;
2512 bool hasRemote =
false;
2516 if (slots[sloti] >= mesh_.nCells())
2543 Info<<
"Overset analysis : nCells : " 2546 <<
indent <<
"calculated : " << nCells[CALCULATED] <<
nl 2547 <<
indent <<
"interpolated : " << nCells[INTERPOLATED]
2551 <<
indent <<
"hole : " << nCells[HOLE] <<
nl static point position(const boundBox &bb, const labelVector &nDivs, const label boxI)
Convert index back into coordinate.
List< scalar > scalarList
List of scalar.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Inverse-distance-weighted interpolation stencil.
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const word zeroGradientType
A zeroGradient patch field type.
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.
UIndirectList< label > labelUIndList
UIndirectList of labels.
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.
Template invariant parts for fvPatchField.
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)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static const List< T > & null()
Return a null List.
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
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.
List< labelList > labelListList
List of labelList.
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.
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). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
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.
List< scalarList > scalarListList
List of scalarList.
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 entries in the list.
dimensionedScalar cbrt(const dimensionedScalar &ds)
Reading is optional [identical to LAZY_READ].
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.
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.
Class containing processor-to-processor mapping information.
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< point > pointList
List of point.
List< label > labelList
A List of labels.
List< pointList > pointListList
List of pointList.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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.
Do not request registration (bool: false)
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))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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)