29 #include "MapLagrangianFields.H" 38 static const scalar perturbFactor = 1
e-6;
43 static label findCell(
const Cloud<passiveParticle>& cloud,
const point& pt)
49 const polyMesh&
mesh = cloud.pMesh();
62 meshSearch meshSearcher
68 label facei = meshSearcher.findNearestBoundaryFace(pt);
74 const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
92 const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
102 const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
103 const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
114 for (
const fileName& cloudDir : cloudDirs)
120 meshSource.time().timeName(),
124 if (objects.found(
"coordinates") || objects.found(
"positions"))
127 Info<<
nl <<
" processing cloud " << cloudDir <<
endl;
130 passiveParticleCloud sourceParcels
137 Info<<
" read " << sourceParcels.size()
138 <<
" parcels from source mesh." <<
endl;
141 passiveParticleCloud targetParcels
148 passiveParticle::trackingData td(targetParcels);
150 label sourceParticleI = 0;
153 DynamicList<label> addParticles(sourceParcels.size());
164 for (
const passiveParticle&
p : sourceParcels)
166 bool foundCell =
false;
172 sourceToTargets[
p.cell()];
178 for (
const label targetCell : targetCells)
181 autoPtr<passiveParticle> newPtr
188 meshTarget.cells()[targetCell][0],
192 passiveParticle& newP = newPtr();
194 newP.track(
p.position() - newP.position(), 0);
200 addParticles.append(sourceParticleI);
201 targetParcels.addParticle(newPtr.ptr());
210 unmappedSource.insert(sourceParticleI);
216 Info<<
" after meshToMesh0 addressing found " 217 << targetParcels.size()
218 <<
" parcels in target mesh." <<
endl;
224 if (unmappedSource.size())
228 for (passiveParticle&
p : sourceParcels)
230 if (unmappedSource.found(sourceParticleI))
232 const label targetCell =
233 findCell(targetParcels,
p.position());
237 unmappedSource.erase(sourceParticleI);
238 addParticles.append(sourceParticleI);
239 targetParcels.addParticle
248 sourceParcels.remove(&
p);
254 addParticles.shrink();
256 Info<<
" after additional mesh searching found " 257 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
259 if (addParticles.size())
261 IOPosition<passiveParticleCloud>(targetParcels).
write();
269 MapLagrangianFields<label>
270 (cloudDir, objects, meshToMesh0Interp, addParticles);
271 MapLagrangianFields<scalar>
272 (cloudDir, objects, meshToMesh0Interp, addParticles);
273 MapLagrangianFields<vector>
274 (cloudDir, objects, meshToMesh0Interp, addParticles);
275 MapLagrangianFields<sphericalTensor>
276 (cloudDir, objects, meshToMesh0Interp, addParticles);
277 MapLagrangianFields<symmTensor>
278 (cloudDir, objects, meshToMesh0Interp, addParticles);
279 MapLagrangianFields<tensor>
280 (cloudDir, objects, meshToMesh0Interp, addParticles);
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
List< labelList > labelListList
List of labelList.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
const dimensionedScalar e
Elementary charge.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
virtual const labelList & faceOwner() const
Return face owner.
const vectorField & cellCentres() const
void mapLagrangian(const meshToMesh0 &meshToMesh0Interp)
Maps lagrangian positions and fields.
vector point
Point is a vector.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
List< label > labelList
A List of labels.
List< fileName > fileNameList
List of fileName.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
static const word prefix
The prefix to local: lagrangian.