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 -------------------------------------------------------------------------------
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  <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 
62 See also
63  - Foam::functionObject
64  - Foam::functionObjects::fvMeshFunctionObject
65  - ExtendedCodeGuide::functionObjects::field::fieldExpression
66 
67 SourceFiles
68  fieldExpression.C
69  fieldExpressionTemplates.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef functionObjects_fieldExpression_H
74 #define functionObjects_fieldExpression_H
75 
76 #include "fvMeshFunctionObject.H"
77 #include "volFieldsFwd.H"
78 #include "zoneSubSet.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace functionObjects
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class fieldExpression Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class fieldExpression
92 :
93  public fvMeshFunctionObject
94 {
95 protected:
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;
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("fieldExpression");
126 
127 
128  // Constructors
129 
130  //- Construct from Time and dictionary
132  (
133  const word& name,
134  const Time& runTime,
135  const dictionary& dict,
136  const word& fieldName = word::null,
137  const word& resultName = word::null
138  );
139 
140  //- No copy construct
141  fieldExpression(const fieldExpression&) = delete;
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #ifdef NoRepository
175  #include "fieldExpressionTemplates.C"
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
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:65
fvMeshFunctionObject.H
fieldExpressionTemplates.C
Foam::functionObjects::fieldExpression::zoneSubSetPtr_
autoPtr< Detail::zoneSubSet > zoneSubSetPtr_
Sub-set mesh.
Definition: fieldExpression.H:135
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:93
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:144
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:75
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:129
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:120
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::functionObjects::fieldExpression::calc
virtual bool calc()=0
Calculate the components of the field and return true if successful.
zoneSubSet.H
Foam::functionObjects::fieldExpression::write
virtual bool write()
Write the result field.
Definition: fieldExpression.C:138
Foam::functionObjects::fieldExpression::execute
virtual bool execute()
Calculate the result field.
Definition: fieldExpression.C:120
Foam::functionObjects::fieldExpression::resultName_
word resultName_
Name of result field.
Definition: fieldExpression.H:132
Foam::functionObjects::fieldExpression::TypeName
TypeName("fieldExpression")
Runtime type information.