Loading...
Searching...
No Matches
zeroGradient.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) 2016-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::zeroGradient
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Creates a volume field with zero-gradient boundary conditions from another
34 volume field.
35
36 The result can be used, for example, to post-process near-wall field values.
37
38 Operands:
39 \table
40 Operand | Type | Location
41 input | vol<Type>Field | <time>/inputField
42 output file | - | -
43 output field | vol<Type>Field | <time>/outputField
44 \endtable
45
46 where \c Type can be one of:
47 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
48
49Usage
50 Minimal example by using \c system/controlDict.functions:
51 \verbatim
52 zeroGradientFO
53 {
54 // Mandatory entries
55 type zeroGradient;
56 libs (fieldFunctionObjects);
57 fields (<field1> ... <fieldN>); \\‍(U "(T|k|epsilon|omega)");
58
59 // Optional entries
60 result @@<name>;
61
62 // Inherited entries
63 ...
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Reqd | Deflt
70 type | Type name: zeroGradient | word | yes | -
71 libs | Library name: fieldFunctionObjects | word | yes | -
72 fields | Name of the operand fields | wordList | yes | -
73 result | Name of the output field | word | no | zeroGradient(@@)
74 \endtable
75
76 The inherited entries are elaborated in:
77 - \link functionObject.H \endlink
78
79Note
80 - A list of fields can contain exact names or regular expressions.
81 The token '\@\@' in the result name is replaced by the name of the source
82 field. In the special case of a single source field (specified as
83 a non-regex), the '\@\@' token checking is suppressed.
84 - The function object will skip over fields that would not benefit
85 i.e., only processor, empty, zeroGradient, symmetry patches.
86 This check should also prevent processing fields multiple times.
87
88SourceFiles
89 zeroGradient.C
90 zeroGradientTemplates.C
91
92\*---------------------------------------------------------------------------*/
93
94#ifndef Foam_functionObjects_zeroGradient_H
95#define Foam_functionObjects_zeroGradient_H
96
98#include "volFieldsFwd.H"
99#include "OFstream.H"
100#include "wordRes.H"
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103
104namespace Foam
105{
106namespace functionObjects
107{
108
109/*---------------------------------------------------------------------------*\
110 Class zeroGradient Declaration
111\*---------------------------------------------------------------------------*/
112
113class zeroGradient
114:
116{
117 // Private Data
118
119 //- Name of fields to process
120 wordRes selectFields_;
121
122 //- Formatting for the result fields
123 word resultName_;
124
125 //- Hashed names of result fields, and their type
126 HashTable<word> results_;
127
128
129 // Private Member Functions
130
131 //- Accept unless field only has constraint patches
132 // (ie, empty/zero-gradient/processor)
133 // This should also avoid fields that were already processed by
134 // zeroGradient.
135 template<class Type>
136 static bool accept(const GeometricField<Type, fvPatchField, volMesh>&);
137
138 //- Apply for the volume field type
139 template<class Type>
140 int apply(const word& inputName, int& state);
141
142 //- Process by trying to apply for various volume field types
143 int process(const word& inputName);
144
145
146public:
147
148 //- Runtime type information
149 TypeName("zeroGradient");
150
151
152 // Constructors
153
154 //- Construct from name, Time and dictionary
156 (
157 const word& name,
158 const Time& runTime,
159 const dictionary& dict
160 );
161
162 //- No copy construct
163 zeroGradient(const zeroGradient&) = delete;
164
165 //- No copy assignment
166 void operator=(const zeroGradient&) = delete;
167
168
169 //- Destructor
170 virtual ~zeroGradient() = default;
171
172
173 // Member Functions
174
175 //- Read the function-object dictionary
176 virtual bool read(const dictionary& dict);
177
178 //- Execute the function-object operations
179 virtual bool execute();
180
181 //- Write the function-object results
182 virtual bool write();
183};
184
185
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188} // End namespace functionObjects
189} // End namespace Foam
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193#ifdef NoRepository
194 #include "zeroGradientTemplates.C"
195#endif
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199#endif
200
201// ************************************************************************* //
Generic GeometricField class.
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
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.
Creates a volume field with zero-gradient boundary conditions from another volume field.
virtual ~zeroGradient()=default
Destructor.
TypeName("zeroGradient")
Runtime type information.
zeroGradient(const zeroGradient &)=delete
No copy construct.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
void operator=(const zeroGradient &)=delete
No copy assignment.
virtual bool execute()
Execute the function-object operations.
zeroGradient(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual bool write()
Write the function-object results.
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
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.
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
Forwards and collection of common volume field types.