functionObject.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 | Copyright (C) 2011-2015 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 defineDebugSwitchWithName(functionObject, "functionObject", 0);
36 defineRunTimeSelectionTable(functionObject, dictionary);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
44  name_(name)
45 {}
46 
47 
48 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
49 
51 (
52  const word& name,
53  const Time& t,
54  const dictionary& functionDict
55 )
56 {
57  const word functionType(functionDict.lookup("type"));
58 
59  if (debug)
60  {
61  Info<< "Selecting function " << functionType << endl;
62  }
63 
64  const_cast<Time&>(t).libs().open
65  (
66  functionDict,
67  "functionObjectLibs",
68  dictionaryConstructorTablePtr_
69  );
70 
71  if (!dictionaryConstructorTablePtr_)
72  {
74  << "Unknown function type "
75  << functionType << nl << nl
76  << "Table of functionObjects is empty" << endl
77  << exit(FatalError);
78  }
79 
80  dictionaryConstructorTable::iterator cstrIter =
81  dictionaryConstructorTablePtr_->find(functionType);
82 
83  if (cstrIter == dictionaryConstructorTablePtr_->end())
84  {
86  << "Unknown function type "
87  << functionType << nl << nl
88  << "Valid functions are : " << nl
89  << dictionaryConstructorTablePtr_->sortedToc() << endl
90  << exit(FatalError);
91  }
92 
93  return autoPtr<functionObject>(cstrIter()(name, t, functionDict));
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98 
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 {
107  return name_;
108 }
109 
110 
112 {
113  return execute(false);
114 }
115 
116 
118 {
119  return false;
120 }
121 
122 
124 {
125  return false;
126 }
127 
128 
129 Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
130 (
131  const word& name,
132  Istream& is
133 ) const
134 {
135  dictionary dict(is);
136  return functionObject::New(name, time_, dict);
137 }
138 
139 
140 // ************************************************************************* //
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::defineDebugSwitchWithName
defineDebugSwitchWithName(pointMVCWeight, "pointMVCWeight", 0)
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::functionObject::~functionObject
virtual ~functionObject()
Destructor.
Definition: functionObject.C:99
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::functionObject::New
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
Definition: functionObject.C:51
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::functionObject::adjustTimeStep
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: functionObject.C:123
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::functionObject::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: functionObject.C:111
Foam::autoPtr< Foam::functionObject >
Foam::functionObject::timeSet
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
Definition: functionObject.C:117
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::functionObject::name
virtual const word & name() const
Name.
Definition: functionObject.C:105
dlLibraryTable.H
dictionary.H
Foam::functionObject::functionObject
functionObject(const functionObject &)
Disallow default bitwise copy construct.
functionObject.H
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47