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();
101 const pointField& targetCc = meshTarget.cellCentres();
119 meshSource.time().timeName(),
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 particle::TrackingData<passiveParticleCloud> 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
185 targetCc[targetCells[i]],
189 passiveParticle& newP = newPtr();
191 label facei = newP.track(iter().position(), td);
193 if (facei < 0 && newP.cell() >= 0)
197 addParticles.append(sourceParticleI);
198 targetParcels.addParticle(newPtr.ptr());
207 unmappedSource.insert(sourceParticleI);
213 Info<<
" after meshToMesh0 addressing found " 214 << targetParcels.size()
215 <<
" parcels in target mesh." <<
endl;
221 if (unmappedSource.size())
225 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
227 if (unmappedSource.found(sourceParticleI))
230 findCell(targetParcels, iter().position());
234 unmappedSource.erase(sourceParticleI);
235 addParticles.append(sourceParticleI);
236 iter().cell() = targetCell;
237 targetParcels.addParticle
239 sourceParcels.remove(&iter())
246 addParticles.shrink();
248 Info<<
" after additional mesh searching found " 249 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
251 if (addParticles.size())
253 IOPosition<passiveParticleCloud>(targetParcels).
write();
261 MapLagrangianFields<label>
262 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
263 MapLagrangianFields<scalar>
264 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
265 MapLagrangianFields<vector>
266 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
267 MapLagrangianFields<sphericalTensor>
268 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
269 MapLagrangianFields<symmTensor>
270 (cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles);
271 MapLagrangianFields<tensor>
272 (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.
const double e
Elementary charge.
#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.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
vectorField pointField
pointField is a vectorField.
List< label > labelList
A List of labels.
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.
List< fileName > fileNameList
A List of fileNames.
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true)
Read a directory and return the entries as a string list.