thermophysicalFunction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 "thermophysicalFunction.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(thermophysicalFunction, 0);
34  defineRunTimeSelectionTable(thermophysicalFunction, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const dictionary& dict,
43  const word& name
44 )
45 {
46  if (debug)
47  {
49  << "Constructing thermophysicalFunction"
50  << endl;
51  }
52 
53  if (dict.isDict(name))
54  {
55  const dictionary& funcDict(dict.subDict(name));
56  const word thermophysicalFunctionType(funcDict.lookup("type"));
57 
58  dictionaryConstructorTable::iterator cstrIter =
59  dictionaryConstructorTablePtr_->find(thermophysicalFunctionType);
60 
61  if (cstrIter == dictionaryConstructorTablePtr_->end())
62  {
64  << "Unknown thermophysicalFunction type "
65  << thermophysicalFunctionType
66  << nl << nl
67  << "Valid thermophysicalFunction types are :" << endl
68  << dictionaryConstructorTablePtr_->sortedToc()
69  << abort(FatalError);
70  }
71 
72  return autoPtr<thermophysicalFunction>(cstrIter()(funcDict));
73  }
74  else
75  {
77  (
79  );
80  }
81 }
82 
83 
84 
85 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 
87 void Foam::thermophysicalFunction::write(Ostream& os, const word& name) const
88 {
89  os << nl;
90  writeKeyword(os, name)
91  << nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
92  write(os);
93  os << decrIndent << indent << token::END_BLOCK << endl;
94 }
95 
96 
97 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
98 
100 {
101  f.write(os);
102  return os;
103 }
104 
105 
106 // ************************************************************************* //
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
Definition: keyType.C:155
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static autoPtr< thermophysicalFunction > New(const dictionary &dict, const word &name)
Return pointer to new thermophysicalFunction created from dict.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:888
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:934
Abstract base class for thermo-physical functions.
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
A class for handling words, derived from string.
Definition: word.H:59
virtual void write(Ostream &os) const =0
Write the function coefficients.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
labelList f(nPoints)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Ostream & operator<<(Ostream &, const ensightPart &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Undefined function which returns an error when called.
Namespace for OpenFOAM.
#define InfoInFunction
Report an information message using Foam::Info.