streamLine.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "streamLine.H"
31 #include "sampledSet.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace functionObjects
39 {
40  defineTypeNameAndDebug(streamLine, 0);
41  addToRunTimeSelectionTable(functionObject, streamLine, dictionary);
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
49 {
50  IDLList<streamLineParticle> initialParticles;
51  streamLineParticleCloud particles
52  (
53  mesh_,
54  cloudName_,
55  initialParticles
56  );
57 
58  const sampledSet& seedPoints = sampledSetPoints();
59 
60  forAll(seedPoints, seedi)
61  {
62  particles.addParticle
63  (
65  (
66  mesh_,
67  seedPoints[seedi],
68  seedPoints.cells()[seedi],
69  (trackDir_ == trackDirType::FORWARD),
70  lifeTime_
71  )
72  );
73 
74  if (trackDir_ == trackDirType::BIDIRECTIONAL)
75  {
76  // Add additional particle for the forward bit of the track
77  particles.addParticle
78  (
80  (
81  mesh_,
82  seedPoints[seedi],
83  seedPoints.cells()[seedi],
84  true,
85  lifeTime_
86  )
87  );
88  }
89  }
90 
91  label nSeeds = returnReduce(particles.size(), sumOp<label>());
92 
93  Log << " seeded " << nSeeds << " particles" << endl;
94 
95  // Read or lookup fields
100 
101  label UIndex = -1;
102 
104  (
105  nSeeds,
106  UIndex,
107  vsFlds,
108  vsInterp,
109  vvFlds,
110  vvInterp
111  );
112 
113  // Additional particle info
115  (
116  particles,
117  vsInterp,
118  vvInterp,
119  UIndex, // index of U in vvInterp
120  nSubCycle_, // automatic track control:step through cells in steps?
121  trackLength_, // fixed track length
122 
123  allTracks_,
124  allScalars_,
126  );
127 
128 
129  // Set very large dt. Note: cannot use GREAT since 1/GREAT is SMALL
130  // which is a trigger value for the tracking...
131  const scalar trackTime = Foam::sqrt(GREAT);
132 
133  // Track
134  particles.move(particles, td, trackTime);
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
139 
141 (
142  const word& name,
143  const Time& runTime,
144  const dictionary& dict
145 )
146 :
148 {
149  read(dict_);
150 }
151 
152 
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154 
156 {
158  {
159  bool subCycling = dict.found("nSubCycle");
160  bool fixedLength = dict.found("trackLength");
161 
162  if (subCycling && fixedLength)
163  {
165  << "Cannot both specify automatic time stepping (through '"
166  << "nSubCycle' specification) and fixed track length (through '"
167  << "trackLength')"
168  << exit(FatalIOError);
169  }
170 
171  nSubCycle_ = 1;
172  if (dict.readIfPresent("nSubCycle", nSubCycle_))
173  {
174  trackLength_ = VGREAT;
175  nSubCycle_ = max(nSubCycle_, 1);
176 
177 
178  Info<< " automatic track length specified through"
179  << " number of sub cycles : " << nSubCycle_ << nl
180  << endl;
181  }
182  }
183  return true;
184 }
185 
186 
187 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:83
Foam::Cloud::addParticle
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:104
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::streamLineBase::trackLength_
scalar trackLength_
Track length.
Definition: streamLineBase.H:112
Foam::functionObjects::streamLineBase::allScalars_
List< DynamicList< scalarList > > allScalars_
Per scalarField, per track, the sampled values.
Definition: streamLineBase.H:145
Log
#define Log
Definition: PDRblock.C:35
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::streamLineParticle::trackingData
Definition: streamLineParticle.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
streamLineParticleCloud.H
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::streamLineParticleCloud
A Cloud of streamLine particles.
Definition: streamLineParticleCloud.H:52
Foam::streamLineParticle
Particle class that samples fields as it passes through. Used in streamline calculation.
Definition: streamLineParticle.H:61
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::functionObjects::streamLineBase::sampledSetPoints
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
Definition: streamLineBase.C:78
Foam::sampledSet::cells
const labelList & cells() const
Definition: sampledSet.H:296
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::functionObjects::streamLineBase::read
virtual bool read(const dictionary &)
Read the field average data.
Definition: streamLineBase.C:875
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
sampledSet.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
streamLine.H
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::functionObjects::streamLineBase::initInterpolations
void initInterpolations(const label nSeeds, label &UIndex, PtrList< volScalarField > &vsFlds, PtrList< interpolation< scalar >> &vsInterp, PtrList< volVectorField > &vvFlds, PtrList< interpolation< vector >> &vvInterp)
Initialise fields, interpolators and track storage.
Definition: streamLineBase.C:142
Foam::functionObjects::streamLine::track
virtual void track()
Do the actual tracking to fill the track data.
Definition: streamLine.C:48
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::functionObjects::streamLineBase
Definition: streamLineBase.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::ILList
Template class for intrusive linked lists.
Definition: ILList.H:52
Foam::Cloud::move
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:147
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::streamLineBase::allVectors_
List< DynamicList< vectorList > > allVectors_
Per vectorField, per track, the sampled values.
Definition: streamLineBase.H:148
Foam::functionObjects::streamLine::streamLine
streamLine(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: streamLine.C:141
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::functionObjects::streamLineBase::trackDir_
trackDirType trackDir_
Whether to use +u or -u or both.
Definition: streamLineBase.H:106
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::functionObjects::streamLineBase::cloudName_
word cloudName_
Optional specified name of particles.
Definition: streamLineBase.H:118
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::functionObjects::streamLineBase::lifeTime_
label lifeTime_
Maximum lifetime (= number of cells) of particle.
Definition: streamLineBase.H:109
Foam::functionObjects::fvMeshFunctionObject::mesh_
const fvMesh & mesh_
Reference to the fvMesh.
Definition: fvMeshFunctionObject.H:73
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::functionObjects::streamLine::read
virtual bool read(const dictionary &)
Read settings.
Definition: streamLine.C:155
Foam::functionObjects::streamLineBase::allTracks_
DynamicList< List< point > > allTracks_
All tracks. Per track the points it passed through.
Definition: streamLineBase.H:142