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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::fieldExpression
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Intermediate class for handling field expression function objects
35  (e.g. \c blendingFactor etc.) whereinto a single field is input.
36 
37 Usage
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  field <field>;
47  result <fieldResult>;
48  }
49  \endverbatim
50 
51  where the entries mean:
52  \table
53  Property | Description | Type | Req'd | Dflt
54  field | Name of the operand field | word | yes | -
55  result | Name of the output field | word | no | <FO>(<field>)
56  \endtable
57 
58 See also
59  - Foam::functionObject
60  - Foam::functionObjects::fvMeshFunctionObject
61  - ExtendedCodeGuide::functionObjects::field::fieldExpression
62 
63 SourceFiles
64  fieldExpression.C
65  fieldExpressionTemplates.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef functionObjects_fieldExpression_H
70 #define functionObjects_fieldExpression_H
71 
72 #include "fvMeshFunctionObject.H"
73 #include "volFieldsFwd.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 namespace functionObjects
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class fieldExpression Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class fieldExpression
87 :
88  public fvMeshFunctionObject
89 {
90 protected:
91 
92  // Protected Member Data
93 
94  //- Name of field to process
95  word fieldName_;
96 
97  //- Name of result field
98  word resultName_;
99 
100 
101  // Protected Member Functions
102 
103  //- Calculate the components of the field and return true if successful
104  virtual bool calc() = 0;
105 
106  //- Set the name of result field
107  void setResultName(const word& typeName, const word& defaultArg);
108 
109  //- Return true if required objects are found
110  template<class Type>
111  bool foundObject(const word& name, const bool verbose = true) const;
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("fieldExpression");
118 
119 
120  // Constructors
121 
122  //- Construct from Time and dictionary
124  (
125  const word& name,
126  const Time& runTime,
127  const dictionary& dict,
128  const word& fieldName = word::null,
129  const word& resultName = word::null
130  );
131 
132  //- No copy construct
133  fieldExpression(const fieldExpression&) = delete;
134 
135  //- No copy assignment
136  void operator=(const fieldExpression&) = delete;
137 
138 
139  //- Destructor
140  virtual ~fieldExpression() = default;
141 
142 
143  // Member Functions
144 
145  //- Read the fieldExpression data
146  virtual bool read(const dictionary& dict);
147 
148  //- Calculate the result field
149  virtual bool execute();
150 
151  //- Write the result field
152  virtual bool write();
153 
154  //- Clear the result field from the objectRegistry
155  virtual bool clear();
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace functionObjects
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #ifdef NoRepository
167  #include "fieldExpressionTemplates.C"
168 #endif
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
fvMeshFunctionObject.H
fieldExpressionTemplates.C
Foam::functionObjects::fieldExpression::foundObject
bool foundObject(const word &name, const bool verbose=true) const
Return true if required objects are found.
Definition: fieldExpressionTemplates.C:34
Foam::functionObjects::fieldExpression::read
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
Definition: fieldExpression.C:91
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fieldExpression::clear
virtual bool clear()
Clear the result field from the objectRegistry.
Definition: fieldExpression.C:130
Foam::functionObjects::fieldExpression::setResultName
void setResultName(const word &typeName, const word &defaultArg)
Set the name of result field.
Definition: fieldExpression.C:46
Foam::functionObjects::fieldExpression::operator=
void operator=(const fieldExpression &)=delete
No copy assignment.
Foam::functionObjects::fieldExpression::fieldExpression
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from Time and dictionary.
Definition: fieldExpression.C:73
Foam::functionObjects::fieldExpression::~fieldExpression
virtual ~fieldExpression()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::fieldExpression::fieldName_
word fieldName_
Name of field to process.
Definition: fieldExpression.H:112
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:103
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::functionObjects::fieldExpression::calc
virtual bool calc()=0
Calculate the components of the field and return true if successful.
Foam::functionObjects::fieldExpression::write
virtual bool write()
Write the result field.
Definition: fieldExpression.C:124
Foam::functionObjects::fieldExpression::execute
virtual bool execute()
Calculate the result field.
Definition: fieldExpression.C:106
Foam::functionObjects::fieldExpression::resultName_
word resultName_
Name of result field.
Definition: fieldExpression.H:115
Foam::functionObjects::fieldExpression::TypeName
TypeName("fieldExpression")
Runtime type information.