29 #include "MapLagrangianFields.H"
38 static const scalar perturbFactor = 1
e-6;
43 static label findCell(
const Cloud<passiveParticle>& cloud,
const point& pt)
49 const polyMesh&
mesh = cloud.pMesh();
62 meshSearch meshSearcher
68 label facei = meshSearcher.findNearestBoundaryFace(pt);
74 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
92 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
102 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
103 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
114 for (
const fileName& cloudDir : cloudDirs)
120 meshSource.time().timeName(),
124 if (objects.found(
"coordinates") || objects.found(
"positions"))
127 Info<<
nl <<
" processing cloud " << cloudDir <<
endl;
130 passiveParticleCloud sourceParcels
136 Info<<
" read " << sourceParcels.size()
137 <<
" parcels from source mesh." <<
endl;
140 passiveParticleCloud targetParcels
144 IDLList<passiveParticle>()
147 passiveParticle::trackingData td(targetParcels);
149 label sourceParticleI = 0;
152 DynamicList<label> addParticles(sourceParcels.size());
163 for (
const passiveParticle&
p : sourceParcels)
165 bool foundCell =
false;
171 sourceToTargets[
p.cell()];
177 for (
const label targetCell : targetCells)
180 autoPtr<passiveParticle> newPtr
187 meshTarget.cells()[targetCell][0],
191 passiveParticle& newP = newPtr();
193 newP.track(
p.position() - newP.position(), 0);
199 addParticles.append(sourceParticleI);
200 targetParcels.addParticle(newPtr.ptr());
209 unmappedSource.insert(sourceParticleI);
215 Info<<
" after meshToMesh0 addressing found "
216 << targetParcels.size()
217 <<
" parcels in target mesh." <<
endl;
223 if (unmappedSource.size())
227 for (passiveParticle&
p : sourceParcels)
229 if (unmappedSource.found(sourceParticleI))
231 const label targetCell =
232 findCell(targetParcels,
p.position());
236 unmappedSource.erase(sourceParticleI);
237 addParticles.append(sourceParticleI);
238 targetParcels.addParticle
247 sourceParcels.remove(&
p);
253 addParticles.shrink();
255 Info<<
" after additional mesh searching found "
256 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
258 if (addParticles.size())
260 IOPosition<passiveParticleCloud>(targetParcels).
write();
268 MapLagrangianFields<label>
269 (cloudDir, objects, meshToMesh0Interp, addParticles);
270 MapLagrangianFields<scalar>
271 (cloudDir, objects, meshToMesh0Interp, addParticles);
272 MapLagrangianFields<vector>
273 (cloudDir, objects, meshToMesh0Interp, addParticles);
274 MapLagrangianFields<sphericalTensor>
275 (cloudDir, objects, meshToMesh0Interp, addParticles);
276 MapLagrangianFields<symmTensor>
277 (cloudDir, objects, meshToMesh0Interp, addParticles);
278 MapLagrangianFields<tensor>
279 (cloudDir, objects, meshToMesh0Interp, addParticles);