FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/dictionary.H>
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
38 Foam::functionObject::functionObject(const word& name)
39 :
40  name_(name)
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
45 
47 (
48  const word& name,
49  const Time& t,
50  const dictionary& functionDict
51 )
52 {
53  word functionType(functionDict.lookup("type"));
54 
55  if (debug)
56  {
57  Info<< "Selecting function " << functionType << endl;
58  }
59 
61  (
62  functionDict,
63  "functionObjectLibs",
64  dictionaryConstructorTablePtr_
65  );
66 
67  if (!dictionaryConstructorTablePtr_)
68  {
70  (
71  "functionObject::New"
72  "(const word& name, const Time&, const dictionary&)"
73  ) << "Unknown function type "
74  << functionType << nl << nl
75  << "Table of functionObjects is empty" << endl
76  << exit(FatalError);
77  }
78 
79  dictionaryConstructorTable::iterator cstrIter =
80  dictionaryConstructorTablePtr_->find(functionType);
81 
82  if (cstrIter == dictionaryConstructorTablePtr_->end())
83  {
85  (
86  "functionObject::New"
87  "(const word& name, const Time&, const dictionary&)"
88  ) << "Unknown function type "
89  << functionType << nl << nl
90  << "Valid functions are : " << nl
91  << dictionaryConstructorTablePtr_->sortedToc() << endl
92  << exit(FatalError);
93  }
94 
95  return autoPtr<functionObject>(cstrIter()(name, t, functionDict));
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  return name_;
110 }
111 
112 
114 {
115  return execute();
116 }
117 
118 
119 Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
120 (
121  const word& name,
122  Istream& is
123 ) const
124 {
125  dictionary dict(is);
126  return functionObject::New(name, time_, dict);
127 }
128 
129 
130 // ************************ vim: set sw=4 sts=4 et: ************************ //