FreeFOAM The Cross-Platform CFD Toolkit
newSolid.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 "solid.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
31 {
32  if (debug)
33  {
34  Info<< "solid::New(Istream&): "
35  << "constructing solid"
36  << endl;
37  }
38 
39  word solidType(is);
40 
41  word coeffs(is);
42 
43  if (coeffs == "defaultCoeffs")
44  {
45  ConstructorTable::iterator cstrIter =
46  ConstructorTablePtr_->find(solidType);
47 
48  if (cstrIter == ConstructorTablePtr_->end())
49  {
50  FatalErrorIn("solid::New(Istream&)")
51  << "Unknown solid type " << solidType << nl << nl
52  << "Valid solid types are:" << endl
53  << ConstructorTablePtr_->sortedToc()
54  << exit(FatalError);
55  }
56 
57  return autoPtr<solid>(cstrIter()());
58  }
59  else if (coeffs == "coeffs")
60  {
61  IstreamConstructorTable::iterator cstrIter =
62  IstreamConstructorTablePtr_->find(solidType);
63 
64  if (cstrIter == IstreamConstructorTablePtr_->end())
65  {
66  FatalErrorIn("solid::New(Istream&)")
67  << "Unknown solid type " << solidType << nl << nl
68  << "Valid solid types are:" << endl
69  << IstreamConstructorTablePtr_->sortedToc()
70  << exit(FatalError);
71  }
72 
73  return autoPtr<solid>(cstrIter()(is));
74  }
75  else
76  {
77  FatalErrorIn("solid::New(Istream&)")
78  << "solid type " << solidType
79  << ", option " << coeffs << " given"
80  << ", should be coeffs or defaultCoeffs"
81  << exit(FatalError);
82 
83  return autoPtr<solid>(NULL);
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //