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
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());
163 for (
const passiveParticle&
p : sourceParcels)
165 bool foundCell =
false;
171 sourceToTargets[
p.cell()];
177 for (
const label targetCell : targetCells)
180 autoPtr<passiveParticle> newPtr
187 meshTarget.cells()[targetCell][0],
191 passiveParticle& newP = newPtr();
193 newP.track(
p.position() - newP.position(), 0);
199 addParticles.append(sourceParticleI);
200 targetParcels.addParticle(newPtr.ptr());
209 unmappedSource.insert(sourceParticleI);
215 Info<<
" after meshToMesh0 addressing found " 216 << targetParcels.size()
217 <<
" parcels in target mesh." <<
endl;
223 if (unmappedSource.size())
227 for (passiveParticle&
p : sourceParcels)
229 if (unmappedSource.found(sourceParticleI))
231 const label targetCell =
232 findCell(targetParcels,
p.position());
236 unmappedSource.erase(sourceParticleI);
237 addParticles.append(sourceParticleI);
238 targetParcels.addParticle
247 sourceParcels.remove(&
p);
253 addParticles.shrink();
255 Info<<
" after additional mesh searching found " 256 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
258 if (addParticles.size())
260 IOPosition<passiveParticleCloud>(targetParcels).
write();
268 MapLagrangianFields<label>
269 (cloudDir, objects, meshToMesh0Interp, addParticles);
270 MapLagrangianFields<scalar>
271 (cloudDir, objects, meshToMesh0Interp, addParticles);
272 MapLagrangianFields<vector>
273 (cloudDir, objects, meshToMesh0Interp, addParticles);
274 MapLagrangianFields<sphericalTensor>
275 (cloudDir, objects, meshToMesh0Interp, addParticles);
276 MapLagrangianFields<symmTensor>
277 (cloudDir, objects, meshToMesh0Interp, addParticles);
278 MapLagrangianFields<tensor>
279 (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)
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.