1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Class for handling debugging switches.
28 \*---------------------------------------------------------------------------*/
31 #include "dictionary.H"
33 #include "OSspecific.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 //! @cond ignoreDocumentation - local scope
43 dictionary* controlDictPtr_(NULL);
44 dictionary* debugSwitchesPtr_(NULL);
45 dictionary* infoSwitchesPtr_(NULL);
46 dictionary* optimisationSwitchesPtr_(NULL);
47 dictionary* tolerancesPtr_(NULL);
49 // to ensure controlDictPtr_ is deleted at the end of the run
50 class deleteControlDictPtr
54 deleteControlDictPtr()
57 ~deleteControlDictPtr()
61 delete controlDictPtr_;
67 deleteControlDictPtr deleteControlDictPtr_;
68 //! @endcond ignoreDocumentation
71 } // End namespace debug
72 } // End namespace Foam
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 Foam::dictionary& Foam::debug::controlDict()
80 controlDictPtr_ = new dictionary
82 IFstream(findEtcFile("controlDict", true))()
86 return *controlDictPtr_;
90 Foam::dictionary& Foam::debug::switchSet
92 const char* subDictName,
93 dictionary*& subDictPtr
98 entry* ePtr = controlDict().lookupEntryPtr
100 subDictName, false, false
103 if (!ePtr || !ePtr->isDict())
105 cerr<< "debug::switchSet(const char*, dictionary*&):\n"
106 << " Cannot find " << subDictName << " in dictionary "
107 << controlDict().name().c_str()
108 << std::endl << std::endl;
113 subDictPtr = &ePtr->dict();
120 Foam::dictionary& Foam::debug::debugSwitches()
122 return switchSet("DebugSwitches", debugSwitchesPtr_);
126 Foam::dictionary& Foam::debug::infoSwitches()
128 return switchSet("InfoSwitches", infoSwitchesPtr_);
132 Foam::dictionary& Foam::debug::optimisationSwitches()
134 return switchSet("OptimisationSwitches", optimisationSwitchesPtr_);
138 int Foam::debug::debugSwitch(const char* name, const int defaultValue)
140 return debugSwitches().lookupOrAddDefault
142 name, defaultValue, false, false
147 int Foam::debug::infoSwitch(const char* name, const int defaultValue)
149 return infoSwitches().lookupOrAddDefault
151 name, defaultValue, false, false
156 int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
158 return optimisationSwitches().lookupOrAddDefault
160 name, defaultValue, false, false
165 Foam::dictionary& Foam::debug::tolerances()
167 return switchSet("Tolerances", tolerancesPtr_);
171 double Foam::debug::tolerances
174 const double defaultValue
177 return tolerances().lookupOrAddDefault
179 name, defaultValue, false, false
184 // ************************************************************************* //