mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
postProcessing: Replaced 'foamCalc' and the 'postCalc' utilities
with the more general and flexible 'postProcess' utility and '-postProcess' solver option
Rationale
---------
Both the 'postProcess' utility and '-postProcess' solver option use the
same extensive set of functionObjects available for data-processing
during the run avoiding the substantial code duplication necessary for
the 'foamCalc' and 'postCalc' utilities and simplifying maintenance.
Additionally consistency is guaranteed between solver data processing
and post-processing.
The functionObjects have been substantially re-written and generalized
to simplify development and encourage contribution.
Configuration
-------------
An extensive set of simple functionObject configuration files are
provided in
OpenFOAM-dev/etc/caseDicts/postProcessing
and more will be added in the future. These can either be copied into
'<case>/system' directory and included into the 'controlDict.functions'
sub-dictionary or included directly from 'etc/caseDicts/postProcessing'
using the '#includeEtc' directive or the new and more convenient
'#includeFunc' directive which searches the
'<etc>/caseDicts/postProcessing' directories for the selected
functionObject, e.g.
functions
{
#includeFunc Q
#includeFunc Lambda2
}
'#includeFunc' first searches the '<case>/system' directory in case
there is a local configuration.
Description of #includeFunc
---------------------------
Specify a functionObject dictionary file to include, expects the
functionObject name to follow (without quotes).
Search for functionObject dictionary file in
user/group/shipped directories.
The search scheme allows for version-specific and
version-independent files using the following hierarchy:
- \b user settings:
- ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
- ~/.OpenFOAM/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is set):
- $WM_PROJECT_SITE/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_SITE/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_INST_DIR/site/caseDicts/postProcessing
- \b other (shipped) settings:
- $WM_PROJECT_DIR/etc/caseDicts/postProcessing
An example of the \c \#includeFunc directive:
\verbatim
#includeFunc <funcName>
\endverbatim
postProcess
-----------
The 'postProcess' utility and '-postProcess' solver option provide the
same set of controls to execute functionObjects after the run either by
reading a specified set of fields to process in the case of
'postProcess' or by reading all fields and models required to start the
run in the case of '-postProcess' for each selected time:
postProcess -help
Usage: postProcess [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
pimpleFoam -postProcess -help
Usage: pimpleFoam [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-postProcess Execute functionObjects only
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
The functionObjects to execute may be specified on the command-line
using the '-func' option for a single functionObject or '-funcs' for a
list, e.g.
postProcess -func Q
postProcess -funcs '(div(U) div(phi))'
In the case of 'Q' the default field to process is 'U' which is
specified in and read from the configuration file but this may be
overridden thus:
postProcess -func 'Q(Ua)'
as is done in the example above to calculate the two forms of the divergence of
the velocity field. Additional fields which the functionObjects may depend on
can be specified using the '-field' or '-fields' options.
The 'postProcess' utility can only be used to execute functionObjects which
process fields present in the time directories. However, functionObjects which
depend on fields obtained from models, e.g. properties derived from turbulence
models can be executed using the '-postProcess' of the appropriate solver, e.g.
pisoFoam -postProcess -func PecletNo
or
sonicFoam -postProcess -func MachNo
In this case all required fields will have already been read so the '-field' or
'-fields' options are not be needed.
Henry G. Weller
CFD Direct Ltd.
This commit is contained in:
11
src/functionObjects/utilities/Make/files
Normal file
11
src/functionObjects/utilities/Make/files
Normal file
@ -0,0 +1,11 @@
|
||||
codedFunctionObject/codedFunctionObject.C
|
||||
residuals/residuals.C
|
||||
timeActivatedFileUpdate/timeActivatedFileUpdate.C
|
||||
setTimeStep/setTimeStepFunctionObject.C
|
||||
systemCall/systemCall.C
|
||||
abort/abort.C
|
||||
removeRegisteredObject/removeRegisteredObject.C
|
||||
writeDictionary/writeDictionary.C
|
||||
writeRegisteredObject/writeRegisteredObject.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects
|
||||
5
src/functionObjects/utilities/Make/options
Normal file
5
src/functionObjects/utilities/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume
|
||||
199
src/functionObjects/utilities/abort/abort.C
Normal file
199
src/functionObjects/utilities/abort/abort.C
Normal file
@ -0,0 +1,199 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "abort.H"
|
||||
#include "dictionary.H"
|
||||
#include "error.H"
|
||||
#include "Time.H"
|
||||
#include "OSspecific.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(abort, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
abort,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::abort::actionType,
|
||||
3
|
||||
>::names[] =
|
||||
{
|
||||
"noWriteNow",
|
||||
"writeNow",
|
||||
"nextWrite"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::abort::actionType,
|
||||
3
|
||||
> Foam::functionObjects::abort::actionTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::abort::removeFile() const
|
||||
{
|
||||
bool hasAbort = isFile(abortFile_);
|
||||
reduce(hasAbort, orOp<bool>());
|
||||
|
||||
if (hasAbort && Pstream::master())
|
||||
{
|
||||
// Cleanup ABORT file (on master only)
|
||||
rm(abortFile_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::abort::abort
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(runTime),
|
||||
abortFile_("$FOAM_CASE/" + name),
|
||||
action_(nextWrite)
|
||||
{
|
||||
abortFile_.expand();
|
||||
read(dict);
|
||||
|
||||
// Remove any old files from previous runs
|
||||
removeFile();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::abort::~abort()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::abort::read(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("action"))
|
||||
{
|
||||
action_ = actionTypeNames_.read(dict.lookup("action"));
|
||||
}
|
||||
else
|
||||
{
|
||||
action_ = nextWrite;
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("fileName", abortFile_))
|
||||
{
|
||||
abortFile_.expand();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::abort::execute(const bool postProcess)
|
||||
{
|
||||
bool hasAbort = isFile(abortFile_);
|
||||
reduce(hasAbort, orOp<bool>());
|
||||
|
||||
if (hasAbort)
|
||||
{
|
||||
switch (action_)
|
||||
{
|
||||
case noWriteNow :
|
||||
{
|
||||
if (time_.stopAt(Time::saNoWriteNow))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop without writing data"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case writeNow :
|
||||
{
|
||||
if (time_.stopAt(Time::saWriteNow))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop+write data"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nextWrite :
|
||||
{
|
||||
if (time_.stopAt(Time::saNextWrite))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop after next data write"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::abort::write(const bool postProcess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::abort::end()
|
||||
{
|
||||
removeFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
152
src/functionObjects/utilities/abort/abort.H
Normal file
152
src/functionObjects/utilities/abort/abort.H
Normal file
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::abort
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Watches for presence of the named file in the $FOAM_CASE directory
|
||||
and aborts the calculation if it is present.
|
||||
|
||||
Currently the following action types are supported:
|
||||
- noWriteNow
|
||||
- writeNow
|
||||
- nextWrite
|
||||
|
||||
SourceFiles
|
||||
abort.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_abort_H
|
||||
#define functionObjects_abort_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class abort Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class abort
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
//- Enumeration defining the type of action
|
||||
enum actionType
|
||||
{
|
||||
noWriteNow, //!< stop immediately without writing data
|
||||
writeNow, //!< write data and stop immediately
|
||||
nextWrite //!< stop the next time data are written
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the Time
|
||||
const Time& time_;
|
||||
|
||||
//- The fully-qualified name of the abort file
|
||||
fileName abortFile_;
|
||||
|
||||
//- Action type names
|
||||
static const NamedEnum<actionType, 3> actionTypeNames_;
|
||||
|
||||
//- The type of action
|
||||
actionType action_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Remove abort file.
|
||||
void removeFile() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
abort(const abort&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const abort&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("abort");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
abort
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~abort();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the dictionary settings
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, check existence of abort file and take action
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Execute, check existence of abort file and take action
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Execute at the final time-loop, used for cleanup
|
||||
virtual bool end();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,292 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codedFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "stringOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(codedFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
codedFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::codedFunctionObject::prepare
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context
|
||||
) const
|
||||
{
|
||||
// Set additional rewrite rules
|
||||
dynCode.setFilterVariable("typeName", name_);
|
||||
dynCode.setFilterVariable("codeData", codeData_);
|
||||
dynCode.setFilterVariable("codeRead", codeRead_);
|
||||
dynCode.setFilterVariable("codeExecute", codeExecute_);
|
||||
dynCode.setFilterVariable("codeWrite", codeWrite_);
|
||||
dynCode.setFilterVariable("codeEnd", codeEnd_);
|
||||
|
||||
// Compile filtered C template
|
||||
dynCode.addCompileFile("functionObjectTemplate.C");
|
||||
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile("functionObjectTemplate.H");
|
||||
|
||||
// Debugging: make BC verbose
|
||||
// dynCode.setFilterVariable("verbose", "true");
|
||||
// Info<<"compile " << name_ << " sha1: "
|
||||
// << context.sha1() << endl;
|
||||
|
||||
// Define Make/options
|
||||
dynCode.setMakeOptions
|
||||
(
|
||||
"EXE_INC = -g \\\n"
|
||||
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||
"-I$(LIB_SRC)/meshTools/lnInclude \\\n"
|
||||
+ context.options()
|
||||
+ "\n\nLIB_LIBS = \\\n"
|
||||
+ " -lOpenFOAM \\\n"
|
||||
+ " -lfiniteVolume \\\n"
|
||||
+ " -lmeshTools \\\n"
|
||||
+ context.libs()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::dlLibraryTable& Foam::codedFunctionObject::libs() const
|
||||
{
|
||||
return const_cast<Time&>(time_).libs();
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::codedFunctionObject::description() const
|
||||
{
|
||||
return "functionObject " + name();
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFunctionObject::clearRedirect() const
|
||||
{
|
||||
redirectFunctionObjectPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::codedFunctionObject::codeDict() const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codedFunctionObject::codedFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
codedBase(),
|
||||
time_(time),
|
||||
dict_(dict)
|
||||
{
|
||||
read(dict_);
|
||||
|
||||
updateLibrary(name_);
|
||||
redirectFunctionObject();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codedFunctionObject::~codedFunctionObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObject& Foam::codedFunctionObject::redirectFunctionObject() const
|
||||
{
|
||||
if (!redirectFunctionObjectPtr_.valid())
|
||||
{
|
||||
dictionary constructDict(dict_);
|
||||
constructDict.set("type", name_);
|
||||
|
||||
redirectFunctionObjectPtr_ = functionObject::New
|
||||
(
|
||||
name_,
|
||||
time_,
|
||||
constructDict
|
||||
);
|
||||
}
|
||||
return redirectFunctionObjectPtr_();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::execute(const bool postProcess)
|
||||
{
|
||||
updateLibrary(name_);
|
||||
return redirectFunctionObject().execute(postProcess);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::write(const bool postProcess)
|
||||
{
|
||||
updateLibrary(name_);
|
||||
return redirectFunctionObject().write(postProcess);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::end()
|
||||
{
|
||||
updateLibrary(name_);
|
||||
return redirectFunctionObject().end();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
// Backward compatibility
|
||||
if (dict.found("redirectType"))
|
||||
{
|
||||
dict.lookup("redirectType") >> name_;
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.lookup("name") >> name_;
|
||||
}
|
||||
|
||||
const entry* dataPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeData",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (dataPtr)
|
||||
{
|
||||
codeData_ = stringOps::trim(dataPtr->stream());
|
||||
stringOps::inplaceExpand(codeData_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeData_,
|
||||
dataPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* readPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeRead",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (readPtr)
|
||||
{
|
||||
codeRead_ = stringOps::trim(readPtr->stream());
|
||||
stringOps::inplaceExpand(codeRead_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeRead_,
|
||||
readPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* execPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeExecute",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (execPtr)
|
||||
{
|
||||
codeExecute_ = stringOps::trim(execPtr->stream());
|
||||
stringOps::inplaceExpand(codeExecute_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeExecute_,
|
||||
execPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* writePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeWrite",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (writePtr)
|
||||
{
|
||||
codeWrite_ = stringOps::trim(writePtr->stream());
|
||||
stringOps::inplaceExpand(codeWrite_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeWrite_,
|
||||
writePtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* endPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeEnd",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (endPtr)
|
||||
{
|
||||
codeEnd_ = stringOps::trim(endPtr->stream());
|
||||
stringOps::inplaceExpand(codeEnd_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeEnd_,
|
||||
endPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
updateLibrary(name_);
|
||||
return redirectFunctionObject().read(dict);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::codedFunctionObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object provides a general interface to enable dynamic code
|
||||
compilation.
|
||||
|
||||
The entries are
|
||||
codeInclude : include files
|
||||
codeOptions : include paths; inserted into EXE_INC in Make/options
|
||||
codeLibs : link line; inserted into LIB_LIBS in Make/options
|
||||
codeData : c++; local member data (null constructed);
|
||||
localCode : c++; local static functions
|
||||
codeRead : c++; upon functionObject::read();
|
||||
codeExecute : c++;upon functionObject::execute();
|
||||
codeWrite : c++; upon functionObject::write()
|
||||
codeEnd : c++; upon functionObject::end();
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
difference
|
||||
{
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
|
||||
type coded;
|
||||
// Name of on-the-fly generated functionObject
|
||||
name writeMagU;
|
||||
codeWrite
|
||||
#{
|
||||
// Lookup U
|
||||
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
|
||||
// Write
|
||||
mag(U).write();
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::codedBase
|
||||
|
||||
SourceFiles
|
||||
codedFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_codedFunctionObject_H
|
||||
#define functionObjects_codedFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "codedBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codedFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codedFunctionObject
|
||||
:
|
||||
public functionObject,
|
||||
public codedBase
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
//- Input dictionary
|
||||
dictionary dict_;
|
||||
|
||||
word name_;
|
||||
|
||||
string codeData_;
|
||||
string codeRead_;
|
||||
string codeExecute_;
|
||||
string codeWrite_;
|
||||
string codeEnd_;
|
||||
|
||||
//- Underlying functionObject
|
||||
mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
// Return a description (type + name) for the output
|
||||
virtual string description() const;
|
||||
|
||||
// Clear any redirected objects
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
// Get the dictionary to initialize the codeContext
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
codedFunctionObject(const codedFunctionObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const codedFunctionObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("coded");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
codedFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~codedFunctionObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Dynamically compiled functionObject
|
||||
functionObject& redirectFunctionObject() const;
|
||||
|
||||
//- Called at each ++ or += of the time-loop.
|
||||
// postProcess overrides the usual executeControl behaviour and
|
||||
// forces execution (used in post-processing mode)
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Called at each ++ or += of the time-loop.
|
||||
// postProcess overrides the usual writeControl behaviour and
|
||||
// forces writing always (used in post-processing mode)
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits.
|
||||
// By default it simply calls execute().
|
||||
virtual bool end();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\defgroup grpUtilitiesFunctionObjects Utility function objects
|
||||
@{
|
||||
\ingroup grpFunctionObjects
|
||||
This group contains utility-based function objects
|
||||
@}
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "removeRegisteredObject.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(removeRegisteredObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
removeRegisteredObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::removeRegisteredObject::removeRegisteredObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
objectNames_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::removeRegisteredObject::~removeRegisteredObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("objects") >> objectNames_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::removeRegisteredObject::execute
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
forAll(objectNames_, i)
|
||||
{
|
||||
if (obr_.foundObject<regIOobject>(objectNames_[i]))
|
||||
{
|
||||
const regIOobject& obj =
|
||||
obr_.lookupObject<regIOobject>(objectNames_[i]);
|
||||
|
||||
if (obj.ownedByRegistry())
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
<< " removing object " << obj.name() << nl
|
||||
<< endl;
|
||||
|
||||
const_cast<regIOobject&>(obj).release();
|
||||
delete &obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::removeRegisteredObject::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,145 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::removeRegisteredObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object removes registered objects if present in the database
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
removeRegisteredObject1
|
||||
{
|
||||
type removeRegisteredObject;
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
objectNames (obj1 obj2);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: removeRegisteredObject | yes |
|
||||
objectNames | objects to remove | yes |
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
removeRegisteredObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_removeRegisteredObject_H
|
||||
#define functionObjects_removeRegisteredObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class removeRegisteredObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class removeRegisteredObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Names of objects to control
|
||||
wordList objectNames_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
removeRegisteredObject(const removeRegisteredObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const removeRegisteredObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("removeRegisteredObject");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
removeRegisteredObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~removeRegisteredObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the removeRegisteredObject data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Remove the registered objects
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Do nothing
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
141
src/functionObjects/utilities/residuals/residuals.C
Normal file
141
src/functionObjects/utilities/residuals/residuals.C
Normal file
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "residuals.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(residuals, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
residuals,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::residuals::residuals
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
writeFiles(name, runTime, dict, name),
|
||||
fieldSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::residuals::~residuals()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::residuals::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::residuals::writeFileHeader(const label i)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeHeader(file(), "Residuals");
|
||||
writeCommented(file(), "Time");
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldSet_[fieldi];
|
||||
|
||||
writeFileHeader<scalar>(fieldName);
|
||||
writeFileHeader<vector>(fieldName);
|
||||
writeFileHeader<sphericalTensor>(fieldName);
|
||||
writeFileHeader<symmTensor>(fieldName);
|
||||
writeFileHeader<tensor>(fieldName);
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::residuals::execute(const bool postProcess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::residuals::write(const bool postProcess)
|
||||
{
|
||||
writeFiles::write();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeTime(file());
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldSet_[fieldi];
|
||||
|
||||
writeResidual<scalar>(fieldName);
|
||||
writeResidual<vector>(fieldName);
|
||||
writeResidual<sphericalTensor>(fieldName);
|
||||
writeResidual<symmTensor>(fieldName);
|
||||
writeResidual<tensor>(fieldName);
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
164
src/functionObjects/utilities/residuals/residuals.H
Normal file
164
src/functionObjects/utilities/residuals/residuals.H
Normal file
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::residuals
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object writes out the initial residual for specified fields.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
residuals
|
||||
{
|
||||
type residuals;
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
fields
|
||||
(
|
||||
U
|
||||
p
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Output data is written to the dir postProcessing/residuals/\<timeDir\>/
|
||||
For vector/tensor fields, e.g. U, where an equation is solved for each
|
||||
component, the largest residual of each component is written out.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeFiles
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
residuals.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_residuals_H
|
||||
#define functionObjects_residuals_H
|
||||
|
||||
#include "writeFiles.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class residuals Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class residuals
|
||||
:
|
||||
public writeFiles
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Fields to write residuals
|
||||
wordList fieldSet_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Output field header information
|
||||
template<class Type>
|
||||
void writeFileHeader(const word& fieldName);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate the field min/max
|
||||
template<class Type>
|
||||
void writeResidual(const word& fieldName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
residuals(const residuals&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const residuals&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("residuals");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
residuals
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~residuals();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the controls
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the residuals
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "residualsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
99
src/functionObjects/utilities/residuals/residualsTemplates.C
Normal file
99
src/functionObjects/utilities/residuals/residualsTemplates.C
Normal file
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "residuals.H"
|
||||
#include "volFields.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::residuals::writeFileHeader(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
|
||||
const fvMesh& mesh = field.mesh();
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh.validComponents<Type>()
|
||||
);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
writeTabbed
|
||||
(
|
||||
file(),
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
|
||||
const fvMesh& mesh = field.mesh();
|
||||
const Foam::dictionary& solverDict = mesh.solverPerformanceDict();
|
||||
|
||||
if (solverDict.found(fieldName))
|
||||
{
|
||||
const List<SolverPerformance<Type>> sp
|
||||
(
|
||||
solverDict.lookup(fieldName)
|
||||
);
|
||||
|
||||
const Type& residual = sp.first().initialResidual();
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh.validComponents<Type>()
|
||||
);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
file() << token::TAB << component(residual, cmpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "setTimeStepFunctionObject.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(setTimeStepFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
setTimeStepFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::setTimeStepFunctionObject::setTimeStepFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(runTime)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::setTimeStepFunctionObject::~setTimeStepFunctionObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Time&
|
||||
Foam::functionObjects::setTimeStepFunctionObject::time() const
|
||||
{
|
||||
return time_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::adjustTimeStep()
|
||||
{
|
||||
const_cast<Time&>(time()).setDeltaT
|
||||
(
|
||||
timeStepPtr_().value(time_.timeOutputValue()),
|
||||
false
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
|
||||
|
||||
// Check that adjustTimeStep is active
|
||||
const dictionary& controlDict = time_.controlDict();
|
||||
|
||||
Switch adjust;
|
||||
if
|
||||
(
|
||||
!controlDict.readIfPresent<Switch>("adjustTimeStep", adjust)
|
||||
|| !adjust
|
||||
)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Need to set 'adjustTimeStep' true to allow timestep control"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::execute
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::setTimeStepFunctionObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Overrides the timeStep. Can only be used with
|
||||
solvers with adjustTimeStep control (e.g. pimpleFoam). Makes no attempt
|
||||
to cooperate with other timeStep 'controllers' (maxCo, other
|
||||
functionObjects). Supports 'enabled' flag but none of othe other ones
|
||||
'timeStart', 'timeEnd', 'writeControl' etc.
|
||||
|
||||
SourceFiles
|
||||
setTimeStepFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_setTimeStepFunctionObject_H
|
||||
#define functionObjects_setTimeStepFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class setTimeStepFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class setTimeStepFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
//- Time step function/table
|
||||
autoPtr<Function1<scalar>> timeStepPtr_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
setTimeStepFunctionObject(const setTimeStepFunctionObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const setTimeStepFunctionObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("setTimeStep");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
setTimeStepFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
virtual ~setTimeStepFunctionObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return time database
|
||||
const Time& time() const;
|
||||
|
||||
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
|
||||
virtual bool adjustTimeStep();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Called at each ++ or += of the time-loop.
|
||||
// postProcess overrides the usual executeControl behaviour and
|
||||
// forces execution (used in post-processing mode)
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Called at each ++ or += of the time-loop.
|
||||
// postProcess overrides the usual writeControl behaviour and
|
||||
// forces writing always (used in post-processing mode)
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
4
src/functionObjects/utilities/systemCall/Make/files
Normal file
4
src/functionObjects/utilities/systemCall/Make/files
Normal file
@ -0,0 +1,4 @@
|
||||
systemCall.C
|
||||
systemCallFunctionObject.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libsystemCall
|
||||
78
src/functionObjects/utilities/systemCall/controlDict
Normal file
78
src/functionObjects/utilities/systemCall/controlDict
Normal file
@ -0,0 +1,78 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application icoFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.5;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 20;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
functions
|
||||
{
|
||||
systemCall1
|
||||
{
|
||||
type systemCall;
|
||||
libs ("libsystemCall.so");
|
||||
enabled true;
|
||||
writeControl writeTime;
|
||||
|
||||
// called every time step
|
||||
executeCalls
|
||||
(
|
||||
"echo execute"
|
||||
);
|
||||
|
||||
// called at the end of the run
|
||||
endCalls
|
||||
(
|
||||
"echo \*\*\* writing .bashrc \*\*\*"
|
||||
"cat ~/.bashrc"
|
||||
"echo \*\*\* done \*\*\*"
|
||||
);
|
||||
|
||||
// called every ouput time
|
||||
writeCalls
|
||||
(
|
||||
"echo \*\*\* writing data \*\*\*"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
141
src/functionObjects/utilities/systemCall/systemCall.C
Normal file
141
src/functionObjects/utilities/systemCall/systemCall.C
Normal file
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "systemCall.H"
|
||||
#include "Time.H"
|
||||
#include "dynamicCode.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(systemCall, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
systemCall,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::systemCall::systemCall
|
||||
(
|
||||
const word& name,
|
||||
const Time&,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
executeCalls_(),
|
||||
endCalls_(),
|
||||
writeCalls_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::systemCall::~systemCall()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::systemCall::read(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("executeCalls", executeCalls_);
|
||||
dict.readIfPresent("endCalls", endCalls_);
|
||||
dict.readIfPresent("writeCalls", writeCalls_);
|
||||
|
||||
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "no executeCalls, endCalls or writeCalls defined."
|
||||
<< endl;
|
||||
}
|
||||
else if (!dynamicCode::allowSystemOperations)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Executing user-supplied system calls is not enabled by "
|
||||
<< "default because of " << nl
|
||||
<< "security issues. If you trust the case you can enable this "
|
||||
<< "facility by " << nl
|
||||
<< "adding to the InfoSwitches setting in the system controlDict:"
|
||||
<< nl << nl
|
||||
<< " allowSystemOperations 1" << nl << nl
|
||||
<< "The system controlDict is either" << nl << nl
|
||||
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << nl << nl
|
||||
<< "or" << nl << nl
|
||||
<< " $WM_PROJECT_DIR/etc/controlDict" << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::systemCall::execute(const bool postProcess)
|
||||
{
|
||||
forAll(executeCalls_, callI)
|
||||
{
|
||||
Foam::system(executeCalls_[callI]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::systemCall::end()
|
||||
{
|
||||
forAll(endCalls_, callI)
|
||||
{
|
||||
Foam::system(endCalls_[callI]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::systemCall::write(const bool postProcess)
|
||||
{
|
||||
forAll(writeCalls_, callI)
|
||||
{
|
||||
Foam::system(writeCalls_[callI]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
178
src/functionObjects/utilities/systemCall/systemCall.H
Normal file
178
src/functionObjects/utilities/systemCall/systemCall.H
Normal file
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::systemCall
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object executes system calls, entered in the form of a
|
||||
string lists. Calls can be made at the following points in the
|
||||
calculation:
|
||||
- every time step
|
||||
- every output time
|
||||
- end of the calculation
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
systemCall1
|
||||
{
|
||||
type systemCall;
|
||||
libs ("libsystemCall.so");
|
||||
...
|
||||
executeCalls
|
||||
(
|
||||
"echo execute"
|
||||
);
|
||||
writeCalls
|
||||
(
|
||||
"echo \*\*\* writing data \*\*\*"
|
||||
);
|
||||
endCalls
|
||||
(
|
||||
"echo \*\*\* writing .bashrc \*\*\*"
|
||||
"cat ~/.bashrc"
|
||||
"echo \*\*\* done \*\*\*"
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: systemCall | yes |
|
||||
executeCalls | list of calls on execute | yes |
|
||||
writeCalls | list of calls on write | yes |
|
||||
endCalls | list of calls on end | yes |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Since this function object executes system calls, there is a potential
|
||||
security risk. In order to use the \c systemCall function object, the
|
||||
\c allowSystemOperations must be set to '1'; otherwise, system calls will
|
||||
not be allowed.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
systemCall.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_systemCall_H
|
||||
#define functionObjects_systemCall_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "stringList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class systemCall Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class systemCall
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Private data
|
||||
|
||||
//- 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_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
systemCall(const systemCall&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const systemCall&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("systemCall");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
systemCall
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~systemCall();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the system calls
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute the "executeCalls" at each time-step
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Execute the "endCalls" at the final time-loop
|
||||
virtual bool end();
|
||||
|
||||
//- Write, execute the "writeCalls"
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,67 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application icoFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.5;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 20;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
functions
|
||||
{
|
||||
fileUpdate1
|
||||
{
|
||||
type timeActivatedFileUpdate;
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
fileToUpdate "$FOAM_CASE/system/fvSolution";
|
||||
|
||||
timeVsFile
|
||||
(
|
||||
( -1 "$FOAM_CASE/system/fvSolution.0" )
|
||||
( 0.10 "$FOAM_CASE/system/fvSolution.10" )
|
||||
( 0.20 "$FOAM_CASE/system/fvSolution.20" )
|
||||
( 0.35 "$FOAM_CASE/system/fvSolution.35" )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeActivatedFileUpdate.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(timeActivatedFileUpdate, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
timeActivatedFileUpdate,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
|
||||
{
|
||||
label i = lastIndex_;
|
||||
while
|
||||
(
|
||||
i < timeVsFile_.size()-1
|
||||
&& timeVsFile_[i+1].first() < time_.value()
|
||||
)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > lastIndex_)
|
||||
{
|
||||
Info<< nl << type() << ": copying file" << nl << timeVsFile_[i].second()
|
||||
<< nl << "to:" << nl << fileToUpdate_ << nl << endl;
|
||||
|
||||
cp(timeVsFile_[i].second(), fileToUpdate_);
|
||||
lastIndex_ = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(runTime),
|
||||
fileToUpdate_(dict.lookup("fileToUpdate")),
|
||||
timeVsFile_(),
|
||||
lastIndex_(-1)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::timeActivatedFileUpdate::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
dict.lookup("fileToUpdate") >> fileToUpdate_;
|
||||
dict.lookup("timeVsFile") >> timeVsFile_;
|
||||
|
||||
lastIndex_ = -1;
|
||||
fileToUpdate_.expand();
|
||||
|
||||
Info<< type() << ": time vs file list:" << nl;
|
||||
forAll(timeVsFile_, i)
|
||||
{
|
||||
timeVsFile_[i].second() = timeVsFile_[i].second().expand();
|
||||
if (!isFile(timeVsFile_[i].second()))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "File: " << timeVsFile_[i].second() << " not found"
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< " " << timeVsFile_[i].first() << tab
|
||||
<< timeVsFile_[i].second() << endl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
updateFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::timeActivatedFileUpdate::execute
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
updateFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::timeActivatedFileUpdate::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::timeActivatedFileUpdate
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Performs a file copy/replacement once a specified time has been reached.
|
||||
|
||||
Example usage to update the fvSolution dictionary at various times
|
||||
throughout the calculation:
|
||||
|
||||
\verbatim
|
||||
fileUpdate1
|
||||
{
|
||||
type timeActivatedFileUpdate;
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
fileToUpdate "$FOAM_CASE/system/fvSolution";
|
||||
timeVsFile
|
||||
(
|
||||
(-1 "$FOAM_CASE/system/fvSolution.0")
|
||||
(0.10 "$FOAM_CASE/system/fvSolution.10")
|
||||
(0.20 "$FOAM_CASE/system/fvSolution.20")
|
||||
(0.35 "$FOAM_CASE/system/fvSolution.35")
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
timeActivatedFileUpdate.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_timeActivatedFileUpdate_H
|
||||
#define functionObjects_timeActivatedFileUpdate_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeActivatedFileUpdate Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeActivatedFileUpdate
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to Time
|
||||
const Time& time_;
|
||||
|
||||
//- Name of file to update
|
||||
fileName fileToUpdate_;
|
||||
|
||||
//- List of times vs filenames
|
||||
List<Tuple2<scalar, fileName>> timeVsFile_;
|
||||
|
||||
//- Index of last file copied
|
||||
label lastIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update file
|
||||
void updateFile();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
timeActivatedFileUpdate(const timeActivatedFileUpdate&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const timeActivatedFileUpdate&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeActivatedFileUpdate");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
timeActivatedFileUpdate
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~timeActivatedFileUpdate();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the timeActivatedFileUpdate data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute file updates
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Do nothing
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
220
src/functionObjects/utilities/writeDictionary/writeDictionary.C
Normal file
220
src/functionObjects/utilities/writeDictionary/writeDictionary.C
Normal file
@ -0,0 +1,220 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeDictionary.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(writeDictionary, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
writeDictionary,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::writeDictionary::tryDirectory
|
||||
(
|
||||
const label dictI,
|
||||
const word& location,
|
||||
bool& firstDict
|
||||
)
|
||||
{
|
||||
IOobject dictIO
|
||||
(
|
||||
dictNames_[dictI],
|
||||
location,
|
||||
obr_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (dictIO.headerOk())
|
||||
{
|
||||
IOdictionary dict(dictIO);
|
||||
|
||||
if (dict.digest() != digests_[dictI])
|
||||
{
|
||||
if (firstDict)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl << endl;
|
||||
|
||||
IOobject::writeDivider(Info);
|
||||
Info<< endl;
|
||||
firstDict = false;
|
||||
}
|
||||
|
||||
Info<< dict.dictName() << dict << nl;
|
||||
|
||||
IOobject::writeDivider(Info);
|
||||
|
||||
digests_[dictI] = dict.digest();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeDictionary::writeDictionary
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
dictNames_(),
|
||||
digests_()
|
||||
{
|
||||
read(dict);
|
||||
execute();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeDictionary::~writeDictionary()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::writeDictionary::read(const dictionary& dict)
|
||||
{
|
||||
wordList dictNames(dict.lookup("dictNames"));
|
||||
HashSet<word> uniqueNames(dictNames);
|
||||
dictNames_ = uniqueNames.toc();
|
||||
|
||||
digests_.setSize(dictNames_.size(), SHA1Digest());
|
||||
|
||||
Info<< type() << " " << name() << ": monitoring dictionaries:" << nl;
|
||||
if (dictNames_.size())
|
||||
{
|
||||
forAll(dictNames_, i)
|
||||
{
|
||||
Info<< " " << dictNames_[i] << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " none" << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeDictionary::execute(const bool postProcess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeDictionary::write(const bool postProcess)
|
||||
{
|
||||
bool firstDict = true;
|
||||
forAll(dictNames_, i)
|
||||
{
|
||||
if (obr_.foundObject<dictionary>(dictNames_[i]))
|
||||
{
|
||||
const dictionary& dict =
|
||||
obr_.lookupObject<dictionary>(dictNames_[i]);
|
||||
|
||||
if (dict.digest() != digests_[i])
|
||||
{
|
||||
if (firstDict)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl << endl;
|
||||
|
||||
IOobject::writeDivider(Info);
|
||||
Info<< endl;
|
||||
firstDict = false;
|
||||
}
|
||||
|
||||
digests_[i] = dict.digest();
|
||||
|
||||
Info<< dict.dictName() << dict << nl;
|
||||
IOobject::writeDivider(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool processed = tryDirectory(i, obr_.time().timeName(), firstDict);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
processed = tryDirectory(i, obr_.time().constant(), firstDict);
|
||||
}
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
processed = tryDirectory(i, obr_.time().system(), firstDict);
|
||||
}
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
Info<< " Unable to locate dictionary " << dictNames_[i]
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
141
src/functionObjects/utilities/writeDictionary/writeDictionary.H
Normal file
141
src/functionObjects/utilities/writeDictionary/writeDictionary.H
Normal file
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::writeDictionary
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object writes dictionaries on start-up, and on change
|
||||
|
||||
SourceFiles
|
||||
writeDictionary.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_writeDictionary_H
|
||||
#define functionObjects_writeDictionary_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordList.H"
|
||||
#include "SHA1Digest.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeDictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeDictionary
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Names of dictionaries to monitor
|
||||
wordList dictNames_;
|
||||
|
||||
//- List of changed dictionaries (only those registered to database)
|
||||
List<SHA1Digest> digests_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Helper function to write the dictionary if found at location
|
||||
bool tryDirectory
|
||||
(
|
||||
const label dictI,
|
||||
const word& location,
|
||||
bool& firstDict
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeDictionary(const writeDictionary&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const writeDictionary&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("writeDictionary");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
writeDictionary
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~writeDictionary();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the writeDictionary data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the selected dictionaries
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
122
src/functionObjects/utilities/writeRegisteredObject/controlDict
Normal file
122
src/functionObjects/utilities/writeRegisteredObject/controlDict
Normal file
@ -0,0 +1,122 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// So we get a decent warning if we have multiple functionObject entries
|
||||
// with the same name.
|
||||
#inputMode error;
|
||||
|
||||
application icoFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.5;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 20;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression uncompressed;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable yes;
|
||||
|
||||
functions
|
||||
{
|
||||
partialWrite
|
||||
{
|
||||
// Write some registered objects more often than others.
|
||||
// Above writeControl determines most frequent dump.
|
||||
|
||||
type partialWrite;
|
||||
|
||||
// Where to load it from
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
|
||||
// Optional mesh region to operate on. Only one partialWrite per
|
||||
// region allowed.
|
||||
region wallFilmRegion;
|
||||
|
||||
// Execute upon options:
|
||||
// timeStep
|
||||
// writeTime
|
||||
// adjustableRunTime
|
||||
// runTime
|
||||
// clockTime
|
||||
// cpuTime
|
||||
writeControl writeTime;
|
||||
|
||||
// Objects (fields or lagrangian fields in any of the clouds)
|
||||
// to write every writeTime
|
||||
objectNames (p positions nParticle);
|
||||
|
||||
// Write as normal every writeInterval'th writeTime.
|
||||
writeInterval 1; // (timeStep, writeTime)
|
||||
|
||||
// Interval of time (sec) to write down(
|
||||
writeInterval 10.5; //(adjustableRunTime, runTime, clockTime, cpuTime)
|
||||
}
|
||||
|
||||
dumpObjects
|
||||
{
|
||||
// Forcibly write registered objects
|
||||
|
||||
type writeRegisteredObject;
|
||||
|
||||
// Where to load it from
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
|
||||
// When to write:
|
||||
// timeStep (with optional writeInterval)
|
||||
// writeTime (with optional writeInterval)
|
||||
// adjustableRunTime
|
||||
// runTime
|
||||
// clockTime
|
||||
// cpuTime
|
||||
writeControl writeTime;
|
||||
|
||||
// Write every writeInterval (only valid for timeStemp, writeTime)
|
||||
writeInterval 1;
|
||||
|
||||
// Interval of time (valid for adjustableRunTime, runTime, clockTime,
|
||||
// cpuTime)
|
||||
writeInterval 10.5;
|
||||
|
||||
// Objects to write
|
||||
objectNames ();
|
||||
|
||||
|
||||
// Is the object written by this function Object alone
|
||||
// (default is false)
|
||||
//exclusiveWriting true;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeRegisteredObject.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(writeRegisteredObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
writeRegisteredObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeRegisteredObject::writeRegisteredObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
exclusiveWriting_(false),
|
||||
objectNames_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeRegisteredObject::~writeRegisteredObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("objects") >> objectNames_;
|
||||
dict.readIfPresent("exclusiveWriting", exclusiveWriting_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeRegisteredObject::execute
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeRegisteredObject::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
if (!obr_.time().writeTime())
|
||||
{
|
||||
obr_.time().writeTimeDict();
|
||||
}
|
||||
|
||||
DynamicList<word> allNames(obr_.toc().size());
|
||||
forAll(objectNames_, i)
|
||||
{
|
||||
wordList names(obr_.names<regIOobject>(objectNames_[i]));
|
||||
|
||||
if (names.size())
|
||||
{
|
||||
allNames.append(names);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Object " << objectNames_[i] << " not found in "
|
||||
<< "database. Available objects:" << nl << obr_.sortedToc()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(allNames, i)
|
||||
{
|
||||
regIOobject& obj =
|
||||
const_cast<regIOobject&>
|
||||
(
|
||||
obr_.lookupObject<regIOobject>(allNames[i])
|
||||
);
|
||||
|
||||
if (exclusiveWriting_)
|
||||
{
|
||||
// Switch off automatic writing to prevent double write
|
||||
obj.writeOpt() = IOobject::NO_WRITE;
|
||||
}
|
||||
|
||||
Info<< " writing object " << obj.name() << nl << endl;
|
||||
|
||||
obj.write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::writeRegisteredObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object allows specification of different writing frequency
|
||||
of objects registered to the database. It has similar functionality
|
||||
as the main time database through the writeControl setting:
|
||||
|
||||
\li \c timeStep
|
||||
\li \c writeTime
|
||||
\li \c adjustableRunTime
|
||||
\li \c runTime
|
||||
\li \c clockTime
|
||||
\li \c cpuTime
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
writeRegisteredObject1
|
||||
{
|
||||
type writeRegisteredObject;
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
exclusiveWriting true;
|
||||
...
|
||||
objectNames (obj1 obj2);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: writeRegisteredObject | yes |
|
||||
objectNames | objects to write | yes |
|
||||
exclusiveWriting | Takes over object writing | no | yes
|
||||
\endtable
|
||||
|
||||
\c exclusiveWriting disables automatic writing (i.e through database) of the
|
||||
objects to avoid duplicate writing.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
writeRegisteredObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_writeRegisteredObject_H
|
||||
#define functionObjects_writeRegisteredObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeRegisteredObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeRegisteredObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Refererence to Db
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Takes over the writing from Db
|
||||
bool exclusiveWriting_;
|
||||
|
||||
//- Names of objects to control
|
||||
wordReList objectNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeRegisteredObject(const writeRegisteredObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const writeRegisteredObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("writeRegisteredObject");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
writeRegisteredObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~writeRegisteredObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the writeRegisteredObject data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Do nothing
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the registered objects
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user