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;
89 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
99 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
100 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
101 const pointField& targetCc = meshTarget.cellCentres();
119 meshSource.time().timeName(),
123 IOobject* positionsPtr = objects.lookup(
"positions");
127 Info<<
nl <<
" processing cloud " << cloudDirs[cloudI] <<
endl;
130 passiveParticleCloud sourceParcels
136 Info<<
" read " << sourceParcels.size()
137 <<
" parcels from source mesh." <<
endl;
140 passiveParticleCloud targetParcels
144 IDLList<passiveParticle>()
147 particle::TrackingData<passiveParticleCloud> td(targetParcels);
149 label sourceParticleI = 0;
152 DynamicList<label> addParticles(sourceParcels.size());
165 bool foundCell =
false;
168 if (iter().cell() >= 0)
171 sourceToTargets[iter().cell()];
180 autoPtr<passiveParticle> newPtr
185 targetCc[targetCells[i]],
189 passiveParticle& newP = newPtr();
191 label faceI = newP.track(iter().position(), td);
193 if (faceI < 0 && newP.cell() >= 0)
197 addParticles.append(sourceParticleI);
198 targetParcels.addParticle(newPtr.ptr());
207 unmappedSource.insert(sourceParticleI);
213 Info<<
" after meshToMesh0 addressing found "
214 << targetParcels.size()
215 <<
" parcels in target mesh." <<
endl;
221 if (unmappedSource.size())
225 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
227 if (unmappedSource.found(sourceParticleI))
230 findCell(targetParcels, iter().position());
234 unmappedSource.erase(sourceParticleI);
235 addParticles.append(sourceParticleI);
236 iter().cell() = targetCell;
237 targetParcels.addParticle
239 sourceParcels.remove(&iter())
246 addParticles.shrink();
248 Info<<
" after additional mesh searching found "
249 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
251 if (addParticles.size())
253 IOPosition<passiveParticleCloud>(targetParcels).
write();
261 MapLagrangianFields<label>
262 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
263 MapLagrangianFields<scalar>
264 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
265 MapLagrangianFields<vector>
266 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
267 MapLagrangianFields<sphericalTensor>
268 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
269 MapLagrangianFields<symmTensor>
270 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
271 MapLagrangianFields<tensor>
272 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);