log.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) 2018-2019 OpenFOAM Foundation
9  Copyright (C) 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::log
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes the natural logarithm of an input \c volScalarField.
35 
36  \f[
37  f = s \ln(max(f_0, a)) + t
38  \f]
39 
40  where
41  \vartable
42  f | Output volScalarField
43  f_0 | Input volScalarField
44  \ln | Natural logarithm operator
45  a | Clip scalar
46  s | Scaling factor
47  t | Offset factor
48  \endvartable
49 
50  \table
51  Operand | Type | Location
52  input | volScalarField | $FOAM_CASE/<time>/<inpField>
53  output file | - | -
54  output field | volScalarField | $FOAM_CASE/<time>/<outField>
55  \endtable
56 
57 Usage
58  Minimal example by using \c system/controlDict.functions:
59  \verbatim
60  log1
61  {
62  // Mandatory entries (unmodifiable)
63  type log;
64  libs (fieldFunctionObjects);
65 
66  // Mandatory (inherited) entry (runtime modifiable)
67  field <inpField>;
68 
69  // Optional entries (runtime modifiable)
70  clip 1e-3;
71  checkDimensions false;
72  scale 1.0;
73  offset 0.0;
74 
75  // Optional (inherited) entries
76  ...
77  }
78  \endverbatim
79 
80  where the entries mean:
81  \table
82  Property | Description | Type | Req'd | Dflt
83  type | Type name: log | word | yes | -
84  libs | Library name: fieldFunctionObjects | word | yes | -
85  field | Name of the operand field | word | yes | -
86  clip | Value to clip the operand field values <!--
87  --> to prevent zero or negative input | scalar | no | SMALL
88  checkDimensions | Flag to check dimensions of the operand field <!--
89  --> | bool | no | true
90  scale | Scaling factor - \c s above | scalar | no | 1.0
91  offset | Offset factor - \c t above | scalar | no | 0.0
92  \endtable
93 
94  The inherited entries are elaborated in:
95  - \link functionObject.H \endlink
96  - \link fieldExpression.H \endlink
97 
98  Minimal example by using the \c postProcess utility:
99  \verbatim
100  postProcess -func "log(<inpField>)" -scale 1.0 -offset 0.0
101  \endverbatim
102 
103 Note
104  - Performs \f$\ln(max(x, a))\f$ where \f$x\f$ is a \c volScalarField, and
105  \f$a\f$ a clip scalar, equals to \c SMALL by default. This prevents zero or
106  negative input \f$x\f$, hence the domain error in the natural logarithm.
107  - Dimension checking can optionally be suspended if \f$x\f$ is dimensioned.
108 
109 See also
110  - Foam::functionObject
111  - Foam::functionObjects::fieldExpression
112  - Foam::functionObjects::fvMeshFunctionObject
113  - ExtendedCodeGuide::functionObjects::field::log
114 
115 SourceFiles
116  log.C
117 
118 \*---------------------------------------------------------------------------*/
119 
120 #ifndef functionObjects_log_H
121 #define functionObjects_log_H
122 
123 #include "fieldExpression.H"
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 namespace Foam
128 {
129 namespace functionObjects
130 {
131 
132 /*---------------------------------------------------------------------------*\
133  Class log Declaration
134 \*---------------------------------------------------------------------------*/
135 
136 class log
137 :
138  public fieldExpression
139 {
140  // Private Data
141 
142  //- Flag to check dimensions of the operand
143  Switch checkDimensions_;
144 
145  //- Value to clip the operand field values
146  //- to prevent zero or negative input
147  scalar clipValue_;
148 
149  //- Scaling factor
150  scalar scale_;
151 
152  //- Offset factor
153  scalar offset_;
154 
155 
156  // Private Member Functions
157 
158  //- Calculate the log field and return true if successful
159  virtual bool calc();
160 
161 
162 public:
163 
164  //- Runtime type information
165  TypeName("log");
166 
167 
168  // Constructors
169 
170  //- Construct from Time and dictionary
171  log
172  (
173  const word& name,
174  const Time& runTime,
175  const dictionary& dict
176  );
177 
178  //- No copy construct
179  log(const log&) = delete;
180 
181  //- No copy assignment
182  void operator=(const log&) = delete;
183 
184 
185  //- Destructor
186  virtual ~log() = default;
187 
188 
189  // Member Functions
190 
191  //- Read the randomise data
192  virtual bool read(const dictionary&);
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace functionObjects
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
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::log::operator=
void operator=(const log &)=delete
No copy assignment.
Foam::functionObjects::log::TypeName
TypeName("log")
Runtime type information.
Foam::functionObjects::log::~log
virtual ~log()=default
Destructor.
Foam::functionObjects::log::read
virtual bool read(const dictionary &)
Read the randomise data.
Definition: log.C:101
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::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
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
fieldExpression.H
Foam::functionObjects::log
Computes the natural logarithm of an input volScalarField.
Definition: log.H:227
Foam::functionObjects::log::log
log(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: log.C:83