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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "streamLine.H"
27 #include "fvMesh.H"
29 #include "sampledSet.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 defineTypeNameAndDebug(streamLine, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
42 {
43  const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
44 
45  IDLList<streamLineParticle> initialParticles;
46  streamLineParticleCloud particles
47  (
48  mesh,
49  cloudName_,
50  initialParticles
51  );
52 
53  const sampledSet& seedPoints = sampledSetPtr_();
54 
55  forAll(seedPoints, i)
56  {
57  particles.addParticle
58  (
60  (
61  mesh,
62  seedPoints[i],
63  seedPoints.cells()[i],
64  lifeTime_ // lifetime
65  )
66  );
67  }
68 
69  label nSeeds = returnReduce(particles.size(), sumOp<label>());
70 
71  if (log_) Info<< " seeded " << nSeeds << " particles" << endl;
72 
73  // Read or lookup fields
78  label UIndex = -1;
79 
81  (
82  nSeeds,
83  UIndex,
84  vsFlds,
85  vsInterp,
86  vvFlds,
87  vvInterp
88  );
89 
90  // Additional particle info
92  (
93  particles,
94  vsInterp,
95  vvInterp,
96  UIndex, // index of U in vvInterp
97  trackForward_, // track in +u direction?
98  nSubCycle_, // automatic track control:step through cells in steps?
99  trackLength_, // fixed track length
100 
101  allTracks_,
102  allScalars_,
104  );
105 
106 
107  // Set very large dt. Note: cannot use GREAT since 1/GREAT is SMALL
108  // which is a trigger value for the tracking...
109  const scalar trackTime = Foam::sqrt(GREAT);
110 
111  // Track
112  particles.move(td, trackTime);
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 (
120  const word& name,
121  const objectRegistry& obr,
122  const dictionary& dict,
123  const bool loadFromFiles
124 )
125 :
126  streamLineBase(name, obr, dict, loadFromFiles)
127 {
128  // Check if the available mesh is an fvMesh otherise deactivate
129  if (setActive<fvMesh>())
130  {
131  read(dict_);
132  }
133 }
134 
135 
136 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
137 
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
145 {
146  if (active_)
147  {
149 
150  bool subCycling = dict.found("nSubCycle");
151  bool fixedLength = dict.found("trackLength");
152 
153  if (subCycling && fixedLength)
154  {
156  << "Cannot both specify automatic time stepping (through '"
157  << "nSubCycle' specification) and fixed track length (through '"
158  << "trackLength')"
159  << exit(FatalIOError);
160  }
161 
162  nSubCycle_ = 1;
163  if (dict.readIfPresent("nSubCycle", nSubCycle_))
164  {
165  trackLength_ = VGREAT;
166  if (nSubCycle_ < 1)
167  {
168  nSubCycle_ = 1;
169  }
170 
171  if (log_) Info
172  << " automatic track length specified through"
173  << " number of sub cycles : " << nSubCycle_ << nl
174  << endl;
175  }
176  }
177 }
178 
179 
180 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
Foam::Cloud::addParticle
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:162
Foam::streamLineBase::obr_
const objectRegistry & obr_
Database this class is registered to.
Definition: streamLineBase.H:72
Foam::streamLineBase::allTracks_
DynamicList< List< point > > allTracks_
All tracks. Per track the points it passed through.
Definition: streamLineBase.H:135
Foam::streamLineParticle::trackingData
Class used to pass tracking data to the trackToFace function.
Definition: streamLineParticle.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
streamLineParticleCloud.H
Foam::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:98
Foam::streamLineBase::allVectors_
List< DynamicList< vectorList > > allVectors_
Per vectorField, per track, the sampled values.
Definition: streamLineBase.H:141
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::streamLineParticleCloud
A Cloud of streamLine particles.
Definition: streamLineParticleCloud.H:49
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::streamLineParticle
Particle class that samples fields as it passes through. Used in streamline calculation.
Definition: streamLineParticle.H:54
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::streamLine::nSubCycle_
label nSubCycle_
Number of subcycling steps.
Definition: streamLine.H:203
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::streamLine::streamLine
streamLine(const streamLine &)
Disallow default bitwise copy construct.
Foam::sampledSet::cells
const labelList & cells() const
Definition: sampledSet.H:263
Foam::streamLineBase::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: streamLineBase.H:78
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::streamLineBase::sampledSetPtr_
autoPtr< sampledSet > sampledSetPtr_
Seed set engine.
Definition: streamLineBase.H:120
Foam::streamLineBase::read
virtual void read(const dictionary &)
Read the field average data.
Definition: streamLineBase.C:560
Foam::streamLine::read
virtual void read(const dictionary &)
Read settings.
Definition: streamLine.C:144
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
sampledSet.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::IDLList
Intrusive doubly-linked list.
Definition: IDLList.H:47
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
streamLine.H
Foam::Cloud::size
label size() const
Definition: Cloud.H:175
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::streamLine::~streamLine
virtual ~streamLine()
Destructor.
Definition: streamLine.C:138
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::streamLineBase::cloudName_
word cloudName_
Optional specified name of particles.
Definition: streamLineBase.H:102
Foam::sumOp
Definition: ops.H:162
Foam::streamLineBase::lifeTime_
label lifeTime_
Maximum lifetime (= number of cells) of particle.
Definition: streamLineBase.H:93
Foam::streamLineBase
Definition: streamLineBase.H:62
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::streamLineBase::trackLength_
scalar trackLength_
Track length.
Definition: streamLineBase.H:96
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::streamLineBase::allScalars_
List< DynamicList< scalarList > > allScalars_
Per scalarField, per track, the sampled values.
Definition: streamLineBase.H:138
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::streamLineBase::trackForward_
bool trackForward_
Whether to use +u or -u.
Definition: streamLineBase.H:90
Foam::streamLine::track
virtual void track()
Do the actual tracking to fill the track data.
Definition: streamLine.C:41
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::Cloud::move
void move(TrackData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:187