ENH: add static set/get dimensionSet::checking() method

- encapsulates toggling

STYLE: noexcept for some Time methods
This commit is contained in:
Mark Olesen
2021-10-26 22:39:37 +02:00
parent 33790ca972
commit f5058bca90
14 changed files with 98 additions and 66 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,13 +50,12 @@ bool Foam::functionObjects::log::calc()
{
const volScalarField& x = lookupObject<volScalarField>(fieldName_);
// Cache the current debug setting for dimensionSet
const bool dimensionSetDebug = dimensionSet::debug;
// Switch-off dimension checking if requested
const bool oldDimChecking = dimensionSet::checking();
if (!checkDimensions_)
{
dimensionSet::debug = 0;
dimensionSet::checking(false);
}
bool stored = store
@ -68,7 +67,7 @@ bool Foam::functionObjects::log::calc()
// Reinstate dimension checking
if (!checkDimensions_)
{
dimensionSet::debug = dimensionSetDebug;
dimensionSet::checking(oldDimChecking);
}
return stored;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,13 +49,12 @@ bool Foam::functionObjects::pow::calc()
{
const volScalarField& x = lookupObject<volScalarField>(fieldName_);
// Cache the current debug setting for dimensionSet
const bool dimensionSetDebug = dimensionSet::debug;
// Switch-off dimension checking if requested
const bool oldDimChecking = dimensionSet::checking();
if (!checkDimensions_)
{
dimensionSet::debug = 0;
dimensionSet::checking(false);
}
bool stored = store
@ -67,7 +66,7 @@ bool Foam::functionObjects::pow::calc()
// Reinstate dimension checking
if (!checkDimensions_)
{
dimensionSet::debug = dimensionSetDebug;
dimensionSet::checking(oldDimChecking);
}
return stored;