ENH: adding hook adjustTimeStep to function objects. The hook is called in

Time::adjustDeltaT(). It allows function objects to manipulate the time step to
    dump at adjustable times. The following options are available for output in
    function objects: timeStep, outputTime, adjustableTime, runTime, clockTime
    and cpuTime.
This commit is contained in:
Sergio Ferraris
2013-09-09 14:13:21 +01:00
parent 470553c61a
commit 2d773bc089
14 changed files with 264 additions and 27 deletions

View File

@ -64,14 +64,24 @@ functions
// region allowed.
region wallFilmRegion;
// Execute upon outputTime
// Execute upon options:
// timeStep
// outputTime
// adjustableTime
// runTime
// clockTime
// cpuTime
outputControl outputTime;
// Objects (fields or lagrangian fields in any of the clouds)
// to write every outputTime
objectNames (p positions nParticle);
// Write as normal every writeInterval'th outputTime.
writeInterval 3;
outputInterval 1; // (timeStep, outputTime)
// Interval of time (sec) to write down(
writeInterval 10.5 //(adjustableTime, runTime, clockTime, cpuTime)
}
dumpObjects
@ -84,9 +94,24 @@ functions
// Where to load it from
functionObjectLibs ("libIOFunctionObjects.so");
// Execute upon outputTime
// Execute upon outputTime:
// timeStep
// outputTime
// adjustableTime
// runTime
// clockTime
// cpuTime
outputControl outputTime;
// Is the object written by this function Object alone
exclusiveWriting true;
// Interval of time (sec) to write down(
writeInterval 10.5 //(adjustableTime, runTime, clockTime, cpuTime)
// Write as normal every writeInterval'th outputTime.
outputInterval 1; // (timeStep, outputTime)
// Objects to write
objectNames ();
}

View File

@ -46,6 +46,7 @@ Foam::writeRegisteredObject::writeRegisteredObject
)
:
name_(name),
exclusiveWriting_(true),
obr_(obr),
objectNames_()
{
@ -64,6 +65,7 @@ Foam::writeRegisteredObject::~writeRegisteredObject()
void Foam::writeRegisteredObject::read(const dictionary& dict)
{
dict.lookup("objectNames") >> objectNames_;
dict.readIfPresent("exclusiveWriting", exclusiveWriting_);
}
@ -96,12 +98,12 @@ void Foam::writeRegisteredObject::write()
(
obr_.lookupObject<regIOobject>(objectNames_[i])
);
// Switch off automatic writing to prevent double write
obj.writeOpt() = IOobject::NO_WRITE;
Info<< type() << " " << name_ << " output:" << nl
<< " writing object " << obj.name() << nl
<< endl;
if (exclusiveWriting_)
{
// Switch off automatic writing to prevent double write
obj.writeOpt() = IOobject::NO_WRITE;
}
obj.write();
}

View File

@ -28,8 +28,15 @@ Group
grpIOFunctionObjects
Description
This function object takes-over the writing of objects registered to the
database.
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 outputControl setting:
timeStep
outputTime
adjustableTime
runTime
clockTime
cpuTime
Example of function object specification:
\verbatim
@ -37,6 +44,7 @@ Description
{
type writeRegisteredObject;
functionObjectLibs ("libIOFunctionObjects.so");
exclusiveWriting true;
...
objectNames (obj1 obj2);
}
@ -47,8 +55,12 @@ Description
Property | Description | Required | Default value
type | type name: writeRegisteredObject | yes |
objectNames | objects to write | yes |
exclusiveWriting | Takes over object writing | no | yes
\endtable
exclusiveWriting disables automatic writing (i.e through database) of the
objects to avoid duplicate writing.
SeeAlso
Foam::functionObject
Foam::OutputFilterFunctionObject
@ -89,6 +101,9 @@ protected:
//- Name of this set of writeRegisteredObject
word name_;
//- Takes over the writing from Db
bool exclusiveWriting_;
const objectRegistry& obr_;
// Read from dictionary