thermophysicalFunction.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 "error.H"
27 
28 #include "thermophysicalFunction.H"
29 #include "HashTable.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(thermophysicalFunction, 0);
36  defineRunTimeSelectionTable(thermophysicalFunction, Istream);
37  defineRunTimeSelectionTable(thermophysicalFunction, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  Istream& is
46 )
47 {
48  if (debug)
49  {
50  Info<< "thermophysicalFunction::New(Istream&) : "
51  << "constructing thermophysicalFunction"
52  << endl;
53  }
54 
55  const word thermophysicalFunctionType(is);
56 
57  IstreamConstructorTable::iterator cstrIter =
58  IstreamConstructorTablePtr_->find(thermophysicalFunctionType);
59 
60  if (cstrIter == IstreamConstructorTablePtr_->end())
61  {
63  << "Unknown thermophysicalFunction type "
64  << thermophysicalFunctionType
65  << nl << nl
66  << "Valid thermophysicalFunction types are :" << endl
67  << IstreamConstructorTablePtr_->sortedToc()
68  << abort(FatalError);
69  }
70 
71  return autoPtr<thermophysicalFunction>(cstrIter()(is));
72 }
73 
74 
76 (
77  const dictionary& dict
78 )
79 {
80  if (debug)
81  {
82  Info<< "thermophysicalFunction::New(const dictionary&) : "
83  << "constructing thermophysicalFunction"
84  << endl;
85  }
86 
87  const word thermophysicalFunctionType(dict.lookup("functionType"));
88 
89  dictionaryConstructorTable::iterator cstrIter =
90  dictionaryConstructorTablePtr_->find(thermophysicalFunctionType);
91 
92  if (cstrIter == IstreamConstructorTablePtr_->end())
93  {
95  << "Unknown thermophysicalFunction type "
96  << thermophysicalFunctionType
97  << nl << nl
98  << "Valid thermophysicalFunction types are :" << endl
99  << dictionaryConstructorTablePtr_->sortedToc()
100  << abort(FatalError);
101  }
102 
103  return autoPtr<thermophysicalFunction>(cstrIter()(dict));
104 }
105 
106 
107 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
HashTable.H
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
error.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
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
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::thermophysicalFunction::New
static autoPtr< thermophysicalFunction > New(Istream &is)
Return pointer to new thermophysicalFunction created from input.
Definition: thermophysicalFunction.C:44
thermophysicalFunction.H