diff --git a/etc/caseDicts/postProcessing/visualization/streamlines.cfg b/etc/caseDicts/postProcessing/visualization/streamlines.cfg index 7d9e242c7..e352ad963 100644 --- a/etc/caseDicts/postProcessing/visualization/streamlines.cfg +++ b/etc/caseDicts/postProcessing/visualization/streamlines.cfg @@ -13,7 +13,7 @@ executeControl writeTime; writeControl writeTime; setFormat vtk; -trackForward true; +direction forward; lifeTime 10000; nSubCycle 5; diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C index 355b8b9c1..4c8753497 100644 --- a/src/functionObjects/field/streamLine/streamLine.C +++ b/src/functionObjects/field/streamLine/streamLine.C @@ -45,6 +45,13 @@ namespace functionObjects { defineTypeNameAndDebug(streamLine, 0); addToRunTimeSelectionTable(functionObject, streamLine, dictionary); + + template<> + const char* NamedEnum::names[] = + {"forward", "backward", "both"}; + + const NamedEnum + streamLine::trackDirectionNames_; } } @@ -257,7 +264,9 @@ void Foam::functionObjects::streamLine::track() vsInterp, vvInterp, UIndex, // index of U in vvInterp - trackForward_, // track in +u direction? + + trackDirection_ == trackDirection::FORWARD, + nSubCycle_, // automatic track control:step through cells in steps? trackLength_, // fixed track length @@ -266,13 +275,24 @@ void Foam::functionObjects::streamLine::track() allVectors_ ); - // Set very large dt. Note: cannot use great since 1/great is small // which is a trigger value for the tracking... const scalar trackTime = Foam::sqrt(great); // Track + if (trackDirection_ == trackDirection::BOTH) + { + initialParticles = particles; + } + particles.move(particles, td, trackTime); + + if (trackDirection_ == trackDirection::BOTH) + { + particles.IDLList::operator=(initialParticles); + td.trackForward_ = !td.trackForward_; + particles.move(particles, td, trackTime); + } } @@ -321,8 +341,19 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict) << exit(FatalIOError); } + // The trackForward entry is maintained here for backwards compatibility + if (!dict.found("direction") && dict.found("trackForward")) + { + trackDirection_ = + dict.lookupType("trackForward") + ? trackDirection::FORWARD + : trackDirection::BACKWARD; + } + else + { + trackDirection_ = trackDirectionNames_[word(dict.lookup("direction"))]; + } - dict.lookup("trackForward") >> trackForward_; dict.lookup("lifeTime") >> lifeTime_; if (lifeTime_ < 1) { diff --git a/src/functionObjects/field/streamLine/streamLine.H b/src/functionObjects/field/streamLine/streamLine.H index b16f4109a..46e27467e 100644 --- a/src/functionObjects/field/streamLine/streamLine.H +++ b/src/functionObjects/field/streamLine/streamLine.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -112,6 +112,7 @@ SourceFiles #include "vectorList.H" #include "writer.H" #include "indirectPrimitivePatch.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -133,6 +134,24 @@ class streamLine : public fvMeshFunctionObject { +public: + + // Public data types + + //- Track direction enumerations + enum trackDirection + { + FORWARD, + BACKWARD, + BOTH + }; + + //- Track direction enumeration names + static const NamedEnum trackDirectionNames_; + + +private: + // Private data //- Input dictionary @@ -147,8 +166,8 @@ class streamLine //- Interpolation scheme to use word interpolationScheme_; - //- Whether to use +u or -u - bool trackForward_; + //- The direction in which to track + trackDirection trackDirection_; //- Maximum lifetime (= number of cells) of particle label lifeTime_; diff --git a/src/functionObjects/field/streamLine/streamLineParticle.H b/src/functionObjects/field/streamLine/streamLineParticle.H index c19a188e4..e9cd83aaa 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.H +++ b/src/functionObjects/field/streamLine/streamLineParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,7 +77,7 @@ public: const label UIndex_; - const bool trackForward_; + bool trackForward_; const label nSubCycle_; diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/controlDict b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/controlDict index ab6ea48d4..10be98ae6 100644 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/controlDict +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/controlDict @@ -54,7 +54,7 @@ functions type streamLine; writeControl writeTime; setFormat vtk; - trackForward true; + direction forward; fields (p U); lifeTime 10000; nSubCycle 5; diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/streamLines b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/streamLines index 1ca71c252..d982472ef 100644 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/streamLines +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/streamLines @@ -16,8 +16,8 @@ streamLines setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight; - // Tracked forwards (+U) or backwards (-U) - trackForward true; + // Track forward (+U) or backward (-U) or both + direction forward; // Names of fields to sample. Should contain above velocity field! fields (p U); diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/streamLines b/tutorials/incompressible/simpleFoam/motorBike/system/streamLines index 4c32d6080..6d8c403e4 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/streamLines +++ b/tutorials/incompressible/simpleFoam/motorBike/system/streamLines @@ -19,8 +19,8 @@ streamLines setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight; - // Tracked forwards (+U) or backwards (-U) - trackForward true; + // Track forward (+U) or backward (-U) or both + direction forward; // Names of fields to sample. Should contain above velocity field! fields (p U k); diff --git a/tutorials/incompressible/simpleFoam/pitzDailyExptInlet/system/controlDict b/tutorials/incompressible/simpleFoam/pitzDailyExptInlet/system/controlDict index d8f946776..07fb09826 100644 --- a/tutorials/incompressible/simpleFoam/pitzDailyExptInlet/system/controlDict +++ b/tutorials/incompressible/simpleFoam/pitzDailyExptInlet/system/controlDict @@ -60,8 +60,8 @@ functions setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight; - // Tracked forwards (+U) or backwards (-U) - trackForward true; + // Track forward (+U) or backward (-U) or both + direction forward; // Names of fields to sample. Should contain above velocity field! fields (p k U);