dimensionedConstants.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 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 "dimensionedConstants.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 dictionary* dimensionedConstantsPtr_(NULL);
36 
38 {
39  return debug::switchSet
40  (
41  "DimensionedConstants",
43  );
44 }
45 
46 
48 (
49  const word& group,
50  const word& varName
51 )
52 {
54 
55  // Check that the entries exist.
56  // Note: should make FatalError robust instead!
57 
58  if (!dict.found("unitSet"))
59  {
60  std::cerr<< "Cannot find unitSet in dictionary " << dict.name()
61  << std::endl;
62  }
63 
64  const word unitSetCoeffs(word(dict.lookup("unitSet")) + "Coeffs");
65 
66  if (!dict.found(unitSetCoeffs))
67  {
68  std::cerr<< "Cannot find " << unitSetCoeffs << " in dictionary "
69  << dict.name() << std::endl;
70  }
71 
72  dictionary& unitDict = dict.subDict(unitSetCoeffs);
73 
74  dictionary& groupDict = unitDict.subDict(group);
75 
76  return dimensionedScalar(groupDict.lookup(varName));
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 } // End namespace Foam
83 
84 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dictionaryName::name
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
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::constant::atomic::group
const char *const group
Group name for atomic constants.
Definition: atomicConstants.C:40
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dimensionedConstant
dimensionedScalar dimensionedConstant(const word &group, const word &varName)
Definition: dimensionedConstants.C:48
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::dimensionedConstants
dictionary & dimensionedConstants()
Definition: dimensionedConstants.C:37
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::debug::switchSet
dictionary & switchSet(const char *subDictName, dictionary *&subDictPtr)
Internal function to lookup a sub-dictionary from controlDict.
Definition: debug.C:117
dimensionedConstants.H
Dictionary reading and supplying the dimensioned constants used within OpenFOAM, particularly for the...
Foam::dimensionedConstantsPtr_
dictionary * dimensionedConstantsPtr_(NULL)