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();
48 mesh.findCellFacePt(pt, celli, tetFacei, tetPtI);
59 meshSearch meshSearcher
65 label facei = meshSearcher.findNearestBoundaryFace(pt);
69 const point& cc = mesh.cellCentres()[mesh.faceOwner()[facei]];
71 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
73 mesh.findCellFacePt(perturbPt, celli, tetFacei, tetPtI);
89 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
99 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
100 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
118 meshSource.time().timeName(),
122 IOobject* positionsPtr =
objects.lookup(
"positions");
126 Info<<
nl <<
" processing cloud " << cloudDirs[cloudI] <<
endl;
129 passiveParticleCloud sourceParcels
135 Info<<
" read " << sourceParcels.size()
136 <<
" parcels from source mesh." <<
endl;
139 passiveParticleCloud targetParcels
143 IDLList<passiveParticle>()
146 passiveParticle::trackingData td(targetParcels);
148 label sourceParticleI = 0;
151 DynamicList<label> addParticles(sourceParcels.size());
164 bool foundCell =
false;
167 if (iter().cell() >= 0)
170 sourceToTargets[iter().cell()];
179 autoPtr<passiveParticle> newPtr
186 meshTarget.cells()[targetCells[i]][0],
190 passiveParticle& newP = newPtr();
192 newP.track(iter().position() - newP.position(), 0);
198 addParticles.append(sourceParticleI);
199 targetParcels.addParticle(newPtr.ptr());
208 unmappedSource.insert(sourceParticleI);
214 Info<<
" after meshToMesh0 addressing found " 215 << targetParcels.size()
216 <<
" parcels in target mesh." <<
endl;
222 if (unmappedSource.size())
226 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
228 if (unmappedSource.found(sourceParticleI))
231 findCell(targetParcels, iter().position());
235 unmappedSource.erase(sourceParticleI);
236 addParticles.append(sourceParticleI);
237 targetParcels.addParticle
246 sourceParcels.remove(&iter());
252 addParticles.shrink();
254 Info<<
" after additional mesh searching found " 255 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
257 if (addParticles.size())
259 IOPosition<passiveParticleCloud>(targetParcels).
write();
267 MapLagrangianFields<label>
268 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
269 MapLagrangianFields<scalar>
270 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
271 MapLagrangianFields<vector>
272 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
273 MapLagrangianFields<sphericalTensor>
274 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
275 MapLagrangianFields<symmTensor>
276 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
277 MapLagrangianFields<tensor>
278 (cloudDirs[cloudI],
objects, meshToMesh0Interp, addParticles);
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< label > labelList
A List of labels.
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.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
static const word prefix
The prefix to local: lagrangian.
void mapLagrangian(const meshToMesh0 &meshToMesh0Interp)
Maps lagrangian positions and fields.
vector point
Point is a vector.
const doubleScalar e
Elementary charge.
List< fileName > fileNameList
A List of fileNames.