Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::log
29
30Group
31 grpFieldFunctionObjects
32
33Description
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 | <time>/inputField
53 output file | - | -
54 output field | volScalarField | <time>/outputField
55 \endtable
56
57Usage
58 Minimal example by using \c system/controlDict.functions:
59 \verbatim
60 logFO
61 {
62 // Mandatory entries
63 type log;
64 libs (fieldFunctionObjects);
65 field <word>;
66
67 // Optional entries
68 clip <scalar>;
69 checkDimensions <bool>;
70 scale <scalar>;
71 offset <scalar>;
72
73 // Inherited entries
74 ...
75 }
76 \endverbatim
77
78 where the entries mean:
79 \table
80 Property | Description | Type | Reqd | Deflt
81 type | Type name: log | word | yes | -
82 libs | Library name: fieldFunctionObjects | word | yes | -
83 field | Name of the operand field | word | yes | -
84 clip | Value to clip the operand field values <!--
85 --> to prevent zero or negative input | scalar | no | SMALL
86 checkDimensions | Flag to check dimensions of the operand field <!--
87 --> | bool | no | true
88 scale | Scaling factor - \c s above | scalar | no | 1.0
89 offset | Offset factor - \c t above | scalar | no | 0.0
90 \endtable
91
92 The inherited entries are elaborated in:
93 - \link fieldExpression.H \endlink
94
95Note
96 - Performs \f$\ln(max(x, a))\f$ where \f$x\f$ is a \c volScalarField, and
97 \f$a\f$ a clip scalar, equals to \c SMALL by default. This prevents zero or
98 negative input \f$x\f$, hence the domain error in the natural logarithm.
99 - Dimension checking can optionally be suspended if \f$x\f$ is dimensioned.
100
101SourceFiles
102 log.C
103
104\*---------------------------------------------------------------------------*/
105
106#ifndef Foam_functionObjects_log_H
107#define Foam_functionObjects_log_H
108
109#include "fieldExpression.H"
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113namespace Foam
114{
115namespace functionObjects
116{
117
118/*---------------------------------------------------------------------------*\
119 Class log Declaration
120\*---------------------------------------------------------------------------*/
121
122class log
123:
124 public fieldExpression
125{
126 // Private Data
127
128 //- Flag to check dimensions of the operand
129 Switch checkDimensions_;
130
131 //- Value to clip the operand field values
132 //- to prevent zero or negative input
133 scalar clipValue_;
134
135 //- Scaling factor
136 scalar scale_;
137
138 //- Offset factor
139 scalar offset_;
140
141
142 // Private Member Functions
143
144 //- Calculate the log field and return true if successful
145 virtual bool calc();
146
147
148public:
149
150 //- Runtime type information
151 TypeName("log");
152
153
154 // Constructors
155
156 //- Construct from name, Time and dictionary
157 log
158 (
159 const word& name,
160 const Time& runTime,
161 const dictionary& dict
162 );
163
164 //- No copy construct
165 log(const log&) = delete;
166
167 //- No copy assignment
168 void operator=(const log&) = delete;
169
170
171 //- Destructor
172 virtual ~log() = default;
173
174
175 // Member Functions
176
177 //- Read the function-object dictionary
178 virtual bool read(const dictionary& dict);
179};
180
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184} // End namespace functionObjects
185} // End namespace Foam
186
187// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188
189#endif
190
191// ************************************************************************* //
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const word & name() const noexcept
Return the name of this functionObject.
bool log
Flag to write log into Info.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
Computes the natural logarithm of an input volScalarField.
Definition log.H:212
log(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition log.C:76
TypeName("log")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition log.C:94
void operator=(const log &)=delete
No copy assignment.
virtual ~log()=default
Destructor.
log(const log &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68