All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
functionObject.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) 2011-2020 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 "functionObject.H"
27 #include "dictionary.H"
28 #include "dlLibraryTable.H"
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(functionObject, 0);
36  defineRunTimeSelectionTable(functionObject, dictionary);
37 }
38 
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 :
46  name_(name),
47  log(false),
48  executeAtStart_(true)
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
53 
55 (
56  const word& name,
57  const Time& runTime,
58  const dictionary& dict
59 )
60 {
61  const word functionType(dict.lookup("type"));
62 
63  if (debug)
64  {
65  Info<< "Selecting function " << functionType << endl;
66  }
67 
68  if (dict.found("functionObjectLibs"))
69  {
70  libs.open
71  (
72  dict,
73  "functionObjectLibs",
74  dictionaryConstructorTablePtr_
75  );
76  }
77  else
78  {
79  libs.open
80  (
81  dict,
82  "libs",
83  dictionaryConstructorTablePtr_
84  );
85  }
86 
87  if (!dictionaryConstructorTablePtr_)
88  {
90  << "Unknown function type "
91  << functionType << nl << nl
92  << "Table of functionObjects is empty" << endl
93  << exit(FatalError);
94  }
95 
96  dictionaryConstructorTable::iterator cstrIter =
97  dictionaryConstructorTablePtr_->find(functionType);
98 
99  if (cstrIter == dictionaryConstructorTablePtr_->end())
100  {
102  << "Unknown function type "
103  << functionType << nl << nl
104  << "Valid functions are : " << nl
105  << dictionaryConstructorTablePtr_->sortedToc() << endl
106  << exit(FatalError);
107  }
108 
109  return autoPtr<functionObject>(cstrIter()(name, runTime, dict));
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
114 
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 {
123  return name_;
124 }
125 
126 
128 {
129  log = dict.lookupOrDefault<Switch>("log", postProcess);
130 
131  if (!postProcess)
132  {
133  executeAtStart_ = dict.lookupOrDefault<Switch>("executeAtStart", true);
134  }
135 
136  return true;
137 }
138 
139 
141 {
142  return executeAtStart_;
143 }
144 
145 
147 {
148  return true;
149 }
150 
151 
153 {
154  return false;
155 }
156 
157 
159 {
160  return vGreat;
161 }
162 
163 
165 {}
166 
167 
169 {}
170 
171 
172 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
virtual ~functionObject()
Destructor.
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const word & name() const
Return the name of this functionObject.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
static bool postProcess
Global post-processing mode switch.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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
dlLibraryTable libs
Table of loaded dynamic libraries.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool end()
Called when Time::run() determines that the time-loop exits.
A class for handling words, derived from string.
Definition: word.H:59
virtual bool setTimeStep()
Called by Time::setDeltaT(). Allows the functionObject to override.
virtual bool read(const dictionary &)
Read and set the functionObject if its data have changed.
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Switch executeAtStart_
Switch write log to Info.
defineTypeNameAndDebug(combustionModel, 0)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
functionObject(const word &name)
Construct from components.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Switch log
Switch write log to Info.
virtual scalar timeToNextWrite()
Called by Time::adjustTimeStep(). Allows the functionObject to.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
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
virtual bool executeAtStart() const
Return true if the functionObject should be executed at the start.