mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add remove objects handling in timeFunctionObject and regionFunctionObject
- makes it easier to implement functionObject or field object removal
This commit is contained in:
@ -71,14 +71,14 @@ bool Foam::functionObjects::regionFunctionObject::writeObject
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
const regIOobject* obj = this->findObject<regIOobject>(fieldName);
|
||||
const regIOobject* ptr = this->cfindObject<regIOobject>(fieldName);
|
||||
|
||||
if (obj)
|
||||
if (ptr)
|
||||
{
|
||||
Log << " functionObjects::" << type() << " " << name()
|
||||
<< " writing field: " << obj->name() << endl;
|
||||
<< " writing field: " << ptr->name() << endl;
|
||||
|
||||
obj->write();
|
||||
ptr->write();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -93,13 +93,13 @@ bool Foam::functionObjects::regionFunctionObject::clearObject
|
||||
)
|
||||
{
|
||||
// Same as getObjectPtr, since the object is already non-const
|
||||
regIOobject* obj = this->findObject<regIOobject>(fieldName);
|
||||
regIOobject* ptr = this->findObject<regIOobject>(fieldName);
|
||||
|
||||
if (obj)
|
||||
if (ptr)
|
||||
{
|
||||
if (obj->ownedByRegistry())
|
||||
if (ptr->ownedByRegistry())
|
||||
{
|
||||
return obj->checkOut();
|
||||
return ptr->checkOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -113,6 +113,23 @@ bool Foam::functionObjects::regionFunctionObject::clearObject
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::regionFunctionObject::clearObjects
|
||||
(
|
||||
const wordList& objNames
|
||||
)
|
||||
{
|
||||
for (const word& objName : objNames)
|
||||
{
|
||||
regIOobject* ptr = this->findObject<regIOobject>(objName);
|
||||
|
||||
if (ptr && ptr->ownedByRegistry())
|
||||
{
|
||||
ptr->checkOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::regionFunctionObject::regionFunctionObject
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016 OpenFOAM Foundation
|
||||
@ -57,7 +57,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::regionFunctionObject Declaration
|
||||
Class regionFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionFunctionObject
|
||||
@ -149,6 +149,9 @@ protected:
|
||||
//- Clear field from the (sub) objectRegistry if present
|
||||
bool clearObject(const word& fieldName);
|
||||
|
||||
//- Clear fields from the (sub) objectRegistry if present
|
||||
void clearObjects(const wordList& objNames);
|
||||
|
||||
|
||||
//- No copy construct
|
||||
regionFunctionObject(const regionFunctionObject&) = delete;
|
||||
|
||||
@ -28,9 +28,12 @@ License
|
||||
#include "stateFunctionObject.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::functionObjects::stateFunctionObject::resultsName_ =
|
||||
"results";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::IOdictionary&
|
||||
|
||||
@ -61,17 +61,14 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::stateFunctionObject Declaration
|
||||
Class stateFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class stateFunctionObject
|
||||
:
|
||||
public functionObjects::timeFunctionObject
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private member data
|
||||
// Private Member Data
|
||||
|
||||
//- Name of the results dictionary
|
||||
static const word resultsName_;
|
||||
|
||||
@ -39,6 +39,22 @@ Foam::functionObjects::timeFunctionObject::timeFunctionObject
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::timeFunctionObject::clearOutputObjects
|
||||
(
|
||||
const wordList& objNames
|
||||
)
|
||||
{
|
||||
objectRegistry& obr = storedObjects();
|
||||
|
||||
for (const word& objName : objNames)
|
||||
{
|
||||
obr.checkOut(objName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::objectRegistry&
|
||||
|
||||
@ -49,7 +49,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::timeFunctionObject Declaration
|
||||
Class timeFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeFunctionObject
|
||||
@ -66,6 +66,10 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Remove specified items from "functionObjectObjects"
|
||||
void clearOutputObjects(const wordList& objNames);
|
||||
|
||||
|
||||
//- No copy construct
|
||||
timeFunctionObject(const timeFunctionObject&) = delete;
|
||||
|
||||
@ -77,7 +81,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
//- Construct from Time
|
||||
timeFunctionObject(const word& name, const Time& runTime);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -564,7 +564,7 @@ bool Foam::functionObjects::externalCoupled::end()
|
||||
|
||||
bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
externalFileCoupler::readDict(dict);
|
||||
|
||||
calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -160,7 +160,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward Declarations
|
||||
class fvMesh;
|
||||
class IFstream;
|
||||
|
||||
@ -168,7 +168,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::externalCoupled Declaration
|
||||
Class externalCoupled Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class externalCoupled
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -159,7 +159,7 @@ Foam::functionObjects::abort::abort
|
||||
|
||||
bool Foam::functionObjects::abort::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
|
||||
file_.clear();
|
||||
|
||||
|
||||
@ -136,12 +136,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
abort
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
abort(const word& name, const Time& runTime, const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2011, 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -185,7 +185,7 @@ bool Foam::functionObjects::codedFunctionObject::end()
|
||||
|
||||
bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
|
||||
dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
@ -89,7 +89,7 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
|
||||
timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||
@ -82,7 +82,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::setTimeStepFunctionObject Declaration
|
||||
Class setTimeStepFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class setTimeStepFunctionObject
|
||||
|
||||
@ -90,8 +90,8 @@ Foam::functionObjects::systemCall::systemCall
|
||||
:
|
||||
functionObject(name),
|
||||
executeCalls_(),
|
||||
endCalls_(),
|
||||
writeCalls_(),
|
||||
endCalls_(),
|
||||
masterOnly_(false)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -118,12 +118,12 @@ protected:
|
||||
//- List of calls to execute - every step
|
||||
stringList executeCalls_;
|
||||
|
||||
//- List of calls to execute when exiting the time-loop
|
||||
stringList endCalls_;
|
||||
|
||||
//- List of calls to execute - write steps
|
||||
stringList writeCalls_;
|
||||
|
||||
//- List of calls to execute when exiting the time-loop
|
||||
stringList endCalls_;
|
||||
|
||||
//- Perform system calls on the master only
|
||||
bool masterOnly_;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-2010, 2015-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2009-2010, 2015-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -108,7 +108,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
|
||||
dict.readEntry("fileToUpdate", fileToUpdate_);
|
||||
dict.readEntry("timeVsFile", timeVsFile_);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-2010, 2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2009-2010, 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -80,14 +80,14 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward Declarations
|
||||
class Time;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjects::timeActivatedFileUpdate Declaration
|
||||
Class timeActivatedFileUpdate Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeActivatedFileUpdate
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -161,7 +161,7 @@ Foam::functionObjects::vtkWrite::vtkWrite
|
||||
|
||||
bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
timeFunctionObject::read(dict);
|
||||
|
||||
readSelection(dict);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
Reference in New Issue
Block a user