40 void Foam::meshToMesh0::calcAddressing()
45 <<
"Calculating mesh-to-mesh cell addressing" <<
endl;
68 List<bool> boundaryCell(fromCells.size(),
false);
80 boundaryCell[bCells[facei]] =
true;
84 treeBoundBox
meshBb(fromPoints);
86 scalar typDim =
meshBb.avgDim()/(2.0*
cbrt(scalar(fromCells.size())));
88 treeBoundBox shiftedBb
98 Info<<
" bounding box (shifted) : " << shiftedBb <<
endl;
99 Info<<
" typical dimension :" << shiftedBb.typDim() <<
endl;
102 indexedOctree<treeDataCell> oc
113 oc.print(
Pout,
false, 0);
129 if (cuttingPatches_.
found(toPatch.name()))
135 boundaryAddressing_[
patchi],
136 toPatch.faceCentres(),
144 patchMap_.found(toPatch.name())
145 && fromMeshPatches_.
found(patchMap_.find(toPatch.name())())
150 fromMeshPatches_.
find(patchMap_.find(toPatch.name())())()
153 if (fromPatch.empty())
156 <<
"Source patch " << fromPatch.name()
157 <<
" has no faces. Not performing mapping for it." 160 boundaryAddressing_[
patchi] = -1;
164 treeBoundBox wallBb(fromPatch.localPoints());
166 wallBb.avgDim()/(2.0*
sqrt(scalar(fromPatch.size())));
168 treeBoundBox shiftedBb
171 wallBb.max() +
vector(typDim, typDim, typDim)
176 indexedOctree<treeDataFace> oc
178 treeDataFace(
false, fromPatch),
186 toPatch.faceCentres();
190 scalar distSqr =
sqr(wallBb.mag());
194 boundaryAddressing_[
patchi][toi] = oc.findNearest
196 centresToBoundary[toi],
207 <<
"Finished calculating mesh-to-mesh cell addressing" <<
endl;
212 void Foam::meshToMesh0::cellAddresses
216 const fvMesh& fromMesh,
217 const List<bool>& boundaryCell,
218 const indexedOctree<treeDataCell>& oc
233 const vectorField& centresFrom = fromMesh.cellCentres();
239 const vector& p = points[toI];
242 scalar distSqr =
magSqr(p - centresFrom[curCell]);
251 const labelList& neighbours = cc[curCell];
256 magSqr(p - centresFrom[neighbours[nI]]);
260 if (curDistSqr < (1 - SMALL)*distSqr)
262 curCell = neighbours[nI];
263 distSqr = curDistSqr;
269 cellAddressing_[toI] = -1;
272 if (fromMesh.pointInCell(p, curCell))
274 cellAddressing_[toI] = curCell;
281 if (boundaryCell[curCell])
283 cellAddressing_[toI] = oc.findInside(p);
291 const labelList& neighbours = cc[curCell];
297 if (fromMesh.pointInCell(p, neighbours[nI]))
299 cellAddressing_[toI] = neighbours[nI];
310 const labelList& neighbours = cc[curCell];
315 const labelList& nn = cc[neighbours[nI]];
321 if (fromMesh.pointInCell(p, nn[nI]))
323 cellAddressing_[toI] = nn[nI];
335 cellAddressing_[toI] = oc.findInside(p);
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.
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
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
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.