36 static const scalar perturbFactor = 1
E-6;
41 static label findCell(
const meshSearch& meshSearcher,
const point& pt)
43 const polyMesh&
mesh = meshSearcher.mesh();
46 label cellI = meshSearcher.
findCell(pt);
57 label faceI = meshSearcher.findNearestBoundaryFace(pt);
61 const point& cc = mesh.cellCentres()[mesh.faceOwner()[faceI]];
62 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
64 return meshSearcher.findCell(perturbPt);
77 const labelList& cellAddressing = meshToMeshInterp.cellAddressing();
87 const fvMesh& meshSource = meshToMeshInterp.fromMesh();
88 const fvMesh& meshTarget = meshToMeshInterp.toMesh();
89 const pointField& targetCc = meshTarget.cellCentres();
107 meshSource.time().timeName(),
111 IOobject* positionsPtr = objects.lookup(
"positions");
115 Info<<
nl <<
" processing cloud " << cloudDirs[cloudI] <<
endl;
118 Cloud<passiveParticle> sourceParcels
124 Info<<
" read " << sourceParcels.size()
125 <<
" parcels from source mesh." <<
endl;
128 Cloud<passiveParticle> targetParcels
132 IDLList<passiveParticle>()
135 label sourceParticleI = 0;
138 DynamicList<label> addParticles(sourceParcels.size());
151 bool foundCell =
false;
154 if (iter().cell() >= 0)
157 sourceToTargets[iter().cell()];
166 autoPtr<passiveParticle> newPtr
171 targetCc[targetCells[i]],
175 passiveParticle& newP = newPtr();
178 label faceI = newP.track(iter().position(), fraction);
180 if (faceI < 0 && newP.cell() >= 0)
184 addParticles.append(sourceParticleI);
185 targetParcels.addParticle(newPtr.ptr());
194 unmappedSource.insert(sourceParticleI);
200 Info<<
" after meshToMesh addressing found "
201 << targetParcels.size()
202 <<
" parcels in target mesh." <<
endl;
208 if (unmappedSource.size())
210 meshSearch targetSearcher(meshTarget,
false);
214 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
216 if (unmappedSource.found(sourceParticleI))
219 findCell(targetSearcher, iter().position());
223 unmappedSource.erase(sourceParticleI);
224 addParticles.append(sourceParticleI);
225 iter().cell()=targetCell;
226 targetParcels.addParticle
228 sourceParcels.remove(&iter())
235 addParticles.shrink();
237 Info<<
" after additional mesh searching found "
238 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
240 if (addParticles.size())
242 IOPosition<passiveParticle>(targetParcels).write();
250 MapLagrangianFields<label>
251 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);
252 MapLagrangianFields<scalar>
253 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);
254 MapLagrangianFields<vector>
255 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);
256 MapLagrangianFields<sphericalTensor>
257 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);
258 MapLagrangianFields<symmTensor>
259 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);
260 MapLagrangianFields<tensor>
261 (cloudDirs[cloudI], objects, meshToMeshInterp, addParticles);