log.C
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) 2018-2019 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 \*---------------------------------------------------------------------------*/
25 
26 #include "log.H"
27 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
37 
39  (
40  functionObject,
41  log,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 bool Foam::functionObjects::log::calc()
51 {
52  if (foundObject<volScalarField>(fieldName_))
53  {
54  const volScalarField& x = lookupObject<volScalarField>(fieldName_);
55 
56  // Cache the current debug setting for dimensionSet
57  const bool dimensionSetDebug = dimensionSet::debug;
58 
59  // Switch-off dimension checking if requested
60  if (!checkDimensions_)
61  {
62  dimensionSet::debug = 0;
63  }
64 
65  bool stored = store
66  (
67  resultName_,
68  clip_ ? Foam::log(max(x, clipValue_)) : Foam::log(x)
69  );
70 
71  // Reinstate dimension checking
72  if (!checkDimensions_)
73  {
74  dimensionSet::debug = dimensionSetDebug;
75  }
76 
77  return stored;
78  }
79  else
80  {
81  return false;
82  }
83 
84  return true;
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 
91 (
92  const word& name,
93  const Time& runTime,
94  const dictionary& dict
95 )
96 :
97  fieldExpression(name, runTime, dict, typeName),
98  clip_(false),
99  clipValue_(0),
100  checkDimensions_(true)
101 {
102  read(dict);
103 }
104 
105 
106 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
107 
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
115 {
116  if (dict.found("clip"))
117  {
118  clip_ = true;
119  dict.lookup("clip") >> clipValue_;
120  }
121 
122  checkDimensions_ = dict.lookupOrDefault<Switch>("checkDimensions", true);
123 
124  return true;
125 }
126 
127 
128 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the randomise data.
Definition: log.C:114
defineTypeNameAndDebug(Qdot, 0)
log(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: log.C:91
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual ~log()
Destructor.
Definition: log.C:108
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812