All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
profileModel.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-2021 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 "profileModel.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(profileModel, 0);
34  defineRunTimeSelectionTable(profileModel, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
39 
41 {
42  return fName_ != fileName::null;
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 :
50  dict_(dict),
51  name_(name),
52  fName_(fileName::null)
53 {
54  dict.readIfPresent("file", fName_);
55 }
56 
57 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
58 
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
66 {
67  return name_;
68 }
69 
70 
72 (
73  const dictionary& dict
74 )
75 {
76  const word& modelName(dict.dictName());
77 
78  const word modelType(dict.lookup("type"));
79 
80  Info<< " - creating " << modelType << " profile " << modelName << endl;
81 
82  dictionaryConstructorTable::iterator cstrIter =
83  dictionaryConstructorTablePtr_->find(modelType);
84 
85  if (cstrIter == dictionaryConstructorTablePtr_->end())
86  {
88  << "Unknown profile model type " << modelType
89  << nl << nl
90  << "Valid model types are :" << nl
91  << dictionaryConstructorTablePtr_->sortedToc()
92  << exit(FatalError);
93  }
94 
95  return autoPtr<profileModel>(cstrIter()(dict, modelName));
96 }
97 
98 
99 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:79
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:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
static const fileName null
An empty fileName.
Definition: fileName.H:97
const word & name() const
Return const access to the source name.
Definition: profileModel.C:65
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Macros for easy insertion into run-time selection tables.
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:121
virtual ~profileModel()
Destructor.
Definition: profileModel.C:59
fileName fName_
File name (optional)
Definition: profileModel.H:64
A class for handling words, derived from string.
Definition: word.H:59
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const word name_
Name of profile model.
Definition: profileModel.H:61
messageStream Info
profileModel(const dictionary &dict, const word &modelName)
Constructor.
Definition: profileModel.C:48
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
bool readFromFile() const
Return true if file name is set.
Definition: profileModel.C:40
static autoPtr< profileModel > New(const dictionary &dict)
Return a reference to the selected fvModel model.
Definition: profileModel.C:72
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864