mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: run-time control clean-up
This commit is contained in:
@ -205,8 +205,8 @@ Foam::functionObjects::stateFunctionObject::objectResultEntries() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::List<Foam::word> Foam::functionObjects::stateFunctionObject::
|
Foam::List<Foam::word>
|
||||||
objectResultEntries
|
Foam::functionObjects::stateFunctionObject::objectResultEntries
|
||||||
(
|
(
|
||||||
const word& objectName
|
const word& objectName
|
||||||
) const
|
) const
|
||||||
|
|||||||
@ -78,12 +78,6 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::averageCondition::~averageCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::averageCondition::apply()
|
bool Foam::functionObjects::runTimeControls::averageCondition::apply()
|
||||||
@ -145,9 +139,8 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
|
|||||||
<< "From function object: " << functionObjectName_ << nl
|
<< "From function object: " << functionObjectName_ << nl
|
||||||
<< "Unprocessed fields:" << nl;
|
<< "Unprocessed fields:" << nl;
|
||||||
|
|
||||||
forAll(unprocessedFields, i)
|
for (const label fieldi : unprocessedFields)
|
||||||
{
|
{
|
||||||
label fieldi = unprocessedFields[i];
|
|
||||||
Info<< " " << fieldNames_[fieldi] << nl;
|
Info<< " " << fieldNames_[fieldi] << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~averageCondition();
|
virtual ~averageCondition() = default;
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|||||||
@ -95,13 +95,6 @@ equationInitialResidualCondition
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::equationInitialResidualCondition::
|
|
||||||
~equationInitialResidualCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::equationInitialResidualCondition::
|
bool Foam::functionObjects::runTimeControls::equationInitialResidualCondition::
|
||||||
|
|||||||
@ -99,7 +99,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~equationInitialResidualCondition();
|
virtual ~equationInitialResidualCondition() = default;
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|||||||
@ -76,13 +76,6 @@ equationMaxIterCondition
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::equationMaxIterCondition::
|
|
||||||
~equationMaxIterCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::equationMaxIterCondition::apply()
|
bool Foam::functionObjects::runTimeControls::equationMaxIterCondition::apply()
|
||||||
|
|||||||
@ -84,7 +84,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~equationMaxIterCondition();
|
virtual ~equationMaxIterCondition() = default;
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|||||||
@ -90,12 +90,6 @@ Foam::functionObjects::runTimeControls::minMaxCondition::minMaxCondition
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::minMaxCondition::~minMaxCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::minMaxCondition::apply()
|
bool Foam::functionObjects::runTimeControls::minMaxCondition::apply()
|
||||||
@ -107,10 +101,8 @@ bool Foam::functionObjects::runTimeControls::minMaxCondition::apply()
|
|||||||
return satisfied;
|
return satisfied;
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(fieldNames_, fieldi)
|
for (const word& fieldName :fieldNames_)
|
||||||
{
|
{
|
||||||
const word& fieldName = fieldNames_[fieldi];
|
|
||||||
|
|
||||||
const word valueType =
|
const word valueType =
|
||||||
state_.objectResultType(functionObjectName_, fieldName);
|
state_.objectResultType(functionObjectName_, fieldName);
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~minMaxCondition();
|
virtual ~minMaxCondition() = default;
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|||||||
@ -63,13 +63,6 @@ minTimeStepCondition
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::minTimeStepCondition::
|
|
||||||
~minTimeStepCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::minTimeStepCondition::apply()
|
bool Foam::functionObjects::runTimeControls::minTimeStepCondition::apply()
|
||||||
|
|||||||
@ -78,7 +78,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~minTimeStepCondition();
|
virtual ~minTimeStepCondition() = default;
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|||||||
@ -89,12 +89,6 @@ Foam::functionObjects::runTimeControls::runTimeCondition::runTimeCondition
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::runTimeCondition::~runTimeCondition()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::word&
|
const Foam::word&
|
||||||
|
|||||||
@ -129,7 +129,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~runTimeCondition();
|
virtual ~runTimeCondition() = default;
|
||||||
|
|
||||||
//- Selector
|
//- Selector
|
||||||
static autoPtr<runTimeCondition> New
|
static autoPtr<runTimeCondition> New
|
||||||
|
|||||||
@ -60,18 +60,13 @@ Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
|
|||||||
nWriteStep_(0),
|
nWriteStep_(0),
|
||||||
writeStepI_(0),
|
writeStepI_(0),
|
||||||
satisfiedAction_(satisfiedAction::end),
|
satisfiedAction_(satisfiedAction::end),
|
||||||
triggerIndex_(labelMin)
|
triggerIndex_(labelMin),
|
||||||
|
active_(getObjectProperty(name, "active", true))
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::runTimeControls::runTimeControl::~runTimeControl()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
||||||
@ -117,17 +112,17 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check that at least one condition is active
|
// Check that at least one condition is active
|
||||||
bool active = false;
|
bool check = false;
|
||||||
for (const auto& condition : conditions_)
|
for (const auto& condition : conditions_)
|
||||||
{
|
{
|
||||||
if (condition.active())
|
if (condition.active())
|
||||||
{
|
{
|
||||||
active = true;
|
check = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!active)
|
if (!check)
|
||||||
{
|
{
|
||||||
Info<< type() << " " << name() << " output:" << nl
|
Info<< type() << " " << name() << " output:" << nl
|
||||||
<< " All conditions are inactive" << nl
|
<< " All conditions are inactive" << nl
|
||||||
@ -156,6 +151,11 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
|||||||
|
|
||||||
bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
||||||
{
|
{
|
||||||
|
if (!active_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< type() << " " << name() << " output:" << nl;
|
Info<< type() << " " << name() << " output:" << nl;
|
||||||
|
|
||||||
// IDs of satisfied conditions
|
// IDs of satisfied conditions
|
||||||
@ -242,12 +242,17 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
|||||||
Info<< " Stopping calculation" << nl
|
Info<< " Stopping calculation" << nl
|
||||||
<< " Writing fields - final step" << nl;
|
<< " Writing fields - final step" << nl;
|
||||||
time.writeAndEnd();
|
time.writeAndEnd();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case satisfiedAction::setTrigger:
|
case satisfiedAction::setTrigger:
|
||||||
{
|
{
|
||||||
|
Info<< " Setting trigger " << triggerIndex_ << nl;
|
||||||
setTrigger(triggerIndex_);
|
setTrigger(triggerIndex_);
|
||||||
|
|
||||||
|
// Deactivate the model
|
||||||
|
active_ = false;
|
||||||
|
setProperty("active", active_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016- OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,7 +32,7 @@ Description
|
|||||||
user-specified conditions.
|
user-specified conditions.
|
||||||
|
|
||||||
Optionally specify a number of write steps before the calculation is
|
Optionally specify a number of write steps before the calculation is
|
||||||
terminated. Here, a write is performed each time that all conditons are
|
terminated. Here, a write is performed each time that all conditions are
|
||||||
satisfied.
|
satisfied.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -96,12 +96,16 @@ private:
|
|||||||
//- Current number of steps written
|
//- Current number of steps written
|
||||||
label writeStepI_;
|
label writeStepI_;
|
||||||
|
|
||||||
//- Action to take when conditions are satified
|
//- Action to take when conditions are satisfied
|
||||||
satisfiedAction satisfiedAction_;
|
satisfiedAction satisfiedAction_;
|
||||||
|
|
||||||
//- Trigger index if satisfiedAction is setTrigger
|
//- Trigger index if satisfiedAction is setTrigger
|
||||||
label triggerIndex_;
|
label triggerIndex_;
|
||||||
|
|
||||||
|
//- Active flag
|
||||||
|
// Used in the trigger case to bypass any evaluations after the
|
||||||
|
// trigger has been set
|
||||||
|
bool active_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
@ -121,8 +125,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct for given objectRegistry and dictionary.
|
//- Construct for given objectRegistry and dictionary
|
||||||
// Allow the possibility to load fields from files
|
|
||||||
runTimeControl
|
runTimeControl
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -132,7 +135,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~runTimeControl();
|
virtual ~runTimeControl() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
Reference in New Issue
Block a user