fieldExpression.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2021 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::fieldExpression
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Intermediate class for handling field expression function objects
35 (e.g. \c blendingFactor etc.) whereinto a single field is input.
36
37Usage
38 Minimal example by using \c system/controlDict.functions:
39 \verbatim
40 <functionObject>
41 {
42 // Mandatory and optional entries
43 ...
44
45 // Inherited entries
46 field <field>;
47 result <fieldResult>;
48 cellZones ( <cellZone1> <cellZone2> ... <cellZoneN> );
49 nLayers <label>;
50 }
51 \endverbatim
52
53 where the entries mean:
54 \table
55 Property | Description | Type | Reqd | Deflt
56 field | Name of the operand field | word | yes | -
57 result | Name of the output field | word | no | <FO>(<field>)
58 cellZones | Names of cellZones | wordRes | no | -
59 nLayers | Number of cell layers around cellZones | label | no | 0
60 \endtable
61
62See also
63 - Foam::functionObject
64 - Foam::functionObjects::fvMeshFunctionObject
65 - ExtendedCodeGuide::functionObjects::field::fieldExpression
66
67SourceFiles
68 fieldExpression.C
69 fieldExpressionTemplates.C
70
71\*---------------------------------------------------------------------------*/
72
73#ifndef functionObjects_fieldExpression_H
74#define functionObjects_fieldExpression_H
75
77#include "volFieldsFwd.H"
78#include "zoneSubSet.H"
79
80// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81
82namespace Foam
83{
84namespace functionObjects
85{
86
87/*---------------------------------------------------------------------------*\
88 Class fieldExpression Declaration
89\*---------------------------------------------------------------------------*/
90
91class fieldExpression
92:
93 public fvMeshFunctionObject
94{
95protected:
96
97 // Protected Data
98
99 //- Name of field to process
100 word fieldName_;
101
102 //- Name of result field
103 word resultName_;
104
105 //- Sub-set mesh
106 autoPtr<Detail::zoneSubSet> zoneSubSetPtr_;
107
108
109 // Protected Member Functions
110
111 //- Calculate the components of the field and return true if successful
112 virtual bool calc() = 0;
113
114 //- Set the name of result field
115 void setResultName(const word& typeName, const word& defaultArg);
116
117 //- Return true if required objects are found
118 template<class Type>
119 bool foundObject(const word& name, const bool verbose = true) const;
121
122public:
123
124 //- Runtime type information
125 TypeName("fieldExpression");
126
127
128 // Constructors
130 //- Construct from Time and dictionary
133 const word& name,
134 const Time& runTime,
136 const word& fieldName = word::null,
137 const word& resultName = word::null
138 );
139
140 //- No copy construct
142
143 //- No copy assignment
144 void operator=(const fieldExpression&) = delete;
145
146
147 //- Destructor
148 virtual ~fieldExpression() = default;
149
150
151 // Member Functions
152
153 //- Read the fieldExpression data
154 virtual bool read(const dictionary& dict);
155
156 //- Calculate the result field
157 virtual bool execute();
158
159 //- Write the result field
160 virtual bool write();
161
162 //- Clear the result field from the objectRegistry
163 virtual bool clear();
164};
165
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169} // End namespace functionObjects
170} // End namespace Foam
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174#ifdef NoRepository
176#endif
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180#endif
181
182// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
bool foundObject(const word &name, const bool verbose=true) const
Return true if required objects are found.
fieldExpression(const fieldExpression &)=delete
No copy construct.
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
word resultName_
Name of result field.
void operator=(const fieldExpression &)=delete
No copy assignment.
word fieldName_
Name of field to process.
virtual bool clear()
Clear the result field from the objectRegistry.
TypeName("fieldExpression")
Runtime type information.
virtual ~fieldExpression()=default
Destructor.
virtual bool execute()
Calculate the result field.
autoPtr< Detail::zoneSubSet > zoneSubSetPtr_
Sub-set mesh.
virtual bool write()
Write the result field.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
void setResultName(const word &typeName, const word &defaultArg)
Set the name of result field.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73