fieldsExpression.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::fieldsExpression
26 
27 Description
28 
29 See also
30  Foam::functionObjects::fvMeshFunctionObject
31 
32 SourceFiles
33  fieldsExpression.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef functionObjects_fieldsExpression_H
38 #define functionObjects_fieldsExpression_H
39 
40 #include "fvMeshFunctionObject.H"
41 #include "volFieldsFwd.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace functionObjects
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class fieldsExpression Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class fieldsExpression
55 :
57 {
58 protected:
59 
60  // Protected member data
61 
62  //- Names of fields to process
64 
65  //- Name of result fields
67 
68 
69  // Protected member functions
70 
71  //- Set the result name
72  void setResultName
73  (
74  const word& functionName,
75  const wordList& defaultFieldNames = wordList::null()
76  );
77 
78  //- Operate on the fields and store the result. Supported overload.
79  template
80  <
81  template<class> class GeoField,
82  template<class ...> class Op,
83  class TypeA,
84  class TypeB,
85  class Enable = Op<TypeA, TypeB>
86  >
87  bool opAndStore
88  (
89  const GeoField<TypeA>& a,
90  const GeoField<TypeB>& b
91  );
92 
93  //- Operate on the fields and store the result. Not-supported overload.
94  template
95  <
96  template<class> class GeoField,
97  template<class ...> class Op,
98  class ... Args
99  >
100  bool opAndStore(const Args& ...);
101 
102  //- Fold the fields expression up one place
103  template
104  <
105  template<class> class GeoField,
106  template<class ...> class Op,
107  class TypeA,
108  class TypeB
109  >
110  bool foldAB(const label i);
111 
112  //- Fold the fields expression up one place
113  template
114  <
115  template<class> class GeoField,
116  template<class ...> class Op,
117  class TypeA
118  >
119  bool foldA(const label i);
120 
121  //- Fold the fields expression up one place
122  template
123  <
124  template<class> class GeoField,
125  template<class ...> class Op
126  >
127  bool fold(const label i);
128 
129  //- Calculate and store the fields expression for the given geometric
130  // field type and operation
131  template<template<class> class GeoField, template<class ...> class Op>
132  bool calcGeoFieldOp();
133 
134  //- Calculate and store the fields expression for the given operation
135  template<template<class ...> class Op>
136  bool calcOp();
137 
138  //- Perform calculation on the list of fields and return success
139  virtual bool calc() = 0;
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("fieldsExpression");
146 
147 
148  // Constructors
149 
150  //- Construct from Time and dictionary
152  (
153  const word& name,
154  const Time& runTime,
155  const dictionary& dict,
157  const word& resultName = word::null
158  );
159 
160  //- Disallow default bitwise copy construction
161  fieldsExpression(const fieldsExpression&) = delete;
162 
163 
164  //- Destructor
165  virtual ~fieldsExpression();
166 
167 
168  // Member Functions
169 
170  //- Read the fieldsExpression data
171  virtual bool read(const dictionary&);
172 
173  //- Calculate the result fields
174  virtual bool execute();
175 
176  //- Write the result fields
177  virtual bool write();
178 
179  //- Clear the result fields from the objectRegistry
180  virtual bool clear();
181 
182 
183  // Member Operators
184 
185  //- Disallow default bitwise assignment
186  void operator=(const fieldsExpression&) = delete;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace functionObjects
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #ifdef NoRepository
198  #include "fieldsExpressionTemplates.C"
199 #endif
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual bool write()
Write the result fields.
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void setResultName(const word &functionName, const wordList &defaultFieldNames=wordList::null())
Set the result name.
virtual bool read(const dictionary &)
Read the fieldsExpression data.
engineTime & runTime
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
#define Op(opName, op)
Definition: ops.H:101
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
wordList fieldNames_
Names of fields to process.
static List< word > fieldNames
Definition: globalFoam.H:46
bool foldA(const label i)
Fold the fields expression up one place.
fieldsExpression(const word &name, const Time &runTime, const dictionary &dict, const wordList &fieldNames=wordList::null(), const word &resultName=word::null)
Construct from Time and dictionary.
A functionName is a word starting with &#39;#&#39;.
Definition: functionName.H:57
virtual bool execute()
Calculate the result fields.
A class for handling words, derived from string.
Definition: word.H:59
virtual bool clear()
Clear the result fields from the objectRegistry.
static const word null
An empty word.
Definition: word.H:77
bool calcGeoFieldOp()
Calculate and store the fields expression for the given geometric.
bool foldAB(const label i)
Fold the fields expression up one place.
bool fold(const label i)
Fold the fields expression up one place.
word resultName_
Name of result fields.
bool calcOp()
Calculate and store the fields expression for the given operation.
virtual bool calc()=0
Perform calculation on the list of fields and return success.
void operator=(const fieldsExpression &)=delete
Disallow default bitwise assignment.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
bool opAndStore(const GeoField< TypeA > &a, const GeoField< TypeB > &b)
Operate on the fields and store the result. Supported overload.
TypeName("fieldsExpression")
Runtime type information.
Namespace for OpenFOAM.