diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.C b/src/functionObjects/utilities/writeObjects/writeObjects.C index b897d64e206a0f95dd2cc6a9f4c6818b127d8940..266d5e9e2974e45f7bf94f765fc65958674d71d4 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.C +++ b/src/functionObjects/utilities/writeObjects/writeObjects.C @@ -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()) diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.H b/src/functionObjects/utilities/writeObjects/writeObjects.H index 6198eb882706270045a45a57b04b5247ce99679b..1804f87a806112f3469b4c40815c455846b3d721 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.H +++ b/src/functionObjects/utilities/writeObjects/writeObjects.H @@ -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: diff --git a/tutorials/incompressible/pisoFoam/RAS/cavity/system/FOs/FOwriteObjects b/tutorials/incompressible/pisoFoam/RAS/cavity/system/FOs/FOwriteObjects new file mode 100644 index 0000000000000000000000000000000000000000..b1b8e0335b95899622c29a0dd18dcf88b532c04e --- /dev/null +++ b/tutorials/incompressible/pisoFoam/RAS/cavity/system/FOs/FOwriteObjects @@ -0,0 +1,36 @@ +/*--------------------------------*- 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; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/RAS/cavity/system/controlDict b/tutorials/incompressible/pisoFoam/RAS/cavity/system/controlDict index 5b24acc375a1f7fa93b9c1f2a043f6532a643e67..bbb2eab23119492d96958c56dc261e31e639827a 100644 --- a/tutorials/incompressible/pisoFoam/RAS/cavity/system/controlDict +++ b/tutorials/incompressible/pisoFoam/RAS/cavity/system/controlDict @@ -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"