Loading...
Searching...
No Matches
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-2022 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"
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace functionObjects
39{
42}
43}
44
45
46// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47
49{
50 // Start with empty cloud
52
53 const sampledSet& seedPoints = sampledSetPoints();
54
55 forAll(seedPoints, seedi)
56 {
57 particles.addParticle
58 (
59 new streamLineParticle
60 (
61 mesh_,
62 seedPoints[seedi],
63 seedPoints.cells()[seedi],
66 )
67 );
68
70 {
71 // Add additional particle for the forward bit of the track
72 particles.addParticle
73 (
74 new streamLineParticle
75 (
76 mesh_,
77 seedPoints[seedi],
78 seedPoints.cells()[seedi],
79 true,
81 )
82 );
83 }
84 }
85
86 label nSeeds = returnReduce(particles.size(), sumOp<label>());
87
88 Log << " seeded " << nSeeds << " particles" << endl;
89
90 // Field interpolators
91 // Velocity interpolator
92 PtrList<interpolation<scalar>> vsInterp;
93 PtrList<interpolation<vector>> vvInterp;
94
95 refPtr<interpolation<vector>> UInterp
96 (
97 initInterpolations(nSeeds, vsInterp, vvInterp)
98 );
99
100 // Additional particle info
101 streamLineParticle::trackingData td
102 (
103 particles,
104 vsInterp,
105 vvInterp,
106 UInterp.cref(), // velocity interpolator (possibly within vvInterp)
107 nSubCycle_, // automatic track control:step through cells in steps?
108 trackLength_, // fixed track length
109
113 );
114
115
116 // Set very large dt. Note: cannot use GREAT since 1/GREAT is SMALL
117 // which is a trigger value for the tracking...
118 const scalar trackTime = Foam::sqrt(GREAT);
119
120 // Track
121 particles.move(particles, td, trackTime);
122}
123
124
125// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
126
128(
129 const word& name,
130 const Time& runTime,
131 const dictionary& dict
132)
133:
136 read(dict_);
137}
138
139
140// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141
143{
145 {
146 bool subCycling = dict.found("nSubCycle");
147 bool fixedLength = dict.found("trackLength");
148
149 if (subCycling && fixedLength)
150 {
152 << "Cannot both specify automatic time stepping (through '"
153 << "nSubCycle' specification) and fixed track length (through '"
154 << "trackLength')"
155 << exit(FatalIOError);
156 }
157
158 nSubCycle_ = 1;
159 if (dict.readIfPresent("nSubCycle", nSubCycle_))
160 {
161 trackLength_ = VGREAT;
162 nSubCycle_ = max(nSubCycle_, 1);
163
164 Info<< " automatic track length specified through"
165 << " number of sub cycles : " << nSubCycle_ << nl
166 << endl;
167 }
168 }
169 return true;
170}
171
172
173// ************************************************************************* //
#define Log
Definition PDRblock.C:28
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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.
streamLineBase(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
label lifeTime_
Maximum lifetime (= number of cells) of particle.
List< DynamicList< scalarList > > allScalars_
Per scalarField, per track, the sampled values.
trackDirType trackDir_
Whether to use +U, -U or both.
dictionary dict_
Input dictionary.
virtual bool read(const dictionary &dict)
Read the field average data.
refPtr< interpolation< vector > > initInterpolations(const label nSeeds, PtrList< interpolation< scalar > > &vsInterp, PtrList< interpolation< vector > > &vvInterp)
Initialise interpolators and track storage.
@ BIDIRECTIONAL
Use "bidirectional" tracking.
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:258
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition streamLine.C:135
streamLine(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition streamLine.C:121
virtual void track()
Do the actual tracking to fill the track data.
Definition streamLine.C:41
const cellList & cells() const
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition refPtrI.H:216
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition sampledSet.H:82
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:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
engineTime & runTime
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
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:40
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
messageStream Info
Information stream (stdout output on master, null elsewhere).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensionedScalar sqrt(const dimensionedScalar &ds)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299