grad.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::grad
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes the gradient of an input field.
35 
36  The operation is limited to scalar and vector volume or surface fields, and
37  the output is a volume vector or tensor field.
38 
39  Operands:
40  \table
41  Operand | Type | Location
42  input | {vol,surface}{Scalar,Vector}Field <!--
43  --> | $FOAM_CASE/<time>/<inpField>
44  output file | - | -
45  output field | vol{Vector,Tensor}Field <!--
46  --> | $FOAM_CASE/<time>/<outField>
47  \endtable
48 
49 Usage
50  Minimal example by using \c system/controlDict.functions:
51  \verbatim
52  grad1
53  {
54  // Mandatory entries (unmodifiable)
55  type grad;
56  libs (fieldFunctionObjects);
57 
58  // Mandatory (inherited) entries (runtime modifiable)
59  field <field>;
60 
61  // Optional (inherited) entries
62  ...
63  }
64  \endverbatim
65 
66  where the entries mean:
67  \table
68  Property | Description | Type | Req'd | Dflt
69  type | Type name: grad | word | yes | -
70  libs | Library name: fieldFunctionObjects | word | yes | -
71  field | Name of the operand field | word | yes | -
72  \endtable
73 
74  The inherited entries are elaborated in:
75  - \link functionObject.H \endlink
76  - \link fieldExpression.H \endlink
77 
78  Minimal example by using the \c postProcess utility:
79  \verbatim
80  postProcess -func "grad(<field>)"
81  \endverbatim
82 
83 See also
84  - Foam::functionObject
85  - Foam::functionObjects::fvMeshFunctionObject
86  - Foam::functionObjects::fieldExpression
87  - ExtendedCodeGuide::functionObjects::field::grad
88 
89 SourceFiles
90  grad.C
91  gradTemplates.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef functionObjects_grad_H
96 #define functionObjects_grad_H
97 
98 #include "fieldExpression.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 namespace functionObjects
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class grad Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 class grad
112 :
113  public fieldExpression
114 {
115  // Private Member Functions
116 
117  //- Calculate the magnitude of the field and register the result
118  template<class Type>
119  bool calcGrad();
120 
121  //- Calculate the gradient field and return true if successful
122  virtual bool calc();
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("grad");
129 
130 
131  // Constructors
132 
133  //- Construct from Time and dictionary
134  grad
135  (
136  const word& name,
137  const Time& runTime,
138  const dictionary& dict
139  );
140 
141  //- No copy construct
142  grad(const grad&) = delete;
143 
144  //- No copy assignment
145  void operator=(const grad&) = delete;
146 
147 
148  //- Destructor
149  virtual ~grad() = default;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace functionObjects
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161  #include "gradTemplates.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::grad::grad
grad(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: grad.C:60
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
Foam::functionObjects::grad
Computes the gradient of an input field.
Definition: grad.H:154
Foam::functionObjects::grad::~grad
virtual ~grad()=default
Destructor.
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
Foam::functionObjects::grad::operator=
void operator=(const grad &)=delete
No copy assignment.
gradTemplates.C
dict
dictionary dict
Definition: searchingEngine.H:14
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::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::functionObjects::grad::TypeName
TypeName("grad")
Runtime type information.
fieldExpression.H