41void Foam::meshToMesh0::calcAddressing()
44 <<
"Calculating mesh-to-mesh cell addressing" <<
endl;
47 const cellList& fromCells = fromMesh_.cells();
48 const pointField& fromPoints = fromMesh_.points();
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())));
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);
108 toMesh_.cellCentres(),
114 forAll(toMesh_.boundaryMesh(), patchi)
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())())
137 const polyPatch& fromPatch = fromMesh_.boundaryMesh()
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())));
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;
196void Foam::meshToMesh0::cellAddresses
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];
SubField< vector > subField
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Mesh data needed to do the Finite Volume discretisation.
Non-pointer based hierarchical recursive searching.
#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< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
List< cell > cellList
List of cell.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensionedScalar cbrt(const dimensionedScalar &ds)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.