36 static const scalar perturbFactor = 1
e-6;
41 static label findCell(
const Cloud<passiveParticle>& cloud,
const point& pt)
47 const polyMesh& mesh = cloud.pMesh();
49 mesh.findCellFacePt(pt, celli, tetFacei, tetPtI);
60 meshSearch meshSearcher
66 label facei = meshSearcher.findNearestBoundaryFace(pt);
70 const point& cc = mesh.cellCentres()[mesh.faceOwner()[facei]];
72 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
74 mesh.findCellFacePt(perturbPt, celli, tetFacei, tetPtI);
90 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
100 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
101 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
119 meshSource.time().name(),
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 passiveParticle::trackingData 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
187 meshTarget.cells()[targetCells[i]][0],
191 passiveParticle& newP = newPtr();
196 iter().position(meshSource)
197 - newP.position(meshTarget),
205 addParticles.append(sourceParticleI);
206 targetParcels.addParticle(newPtr.ptr());
215 unmappedSource.insert(sourceParticleI);
221 Info<<
" after meshToMesh0 addressing found "
222 << targetParcels.size()
223 <<
" parcels in target mesh." <<
endl;
229 if (unmappedSource.size())
233 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
235 if (unmappedSource.found(sourceParticleI))
241 iter().position(meshSource)
246 label nLocateBoundaryHits = 0;
247 autoPtr<passiveParticle> pPtr
252 iter().position(meshSource),
258 if (nLocateBoundaryHits == 0)
260 unmappedSource.erase(sourceParticleI);
261 addParticles.append(sourceParticleI);
262 targetParcels.addParticle(pPtr.ptr());
263 sourceParcels.remove(&iter());
270 addParticles.shrink();
272 Info<<
" after additional mesh searching found "
273 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
275 if (addParticles.size())
277 IOPosition<passiveParticleCloud>(targetParcels).
write();
285 MapLagrangianFields<label>
286 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
287 MapLagrangianFields<scalar>
288 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
289 MapLagrangianFields<vector>
290 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
291 MapLagrangianFields<sphericalTensor>
292 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
293 MapLagrangianFields<symmTensor>
294 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
295 MapLagrangianFields<tensor>
296 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
Gets the indices of (source)particles that have been appended to the target cloud and maps the lagran...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
virtual Ostream & write(const char)=0
Write character.
static const word prefix
The prefix to local: lagrangian.
List< fileName > fileNameList
A List of fileNames.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
vector point
Point is a vector.
List< labelList > labelListList
A List of labelList.
void mapLagrangian(const meshToMesh0 &meshToMesh0Interp)
Maps lagrangian positions and fields.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.