log.C
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-2021 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
27\*---------------------------------------------------------------------------*/
28
29#include "log.H"
30#include "volFields.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace functionObjects
38{
41}
42}
43
44
45// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46
47bool Foam::functionObjects::log::calc()
48{
49 if (foundObject<volScalarField>(fieldName_))
50 {
51 const volScalarField& x = lookupObject<volScalarField>(fieldName_);
52
53 // Switch-off dimension checking if requested
54 const bool oldDimChecking = dimensionSet::checking();
55
56 if (!checkDimensions_)
57 {
59 }
60
61 bool stored = store
62 (
64 scale_*Foam::log(max(x, clipValue_)) + offset_
65 );
66
67 // Reinstate dimension checking
68 if (!checkDimensions_)
69 {
70 dimensionSet::checking(oldDimChecking);
71 }
72
73 return stored;
74 }
75
76 return false;
77}
78
79
80// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81
83(
84 const word& name,
85 const Time& runTime,
86 const dictionary& dict
87)
88:
89 fieldExpression(name, runTime, dict, typeName),
90 checkDimensions_(true),
91 clipValue_(SMALL),
92 scale_(1.0),
93 offset_(0.0)
94{
95 read(dict);
96}
97
98
99// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100
102{
104 {
105 checkDimensions_ = dict.getOrDefault<Switch>("checkDimensions", true);
106 clipValue_ =
107 dict.getCheckOrDefault<scalar>
108 (
109 "clip",
110 SMALL,
111 scalarMinMax::ge(SMALL)
112 );
113 scale_ = dict.getOrDefault<scalar>("scale", 1.0);
114 offset_ = dict.getOrDefault<scalar>("offset", 0.0);
115
116 return true;
117 }
118
119 return false;
120}
121
122
123// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static MinMax< scalar > ge(const scalar &minVal)
A semi-infinite range from minVal to the type max.
Definition: MinMaxI.H:31
virtual bool read()
Re-read model coefficients if they have changed.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:78
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
static bool checking() noexcept
True if dimension checking is enabled (the usual default)
Definition: dimensionSet.H:229
Abstract base-class for Time/database function objects.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
word resultName_
Name of result field.
word fieldName_
Name of field to process.
Computes the natural logarithm of an input volScalarField.
Definition: log.H:230
virtual bool read(const dictionary &)
Read the randomise data.
Definition: log.C:101
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
engineTime & runTime
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
dimensionedScalar log(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict