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-2025 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 streamlines_functionObject_H
105 #define streamlines_functionObject_H
106 
107 #include "fvMeshFunctionObject.H"
108 #include "meshSearch.H"
109 #include "setWriter.H"
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 namespace Foam
114 {
115 
116 // Forward declaration of classes
117 class sampledSet;
118 
119 namespace functionObjects
120 {
121 
122 /*---------------------------------------------------------------------------*\
123  Class streamlines Declaration
124 \*---------------------------------------------------------------------------*/
125 
126 class streamlines
127 :
128  public fvMeshFunctionObject
129 {
130 public:
131 
132  // Public data types
133 
134  //- Track direction enumerations
135  enum class trackDirection
136  {
137  forward,
138  backward,
139  both
140  };
141 
142  //- Track direction enumeration names
143  static const NamedEnum<trackDirection, 3> trackDirectionNames_;
144 
145 
146 private:
147 
148  // Private Data
149 
150  //- List of fields to sample
151  wordList fields_;
152 
153  //- Field to transport particle with
154  word UName_;
155 
156  //- Interpolation scheme to use
157  word interpolationScheme_;
158 
159  //- The direction in which to track
160  trackDirection trackDirection_;
161 
162  //- Whether or not to track outside of the mesh in periodic geometries
163  Switch trackOutside_;
164 
165  //- Maximum lifetime (= number of cells) of particle
166  label lifeTime_;
167 
168  //- Number of subcycling steps
169  label nSubCycle_;
170 
171  //- Track length
172  scalar trackLength_;
173 
174  //- Optional specified name of particles
175  word cloudName_;
176 
177  //- Write the streamlines ages
178  Switch writeAge_;
179 
180  //- Mesh searching engine
181  meshSearch searchEngine_;
182 
183  //- Seed set engine
184  autoPtr<sampledSet> sampledSetPtr_;
185 
186  //- File writer
187  autoPtr<setWriter> formatterPtr_;
188 
189 
190 public:
191 
192  //- Runtime type information
193  TypeName("streamlines");
194 
195 
196  // Constructors
197 
198  //- Construct from Time and dictionary
200  (
201  const word& name,
202  const Time& runTime,
203  const dictionary& dict
204  );
205 
206  //- Disallow default bitwise copy construction
207  streamlines(const streamlines&) = delete;
208 
209 
210  //- Destructor
211  virtual ~streamlines();
212 
213 
214  // Member Functions
215 
216  //- Read the field average data
217  virtual bool read(const dictionary&);
218 
219  //- Return the list of fields required
220  virtual wordList fields() const;
221 
222  //- Do nothing
223  virtual bool execute();
224 
225  //- Calculate and write the streamlines
226  virtual bool write();
227 
228  //- Update for mesh point-motion
229  virtual void movePoints(const polyMesh&);
230 
231  //- Update topology using the given map
232  virtual void topoChange(const polyTopoChangeMap&);
233 
234  //- Update from another mesh using the given map
235  virtual void mapMesh(const polyMeshMap&);
236 
237  //- Redistribute or update using the given distribution map
238  virtual void distribute(const polyDistributionMap&);
239 
240 
241  // Member Operators
242 
243  //- Disallow default bitwise assignment
244  void operator=(const streamlines&) = delete;
245 };
246 
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace functionObjects
251 } // End namespace Foam
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #endif
256 
257 // ************************************************************************* //
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
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:209
streamlines(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: streamlines.C:86
virtual wordList fields() const
Return the list of fields required.
Definition: streamlines.C:179
TypeName("streamlines")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: streamlines.C:592
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: streamlines.C:620
trackDirection
Track direction enumerations.
Definition: streamlines.H:216
virtual ~streamlines()
Destructor.
Definition: streamlines.C:102
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: streamlines.C:606
void operator=(const streamlines &)=delete
Disallow default bitwise assignment.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: streamlines.C:581
virtual bool execute()
Do nothing.
Definition: streamlines.C:188
virtual bool write()
Calculate and write the streamlines.
Definition: streamlines.C:194
virtual bool read(const dictionary &)
Read the field average data.
Definition: streamlines.C:108
static const NamedEnum< trackDirection, 3 > trackDirectionNames_
Track direction enumeration names.
Definition: streamlines.H:223
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.
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