45 void meshToMesh::calcAddressing()
49 Info<<
"meshToMesh::calculateAddressing() : "
50 <<
"calculating mesh-to-mesh cell addressing" <<
endl;
70 Info<<
"meshToMesh::calculateAddressing() : "
71 <<
"Setting up rescue" <<
endl;
74 List<bool> boundaryCell(fromCells.size(),
false);
79 forAll (patchesFrom, patchI)
86 boundaryCell[bCells[faceI]] =
true;
90 treeBoundBox meshBb(fromPoints);
92 scalar typDim = meshBb.avgDim()/(2.0*
cbrt(scalar(fromCells.size())));
94 treeBoundBox shiftedBb
97 meshBb.max() +
vector(typDim, typDim, typDim)
103 Info<<
" bounding box : " << meshBb <<
endl;
104 Info<<
" bounding box (shifted) : " << shiftedBb <<
endl;
105 Info<<
" typical dimension :" << shiftedBb.typDim() <<
endl;
109 octreeDataCell shapes(fromMesh_);
111 octree<octreeDataCell> oc
138 if (cuttingPatches_.
found(toPatch.name()))
144 boundaryAddressing_[
patchi],
145 toPatch.faceCentres(),
153 patchMap_.
found(toPatch.name())
154 && fromMeshPatches_.
found(patchMap_.
find(toPatch.name())())
159 fromMeshPatches_.
find(patchMap_.
find(toPatch.name())())()
162 if (fromPatch.empty())
164 WarningIn(
"meshToMesh::calcAddressing()")
165 <<
"Source patch " << fromPatch.name()
166 <<
" has no faces. Not performing mapping for it."
168 boundaryAddressing_[
patchi] = -1;
172 treeBoundBox wallBb(fromPatch.localPoints());
174 wallBb.avgDim()/(2.0*
sqrt(scalar(fromPatch.size())));
176 treeBoundBox shiftedBb
179 wallBb.max() +
vector(typDim, typDim, typDim)
183 octreeDataFace shapes(fromPatch);
185 octree<octreeDataFace> oc
196 toPatch.faceCentres();
200 treeBoundBox tightest;
206 tightestDist = Foam::GREAT;
208 boundaryAddressing_[
patchi][toi] = oc.findNearest
210 centresToBoundary[toi],
221 Info<<
"meshToMesh::calculateAddressing() : "
222 <<
"finished calculating mesh-to-mesh acell ddressing" <<
endl;
227 void meshToMesh::cellAddresses
231 const fvMesh& fromMesh,
232 const List<bool>& boundaryCell,
233 const octree<octreeDataCell>& oc
245 register label curCell = 0;
248 const vectorField& centresFrom = fromMesh.cellCentres();
257 scalar distSqr =
magSqr(p - centresFrom[curCell]);
266 const labelList& neighbours = cc[curCell];
271 magSqr(p - centresFrom[neighbours[nI]]);
275 if (curDistSqr < (1 - SMALL)*distSqr)
277 curCell = neighbours[nI];
278 distSqr = curDistSqr;
284 cellAddressing_[toI] = -1;
287 if (fromMesh.pointInCell(p, curCell))
289 cellAddressing_[toI] = curCell;
296 if (boundaryCell[curCell])
298 cellAddressing_[toI] = oc.find(p);
306 const labelList& neighbours = cc[curCell];
312 if (fromMesh.pointInCell(p, neighbours[nI]))
314 cellAddressing_[toI] = neighbours[nI];
325 const labelList& neighbours = cc[curCell];
330 const labelList& nn = cc[neighbours[nI]];
336 if (fromMesh.pointInCell(p, nn[nI]))
338 cellAddressing_[toI] = nn[nI];
350 cellAddressing_[toI] = oc.find(p);