26 #include "MapLagrangianFields.H"
35 static const scalar perturbFactor = 1
e-6;
40 static label findCell(
const Cloud<passiveParticle>& cloud,
const point& pt)
46 const polyMesh&
mesh = cloud.pMesh();
59 meshSearch meshSearcher
65 label faceI = meshSearcher.findNearestBoundaryFace(pt);
71 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
88 const polyMesh& meshSource = interp.srcRegion();
89 const polyMesh& meshTarget = interp.tgtRegion();
90 const labelListList& sourceToTarget = interp.srcToTgtCellAddr();
92 const pointField& targetCc = meshTarget.cellCentres();
109 meshSource.time().timeName(),
113 bool foundPositions =
114 returnReduce(objects.found(
"positions"), orOp<bool>());;
118 Info<<
nl <<
" processing cloud " << cloudDirs[cloudI] <<
endl;
121 passiveParticleCloud sourceParcels
127 Info<<
" read " << sourceParcels.size()
128 <<
" parcels from source mesh." <<
endl;
131 passiveParticleCloud targetParcels
135 IDLList<passiveParticle>()
138 particle::TrackingData<passiveParticleCloud> td(targetParcels);
140 label sourceParticleI = 0;
143 DynamicList<label> addParticles(sourceParcels.size());
156 bool foundCell =
false;
159 if (iter().cell() >= 0)
162 sourceToTarget[iter().cell()];
171 autoPtr<passiveParticle> newPtr
176 targetCc[targetCells[i]],
180 passiveParticle& newP = newPtr();
182 label faceI = newP.track(iter().position(), td);
184 if (faceI < 0 && newP.cell() >= 0)
188 addParticles.append(sourceParticleI);
189 targetParcels.addParticle(newPtr.ptr());
198 unmappedSource.insert(sourceParticleI);
204 Info<<
" after meshToMesh addressing found "
205 << targetParcels.size()
206 <<
" parcels in target mesh." <<
endl;
212 if (unmappedSource.size())
216 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
218 if (unmappedSource.found(sourceParticleI))
221 findCell(targetParcels, iter().position());
225 unmappedSource.erase(sourceParticleI);
226 addParticles.append(sourceParticleI);
227 iter().cell() = targetCell;
228 targetParcels.addParticle
230 sourceParcels.remove(&iter())
237 addParticles.shrink();
239 Info<<
" after additional mesh searching found "
240 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
242 if (addParticles.size())
244 IOPosition<passiveParticleCloud>(targetParcels).
write();
252 MapLagrangianFields<label>
259 MapLagrangianFields<scalar>
266 MapLagrangianFields<vector>
273 MapLagrangianFields<sphericalTensor>
280 MapLagrangianFields<symmTensor>
287 MapLagrangianFields<tensor>