Skip to content
Snippets Groups Projects
Commit 528ea551 authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'feature-write-objects' into 'develop'

ENH: writeObjects: add flag to report registered objects

See merge request !705
parents 5d0058bc c77cc498
2 merge requests!722RELEASE: develop branch to master,!705ENH: writeObjects: add flag to report registered objects
......@@ -58,6 +58,7 @@ Foam::functionObjects::writeObjects::writeOptionNames_
{ writeOption::NO_WRITE, "noWrite" },
{ writeOption::AUTO_WRITE, "autoWrite" },
{ writeOption::ANY_WRITE, "anyWrite" },
{ writeOption::LOG, "log" },
});
const Foam::objectRegistry& setRegistry
......@@ -99,7 +100,10 @@ Foam::functionObjects::writeObjects::writeObjects
bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
{
functionObject::read(dict);
if (!functionObject::read(dict))
{
return false;
}
if (dict.found("field"))
{
......@@ -134,6 +138,31 @@ bool Foam::functionObjects::writeObjects::execute()
bool Foam::functionObjects::writeObjects::write()
{
if (writeOption_ == writeOption::LOG)
{
const auto& classes = obr_.classes();
Log << "Registered objects:\n";
forAllConstIters(classes, classInfo)
{
const word& className = classInfo.key();
const wordHashSet& objectSet = classInfo();
Log << " " << className << ":\n";
for (const auto& objectName : objectSet)
{
Log << " " << objectName << "\n";
}
Log << nl;
}
Log << endl;
return true;
}
Log << type() << " " << name() << " write:" << nl;
if (!obr_.time().writeTime())
......
......@@ -34,49 +34,55 @@ Description
Allows specification of different writing frequency of objects registered
to the database.
It has similar functionality as the main time database through the
\c writeControl setting:
- timeStep
- writeTime
- adjustableRunTime
- runTime
- clockTime
- cpuTime
It also has the ability to write the selected objects that were defined
with the respective write mode for the requested \c writeOption, namely:
\vartable
autoWrite | objects set to write at output time
noWrite | objects set to not write by default
anyWrite | any option of the previous two
\endvartable
Usage
Example of function object specification:
Minimal example by using \c system/controlDict.functions:
\verbatim
writeObjects1
{
type writeObjects;
libs (utilityFunctionObjects);
// Mandatory entries
type writeObjects;
libs (utilityFunctionObjects);
// Optional entries
writeOption <word>;
// Conditional entries
// Option-1
field <word>;
// Option-2
fields (<wordRes>);
// Option-3
objects (<wordRes>);
// Inherited entries
...
objects (obj1 obj2);
writeOption anyWrite;
}
\endverbatim
Where the entries comprise:
where the entries mean:
\table
Property | Description | Required | Default value
type | type name: writeObjects | yes |
objects | objects to write | yes |
writeOption | only those with this write option | no | anyWrite
Property | Description | Type | Reqd | Deflt
type | Type name: writeObjects | word | yes | -
libs | Library name: utilityFunctionObjects | word | yes | -
writeOption | Select objects with the specified write mode | no | anyWrite
field | Name of field to write | word | no | -
fields | Names of fields to write | wordRes | no | -
objects | Names of objects to write | wordRes | no | -
\endtable
Note: Regular expressions can also be used in \c objects.
Options for the \c writeOption entry:
\vartable
autoWrite | Objects set to write at output time
noWrite | Objects set to not write by default
anyWrite | Any option of the previous two
log | Only report registered objects without writing objects
\endvartable
See also
Foam::functionObject
Foam::functionObjects::timeControl
The inherited entries are elaborated in:
- \link functionObject.H \endlink
SourceFiles
writeObjects.C
......@@ -119,9 +125,11 @@ public:
{
NO_WRITE,
AUTO_WRITE,
ANY_WRITE
ANY_WRITE,
LOG
};
//- Names for writeOption
static const Enum<writeOption> writeOptionNames_;
private:
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
writeObjects1
{
// Mandatory entries
type writeObjects;
libs (utilityFunctionObjects);
// Optional entries
writeOption log;
// Conditional entries
// field U;
// fields ( ".*" );
objects ( ".*" );
// Inherited entries
region region0;
enabled true;
log true;
timeStart 0;
timeEnd 1000;
executeControl timeStep;
executeInterval -1;
writeControl onEnd;
writeInterval -1;
}
// ************************************************************************* //
......@@ -94,6 +94,7 @@ functions
#include "FOs/FOwallShearStress"
#include "FOs/FOwriteCellCentres"
#include "FOs/FOwriteCellVolumes"
#include "FOs/FOwriteObjects"
#include "FOs/FOyPlus"
#include "FOs/FOzeroGradient"
#include "FOs/FOnorm"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment