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 // ************************************************************************* //
const char *const group
Group name for atomic constants.
dictionary dict
dictionary & switchSet(const char *subDictName, dictionary *&subDictPtr)
Internal function to lookup a sub-dictionary from controlDict.
Definition: debug.C:119
Dictionary reading and supplying the dimensioned constants used within OpenFOAM, particularly for the...
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
dictionary & dimensionedConstants()
dictionary * dimensionedConstantsPtr_(NULL)
A class for handling words, derived from string.
Definition: word.H:59
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensionedScalar dimensionedConstant(const word &group, const word &varName)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451