36 static const scalar perturbFactor = 1
e-6;
41 const meshSearch& searchEngine,
42 const meshBoundarySearch& boundarySearchEngine,
43 const lagrangian::Cloud<passiveParticle>& cloud,
47 const polyMesh&
mesh = cloud.pMesh();
50 const label celli = searchEngine.findCell(pt);
59 const label facei = boundarySearchEngine.findNearestBoundaryFace(pt);
63 const point perturbPt = (1 - perturbFactor)*pt + perturbFactor*cc;
64 return searchEngine.findCell(perturbPt);
77 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
87 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
88 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
90 const meshSearch& targetInternalSearchEngine =
92 const meshBoundarySearch& targetBoundarySearchEngine =
110 meshSource.time().name(),
114 IOobject* positionsPtr =
objects.lookup(
"positions");
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 passiveParticle::trackingData td(targetParcels);
140 label sourceParticleI = 0;
143 DynamicList<label> addParticles(sourceParcels.size());
156 lagrangian::Cloud<passiveParticle>,
161 bool foundCell =
false;
164 if (iter().
cell() >= 0)
167 sourceToTargets[iter().cell()];
176 autoPtr<passiveParticle> newPtr
183 meshTarget.cells()[targetCells[i]][0],
187 passiveParticle& newP = newPtr();
193 - newP.position(meshTarget),
201 addParticles.append(sourceParticleI);
202 targetParcels.addParticle(newPtr.ptr());
211 unmappedSource.insert(sourceParticleI);
217 Info<<
" after meshToMesh0 addressing found "
218 << targetParcels.size()
219 <<
" parcels in target mesh." <<
endl;
225 if (unmappedSource.size())
231 lagrangian::Cloud<passiveParticle>,
236 if (unmappedSource.found(sourceParticleI))
241 targetInternalSearchEngine,
242 targetBoundarySearchEngine,
249 label nLocateBoundaryHits = 0;
250 autoPtr<passiveParticle> pPtr
254 targetInternalSearchEngine,
261 if (nLocateBoundaryHits == 0)
263 unmappedSource.erase(sourceParticleI);
264 addParticles.append(sourceParticleI);
265 targetParcels.addParticle(pPtr.ptr());
266 sourceParcels.remove(&iter());
273 addParticles.shrink();
275 Info<<
" after additional mesh searching found "
276 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
278 if (addParticles.size())
280 IOPosition<passiveParticleCloud>(targetParcels).
write();
288 MapLagrangianFields<label>
289 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
290 MapLagrangianFields<scalar>
291 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
292 MapLagrangianFields<vector>
293 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
294 MapLagrangianFields<sphericalTensor>
295 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
296 MapLagrangianFields<symmTensor>
297 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
298 MapLagrangianFields<tensor>
299 (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.
static meshBoundarySearch & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
virtual Ostream & write(const token &)
Write token.
static const word prefix
The prefix to local: lagrangian.
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
virtual const labelList & faceOwner() const
Return face owner.
const vectorField & cellCentres() const
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
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.