streamLineBase.H
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) 2015 OpenFOAM Foundation
9  Copyright (C) 2016 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::functionObjects::streamLineBase
29 
30 SeeAlso
31  Foam::functionObjects::streamLine
32  Foam::functionObjects::wallBoundedStreamLine
33 
34 SourceFiles
35  streamLineBase.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef streamLineBase_H
40 #define streamLineBase_H
41 
42 #include "fvMeshFunctionObject.H"
43 #include "DynamicList.H"
44 #include "scalarList.H"
45 #include "vectorList.H"
46 #include "writer.H"
47 #include "indirectPrimitivePatch.H"
48 #include "interpolation.H"
49 #include "Enum.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class meshSearch;
57 class sampledSet;
58 
59 namespace functionObjects
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class streamLineBase Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class streamLineBase
67 :
69 {
70 public:
71 
72  // Public data types
73 
74  //- Enumeration defining the track direction
75  enum trackDirType : char
76  {
80  };
81 
82  //- Names for the trackDir
84 
85 
86 protected:
87 
88  //- Seed set engine
90 
91  //- Axis of the sampled points to output
92  mutable word sampledSetAxis_;
93 
94  //- Input dictionary
96 
97  //- List of fields to sample
99 
100  //- Field to transport particle with
101  word UName_;
102 
103  //- Interpolation scheme to use
105 
106  //- Whether to use +u or -u or both
108 
109  //- Maximum lifetime (= number of cells) of particle
110  label lifeTime_;
111 
112  //- Track length
113  scalar trackLength_;
114 
115  //- Optional trimming of tracks
117 
118  //- Optional specified name of particles
120 
121  //- Type of seed
122  word seedSet_;
123 
124  //- Names of scalar fields
126 
127  //- Names of vector fields
129 
130 
131  // Demand driven
132 
133  //- File writer for scalar data
135 
136  //- File writer for vector data
138 
139 
140  // Generated data
141 
142  //- All tracks. Per track the points it passed through
144 
145  //- Per scalarField, per track, the sampled values
147 
148  //- Per vectorField, per track, the sampled values
150 
151 
152  // Protected Member Functions
153 
154  //- The axis of the sampledSet. Creates sampledSet if required.
155  const word& sampledSetAxis() const;
156 
157  //- Demand driven construction of the sampledSet.
158  // Also updates sampledSetAxis_
159  const sampledSet& sampledSetPoints() const;
160 
161  //- Construct patch out of all wall patch faces
163 
164  //- Initialise fields, interpolators and track storage
165  void initInterpolations
166  (
167  const label nSeeds,
168  label& UIndex,
169  PtrList<volScalarField>& vsFlds,
170  PtrList<interpolation<scalar>>& vsInterp,
171  PtrList<volVectorField>& vvFlds,
172  PtrList<interpolation<vector>>& vvInterp
173  );
174 
175  //- Generate point and values by interpolating from existing values
176  void storePoint
177  (
178  const label tracki,
179 
180  const scalar w,
181  const label lefti,
182  const label righti,
183 
184  DynamicList<point>& newTrack,
185  DynamicList<List<scalar>>& newScalars,
186  DynamicList<List<vector>>& newVectors
187  ) const;
188 
189  //- Trim and possibly split a track
190  void trimToBox
191  (
192  const treeBoundBox& bb,
193  const label tracki,
194  PtrList<DynamicList<point>>& newTracks,
195  PtrList<DynamicList<scalarList>>& newScalars,
196  PtrList<DynamicList<vectorList>>& newVectors
197  ) const;
198 
199  //- Trim tracks to bounding box
200  void trimToBox(const treeBoundBox& bb);
201 
202  //- Do the actual tracking to fill the track data
203  virtual void track() = 0;
204 
205  //- Write tracks to file
206  virtual bool writeToFile();
207 
208  //- Reset the field names
209  virtual void resetFieldNames
210  (
211  const word& newUName,
212  const wordList& newFieldNames
213  );
214 
215 
216 public:
217 
218  //- Runtime type information
219  TypeName("streamLineBase");
220 
221 
222  // Constructors
223 
224  //- Construct for given objectRegistry and dictionary.
225  // Allow the possibility to load fields from files
227  (
228  const word& name,
229  const Time& runTime,
230  const dictionary& dict
231  );
232 
233  //- Construct from Time and dictionary and list of fields to sample
235  (
236  const word& name,
237  const Time& runTime,
238  const dictionary& dict,
239  const wordList& fieldNames
240  );
241 
242 
243  //- Destructor
244  virtual ~streamLineBase();
245 
246 
247  // Member Functions
248 
249  //- Read the field average data
250  virtual bool read(const dictionary&);
251 
252  //- Execute the averaging
253  virtual bool execute();
254 
255  //- Track and write
256  virtual bool write();
257 
258  //- Update for changes of mesh
259  virtual void updateMesh(const mapPolyMesh&);
260 
261  //- Update for mesh point-motion
262  virtual void movePoints(const polyMesh&);
263 };
264 
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 } // End namespace functionObjects
269 } // End namespace Foam
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:83
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::streamLineBase::trackLength_
scalar trackLength_
Track length.
Definition: streamLineBase.H:112
Foam::functionObjects::streamLineBase::trackDirType
trackDirType
Enumeration defining the track direction.
Definition: streamLineBase.H:74
Foam::functionObjects::streamLineBase::allScalars_
List< DynamicList< scalarList > > allScalars_
Per scalarField, per track, the sampled values.
Definition: streamLineBase.H:145
Foam::Enum< trackDirType >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
vectorList.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::streamLineBase::track
virtual void track()=0
Do the actual tracking to fill the track data.
fvMeshFunctionObject.H
Foam::functionObjects::streamLineBase::~streamLineBase
virtual ~streamLineBase()
Destructor.
Definition: streamLineBase.C:869
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::functionObjects::streamLineBase::write
virtual bool write()
Track and write.
Definition: streamLineBase.C:975
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::functionObjects::streamLineBase::sampledSetPoints
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
Definition: streamLineBase.C:78
Foam::functionObjects::streamLineBase::storePoint
void storePoint(const label tracki, const scalar w, const label lefti, const label righti, DynamicList< point > &newTrack, DynamicList< List< scalar >> &newScalars, DynamicList< List< vector >> &newVectors) const
Generate point and values by interpolating from existing values.
Definition: streamLineBase.C:262
Foam::functionObjects::streamLineBase::scalarFormatterPtr_
autoPtr< writer< scalar > > scalarFormatterPtr_
File writer for scalar data.
Definition: streamLineBase.H:133
Foam::functionObjects::streamLineBase::wallPatch
autoPtr< indirectPrimitivePatch > wallPatch() const
Construct patch out of all wall patch faces.
Definition: streamLineBase.C:98
Foam::functionObjects::streamLineBase::bounds_
boundBox bounds_
Optional trimming of tracks.
Definition: streamLineBase.H:115
interpolation.H
Foam::functionObjects::streamLineBase::movePoints
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: streamLineBase.C:997
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::streamLineBase::seedSet_
word seedSet_
Type of seed.
Definition: streamLineBase.H:121
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObjects::streamLineBase::read
virtual bool read(const dictionary &)
Read the field average data.
Definition: streamLineBase.C:875
scalarList.H
Foam::functionObjects::streamLineBase::writeToFile
virtual bool writeToFile()
Write tracks to file.
Definition: streamLineBase.C:527
Foam::functionObjects::streamLineBase::dict_
dictionary dict_
Input dictionary.
Definition: streamLineBase.H:94
Foam::functionObjects::streamLineBase::sampledSetPtr_
autoPtr< sampledSet > sampledSetPtr_
Seed set engine.
Definition: streamLineBase.H:88
Foam::functionObjects::streamLineBase::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: streamLineBase.C:988
Foam::functionObjects::streamLineBase::fields_
wordList fields_
List of fields to sample.
Definition: streamLineBase.H:97
Foam::functionObjects::streamLineBase::execute
virtual bool execute()
Execute the averaging.
Definition: streamLineBase.C:969
Foam::functionObjects::streamLineBase::scalarNames_
wordList scalarNames_
Names of scalar fields.
Definition: streamLineBase.H:124
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::functionObjects::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:142
Foam::functionObjects::streamLineBase::BIDIRECTIONAL
Definition: streamLineBase.H:78
Foam::functionObjects::streamLineBase
Definition: streamLineBase.H:65
indirectPrimitivePatch.H
Foam::interpolation< scalar >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
fieldNames
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::streamLineBase::allVectors_
List< DynamicList< vectorList > > allVectors_
Per vectorField, per track, the sampled values.
Definition: streamLineBase.H:148
Foam::functionObjects::streamLineBase::vectorNames_
wordList vectorNames_
Names of vector fields.
Definition: streamLineBase.H:127
Foam::functionObjects::streamLineBase::FORWARD
Definition: streamLineBase.H:76
Foam::functionObjects::streamLineBase::BACKWARD
Definition: streamLineBase.H:77
Foam::functionObjects::streamLineBase::trackDirTypeNames
static const Enum< trackDirType > trackDirTypeNames
Names for the trackDir.
Definition: streamLineBase.H:82
Foam::functionObjects::streamLineBase::trackDir_
trackDirType trackDir_
Whether to use +u or -u or both.
Definition: streamLineBase.H:106
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::streamLineBase::cloudName_
word cloudName_
Optional specified name of particles.
Definition: streamLineBase.H:118
Foam::functionObjects::streamLineBase::vectorFormatterPtr_
autoPtr< writer< vector > > vectorFormatterPtr_
File writer for vector data.
Definition: streamLineBase.H:136
Foam::functionObjects::streamLineBase::UName_
word UName_
Field to transport particle with.
Definition: streamLineBase.H:100
Foam::List< word >
Foam::functionObjects::streamLineBase::interpolationScheme_
word interpolationScheme_
Interpolation scheme to use.
Definition: streamLineBase.H:103
Foam::functionObjects::streamLineBase::lifeTime_
label lifeTime_
Maximum lifetime (= number of cells) of particle.
Definition: streamLineBase.H:109
Foam::functionObjects::streamLineBase::trimToBox
void trimToBox(const treeBoundBox &bb, const label tracki, PtrList< DynamicList< point >> &newTracks, PtrList< DynamicList< scalarList >> &newScalars, PtrList< DynamicList< vectorList >> &newVectors) const
Trim and possibly split a track.
Definition: streamLineBase.C:308
Foam::functionObjects::streamLineBase::sampledSetAxis_
word sampledSetAxis_
Axis of the sampled points to output.
Definition: streamLineBase.H:91
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
DynamicList.H
Foam::functionObjects::streamLineBase::streamLineBase
streamLineBase(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: streamLineBase.C:841
Foam::functionObjects::streamLineBase::TypeName
TypeName("streamLineBase")
Runtime type information.
writer.H
Foam::functionObjects::streamLineBase::allTracks_
DynamicList< List< point > > allTracks_
All tracks. Per track the points it passed through.
Definition: streamLineBase.H:142
Foam::functionObjects::streamLineBase::resetFieldNames
virtual void resetFieldNames(const word &newUName, const wordList &newFieldNames)
Reset the field names.
Definition: streamLineBase.C:828
Enum.H
Foam::functionObjects::streamLineBase::sampledSetAxis
const word & sampledSetAxis() const
The axis of the sampledSet. Creates sampledSet if required.
Definition: streamLineBase.C:66