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);
80 treeBoundBox shiftedBb(
meshBb);
82 scalar typDim =
meshBb.avgDim()/(2.0*
cbrt(scalar(fromCells.size())));
83 shiftedBb.max() += vector::uniform(typDim);
87 <<
" bounding box : " <<
meshBb <<
nl 88 <<
" bounding box (shifted) : " << shiftedBb <<
nl 89 <<
" typical dimension : " << shiftedBb.avgDim() <<
endl;
91 indexedOctree<treeDataCell> cellTree
102 cellTree.print(
Pout,
false, 0);
116 const polyPatch& toPatch = toMesh_.
boundaryMesh()[patchi];
118 if (cuttingPatches_.
found(toPatch.name()))
120 boundaryAddressing_[patchi].
setSize(toPatch.size());
124 boundaryAddressing_[patchi],
125 toPatch.faceCentres(),
133 patchMap_.found(toPatch.name())
134 && fromMeshPatches_.
found(patchMap_.find(toPatch.name())())
139 fromMeshPatches_.
find(patchMap_.find(toPatch.name())())()
142 if (fromPatch.empty())
145 <<
"Source patch " << fromPatch.name()
146 <<
" has no faces. Not performing mapping for it." 148 boundaryAddressing_[patchi].
setSize(toPatch.size());
149 boundaryAddressing_[patchi] = -1;
153 treeBoundBox wallBb(fromPatch.localPoints());
154 treeBoundBox shiftedBb(wallBb);
157 wallBb.avgDim()/(2.0*
sqrt(scalar(fromPatch.size())));
159 shiftedBb.max() += vector::uniform(typDim);
163 indexedOctree<treeDataFace> faceTree
165 treeDataFace(fromPatch),
173 toPatch.faceCentres();
175 boundaryAddressing_[patchi].
setSize(toPatch.size());
177 scalar distSqr = wallBb.magSqr();
181 boundaryAddressing_[patchi][toi] = faceTree.findNearest
183 centresToBoundary[toi],
192 <<
"Finished calculating mesh-to-mesh cell addressing" <<
endl;
196 void Foam::meshToMesh0::cellAddresses
200 const fvMesh& fromMesh,
201 const List<bool>& boundaryCell,
202 const indexedOctree<treeDataCell>& cellTree
217 const vectorField& centresFrom = fromMesh.cellCentres();
226 scalar distSqr =
p.distSqr(centresFrom[curCell]);
235 const labelList& neighbours = cc[curCell];
239 scalar curDistSqr =
p.distSqr(centresFrom[neighbours[nI]]);
243 if (curDistSqr < (1 - SMALL)*distSqr)
245 curCell = neighbours[nI];
246 distSqr = curDistSqr;
252 cellAddressing_[toI] = -1;
255 if (fromMesh.pointInCell(
p, curCell))
257 cellAddressing_[toI] = curCell;
264 if (boundaryCell[curCell])
266 cellAddressing_[toI] = cellTree.findInside(
p);
268 if (cellAddressing_[toI] != -1)
270 curCell = cellAddressing_[toI];
279 const labelList& neighbours = cc[curCell];
285 if (fromMesh.pointInCell(
p, neighbours[nI]))
287 cellAddressing_[toI] = neighbours[nI];
298 const labelList& neighbours = cc[curCell];
303 const labelList& nn = cc[neighbours[nI]];
309 if (fromMesh.pointInCell(
p, nn[nI]))
311 cellAddressing_[toI] = nn[nI];
323 cellAddressing_[toI] = cellTree.findInside(
p);
325 if (cellAddressing_[toI] != -1)
327 curCell = cellAddressing_[toI];
List< cell > cellList
List of cell.
bool found(const Key &key) const
Same as contains()
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
List< labelList > labelListList
List of labelList.
UList< label > labelUList
A UList of labels.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
#define DebugInFunction
Report an information message using Foam::Info.
dimensionedScalar cbrt(const dimensionedScalar &ds)
const vectorField & cellCentres() const
#define DebugInfo
Report an information message using Foam::Info.
int debug
Static debugging option.
#define WarningInFunction
Report a warning using Foam::Warning.
SubField< vector > subField
Declare type of subField.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))