nearWallFields.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015 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::nearWallFields
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Samples near-patch volume fields.
35 
36  Fields are stored
37  - every time step the field is updated with new values
38  - at output it writes the fields
39 
40  This functionObject can either be used
41  - to calculate a new field as a post-processing step or
42  - since the fields are registered, used in another functionObject
43 
44 Usage
45  Example of function object specification:
46  \verbatim
47  nearWallFields1
48  {
49  type nearWallFields;
50  libs ("libfieldFunctionObjects.so");
51 
52  writeControl writeTime;
53 
54  fields
55  (
56  (p pNear)
57  (U UNear)
58  );
59 
60  patches (movingWall);
61 
62  distance 0.13;
63  }
64  \endverbatim
65 
66  Where the entries comprise:
67  \table
68  Property | Description | Required | Default value
69  type | type name: nearWallFields | yes |
70  fields | list of fields with corresponding output field names | yes |
71  patches | list of patches to sample | yes |
72  distance | distance from patch to sample | yes |
73  log | Log to standard output | no | yes
74  \endtable
75 
76 See also
77  Foam::functionObjects::fvMeshFunctionObject
78 
79 SourceFiles
80  nearWallFields.C
81 
82 \*---------------------------------------------------------------------------*/
83 
84 #ifndef functionObjects_nearWallFields_H
85 #define functionObjects_nearWallFields_H
86 
87 #include "fvMeshFunctionObject.H"
88 #include "volFields.H"
89 #include "Tuple2.H"
90 #include "interpolationCellPoint.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 namespace functionObjects
97 {
98 
99 /*---------------------------------------------------------------------------*\
100  Class nearWallFields Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 class nearWallFields
104 :
105  public fvMeshFunctionObject
106 {
107 protected:
108 
109  // Protected member data
110 
111  // Read from dictionary
112 
113  //- Fields to process (input-name output-name)
114  List<Tuple2<word, word>> fieldSet_;
115 
116  //- Switch to send output to Info as well as to file
117  Switch log_;
118 
119  //- Patches to sample
121 
122  //- Distance away from wall
123  scalar distance_;
124 
125  //- From original field to sampled result
126  HashTable<word> fieldMap_;
127 
128  //- From resulting back to original field
129  HashTable<word> reverseFieldMap_;
130 
131 
132  // Calculated addressing
133 
134  //- From cell to seed patch faces
136 
137  //- From cell to tracked end point
139 
140  //- Map from cell based data back to patch based data
142 
143 
144  // Locally constructed fields
145 
151 
152 
153  // Protected Member Functions
154 
155  //- Calculate addressing from cells back to patch faces
156  void calcAddressing();
157 
158  template<class Type>
159  void createFields
160  (
162  ) const;
163 
164  //- Override boundary fields with sampled values
165  template<class Type>
167  (
168  const interpolationCellPoint<Type>& interpolator,
170  ) const;
171 
172  template<class Type>
173  void sampleFields
174  (
176  ) const;
177 
178 
179 private:
180 
181  //- No copy construct
182  nearWallFields(const nearWallFields&) = delete;
183 
184  //- No copy assignment
185  void operator=(const nearWallFields&) = delete;
186 
187 public:
188 
189  //- Runtime type information
190  TypeName("nearWallFields");
191 
192 
193  // Constructors
194 
195  //- Construct for given objectRegistry and dictionary.
196  // Allow the possibility to load fields from files
198  (
199  const word& name,
200  const Time& runTime,
201  const dictionary& dict
202  );
203 
204 
205  //- Destructor
206  virtual ~nearWallFields();
207 
208 
209  // Member Functions
210 
211  //- Read the controls
212  virtual bool read(const dictionary&);
213 
214  //- Calculate the near-wall fields
215  virtual bool execute();
216 
217  //- Write the near-wall fields
218  virtual bool write();
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace functionObjects
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #ifdef NoRepository
230  #include "nearWallFieldsTemplates.C"
231 #endif
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #endif
236 
237 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::nearWallFields::TypeName
TypeName("nearWallFields")
Runtime type information.
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
Foam::functionObjects::nearWallFields::cellToSamples_
List< List< point > > cellToSamples_
From cell to tracked end point.
Definition: nearWallFields.H:167
nearWallFieldsTemplates.C
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::nearWallFields::fieldSet_
List< Tuple2< word, word > > fieldSet_
Fields to process (input-name output-name)
Definition: nearWallFields.H:143
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::nearWallFields::read
virtual bool read(const dictionary &)
Read the controls.
Definition: nearWallFields.C:269
Foam::functionObjects::nearWallFields::vSpheretf_
PtrList< volSphericalTensorField > vSpheretf_
Definition: nearWallFields.H:177
fvMeshFunctionObject.H
Tuple2.H
Foam::functionObjects::nearWallFields::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: nearWallFields.H:146
Foam::functionObjects::nearWallFields::write
virtual bool write()
Write the near-wall fields.
Definition: nearWallFields.C:353
Foam::functionObjects::nearWallFields::getPatchDataMapPtr_
autoPtr< mapDistribute > getPatchDataMapPtr_
Map from cell based data back to patch based data.
Definition: nearWallFields.H:170
Foam::functionObjects::nearWallFields
Samples near-patch volume fields.
Definition: nearWallFields.H:132
Foam::functionObjects::nearWallFields::vsf_
PtrList< volScalarField > vsf_
Definition: nearWallFields.H:175
Foam::HashSet< label, Hash< label > >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
interpolationCellPoint.H
Foam::functionObjects::nearWallFields::calcAddressing
void calcAddressing()
Calculate addressing from cells back to patch faces.
Definition: nearWallFields.C:50
Foam::interpolationCellPoint
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
Definition: interpolationCellPoint.H:50
Foam::functionObjects::nearWallFields::sampleBoundaryField
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
Definition: nearWallFieldsTemplates.C:88
Foam::functionObjects::nearWallFields::patchSet_
labelHashSet patchSet_
Patches to sample.
Definition: nearWallFields.H:149
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::nearWallFields::vSymmtf_
PtrList< volSymmTensorField > vSymmtf_
Definition: nearWallFields.H:178
Foam::functionObjects::nearWallFields::sampleFields
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
Definition: nearWallFieldsTemplates.C:136
Foam::functionObjects::nearWallFields::execute
virtual bool execute()
Calculate the near-wall fields.
Definition: nearWallFields.C:312
Foam::functionObjects::nearWallFields::distance_
scalar distance_
Distance away from wall.
Definition: nearWallFields.H:152
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::functionObjects::nearWallFields::createFields
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
Definition: nearWallFieldsTemplates.C:35
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObjects::nearWallFields::fieldMap_
HashTable< word > fieldMap_
From original field to sampled result.
Definition: nearWallFields.H:155
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::functionObjects::nearWallFields::cellToWalls_
labelListList cellToWalls_
From cell to seed patch faces.
Definition: nearWallFields.H:164
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::functionObjects::nearWallFields::vtf_
PtrList< volTensorField > vtf_
Definition: nearWallFields.H:179
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
Definition: HashSet.H:415
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::functionObjects::nearWallFields::vvf_
PtrList< volVectorField > vvf_
Definition: nearWallFields.H:176
Foam::functionObjects::nearWallFields::~nearWallFields
virtual ~nearWallFields()
Destructor.
Definition: nearWallFields.C:261
Foam::functionObjects::nearWallFields::reverseFieldMap_
HashTable< word > reverseFieldMap_
From resulting back to original field.
Definition: nearWallFields.H:158