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-2020 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 within an input distance range.
35 
36  Operands:
37  \table
38  Operand | Type | Location
39  input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
40  output file | - | -
41  output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
42  \endtable
43 
44  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
45 
46 Usage
47  Minimal example by using \c system/controlDict.functions:
48  \verbatim
49  nearWallFields1
50  {
51  // Mandatory entries (unmodifiable)
52  type nearWallFields;
53  libs (fieldFunctionObjects);
54  fields
55  (
56  (<field1> <outField1>)
57  (<field2> <outField2>)
58  );
59  patches (<patch1> <patch2> ... <patchN>);
60  distance 0.01;
61 
62  // Optional (inherited) entries
63  ...
64  }
65  \endverbatim
66 
67  where the entries mean:
68  \table
69  Property | Description | Type | Req'd | Dflt
70  type | Type name: nearWallFields | word | yes | -
71  libs | Library name: fieldFunctionObjects | word | yes | -
72  fields | Names of input-output fields | wordHashTable | yes | -
73  patches | Names of patches to sample | wordList | yes | -
74  distance | Wall-normal distance from patch to sample | scalar | yes | -
75  \endtable
76 
77  The inherited entries are elaborated in:
78  - \link functionObject.H \endlink
79 
80  Usage by the \c postProcess utility is not available.
81 
82 See also
83  - Foam::functionObject
84  - Foam::functionObjects::fvMeshFunctionObject
85  - ExtendedCodeGuide::functionObjects::field::nearWallFields
86 
87 SourceFiles
88  nearWallFields.C
89  nearWallFieldsTemplates.C
90 
91 \*---------------------------------------------------------------------------*/
92 
93 #ifndef functionObjects_nearWallFields_H
94 #define functionObjects_nearWallFields_H
95 
96 #include "fvMeshFunctionObject.H"
97 #include "volFields.H"
98 #include "Tuple2.H"
99 #include "interpolationCellPoint.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 namespace functionObjects
106 {
107 
108 /*---------------------------------------------------------------------------*\
109  Class nearWallFields Declaration
110 \*---------------------------------------------------------------------------*/
111 
112 class nearWallFields
113 :
114  public fvMeshFunctionObject
115 {
116 protected:
117 
118  // Protected Data
119 
120  // Read from dictionary
121 
122  //- Fields to process (input-name output-name)
123  List<Tuple2<word, word>> fieldSet_;
124 
125  //- Patches to sample
127 
128  //- Distance away from wall
129  scalar distance_;
130 
131  //- From original field to sampled result
132  HashTable<word> fieldMap_;
133 
134  //- From resulting back to original field
135  HashTable<word> reverseFieldMap_;
136 
137 
138  // Calculated addressing
139 
140  //- From cell to seed patch faces
142 
143  //- From cell to tracked end point
144  List<List<point>> cellToSamples_;
145 
146  //- Map from cell based data back to patch based data
147  autoPtr<mapDistribute> getPatchDataMapPtr_;
148 
149 
150  // Locally constructed fields
151 
152  PtrList<volScalarField> vsf_;
153  PtrList<volVectorField> vvf_;
154  PtrList<volSphericalTensorField> vSpheretf_;
155  PtrList<volSymmTensorField> vSymmtf_;
156  PtrList<volTensorField> vtf_;
157 
158 
159  // Protected Member Functions
160 
161  //- Calculate addressing from cells back to patch faces
162  void calcAddressing();
163 
164  template<class Type>
165  void createFields
166  (
168  ) const;
169 
170  //- Override boundary fields with sampled values
171  template<class Type>
173  (
174  const interpolationCellPoint<Type>& interpolator,
176  ) const;
177 
178  template<class Type>
179  void sampleFields
180  (
182  ) const;
183 
184 
185 public:
186 
187  //- Runtime type information
188  TypeName("nearWallFields");
189 
190 
191  // Constructors
192 
193  //- Construct for given objectRegistry and dictionary.
194  // Allow the possibility to load fields from files
196  (
197  const word& name,
198  const Time& runTime,
199  const dictionary& dict
200  );
201 
202  //- No copy construct
203  nearWallFields(const nearWallFields&) = delete;
204 
205  //- No copy assignment
206  void operator=(const nearWallFields&) = delete;
207 
208 
209  //- Destructor
210  virtual ~nearWallFields() = default;
211 
212 
213  // Member Functions
214 
215  //- Read the controls
216  virtual bool read(const dictionary& dict);
217 
218  //- Calculate the near-wall fields
219  virtual bool execute();
220 
221  //- Write the near-wall fields
222  virtual bool write();
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace functionObjects
229 } // End namespace Foam
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #ifdef NoRepository
234  #include "nearWallFieldsTemplates.C"
235 #endif
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::nearWallFields::TypeName
TypeName("nearWallFields")
Runtime type information.
Foam::functionObjects::nearWallFields::cellToSamples_
List< List< point > > cellToSamples_
From cell to tracked end point.
Definition: nearWallFields.H:195
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:174
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::nearWallFields::vSpheretf_
PtrList< volSphericalTensorField > vSpheretf_
Definition: nearWallFields.H:205
fvMeshFunctionObject.H
Tuple2.H
Foam::functionObjects::nearWallFields::write
virtual bool write()
Write the near-wall fields.
Definition: nearWallFields.C:350
Foam::functionObjects::nearWallFields::getPatchDataMapPtr_
autoPtr< mapDistribute > getPatchDataMapPtr_
Map from cell based data back to patch based data.
Definition: nearWallFields.H:198
Foam::functionObjects::nearWallFields
Samples near-patch volume fields within an input distance range.
Definition: nearWallFields.H:163
Foam::functionObjects::nearWallFields::vsf_
PtrList< volScalarField > vsf_
Definition: nearWallFields.H:203
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:92
Foam::functionObjects::nearWallFields::patchSet_
labelHashSet patchSet_
Patches to sample.
Definition: nearWallFields.H:177
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
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:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::nearWallFields::vSymmtf_
PtrList< volSymmTensorField > vSymmtf_
Definition: nearWallFields.H:206
Foam::functionObjects::nearWallFields::sampleFields
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
Definition: nearWallFieldsTemplates.C:140
Foam::functionObjects::nearWallFields::execute
virtual bool execute()
Calculate the near-wall fields.
Definition: nearWallFields.C:309
Foam::functionObjects::nearWallFields::distance_
scalar distance_
Distance away from wall.
Definition: nearWallFields.H:180
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::functionObjects::nearWallFields::read
virtual bool read(const dictionary &dict)
Read the controls.
Definition: nearWallFields.C:261
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::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
Foam::functionObjects::nearWallFields::~nearWallFields
virtual ~nearWallFields()=default
Destructor.
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::nearWallFields::fieldMap_
HashTable< word > fieldMap_
From original field to sampled result.
Definition: nearWallFields.H:183
Foam::functionObjects::nearWallFields::cellToWalls_
labelListList cellToWalls_
From cell to seed patch faces.
Definition: nearWallFields.H:192
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::functionObjects::nearWallFields::vtf_
PtrList< volTensorField > vtf_
Definition: nearWallFields.H:207
Foam::functionObjects::nearWallFields::nearWallFields
nearWallFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: nearWallFields.C:246
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::functionObjects::nearWallFields::operator=
void operator=(const nearWallFields &)=delete
No copy assignment.
Foam::functionObjects::nearWallFields::vvf_
PtrList< volVectorField > vvf_
Definition: nearWallFields.H:204
Foam::functionObjects::nearWallFields::reverseFieldMap_
HashTable< word > reverseFieldMap_
From resulting back to original field.
Definition: nearWallFields.H:186