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);
88 const polyMesh& meshSource = interp.srcRegion();
89 const polyMesh& meshTarget = interp.tgtRegion();
90 const labelListList& sourceToTarget = interp.srcToTgtCellAddr();
107 meshSource.time().timeName(),
111 IOobject* positionsPtr =
objects.lookup(word(
"positions"));
115 Info<<
nl <<
" processing cloud " << cloudDirs[cloudI] <<
endl;
118 passiveParticleCloud sourceParcels
124 Info<<
" read " << sourceParcels.size()
125 <<
" parcels from source mesh." <<
endl;
128 passiveParticleCloud targetParcels
132 IDLList<passiveParticle>()
135 passiveParticle::trackingData td(targetParcels);
137 label sourceParticleI = 0;
140 DynamicList<label> addParticles(sourceParcels.size());
153 bool foundCell =
false;
156 if (iter().cell() >= 0)
159 sourceToTarget[iter().cell()];
168 autoPtr<passiveParticle> newPtr
175 meshTarget.cells()[targetCells[i]][0],
179 passiveParticle& newP = newPtr();
181 newP.track(iter().position() - newP.position(), 0);
187 addParticles.append(sourceParticleI);
188 targetParcels.addParticle(newPtr.ptr());
197 unmappedSource.insert(sourceParticleI);
203 Info<<
" after meshToMesh addressing found " 204 << targetParcels.size()
205 <<
" parcels in target mesh." <<
endl;
211 if (unmappedSource.size())
215 forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
217 if (unmappedSource.found(sourceParticleI))
220 findCell(targetParcels, iter().position());
224 unmappedSource.erase(sourceParticleI);
225 addParticles.append(sourceParticleI);
226 targetParcels.addParticle
235 sourceParcels.remove(&iter());
241 addParticles.shrink();
243 Info<<
" after additional mesh searching found " 244 << targetParcels.size() <<
" parcels in target mesh." <<
endl;
246 if (addParticles.size())
248 IOPosition<passiveParticleCloud>(targetParcels).
write();
256 MapLagrangianFields<label>
263 MapLagrangianFields<scalar>
270 MapLagrangianFields<vector>
277 MapLagrangianFields<sphericalTensor>
284 MapLagrangianFields<symmTensor>
291 MapLagrangianFields<tensor>
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.
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.