41void 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;
202void 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];
SubField< vector > subField
Declare type of subField.
bool found(const Key &key) const
Return true if hashed entry is found in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
void setSize(const label n)
Alias for resize()
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
const vectorField & cellCentres() const
const cellList & cells() const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
List< cell > cellList
A List of cells.
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
List< labelList > labelListList
A List of labelList.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensionedScalar cbrt(const dimensionedScalar &ds)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.