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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "dimensionedConstants.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  dictionary* dimensionedConstantsPtr_(nullptr);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
42 {
43  return debug::switchSet
44  (
45  "DimensionedConstants",
47  );
48 }
49 
50 
52 (
53  const word& group,
54  const word& varName
55 )
56 {
58 
59  // Check that the entries exist.
60  // Note: should make FatalError robust instead!
61 
62  if (!dict.found("unitSet"))
63  {
64  std::cerr
65  << "Cannot find unitSet in dictionary " << dict.name()
66  << std::endl;
67  }
68 
69  const word unitSetCoeffs(dict.get<word>("unitSet") + "Coeffs");
70 
71  const dictionary* unitDictPtr = dict.findDict(unitSetCoeffs);
72 
73  if (!unitDictPtr)
74  {
75  std::cerr
76  << "Cannot find " << unitSetCoeffs << " in dictionary "
77  << dict.name() << std::endl;
78  }
79 
80  return dimensionedScalar(varName, unitDictPtr->subDict(group));
81 }
82 
83 
84 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dimensionedConstantsPtr_
dictionary * dimensionedConstantsPtr_(nullptr)
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
Foam::dimensionedConstants
dictionary & dimensionedConstants()
Definition: dimensionedConstants.C:41
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::dimensionedConstant
dimensionedScalar dimensionedConstant(const word &group, const word &varName)
Definition: dimensionedConstants.C:52
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::debug::switchSet
dictionary & switchSet(const char *subDictName, dictionary *&subDictPtr)
Internal function to lookup a sub-dictionary from controlDict.
Definition: debug.C:180
dimensionedConstants.H
Dictionary reading and supplying the dimensioned constants used within OpenFOAM, particularly for the...