streamLine: Added option to track in both directions

Streamlines can now be tracked in both directions from the set of
initial locations. The keyword controlling this behaviour is
"direction", which can be set to "forward", "backward" or "both".

This new keyword superseeds the "trackForward" entry, which has been
retained for backwards compatibility.
This commit is contained in:
Will Bainbridge
2018-04-06 16:46:12 +01:00
parent 7ea428af52
commit 8dcfc9e9f8
8 changed files with 66 additions and 16 deletions

View File

@ -45,6 +45,13 @@ namespace functionObjects
{
defineTypeNameAndDebug(streamLine, 0);
addToRunTimeSelectionTable(functionObject, streamLine, dictionary);
template<>
const char* NamedEnum<streamLine::trackDirection, 3>::names[] =
{"forward", "backward", "both"};
const NamedEnum<streamLine::trackDirection, 3>
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<streamLineParticle>::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<bool>("trackForward")
? trackDirection::FORWARD
: trackDirection::BACKWARD;
}
else
{
trackDirection_ = trackDirectionNames_[word(dict.lookup("direction"))];
}
dict.lookup("trackForward") >> trackForward_;
dict.lookup("lifeTime") >> lifeTime_;
if (lifeTime_ < 1)
{

View File

@ -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<trackDirection, 3> 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_;

View File

@ -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_;