BUG: scaleFactor for fieldValue function-objects is 'sticky' (issue #331)

- if set in a dictionary and later removed, the intermediate value is
  retained rather than reverting to a normal default value.

- same applies for a few other function objects and their variables
This commit is contained in:
Mark Olesen
2016-12-08 11:33:39 +00:00
parent b4182c60a3
commit b6d79ed4ce
6 changed files with 15 additions and 10 deletions

View File

@ -157,7 +157,7 @@ Foam::functionObjects::PecletNo::~PecletNo()
bool Foam::functionObjects::PecletNo::read(const dictionary& dict)
{
dict.readIfPresent("rho", rhoName_);
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
return true;
}

View File

@ -117,8 +117,13 @@ bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
writeFile::read(dict);
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
dict.readIfPresent("tolerance", tolerance_);
if ((tolerance_ < 0) || (tolerance_ > 1))
tolerance_ = 0.001;
if
(
dict.readIfPresent("tolerance", tolerance_)
&& (tolerance_ < 0 || tolerance_ > 1)
)
{
FatalErrorInFunction
<< "tolerance must be in the range 0 to 1. Supplied value: "

View File

@ -97,7 +97,7 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
dict.lookup("fields") >> fields_;
dict.lookup("writeFields") >> writeFields_;
dict.readIfPresent("scaleFactor", scaleFactor_);
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
return true;
}

View File

@ -70,7 +70,7 @@ protected:
// Protected data
//- Optional scale value
//- Optional scaling factor
scalar scaleFactor_;
//- Construction dictionary

View File

@ -616,9 +616,9 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
writeFile::read(dict);
mode_ = modeTypeNames_.read(dict.lookup("mode"));
phiName_= dict.lookupOrDefault<word>("phi", "phi");
dict.readIfPresent("scaleFactor", scaleFactor_);
dict.readIfPresent("tolerance", tolerance_);
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);
// Initialise with capacity of 10 faceZones
DynamicList<vector> refDir(10);

View File

@ -232,8 +232,8 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
{
fieldExpression::read(dict);
dict.readIfPresent("U", UName_);
dict.readIfPresent("rho", rhoName_);
UName_ = dict.lookupOrDefault<word>("U", "U");
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
if (rhoName_ == "rhoInf")
{