Loading...
Searching...
No Matches
fieldsExpression.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-2020 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::fieldsExpression
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Intermediate class for handling field expression function objects
35 (e.g. \c add, \c subtract etc.) whereinto more than one fields are input.
36
37Usage
38 Minimal example by using \c system/controlDict.functions:
39 \verbatim
40 FOname
41 {
42 // Mandatory and optional entries
43 ...
44
45 // Mandatory entries
46 fields <wordList>; // (<field1> <field2> ... <fieldN>);
47
48 // Optional entries
49 result <word>;
50 }
51 \endverbatim
52
53 where the entries mean:
54 \table
55 Property | Description | Type | Reqd | Deflt
56 fields | Names of operand fields | wordList | yes | -
57 result | Names of output fields | wordList | no | <FO>(<f1>,...)
58 \endtable
59
60 The inherited entries are elaborated in:
61 - \link functionObject.H \endlink
62
63SourceFiles
64 fieldsExpression.C
65 fieldsExpressionTemplates.C
66
67\*---------------------------------------------------------------------------*/
68
69#ifndef Foam_functionObjects_fieldsExpression_H
70#define Foam_functionObjects_fieldsExpression_H
71
73#include "volFieldsFwd.H"
74
75// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76
77namespace Foam
78{
79namespace functionObjects
80{
81
82/*---------------------------------------------------------------------------*\
83 Class fieldsExpression Declaration
84\*---------------------------------------------------------------------------*/
85
87:
89{
90protected:
91
92 // Protected Member Data
93
94 //- Names of fields to process
96
97 //- Name of result fields
98 word resultName_;
100
101 // Protected Member Functions
102
103 //- Set the result name
104 void setResultName
105 (
106 const word& typeName,
107 const wordList& defaultArg = wordList::null()
108 );
109
110 //- Call 'calcFieldType' for the given functionObject
111 // for 'volField' and 'surfaceField' field types
112 template<class Type, class FOType>
113 bool calcFieldTypes(FOType& fo);
114
115 //- Call 'calcFieldTypes' for the given 'Type' and functionObject
116 template<class Type, class FOType>
117 bool calcType(FOType& fo);
118
119 //- Call 'calcType' for the given functionObject
120 // for each primitive type
121 template<class FOType>
122 bool calcAllTypes(FOType& fo);
123
124 //- Calculate expression
125 virtual bool calc() = 0;
126
127
128public:
129
130 //- Runtime type information
131 TypeName("fieldsExpression");
132
133
134 // Constructors
135
136 //- Construct from name, Time and dictionary
138 (
139 const word& name,
140 const Time& runTime,
141 const dictionary& dict,
142 const wordList& fieldNames = wordList::null(),
143 const word& resultName = word::null
144 );
145
146 //- No copy construct
147 fieldsExpression(const fieldsExpression&) = delete;
148
149 //- No copy assignment
150 void operator=(const fieldsExpression&) = delete;
151
152
153 //- Destructor
154 virtual ~fieldsExpression() = default;
155
156
157 // Member Functions
158
159 //- Read the function-object dictionary
160 virtual bool read(const dictionary& dict);
161
162 //- Execute the function-object operations
163 virtual bool execute();
164
165 //- Write the function-object results
166 virtual bool write();
167
168 //- Clear the result fields from the objectRegistry
169 virtual bool clear();
170};
171
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175} // End namespace functionObjects
176} // End namespace Foam
177
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180#ifdef NoRepository
182#endif
183
184// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185
186#endif
188// ************************************************************************* //
static const List< word > & null() noexcept
Definition List.H:138
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
Intermediate class for handling field expression function objects (e.g. add, subtract etc....
virtual ~fieldsExpression()=default
Destructor.
fieldsExpression(const fieldsExpression &)=delete
No copy construct.
wordList fieldNames_
Names of fields to process.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
void setResultName(const word &typeName, const wordList &defaultArg=wordList::null())
Set the result name.
bool calcType(FOType &fo)
Call 'calcFieldTypes' for the given 'Type' and functionObject.
bool calcAllTypes(FOType &fo)
Call 'calcType' for the given functionObject.
virtual bool clear()
Clear the result fields from the objectRegistry.
TypeName("fieldsExpression")
Runtime type information.
fieldsExpression(const word &name, const Time &runTime, const dictionary &dict, const wordList &fieldNames=wordList::null(), const word &resultName=word::null)
Construct from name, Time and dictionary.
bool calcFieldTypes(FOType &fo)
Call 'calcFieldType' for the given functionObject.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
virtual bool calc()=0
Calculate expression.
void operator=(const fieldsExpression &)=delete
No copy assignment.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
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.