solidPropertiesNew.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-2016 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 "solidProperties.H"
27 #include "Switch.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
32 {
33  if (debug)
34  {
35  InfoInFunction << "Constructing solid" << endl;
36  }
37 
38  const word solidType(is);
39  const word coeffs(is);
40 
41  if (coeffs == "defaultCoeffs")
42  {
43  ConstructorTable::iterator cstrIter =
44  ConstructorTablePtr_->find(solidType);
45 
46  if (cstrIter == ConstructorTablePtr_->end())
47  {
49  << "Unknown solidProperties type " << solidType << nl << nl
50  << "Valid solidProperties types are :" << endl
51  << ConstructorTablePtr_->sortedToc()
52  << exit(FatalError);
53  }
54 
55  return autoPtr<solidProperties>(cstrIter()());
56  }
57  else if (coeffs == "coeffs")
58  {
60  }
61  else
62  {
64  << "solidProperties type " << solidType
65  << ", option " << coeffs << " given"
66  << ", should be coeffs or defaultCoeffs"
67  << exit(FatalError);
68 
69  return autoPtr<solidProperties>(NULL);
70  }
71 }
72 
73 
75 (
76  const dictionary& dict
77 )
78 {
79  if (debug)
80  {
81  InfoInFunction << "Constructing solid" << endl;
82  }
83 
84  const word solidType(dict.dictName());
85  const Switch defaultCoeffs(dict.lookup("defaultCoeffs"));
86 
87  if (defaultCoeffs)
88  {
89  ConstructorTable::iterator cstrIter =
90  ConstructorTablePtr_->find(solidType);
91 
92  if (cstrIter == ConstructorTablePtr_->end())
93  {
95  << "Unknown solidProperties type " << solidType << nl << nl
96  << "Valid solidProperties types are :" << endl
97  << ConstructorTablePtr_->sortedToc()
98  << exit(FatalError);
99  }
100 
101  return autoPtr<solidProperties>(cstrIter()());
102  }
103  else
104  {
106  (
107  new solidProperties
108  (
109  dict.subDict(solidType + "Coeffs")
110  )
111  );
112  }
113 }
114 
115 
116 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static autoPtr< solidProperties > New(Istream &is)
Return a pointer to a new solidProperties created from input.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
A class for handling words, derived from string.
Definition: word.H:59
solidProperties(scalar rho, scalar Cp, scalar K, scalar Hf, scalar emissivity)
Construct from components.
static const char nl
Definition: Ostream.H:262
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451
#define InfoInFunction
Report an information message using Foam::Info.