41 void Foam::meshToMesh0::calcAddressing()
44 <<
"Calculating mesh-to-mesh cell addressing" <<
endl;
63 List<bool> boundaryCell(fromCells.size(),
false);
68 forAll(patchesFrom, patchi)
71 const labelUList& bCells = patchesFrom[patchi].faceCells();
75 boundaryCell[bCells[facei]] =
true;
79 treeBoundBox
meshBb(fromPoints);
81 scalar typDim =
meshBb.avgDim()/(2.0*
cbrt(scalar(fromCells.size())));
83 treeBoundBox shiftedBb
91 <<
" bounding box : " <<
meshBb <<
nl
92 <<
" bounding box (shifted) : " << shiftedBb <<
nl
93 <<
" typical dimension : " << shiftedBb.typDim() <<
endl;
95 indexedOctree<treeDataCell> oc
106 oc.print(
Pout,
false, 0);
120 const polyPatch& toPatch = toMesh_.
boundaryMesh()[patchi];
122 if (cuttingPatches_.
found(toPatch.name()))
124 boundaryAddressing_[patchi].
setSize(toPatch.size());
128 boundaryAddressing_[patchi],
129 toPatch.faceCentres(),
137 patchMap_.found(toPatch.name())
138 && fromMeshPatches_.
found(patchMap_.find(toPatch.name())())
143 fromMeshPatches_.
find(patchMap_.find(toPatch.name())())()
146 if (fromPatch.empty())
149 <<
"Source patch " << fromPatch.name()
150 <<
" has no faces. Not performing mapping for it."
152 boundaryAddressing_[patchi].
setSize(toPatch.size());
153 boundaryAddressing_[patchi] = -1;
157 treeBoundBox wallBb(fromPatch.localPoints());
159 wallBb.avgDim()/(2.0*
sqrt(scalar(fromPatch.size())));
161 treeBoundBox shiftedBb
164 wallBb.max() +
vector(typDim, typDim, typDim)
169 indexedOctree<treeDataFace> oc
171 treeDataFace(
false, fromPatch),
179 toPatch.faceCentres();
181 boundaryAddressing_[patchi].
setSize(toPatch.size());
183 scalar distSqr =
sqr(wallBb.mag());
187 boundaryAddressing_[patchi][toi] = oc.findNearest
189 centresToBoundary[toi],
198 <<
"Finished calculating mesh-to-mesh cell addressing" <<
endl;
202 void Foam::meshToMesh0::cellAddresses
206 const fvMesh& fromMesh,
207 const List<bool>& boundaryCell,
208 const indexedOctree<treeDataCell>& oc
223 const vectorField& centresFrom = fromMesh.cellCentres();
232 scalar distSqr =
magSqr(
p - centresFrom[curCell]);
241 const labelList& neighbours = cc[curCell];
246 magSqr(
p - centresFrom[neighbours[nI]]);
250 if (curDistSqr < (1 - SMALL)*distSqr)
252 curCell = neighbours[nI];
253 distSqr = curDistSqr;
259 cellAddressing_[toI] = -1;
262 if (fromMesh.pointInCell(
p, curCell))
264 cellAddressing_[toI] = curCell;
271 if (boundaryCell[curCell])
273 cellAddressing_[toI] = oc.findInside(
p);
275 if (cellAddressing_[toI] != -1)
277 curCell = cellAddressing_[toI];
286 const labelList& neighbours = cc[curCell];
292 if (fromMesh.pointInCell(
p, neighbours[nI]))
294 cellAddressing_[toI] = neighbours[nI];
305 const labelList& neighbours = cc[curCell];
310 const labelList& nn = cc[neighbours[nI]];
316 if (fromMesh.pointInCell(
p, nn[nI]))
318 cellAddressing_[toI] = nn[nI];
330 cellAddressing_[toI] = oc.findInside(
p);
332 if (cellAddressing_[toI] != -1)
334 curCell = cellAddressing_[toI];