pow.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) 2020 OpenCFD Ltd.
9 ------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "pow.H"
29 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace functionObjects
37 {
39  addToRunTimeSelectionTable(functionObject, pow, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 bool Foam::functionObjects::pow::calc()
47 {
48  if (foundObject<volScalarField>(fieldName_))
49  {
50  const volScalarField& x = lookupObject<volScalarField>(fieldName_);
51 
52  // Cache the current debug setting for dimensionSet
53  const bool dimensionSetDebug = dimensionSet::debug;
54 
55  // Switch-off dimension checking if requested
56  if (!checkDimensions_)
57  {
59  }
60 
61  bool stored = store
62  (
64  scale_*Foam::pow(x, n_) + offset_
65  );
66 
67  // Reinstate dimension checking
68  if (!checkDimensions_)
69  {
70  dimensionSet::debug = dimensionSetDebug;
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  n_(0.0),
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  n_ = dict.get<scalar>("n");
107  scale_ = dict.getOrDefault<scalar>("scale", 1.0);
108  offset_ = dict.getOrDefault<scalar>("offset", 0.0);
109 
110  return true;
111  }
112 
113  return false;
114 }
115 
116 
117 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
volFields.H
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:62
Foam::functionObjects::pow::pow
pow(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: pow.C:83
pow.H
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::functionObjects::pow::read
virtual bool read(const dictionary &)
Read the randomise data.
Definition: pow.C:101
Foam::functionObjects::fieldExpression::read
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
Definition: fieldExpression.C:91
Foam::functionObjects::regionFunctionObject::store
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
Definition: regionFunctionObjectTemplates.C:107
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::fieldExpression::fieldName_
word fieldName_
Name of field to process.
Definition: fieldExpression.H:112
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Read optional controls.
Definition: regionFunctionObject.C:173
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:103
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::functionObjects::fieldExpression::resultName_
word resultName_
Name of result field.
Definition: fieldExpression.H:115