utilities particleTracks, steadyParticleTracks: Updated and corrected

This commit is contained in:
Henry Weller
2016-06-27 20:44:11 +01:00
parent 565c96f3d1
commit 9abbe4d31d
12 changed files with 56 additions and 67 deletions

View File

@ -13,11 +13,6 @@ const word cloudName(propsDict.lookup("cloudName"));
label sampleFrequency(readLabel(propsDict.lookup("sampleFrequency")));
// outputMode: compositeFile, filePerTrack
//word outputmode(propsDict.lookup("outputMode"))
label maxPositions(readLabel(propsDict.lookup("maxPositions")));
// outputFormat: raw, vtk
//word outputFormat(propsDict.lookup("outputFormat"));
word setFormat(propsDict.lookupOrDefault<word>("setFormat", "vtk"));

View File

@ -72,6 +72,7 @@ int main(int argc, char *argv[])
Info<< " Reading particle positions" << endl;
passiveParticleCloud myCloud(mesh, cloudName);
Info<< " Read " << returnReduce(myCloud.size(), sumOp<label>())
<< " particles" << endl;
@ -82,7 +83,6 @@ int main(int argc, char *argv[])
if (origProc >= maxIds.size())
{
// Expand size
maxIds.setSize(origProc+1, -1);
}
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
Info<< nl << endl;
// calc starting ids for particles on each processor
// Calculate starting ids for particles on each processor
List<label> startIds(numIds.size(), 0);
for (label i = 0; i < numIds.size()-1; i++)
{
@ -120,11 +120,10 @@ int main(int argc, char *argv[])
label nParticle = startIds.last() + numIds[startIds.size()-1];
// number of tracks to generate
// Number of tracks to generate
label nTracks = nParticle/sampleFrequency;
// storage for all particle tracks
// Storage for all particle tracks
List<DynamicList<vector>> allTracks(nTracks);
Info<< "\nGenerating " << nTracks << " particle tracks for cloud "
@ -143,7 +142,7 @@ int main(int argc, char *argv[])
Info<< " Reading particle positions" << endl;
passiveParticleCloud myCloud(mesh, cloudName);
// collect the track data on all processors that have positions
// Collect the track data on all processors that have positions
allPositions[Pstream::myProcNo()].setSize
(
myCloud.size(),
@ -161,7 +160,7 @@ int main(int argc, char *argv[])
i++;
}
// collect the track data on the master processor
// Collect the track data on the master processor
Pstream::gatherList(allPositions);
Pstream::gatherList(allOrigIds);
Pstream::gatherList(allOrigProcs);
@ -228,18 +227,16 @@ int main(int argc, char *argv[])
OFstream vtkTracks
(
vtkPath
/ "particleTracks." + vtkFile.ext()
vtkPath/("particleTracks." + vtkFile.ext())
);
Info<< "\nWriting particle tracks in " << setFormat
<< " format to " << vtkTracks.name()
<< nl << endl;
scalarFormatterPtr().write
(
true, // writeTracks
true,
tracks,
wordList(0),
List<List<scalarField>>(0),

View File

@ -141,7 +141,7 @@ int main(int argc, char *argv[])
PtrList<passiveParticle> particles(0);
// transfer particles to (more convenient) list
// Transfer particles to (more convenient) list
{
passiveParticleCloud ppc(mesh, cloudName);
Info<< "\n Read " << returnReduce(ppc.size(), sumOp<label>())
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
{
Info<< "\n Generating " << nTracks << " tracks" << endl;
// determine length of each track
// Determine length of each track
labelList trackLengths(nTracks, 0);
forAll(particleToTrack, i)
{
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
trackLengths[trackI]++;
}
// particle "age" property used to sort the tracks
// Particle "age" property used to sort the tracks
List<SortableList<scalar>> agePerTrack(nTracks);
List<List<label>> particleMap(nTracks);
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
particleMap[i].setSize(length);
}
// store the particle age per track
// Store the particle age per track
IOobjectList cloudObjs
(
mesh,
@ -224,8 +224,11 @@ int main(int argc, char *argv[])
{
tmp<scalarField> tage =
readParticleField<scalar>("age", cloudObjs);
const scalarField& age = tage();
List<label> trackSamples(nTracks, 0);
forAll(particleToTrack, i)
{
const label trackI = particleToTrack[i];
@ -263,7 +266,7 @@ int main(int argc, char *argv[])
labelList& particleIds = particleMap[i];
{
// update addressing
// Update addressing
List<label> sortedIds(ids);
forAll(sortedIds, j)
{
@ -283,7 +286,7 @@ int main(int argc, char *argv[])
}
// write track (line) connectivity to file
// Write track (line) connectivity to file
Info<< "\n Writing track lines" << endl;
os << "\nLINES " << nTracks << ' ' << nPoints + nTracks << nl;

View File

@ -27,13 +27,8 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
bool fieldOk(const IOobjectList& cloudObjs, const word& name)
bool Foam::fieldOk(const IOobjectList& cloudObjs, const word& name)
{
IOobjectList objects(cloudObjs.lookupClass(IOField<Type>::typeName));
@ -42,7 +37,7 @@ bool fieldOk(const IOobjectList& cloudObjs, const word& name)
template<class Type>
tmp<Field<Type>> readParticleField
Foam::tmp<Foam::Field<Type>> Foam::readParticleField
(
const word& name,
const IOobjectList cloudObjs
@ -66,7 +61,7 @@ tmp<Field<Type>> readParticleField
template<class Type>
void readFields
void Foam::readFields
(
PtrList<List<Type>>& values,
const List<word>& fieldNames,
@ -95,7 +90,7 @@ void readFields
template<class Type>
void writeVTK(OFstream& os, const Type& value)
void Foam::writeVTK(OFstream& os, const Type& value)
{
os << value.component(0);
for (label i=1; i<pTraits<Type>::nComponents; i++)
@ -106,7 +101,7 @@ void writeVTK(OFstream& os, const Type& value)
template<class Type>
void writeVTKFields
void Foam::writeVTKFields
(
OFstream& os,
const PtrList<List<Type>>& values,
@ -147,7 +142,7 @@ void writeVTKFields
template<class Type>
void processFields
void Foam::processFields
(
OFstream& os,
const List<List<label>>& addr,
@ -183,8 +178,5 @@ void processFields
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
bool fieldOk(const IOobjectList& cloudObjs, const word& name);
template<class Type>
@ -64,10 +65,11 @@ namespace Foam
(
OFstream& os,
const PtrList<List<Type>>& values,
const List<SortableList<scalar>>& agePerTrack,
const List<List<label>>& addr,
const List<word>& fieldNames
);
template<class Type>
void processFields
(
OFstream& os,