pyrolysisModelNew.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-2013 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 "pyrolysisModel.H"
27 #include "fvMesh.H"
28 #include "Time.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace regionModels
35 {
36 namespace pyrolysisModels
37 {
38 
39 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
40 
41 autoPtr<pyrolysisModel> pyrolysisModel::New
42 (
43  const fvMesh& mesh,
44  const word& regionType
45 )
46 {
47  // get model name, but do not register the dictionary
48  const word modelType
49  (
51  (
52  IOobject
53  (
54  regionType + "Properties",
55  mesh.time().constant(),
56  mesh,
59  false
60  )
61  ).lookup("pyrolysisModel")
62  );
63 
64  Info<< "Selecting pyrolysisModel " << modelType << endl;
65 
66  meshConstructorTable::iterator cstrIter =
67  meshConstructorTablePtr_->find(modelType);
68 
69  if (cstrIter == meshConstructorTablePtr_->end())
70  {
71  FatalErrorIn("pyrolysisModel::New(const fvMesh&, const word&)")
72  << "Unknown pyrolysisModel type " << modelType
73  << nl << nl << "Valid pyrolisisModel types are:" << nl
74  << meshConstructorTablePtr_->sortedToc()
75  << exit(FatalError);
76  }
77 
78  return autoPtr<pyrolysisModel>(cstrIter()(modelType, mesh, regionType));
79 }
80 
81 
83 (
84  const fvMesh& mesh,
85  const dictionary& dict,
86  const word& regionType
87 )
88 {
89 
90  const word modelType = dict.lookup("pyrolysisModel");
91 
92  Info<< "Selecting pyrolysisModel " << modelType << endl;
93 
94  dictionaryConstructorTable::iterator cstrIter =
95  dictionaryConstructorTablePtr_->find(modelType);
96 
97  if (cstrIter == dictionaryConstructorTablePtr_->end())
98  {
100  (
101  "pyrolysisModel::New"
102  "("
103  "const fvMesh&, "
104  "const dictionary&, "
105  "const word&"
106  ")"
107  )
108  << "Unknown pyrolysisModel type " << modelType
109  << nl << nl << "Valid pyrolisisModel types are:" << nl
110  << dictionaryConstructorTablePtr_->sortedToc()
111  << exit(FatalError);
112  }
113 
115  (
116  cstrIter()
117  (
118  modelType,
119  mesh,
120  dict,
121  regionType
122  )
123  );
124 }
125 
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace surfaceFilmModels
130 } // End namespace regionModels
131 } // End namespace Foam
132 
133 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
messageStream Info
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
dictionary dict
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
static autoPtr< pyrolysisModel > New(const fvMesh &mesh, const word &regionType="pyrolysis")
Return a reference to the selected pyrolysis model.