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 <userDefinedSubDictName1>
41 {
42 // Mandatory and other optional entries
43 ...
44
45 // Optional (inherited) entries (runtime modifiable)
46 fields (<field1> <field2> ... <fieldN>);
47 result <fieldResult>;
48 }
49 \endverbatim
50
51 where the entries mean:
52 \table
53 Property | Description | Type | Req'd | Dflt
54 fields | Names of operand fields | wordList | yes | -
55 result | Names of output fields | wordList | no | <FO>(<f1>,...)
56 \endtable
57
58See also
59 - Foam::functionObject
60 - Foam::functionObjects::fvMeshFunctionObject
61 - ExtendedCodeGuide::functionObjects::field::fieldsExpression
62
63SourceFiles
64 fieldsExpression.C
65 fieldsExpressionTemplates.C
66
67\*---------------------------------------------------------------------------*/
68
69#ifndef functionObjects_fieldsExpression_H
70#define 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
86class fieldsExpression
87:
88 public fvMeshFunctionObject
89{
90protected:
91
92 // Protected Member Data
93
94 //- Names of fields to process
96
97 //- Name of result fields
98 word resultName_;
99
100
101 // Protected Member Functions
102
104 (
105 const word& typeName,
106 const wordList& defaultArg = wordList::null()
107 );
108
109 //- Call 'calcFieldType' for the given functionObject
110 // for 'volField' and 'surfaceField' field types
111 template<class Type, class FOType>
112 bool calcFieldTypes(FOType& fo);
113
114 //- Call 'calcFieldTypes' for the given 'Type' and functionObject
115 template<class Type, class FOType>
116 bool calcType(FOType& fo);
117
118 //- Call 'calcType' for the given functionObject
119 // for each primitive type
120 template<class FOType>
121 bool calcAllTypes(FOType& fo);
122
123 //- Calculate expression
124 virtual bool calc() = 0;
125
126
127public:
128
129 //- Runtime type information
130 TypeName("fieldsExpression");
131
132
133 // Constructors
134
135 //- Construct from Time and dictionary
137 (
138 const word& name,
139 const Time& runTime,
140 const dictionary& dict,
141 const wordList& fieldNames = wordList::null(),
142 const word& resultName = word::null
143 );
144
145 //- No copy construct
146 fieldsExpression(const fieldsExpression&) = delete;
148 //- No copy assignment
149 void operator=(const fieldsExpression&) = delete;
150
151
152 //- Destructor
153 virtual ~fieldsExpression() = default;
154
155
156 // Member Functions
157
158 //- Read the fieldsExpression data
159 virtual bool read(const dictionary& dict);
160
161 //- Calculate the result fields
162 virtual bool execute();
164 //- Write the result fields
165 virtual bool write();
167 //- Clear the result fields from the objectRegistry
168 virtual bool clear();
169};
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174} // End namespace functionObjects
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#ifdef NoRepository
181#endif
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185#endif
186
187// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
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. 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 fieldsExpression data.
word resultName_
Name of result fields.
void setResultName(const word &typeName, const wordList &defaultArg=wordList::null())
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.
bool calcFieldTypes(FOType &fo)
Call 'calcFieldType' for the given functionObject.
virtual bool execute()
Calculate the result fields.
virtual bool write()
Write the result fields.
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...
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73