Loading...
Searching...
No Matches
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-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::nearWallFields
29
30Group
31 grpFieldFunctionObjects
32
33Description
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 | <time>/inputFields
40 output file | - | -
41 output field | vol<Type>Field | <time>/outputField
42 \endtable
43
44 where \c Type can be one of:
45 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
46
47Usage
48 Minimal example by using \c system/controlDict.functions:
49 \verbatim
50 nearWallFieldsFO
51 {
52 // Mandatory entries
53 type nearWallFields;
54 libs (fieldFunctionObjects);
55 fields
56 (
57 (<field1> <outField1>)
58 (<field2> <outField2>)
59 );
60 patches <wordList>; // (<patch1> <patch2> ... <patchN>);
61 distance <scalar>;
62
63 // Inherited entries
64 ...
65 }
66 \endverbatim
67
68 where the entries mean:
69 \table
70 Property | Description | Type | Reqd | Deflt
71 type | Type name: nearWallFields | word | yes | -
72 libs | Library name: fieldFunctionObjects | word | yes | -
73 fields | Names of input-output fields | wordHashTable | yes | -
74 patches | Names of patches to sample | wordList | yes | -
75 distance | Wall-normal distance from patch to sample | scalar | yes | -
76 \endtable
77
78 The inherited entries are elaborated in:
79 - \link functionObject.H \endlink
80
81SourceFiles
82 nearWallFields.C
83 nearWallFieldsTemplates.C
84
85\*---------------------------------------------------------------------------*/
86
87#ifndef Foam_functionObjects_nearWallFields_H
88#define Foam_functionObjects_nearWallFields_H
89
91#include "volFields.H"
92#include "Tuple2.H"
94
95// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96
97namespace Foam
98{
99namespace functionObjects
100{
101
102/*---------------------------------------------------------------------------*\
103 Class nearWallFields Declaration
104\*---------------------------------------------------------------------------*/
105
106class nearWallFields
107:
109{
110protected:
111
112 // Protected Data
113
114 // Read from dictionary
115
116 //- Fields to process (input-name output-name)
117 List<Tuple2<word, word>> fieldSet_;
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
138 List<List<point>> cellToSamples_;
139
140 //- Map from cell based data back to patch based data
141 autoPtr<mapDistribute> getPatchDataMapPtr_;
142
143
144 // Locally constructed fields
145
146 PtrList<volScalarField> vsf_;
147 PtrList<volVectorField> vvf_;
148 PtrList<volSphericalTensorField> vSpheretf_;
149 PtrList<volSymmTensorField> vSymmtf_;
150 PtrList<volTensorField> vtf_;
151
152
153 // Protected Member Functions
154
155 //- Calculate addressing from cells back to patch faces
156 void calcAddressing();
157
158 //- Create the local fields
159 template<class Type>
160 void createFields
161 (
163 ) const;
164
165 //- Override boundary fields with sampled values
166 template<class Type>
168 (
169 const interpolationCellPoint<Type>& interpolator,
171 ) const;
172
173 //- Sample the fields
174 template<class Type>
175 void sampleFields
178 ) const;
179
180
181public:
182
183 //- Runtime type information
184 TypeName("nearWallFields");
185
187 // Constructors
188
189 //- Construct for given objectRegistry and dictionary.
190 // Allow the possibility to load fields from files
192 (
193 const word& name,
194 const Time& runTime,
195 const dictionary& dict
196 );
197
198 //- No copy construct
200
201 //- No copy assignment
202 void operator=(const nearWallFields&) = delete;
203
205 //- Destructor
206 virtual ~nearWallFields() = default;
207
208
209 // Member Functions
211 //- Read the function-object dictionary
212 virtual bool read(const dictionary& dict);
214 //- Execute the function-object operations
215 virtual bool execute();
216
217 //- Write the function-object results
218 virtual bool write();
219};
220
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223
224} // End namespace functionObjects
225} // End namespace Foam
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229#ifdef NoRepository
231#endif
232
233// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234
235#endif
236
237// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic GeometricField class.
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Samples near-patch volume fields within an input distance range.
scalar distance_
Distance away from wall.
HashTable< word > reverseFieldMap_
From resulting back to original field.
virtual ~nearWallFields()=default
Destructor.
autoPtr< mapDistribute > getPatchDataMapPtr_
Map from cell based data back to patch based data.
List< Tuple2< word, word > > fieldSet_
Fields to process (input-name output-name).
List< List< point > > cellToSamples_
From cell to tracked end point.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
labelListList cellToWalls_
From cell to seed patch faces.
void calcAddressing()
Calculate addressing from cells back to patch faces.
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &) const
Create the local fields.
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
TypeName("nearWallFields")
Runtime type information.
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &) const
Sample the fields.
PtrList< volSymmTensorField > vSymmtf_
nearWallFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
nearWallFields(const nearWallFields &)=delete
No copy construct.
virtual bool execute()
Execute the function-object operations.
PtrList< volSphericalTensorField > vSpheretf_
void operator=(const nearWallFields &)=delete
No copy assignment.
virtual bool write()
Write the function-object results.
labelList patchIDs_
Patches to sample.
HashTable< word > fieldMap_
From original field to sampled result.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68