49 const label startSeedI,
56 for (label i = startSeedI; i < srcCellIDs.
size(); i++)
58 label srcI = srcCellIDs[i];
62 const point& srcCc = srcCcs[srcI];
69 tgtSeedI = hit.
index();
76 <<
"Unable to find nearest target cell" 77 <<
" for source cell " << srcI
78 <<
" with centre " << srcCc
88 Pout<<
"could not find starting seed" <<
endl;
101 const label srcSeedI,
102 const label tgtSeedI,
108 List<DynamicList<label>> srcToTgt(src_.nCells());
109 List<DynamicList<label>> tgtToSrc(tgt_.nCells());
115 label srcCelli = srcSeedI;
116 label tgtCelli = tgtSeedI;
121 findNearestCell(src_, tgt_, srcCelli, tgtCelli);
124 srcToTgt[srcCelli].append(tgtCelli);
125 tgtToSrc[tgtCelli].append(srcCelli);
128 mapFlag[srcCelli] =
false;
131 V_ += srcVc[srcCelli];
143 while (srcCelli >= 0);
151 forAll(tgtToSrc, targetCelli)
153 if (tgtToSrc[targetCelli].size() > 1)
155 const vector& tgtC = tgtCc[targetCelli];
157 DynamicList<label>& srcCells = tgtToSrc[targetCelli];
159 label srcCelli = srcCells[0];
160 scalar d =
magSqr(tgtC - srcCc[srcCelli]);
162 for (label i = 1; i < srcCells.size(); i++)
164 label srcI = srcCells[i];
165 scalar dNew =
magSqr(tgtC - srcCc[srcI]);
174 srcCells.append(srcCelli);
180 forAll(tgtToSrc, tgtCelli)
182 if (tgtToSrc[tgtCelli].empty())
184 label srcCelli = findMappedSrcCell(tgtCelli, tgtToSrc);
186 findNearestCell(tgt_, src_, tgtCelli, srcCelli);
188 tgtToSrc[tgtCelli].append(srcCelli);
193 forAll(srcToTgtCellAddr, i)
195 srcToTgtCellWght[i] =
scalarList(srcToTgt[i].size(), srcVc[i]);
196 srcToTgtCellAddr[i].transfer(srcToTgt[i]);
199 forAll(tgtToSrcCellAddr, i)
201 tgtToSrcCellWght[i] =
scalarList(tgtToSrc[i].size(), tgtVc[i]);
202 tgtToSrcCellAddr[i].transfer(tgtToSrc[i]);
209 const polyMesh& mesh1,
210 const polyMesh& mesh2,
218 const vector& p1 = Cc1[cell1];
220 DynamicList<label> queuedCells(10);
221 DynamicList<label> visitedCells(10);
223 queuedCells.push_back(cell2);
227 while (!queuedCells.empty())
230 const label currCelli = queuedCells.back();
231 queuedCells.pop_back();
232 visitedCells.push_back(currCelli);
234 scalar dTest = p1.distSqr(Cc2[currCelli]);
240 appendNbrCells(cell2, mesh2, visitedCells, queuedCells);
255 const labelList& srcNbr = src_.cellCells()[srcCelli];
260 label celli = srcNbr[i];
268 for (label i = startSeedI; i < srcCellIDs.size(); i++)
270 label celli = srcCellIDs[i];
278 (void)findInitialSeeds
291 const label tgtCelli,
300 while (!queuedCells.
empty())
303 const label tgtI = queuedCells.
back();
308 if (!visitedCells.
found(tgtI))
312 if (tgtToSrc[tgtI].size())
314 return tgtToSrc[tgtI][0];
318 const labelList& nbrCells = tgt_.cellCells()[tgtI];
320 for (
const label nbrCelli : nbrCells)
322 if (!visitedCells.
found(nbrCelli))
383 boolList mapFlag(src_.nCells(),
false);
389 label startSeedI = 0;
List< scalar > scalarList
List of scalar.
virtual void calculateAddressing(labelListList &srcToTgtCellAddr, scalarListList &srcToTgtCellWght, labelListList &tgtToSrcCellAddr, scalarListList &tgtToSrcCellWght, const label srcSeedI, const label tgtSeedI, const labelList &srcCellIDs, boolList &mapFlag, label &startSeedI)
Calculate the mesh-to-mesh addressing and weights.
void size(const label n)
Older name for setAddressableSize.
const polyMesh & src_
Reference to the source mesh.
virtual void setNextNearestCells(label &startSeedI, label &srcCelli, label &tgtCelli, boolList &mapFlag, const labelList &srcCellIDs) const
Set the next cells for the marching front algorithm.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
virtual void calculate(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, pointListList &srcToTgtVec, labelListList &tgtToSrcAddr, scalarListList &tgtToSrcWght, pointListList &tgtToSrcVec)
Calculate addressing and weights and optionally offset vectors.
virtual void findNearestCell(const polyMesh &mesh1, const polyMesh &mesh2, const label cell1, label &cell2) const
Find the nearest cell on mesh2 for cell1 on mesh1.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
List< labelList > labelListList
List of labelList.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
List< scalarList > scalarListList
List of scalarList.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const vectorField & cellCentres() const
const polyMesh & tgt_
Reference to the target mesh.
label index() const noexcept
Return the hit index.
errorManip< error > abort(error &err)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
Base class for mesh-to-mesh calculation methods.
void push_back(const T &val)
Copy append an element to the end of this list.
virtual ~mapNearestMethod()
Destructor.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
bool hit() const noexcept
Is there a hit?
mapNearestMethod(const mapNearestMethod &)=delete
No copy construct.
virtual bool findInitialSeeds(const labelList &srcCellIDs, const boolList &mapFlag, const label startSeedI, label &srcSeedI, label &tgtSeedI) const
Find indices of overlapping cells in src and tgt meshes - returns.
T & back()
Access last element of the list, position [size()-1].
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
virtual label findMappedSrcCell(const label tgtCelli, const List< DynamicList< label >> &tgtToSrc) const
Find a source cell mapped to target cell tgtCelli.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Map nearest mesh-to-mesh interpolation class.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)