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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -84,8 +84,8 @@ Foam::functionObjects::runTimeControls::runTimeCondition::runTimeCondition
state_(state), state_(state),
active_(dict.lookupOrDefault("active", true)), active_(dict.lookupOrDefault("active", true)),
conditionDict_(setConditionDict()), 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 //- Reference to the condition dictionary
dictionary& conditionDict_; dictionary& conditionDict_;
//- Switch to send output to Info
Switch log_;
//- Group index - if applied, all conditions in a group must be //- Group index - if applied, all conditions in a group must be
// satisfied before condition is met // satisfied before condition is met
label groupID_; label groupID_;
@ -140,6 +137,11 @@ public:
stateFunctionObject& state stateFunctionObject& state
); );
// Public Data
//- Switch to send output to Info
Switch log;
// Public Member Functions // Public Member Functions