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-------------------------------------------------------------------------------
11License
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
36namespace Foam
37{
38namespace functionObjects
39{
42}
43}
44
45
46// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47
49{
50 IDLList<streamLineParticle> initialParticles;
52 (
53 mesh_,
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],
71 )
72 );
73
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,
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
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// ************************************************************************* //
#define Log
Definition: PDRblock.C:35
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:147
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:104
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
Template class for intrusive linked lists.
Definition: ILList.H:69
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base-class for Time/database function objects.
const fvMesh & mesh_
Reference to the fvMesh.
word cloudName_
Optional specified name of particles.
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
label lifeTime_
Maximum lifetime (= number of cells) of particle.
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.
List< DynamicList< scalarList > > allScalars_
Per scalarField, per track, the sampled values.
trackDirType trackDir_
Whether to use +u or -u or both.
dictionary dict_
Input dictionary.
List< DynamicList< vectorList > > allVectors_
Per vectorField, per track, the sampled values.
DynamicList< List< point > > allTracks_
All tracks. Per track the points it passed through.
Generates streamline data by sampling a set of user-specified fields along a particle track,...
Definition: streamLine.H:274
virtual void track()
Do the actual tracking to fill the track data.
Definition: streamLine.C:48
virtual bool read(const dictionary &)
Read settings.
Definition: streamLine.C:155
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:86
const labelList & cells() const noexcept
Definition: sampledSet.H:334
A Cloud of streamLine particles.
Particle class that samples fields as it passes through. Used in streamline calculation.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
engineTime & runTime
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensionedScalar sqrt(const dimensionedScalar &ds)
IOerror FatalIOError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333