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-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 "solidProperties.H"
27 #include "Switch.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
32 {
33  if (debug)
34  {
35  Info<< "solidProperties::New(Istream&): constructing solid"
36  << endl;
37  }
38 
39  const word solidType(is);
40  const word coeffs(is);
41 
42  if (coeffs == "defaultCoeffs")
43  {
44  ConstructorTable::iterator cstrIter =
45  ConstructorTablePtr_->find(solidType);
46 
47  if (cstrIter == ConstructorTablePtr_->end())
48  {
50  << "Unknown solidProperties type " << solidType << nl << nl
51  << "Valid solidProperties types are :" << endl
52  << ConstructorTablePtr_->sortedToc()
53  << exit(FatalError);
54  }
55 
56  return autoPtr<solidProperties>(cstrIter()());
57  }
58  else if (coeffs == "coeffs")
59  {
61  }
62  else
63  {
65  << "solidProperties type " << solidType
66  << ", option " << coeffs << " given"
67  << ", should be coeffs or defaultCoeffs"
68  << exit(FatalError);
69 
70  return autoPtr<solidProperties>(NULL);
71  }
72 }
73 
74 
76 (
77  const dictionary& dict
78 )
79 {
80  if (debug)
81  {
82  Info<< "solidProperties::New(const dictionary&): constructing solid"
83  << endl;
84  }
85 
86  const word solidType(dict.dictName());
87  const Switch defaultCoeffs(dict.lookup("defaultCoeffs"));
88 
89  if (defaultCoeffs)
90  {
91  ConstructorTable::iterator cstrIter =
92  ConstructorTablePtr_->find(solidType);
93 
94  if (cstrIter == ConstructorTablePtr_->end())
95  {
97  << "Unknown solidProperties type " << solidType << nl << nl
98  << "Valid solidProperties types are :" << endl
99  << ConstructorTablePtr_->sortedToc()
100  << exit(FatalError);
101  }
102 
103  return autoPtr<solidProperties>(cstrIter()());
104  }
105  else
106  {
108  (
109  new solidProperties
110  (
111  dict.subDict(solidType + "Coeffs")
112  )
113  );
114  }
115 }
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::solidProperties::New
static autoPtr< solidProperties > New(Istream &is)
Return a pointer to a new solidProperties created from input.
Definition: solidPropertiesNew.C:31
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::solidProperties
The thermophysical properties of a solid.
Definition: solidProperties.H:60
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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
Switch.H
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::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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::solidProperties::solidProperties
solidProperties(scalar rho, scalar Cp, scalar K, scalar Hf, scalar emissivity)
Construct from components.
Definition: solidProperties.C:41
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
solidProperties.H