streamlines.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
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 Class
25  Foam::functionObjects::streamlines
26 
27 Description
28  Generates streamline data by sampling a set of user-specified fields along
29  a particle track, transported by a user-specified velocity field.
30 
31  Example of function object specification:
32  \verbatim
33  streamlines1
34  {
35  type streamlines;
36  libs ("libfieldFunctionObjects.so");
37 
38  writeControl writeTime;
39 
40  setFormat vtk;
41  U U;
42  direction both;
43 
44  fields
45  (
46  U
47  p
48  );
49 
50  lifeTime 10000;
51  trackLength 1e-3;
52  nSubCycle 5;
53 
54  seedSampleSet
55  {
56  type lineUniform;
57  axis xyz;
58  start (-0.0205 0.0001 0.00001);
59  end (-0.0205 0.0005 0.00001);
60  nPoints 100;
61  }
62  }
63  \endverbatim
64 
65 Usage
66  \table
67  Property | Description | Required | Default value
68  type | Type name: streamlines | yes |
69  setFormat | Output data type | yes |
70  U | Tracking velocity field name | no | U
71  direction | Direction in which to track | yes |
72  outside | Track outside of periodic meshes | no | no
73  fields | Fields to sample | yes |
74  writeTime | Write the flow time along the streamlines | no | no
75  lifetime | Maximum number of particle tracking steps | yes |
76  trackLength | Tracking segment length | no |
77  nSubCycle | Number of tracking steps per cell | no |
78  cloudName | Cloud name to use | no |
79  seedSampleSet | Seeding method (see below) | yes |
80  \endtable
81 
82  Where the \c seedSampleSet \c type is typically one of
83  \plaintable
84  lineUniform | uniform particle seeding along a line
85  sphereRandom | random particle seeding within a sphere
86  boundaryRandom | random particle seeding on a number of patches
87  points | a specified set of locations
88  \endplaintable
89 
90  Note:
91  When specifying the track resolution, the \c trackLength OR \c nSubCycle
92  option should be used
93 
94 See also
95  Foam::functionObject
96  Foam::functionObjects::timeControl
97  Foam::sampledSet
98 
99 SourceFiles
100  streamlines.C
101 
102 \*---------------------------------------------------------------------------*/
103 
104 #ifndef functionObjects_streamlines_H
105 #define functionObjects_streamlines_H
106 
107 #include "fvMeshFunctionObject.H"
108 #include "volFieldsFwd.H"
109 #include "DynamicList.H"
110 #include "DynamicField.H"
111 #include "scalarList.H"
112 #include "vectorList.H"
113 #include "setWriter.H"
114 #include "indirectPrimitivePatch.H"
115 #include "NamedEnum.H"
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 namespace Foam
120 {
121 
122 // Forward declaration of classes
123 class meshSearch;
124 class sampledSet;
125 
126 namespace functionObjects
127 {
128 
129 /*---------------------------------------------------------------------------*\
130  Class streamlines Declaration
131 \*---------------------------------------------------------------------------*/
132 
133 class streamlines
134 :
135  public fvMeshFunctionObject
136 {
137 public:
138 
139  // Public data types
140 
141  //- Track direction enumerations
142  enum class trackDirection
143  {
144  forward,
145  backward,
146  both
147  };
148 
149  //- Track direction enumeration names
150  static const NamedEnum<trackDirection, 3> trackDirectionNames_;
151 
152 
153 private:
154 
155  // Private Data
156 
157  //- Input dictionary
158  dictionary dict_;
159 
160  //- List of fields to sample
161  wordList fields_;
162 
163  //- Field to transport particle with
164  word UName_;
165 
166  //- Interpolation scheme to use
167  word interpolationScheme_;
168 
169  //- The direction in which to track
170  trackDirection trackDirection_;
171 
172  //- Whether or not to track outside of the mesh in periodic geometries
173  Switch trackOutside_;
174 
175  //- Maximum lifetime (= number of cells) of particle
176  label lifeTime_;
177 
178  //- Number of subcycling steps
179  label nSubCycle_;
180 
181  //- Track length
182  scalar trackLength_;
183 
184  //- Optional specified name of particles
185  word cloudName_;
186 
187  //- Write the streamlines ages
188  Switch writeAge_;
189 
190 
191  // Demand driven
192 
193  //- Mesh searching engine
194  autoPtr<meshSearch> meshSearchPtr_;
195 
196  //- Seed set engine
197  autoPtr<sampledSet> sampledSetPtr_;
198 
199  //- File writer
200  autoPtr<setWriter> formatterPtr_;
201 
202 
203 public:
204 
205  //- Runtime type information
206  TypeName("streamlines");
207 
208 
209  // Constructors
210 
211  //- Construct from Time and dictionary
213  (
214  const word& name,
215  const Time& runTime,
216  const dictionary& dict
217  );
218 
219  //- Disallow default bitwise copy construction
220  streamlines(const streamlines&) = delete;
221 
222 
223  //- Destructor
224  virtual ~streamlines();
225 
226 
227  // Member Functions
228 
229  //- Read the field average data
230  virtual bool read(const dictionary&);
231 
232  //- Return the list of fields required
233  virtual wordList fields() const;
234 
235  //- Do nothing
236  virtual bool execute();
237 
238  //- Calculate and write the streamlines
239  virtual bool write();
240 
241  //- Update for mesh point-motion
242  virtual void movePoints(const polyMesh&);
243 
244  //- Update topology using the given map
245  virtual void topoChange(const polyTopoChangeMap&);
246 
247  //- Update from another mesh using the given map
248  virtual void mapMesh(const polyMeshMap&);
249 
250  //- Redistribute or update using the given distribution map
251  virtual void distribute(const polyDistributionMap&);
252 
253 
254  // Member Operators
255 
256  //- Disallow default bitwise assignment
257  void operator=(const streamlines&) = delete;
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace functionObjects
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
const word & name() const
Return the name of this functionObject.
Generates streamline data by sampling a set of user-specified fields along a particle track,...
Definition: streamlines.H:216
streamlines(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: streamlines.C:90
virtual wordList fields() const
Return the list of fields required.
Definition: streamlines.C:190
TypeName("streamlines")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: streamlines.C:599
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: streamlines.C:623
trackDirection
Track direction enumerations.
Definition: streamlines.H:223
virtual ~streamlines()
Destructor.
Definition: streamlines.C:106
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: streamlines.C:611
void operator=(const streamlines &)=delete
Disallow default bitwise assignment.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: streamlines.C:588
static const NamedEnum< trackDirection, 3 > trackDirectionNames_
Track direction enumeration names.
Definition: streamlines.H:230
virtual bool execute()
Do nothing.
Definition: streamlines.C:199
virtual bool write()
Calculate and write the streamlines.
Definition: streamlines.C:205
virtual bool read(const dictionary &)
Read the field average data.
Definition: streamlines.C:112
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
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
dictionary dict