FreeFOAM The Cross-Platform CFD Toolkit
liquid.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 <OpenFOAM/error.H>
27 
28 #include "liquid.H"
29 #include <OpenFOAM/HashTable.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(liquid, 0);
37  defineRunTimeSelectionTable(liquid, Istream);
38 }
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 {
44  if (debug)
45  {
46  Info<< "liquid::New(Istream&) : "
47  << "constructing liquid"
48  << endl;
49  }
50 
51  word liquidType(is);
52 
53  word coeffs(is);
54 
55  if (coeffs == "defaultCoeffs")
56  {
57  ConstructorTable::iterator cstrIter =
58  ConstructorTablePtr_->find(liquidType);
59 
60  if (cstrIter == ConstructorTablePtr_->end())
61  {
62  FatalErrorIn("liquid::New(Istream&)")
63  << "Unknown liquid type " << liquidType
64  << nl << nl
65  << "Valid liquid types are:" << nl
66  << ConstructorTablePtr_->sortedToc()
67  << abort(FatalError);
68  }
69 
70  return autoPtr<liquid>(cstrIter()());
71  }
72  else if (coeffs == "coeffs")
73  {
74  IstreamConstructorTable::iterator cstrIter =
75  IstreamConstructorTablePtr_->find(liquidType);
76 
77  if (cstrIter == IstreamConstructorTablePtr_->end())
78  {
79  FatalErrorIn("liquid::New(Istream&)")
80  << "Unknown liquid type " << liquidType
81  << endl << endl
82  << "Valid liquid types are:" << nl
83  << IstreamConstructorTablePtr_->sortedToc()
84  << abort(FatalError);
85  }
86 
87  return autoPtr<liquid>(cstrIter()(is));
88  }
89  else
90  {
91  FatalErrorIn("liquid::New(Istream&)")
92  << "liquid type " << liquidType
93  << ", option " << coeffs << " given"
94  << ", should be coeffs or defaultCoeffs"
95  << abort(FatalError);
96 
97  return autoPtr<liquid>(NULL);
98  }
99 }
100 
101 
102 // ************************ vim: set sw=4 sts=4 et: ************************ //