32 void Foam::meshToMesh0::calcAddressing()
37 <<
"Calculating mesh-to-mesh cell addressing" <<
endl;
60 List<bool> boundaryCell(fromCells.size(),
false);
72 boundaryCell[bCells[facei]] =
true;
76 treeBoundBox
meshBb(fromPoints);
78 scalar typDim =
meshBb.avgDim()/(2.0*
cbrt(scalar(fromCells.size())));
80 treeBoundBox shiftedBb
89 <<
" bounding box : " <<
meshBb <<
nl 90 <<
" bounding box (shifted) : " << shiftedBb <<
nl 91 <<
" typical dimension :" << shiftedBb.typDim() <<
endl;
94 indexedOctree<treeDataCell> oc
105 oc.print(
Pout,
false, 0);
121 if (cuttingPatches_.
found(toPatch.name()))
127 boundaryAddressing_[
patchi],
128 toPatch.faceCentres(),
136 patchMap_.found(toPatch.name())
137 && fromMeshPatches_.
found(patchMap_.find(toPatch.name())())
142 fromMeshPatches_.
find(patchMap_.find(toPatch.name())())()
145 if (fromPatch.empty())
148 <<
"Source patch " << fromPatch.name()
149 <<
" has no faces. Not performing mapping for it." 152 boundaryAddressing_[
patchi] = -1;
156 treeBoundBox wallBb(fromPatch.localPoints());
158 wallBb.avgDim()/(2.0*
sqrt(scalar(fromPatch.size())));
160 treeBoundBox shiftedBb
163 wallBb.max() +
vector(typDim, typDim, typDim)
168 indexedOctree<treeDataFace> oc
170 treeDataFace(
false, fromPatch),
178 toPatch.faceCentres();
182 const scalar distSqr =
sqr(wallBb.mag());
186 boundaryAddressing_[
patchi][toi] = oc.findNearest
188 centresToBoundary[toi],
199 <<
"Finished calculating mesh-to-mesh cell addressing" <<
endl;
204 void Foam::meshToMesh0::cellAddresses
208 const fvMesh& fromMesh,
209 const List<bool>& boundaryCell,
210 const indexedOctree<treeDataCell>& oc
225 const vectorField& centresFrom = fromMesh.cellCentres();
231 const vector& p = points[toi];
234 scalar distSqr =
magSqr(p - centresFrom[curCell]);
243 const labelList& neighbours = cc[curCell];
247 const scalar curDistSqr =
248 magSqr(p - centresFrom[neighbours[ni]]);
252 if (curDistSqr < (1 - small)*distSqr)
254 curCell = neighbours[ni];
255 distSqr = curDistSqr;
261 cellAddressing_[toi] = -1;
264 if (fromMesh.pointInCell(p, curCell))
266 cellAddressing_[toi] = curCell;
273 if (boundaryCell[curCell])
275 cellAddressing_[toi] = oc.findInside(p);
276 if (cellAddressing_[toi] != -1)
278 curCell = cellAddressing_[toi];
287 const labelList& neighbours = cc[curCell];
293 if (fromMesh.pointInCell(p, neighbours[ni]))
295 cellAddressing_[toi] = neighbours[ni];
306 const labelList& neighbours = cc[curCell];
311 const labelList& nn = cc[neighbours[ni]];
317 if (fromMesh.pointInCell(p, nn[ni]))
319 cellAddressing_[toi] = nn[ni];
331 cellAddressing_[toi] = oc.findInside(p);
333 if (cellAddressing_[toi] != -1)
335 curCell = cellAddressing_[toi];
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
Vector< scalar > vector
A scalar version of the templated Vector.
UList< label > labelUList
virtual const pointField & points() const
Return raw points.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
vectorField pointField
pointField is a vectorField.
bool found(const Key &) const
Return true if hashedEntry is found in table.
dimensionedScalar cbrt(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
const vectorField & cellCentres() const
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(1e-3))
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
SubField< vector > subField
Declare type of subField.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< cell > cellList
list of cells
#define InfoInFunction
Report an information message using Foam::Info.