BUG: corrected steadyParticleTracks utility

This commit is contained in:
andy
2013-08-29 17:24:30 +01:00
parent 73b7f6e617
commit 668cd823b5
3 changed files with 73 additions and 39 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -184,6 +184,7 @@ int main(int argc, char *argv[])
}
}
if (nTracks == 0)
{
Info<< "\n No track data" << endl;
@ -202,11 +203,13 @@ int main(int argc, char *argv[])
// particle "age" property used to sort the tracks
List<SortableList<scalar> > agePerTrack(nTracks);
List<List<label> > particleMap(nTracks);
forAll(trackLengths, i)
{
const label length = trackLengths[i];
agePerTrack[i].setSize(length);
particleMap[i].setSize(length);
}
// store the particle age per track
@ -228,6 +231,7 @@ int main(int argc, char *argv[])
const label trackI = particleToTrack[i];
const label sampleI = trackSamples[trackI];
agePerTrack[trackI][sampleI] = age[i];
particleMap[trackI][sampleI] = i;
trackSamples[trackI]++;
}
tage.clear();
@ -251,21 +255,30 @@ int main(int argc, char *argv[])
Info<< "\n Writing points" << endl;
{
label offset = 0;
forAll(agePerTrack, i)
{
agePerTrack[i].sort();
const labelList& ids = agePerTrack[i].indices();
labelList& particleIds = particleMap[i];
{
// update addressing
List<label> sortedIds(ids);
forAll(sortedIds, j)
{
sortedIds[j] = particleIds[ids[j]];
}
particleIds = sortedIds;
}
forAll(ids, j)
{
const label localId = offset + ids[j];
const label localId = particleIds[j];
const vector& pos = particles[localId].position();
os << pos.x() << ' ' << pos.y() << ' ' << pos.z()
<< nl;
}
offset += trackLengths[i];
}
}
@ -278,13 +291,14 @@ int main(int argc, char *argv[])
// Write ids of track points to file
{
label globalPtI = 0;
forAll(agePerTrack, i)
forAll(particleMap, i)
{
os << agePerTrack[i].size() << nl;
os << particleMap[i].size() << nl;
forAll(agePerTrack[i], j)
forAll(particleMap[i], j)
{
os << ' ' << globalPtI++;
if (((j + 1) % 10 == 0) && (j != 0))
{
os << nl;
@ -303,14 +317,14 @@ int main(int argc, char *argv[])
Info<< "\n Processing fields" << nl << endl;
processFields<label>(os, agePerTrack, userFields, cloudObjs);
processFields<scalar>(os, agePerTrack, userFields, cloudObjs);
processFields<vector>(os, agePerTrack, userFields, cloudObjs);
processFields<label>(os, particleMap, userFields, cloudObjs);
processFields<scalar>(os, particleMap, userFields, cloudObjs);
processFields<vector>(os, particleMap, userFields, cloudObjs);
processFields<sphericalTensor>
(os, agePerTrack, userFields, cloudObjs);
(os, particleMap, userFields, cloudObjs);
processFields<symmTensor>
(os, agePerTrack, userFields, cloudObjs);
processFields<tensor>(os, agePerTrack, userFields, cloudObjs);
(os, particleMap, userFields, cloudObjs);
processFields<tensor>(os, particleMap, userFields, cloudObjs);
}
}