mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
utilities particleTracks, steadyParticleTracks: Updated and corrected
This commit is contained in:
@ -13,11 +13,6 @@ const word cloudName(propsDict.lookup("cloudName"));
|
|||||||
|
|
||||||
label sampleFrequency(readLabel(propsDict.lookup("sampleFrequency")));
|
label sampleFrequency(readLabel(propsDict.lookup("sampleFrequency")));
|
||||||
|
|
||||||
// outputMode: compositeFile, filePerTrack
|
|
||||||
//word outputmode(propsDict.lookup("outputMode"))
|
|
||||||
|
|
||||||
label maxPositions(readLabel(propsDict.lookup("maxPositions")));
|
label maxPositions(readLabel(propsDict.lookup("maxPositions")));
|
||||||
|
|
||||||
// outputFormat: raw, vtk
|
|
||||||
//word outputFormat(propsDict.lookup("outputFormat"));
|
|
||||||
word setFormat(propsDict.lookupOrDefault<word>("setFormat", "vtk"));
|
word setFormat(propsDict.lookupOrDefault<word>("setFormat", "vtk"));
|
||||||
@ -72,6 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< " Reading particle positions" << endl;
|
Info<< " Reading particle positions" << endl;
|
||||||
passiveParticleCloud myCloud(mesh, cloudName);
|
passiveParticleCloud myCloud(mesh, cloudName);
|
||||||
|
|
||||||
Info<< " Read " << returnReduce(myCloud.size(), sumOp<label>())
|
Info<< " Read " << returnReduce(myCloud.size(), sumOp<label>())
|
||||||
<< " particles" << endl;
|
<< " particles" << endl;
|
||||||
|
|
||||||
@ -82,7 +83,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (origProc >= maxIds.size())
|
if (origProc >= maxIds.size())
|
||||||
{
|
{
|
||||||
// Expand size
|
|
||||||
maxIds.setSize(origProc+1, -1);
|
maxIds.setSize(origProc+1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< nl << endl;
|
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);
|
List<label> startIds(numIds.size(), 0);
|
||||||
for (label i = 0; i < numIds.size()-1; i++)
|
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];
|
label nParticle = startIds.last() + numIds[startIds.size()-1];
|
||||||
|
|
||||||
|
|
||||||
|
// Number of tracks to generate
|
||||||
// number of tracks to generate
|
|
||||||
label nTracks = nParticle/sampleFrequency;
|
label nTracks = nParticle/sampleFrequency;
|
||||||
|
|
||||||
// storage for all particle tracks
|
// Storage for all particle tracks
|
||||||
List<DynamicList<vector>> allTracks(nTracks);
|
List<DynamicList<vector>> allTracks(nTracks);
|
||||||
|
|
||||||
Info<< "\nGenerating " << nTracks << " particle tracks for cloud "
|
Info<< "\nGenerating " << nTracks << " particle tracks for cloud "
|
||||||
@ -143,7 +142,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< " Reading particle positions" << endl;
|
Info<< " Reading particle positions" << endl;
|
||||||
passiveParticleCloud myCloud(mesh, cloudName);
|
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
|
allPositions[Pstream::myProcNo()].setSize
|
||||||
(
|
(
|
||||||
myCloud.size(),
|
myCloud.size(),
|
||||||
@ -161,7 +160,7 @@ int main(int argc, char *argv[])
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect the track data on the master processor
|
// Collect the track data on the master processor
|
||||||
Pstream::gatherList(allPositions);
|
Pstream::gatherList(allPositions);
|
||||||
Pstream::gatherList(allOrigIds);
|
Pstream::gatherList(allOrigIds);
|
||||||
Pstream::gatherList(allOrigProcs);
|
Pstream::gatherList(allOrigProcs);
|
||||||
@ -228,18 +227,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
OFstream vtkTracks
|
OFstream vtkTracks
|
||||||
(
|
(
|
||||||
vtkPath
|
vtkPath/("particleTracks." + vtkFile.ext())
|
||||||
/ "particleTracks." + vtkFile.ext()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "\nWriting particle tracks in " << setFormat
|
Info<< "\nWriting particle tracks in " << setFormat
|
||||||
<< " format to " << vtkTracks.name()
|
<< " format to " << vtkTracks.name()
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
|
|
||||||
scalarFormatterPtr().write
|
scalarFormatterPtr().write
|
||||||
(
|
(
|
||||||
true, // writeTracks
|
true,
|
||||||
tracks,
|
tracks,
|
||||||
wordList(0),
|
wordList(0),
|
||||||
List<List<scalarField>>(0),
|
List<List<scalarField>>(0),
|
||||||
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
PtrList<passiveParticle> particles(0);
|
PtrList<passiveParticle> particles(0);
|
||||||
|
|
||||||
// transfer particles to (more convenient) list
|
// Transfer particles to (more convenient) list
|
||||||
{
|
{
|
||||||
passiveParticleCloud ppc(mesh, cloudName);
|
passiveParticleCloud ppc(mesh, cloudName);
|
||||||
Info<< "\n Read " << returnReduce(ppc.size(), sumOp<label>())
|
Info<< "\n Read " << returnReduce(ppc.size(), sumOp<label>())
|
||||||
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "\n Generating " << nTracks << " tracks" << endl;
|
Info<< "\n Generating " << nTracks << " tracks" << endl;
|
||||||
|
|
||||||
// determine length of each track
|
// Determine length of each track
|
||||||
labelList trackLengths(nTracks, 0);
|
labelList trackLengths(nTracks, 0);
|
||||||
forAll(particleToTrack, i)
|
forAll(particleToTrack, i)
|
||||||
{
|
{
|
||||||
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
|||||||
trackLengths[trackI]++;
|
trackLengths[trackI]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// particle "age" property used to sort the tracks
|
// Particle "age" property used to sort the tracks
|
||||||
List<SortableList<scalar>> agePerTrack(nTracks);
|
List<SortableList<scalar>> agePerTrack(nTracks);
|
||||||
List<List<label>> particleMap(nTracks);
|
List<List<label>> particleMap(nTracks);
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
|
|||||||
particleMap[i].setSize(length);
|
particleMap[i].setSize(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the particle age per track
|
// Store the particle age per track
|
||||||
IOobjectList cloudObjs
|
IOobjectList cloudObjs
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
@ -224,8 +224,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
tmp<scalarField> tage =
|
tmp<scalarField> tage =
|
||||||
readParticleField<scalar>("age", cloudObjs);
|
readParticleField<scalar>("age", cloudObjs);
|
||||||
|
|
||||||
const scalarField& age = tage();
|
const scalarField& age = tage();
|
||||||
|
|
||||||
List<label> trackSamples(nTracks, 0);
|
List<label> trackSamples(nTracks, 0);
|
||||||
|
|
||||||
forAll(particleToTrack, i)
|
forAll(particleToTrack, i)
|
||||||
{
|
{
|
||||||
const label trackI = particleToTrack[i];
|
const label trackI = particleToTrack[i];
|
||||||
@ -263,7 +266,7 @@ int main(int argc, char *argv[])
|
|||||||
labelList& particleIds = particleMap[i];
|
labelList& particleIds = particleMap[i];
|
||||||
|
|
||||||
{
|
{
|
||||||
// update addressing
|
// Update addressing
|
||||||
List<label> sortedIds(ids);
|
List<label> sortedIds(ids);
|
||||||
forAll(sortedIds, j)
|
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;
|
Info<< "\n Writing track lines" << endl;
|
||||||
os << "\nLINES " << nTracks << ' ' << nPoints + nTracks << nl;
|
os << "\nLINES " << nTracks << ' ' << nPoints + nTracks << nl;
|
||||||
@ -27,13 +27,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
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));
|
IOobjectList objects(cloudObjs.lookupClass(IOField<Type>::typeName));
|
||||||
|
|
||||||
@ -42,7 +37,7 @@ bool fieldOk(const IOobjectList& cloudObjs, const word& name)
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type>> readParticleField
|
Foam::tmp<Foam::Field<Type>> Foam::readParticleField
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const IOobjectList cloudObjs
|
const IOobjectList cloudObjs
|
||||||
@ -66,7 +61,7 @@ tmp<Field<Type>> readParticleField
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void readFields
|
void Foam::readFields
|
||||||
(
|
(
|
||||||
PtrList<List<Type>>& values,
|
PtrList<List<Type>>& values,
|
||||||
const List<word>& fieldNames,
|
const List<word>& fieldNames,
|
||||||
@ -95,7 +90,7 @@ void readFields
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeVTK(OFstream& os, const Type& value)
|
void Foam::writeVTK(OFstream& os, const Type& value)
|
||||||
{
|
{
|
||||||
os << value.component(0);
|
os << value.component(0);
|
||||||
for (label i=1; i<pTraits<Type>::nComponents; i++)
|
for (label i=1; i<pTraits<Type>::nComponents; i++)
|
||||||
@ -106,7 +101,7 @@ void writeVTK(OFstream& os, const Type& value)
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeVTKFields
|
void Foam::writeVTKFields
|
||||||
(
|
(
|
||||||
OFstream& os,
|
OFstream& os,
|
||||||
const PtrList<List<Type>>& values,
|
const PtrList<List<Type>>& values,
|
||||||
@ -147,7 +142,7 @@ void writeVTKFields
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void processFields
|
void Foam::processFields
|
||||||
(
|
(
|
||||||
OFstream& os,
|
OFstream& os,
|
||||||
const List<List<label>>& addr,
|
const List<List<label>>& addr,
|
||||||
@ -183,8 +178,5 @@ void processFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -39,6 +39,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
bool fieldOk(const IOobjectList& cloudObjs, const word& name);
|
bool fieldOk(const IOobjectList& cloudObjs, const word& name);
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -64,10 +65,11 @@ namespace Foam
|
|||||||
(
|
(
|
||||||
OFstream& os,
|
OFstream& os,
|
||||||
const PtrList<List<Type>>& values,
|
const PtrList<List<Type>>& values,
|
||||||
const List<SortableList<scalar>>& agePerTrack,
|
const List<List<label>>& addr,
|
||||||
const List<word>& fieldNames
|
const List<word>& fieldNames
|
||||||
);
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
void processFields
|
void processFields
|
||||||
(
|
(
|
||||||
OFstream& os,
|
OFstream& os,
|
||||||
Reference in New Issue
Block a user