STYLE: runTimeControl FO conditions - refactor to use the Log macro

This commit is contained in:
Andrew Heather
2018-08-21 12:53:29 +01:00
parent 7ffa7bb923
commit a3327b3761
8 changed files with 28 additions and 41 deletions

View File

@ -116,7 +116,7 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
const scalar dt = obr_.time().deltaTValue();
if (log_) Info<< " " << type() << ": " << name_ << " averages:" << nl;
Log << " " << type() << ": " << name_ << " averages:" << nl;
DynamicList<label> unprocessedFields(fieldNames_.size());
@ -149,7 +149,7 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
}
}
if (log_) Info<< endl;
Log << endl;
return satisfied;
}

View File

@ -159,11 +159,8 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
scalar delta = mag(meanValue - currentValue);
if (log_)
{
Info<< " " << meanName << ": " << meanValue
<< ", delta: " << delta << nl;
}
Log << " " << meanName << ": " << meanValue
<< ", delta: " << delta << nl;
// Note: Writing result to owner function object and not the local run-time
// condition

View File

@ -183,24 +183,18 @@ apply()
if (satisfied && valid)
{
if (log_)
{
Info<< type() << ": " << name_
<< ": satisfied using threshold value: " << value_ << nl;
}
Log << type() << ": " << name_
<< ": satisfied using threshold value: " << value_ << nl;
forAll(result, resulti)
{
if (result[resulti] > 0)
{
if (log_)
{
Info<< " field: " << fieldNames_[resulti]
<< ", residual: " << result[resulti] << nl;
}
Log << " field: " << fieldNames_[resulti]
<< ", residual: " << result[resulti] << nl;
}
}
if (log_) Info<< endl;
Log << endl;
}
return satisfied;

View File

@ -141,24 +141,18 @@ bool Foam::functionObjects::runTimeControls::equationMaxIterCondition::apply()
if (satisfied && valid)
{
if (log_)
{
Info<< type() << ": " << name_
<< ": satisfied using threshold value: " << threshold_ << nl;
}
Log << type() << ": " << name_
<< ": satisfied using threshold value: " << threshold_ << nl;
forAll(result, resulti)
{
if (result[resulti] != -1)
{
if (log_)
{
Info<< " field: " << fieldNames_[resulti]
<< ", iterations: " << result[resulti] << nl;
}
Log << " field: " << fieldNames_[resulti]
<< ", iterations: " << result[resulti] << nl;
}
}
if (log_) Info<< endl;
Log << endl;
}
return satisfied;

View File

@ -94,6 +94,9 @@ bool Foam::functionObjects::runTimeControls::maxDurationCondition::apply()
scalar delta = obr_.time().value() - startTime_;
delta = obr_.time().timeToUserTime(delta);
Log << " " << type() << ": " << name_ << nl
<< " Completed " << delta << " out of " << duration_ << nl;
return delta >= duration_;
}

View File

@ -145,13 +145,10 @@ bool Foam::functionObjects::runTimeControls::minMaxCondition::apply()
}
}
if (log_)
{
Info<< " " << type() << ": " << modeTypeNames_[mode_] << " "
<< fieldName << ": value = " << v
<< ", threshold value = " << value_
<< ", satisfied = " << ok << endl;
}
Log << " " << type() << ": " << modeTypeNames_[mode_] << " "
<< fieldName << ": value = " << v
<< ", threshold value = " << value_
<< ", satisfied = " << ok << endl;
satisfied = satisfied && ok;
}

View File

@ -84,8 +84,8 @@ Foam::functionObjects::runTimeControls::runTimeCondition::runTimeCondition
state_(state),
active_(dict.lookupOrDefault("active", true)),
conditionDict_(setConditionDict()),
log_(dict.lookupOrDefault("log", true)),
groupID_(dict.lookupOrDefault("groupID", -1))
groupID_(dict.lookupOrDefault("groupID", -1)),
log(dict.lookupOrDefault("log", true))
{}

View File

@ -78,9 +78,6 @@ protected:
//- Reference to the condition dictionary
dictionary& conditionDict_;
//- Switch to send output to Info
Switch log_;
//- Group index - if applied, all conditions in a group must be
// satisfied before condition is met
label groupID_;
@ -140,6 +137,11 @@ public:
stateFunctionObject& state
);
// Public Data
//- Switch to send output to Info
Switch log;
// Public Member Functions