functionObjects::writeObjects: improved code and docs

Patch contributed by Bruno Santos
Resolves bug-report http://bugs.openfoam.org/view.php?id=2090
This commit is contained in:
Henry Weller
2016-08-17 14:41:42 +01:00
parent e078fa031b
commit b2e9655495
2 changed files with 36 additions and 29 deletions

View File

@ -58,7 +58,7 @@ namespace functionObjects
}
const Foam::NamedEnum<Foam::functionObjects::writeObjects::writeOption, 3>
Foam::functionObjects::writeObjects::writeOptionNames;
Foam::functionObjects::writeObjects::writeOptionNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -111,7 +111,7 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
if (dict.found("writeOption"))
{
writeOption_ = writeOptionNames.read(dict.lookup("writeOption"));
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
}
else
{
@ -162,33 +162,38 @@ bool Foam::functionObjects::writeObjects::write()
obr_.lookupObject<regIOobject>(allNames[i])
);
switch(writeOption_)
switch (writeOption_)
{
case AUTO_WRITE:
if (obj.writeOpt() != IOobject::AUTO_WRITE)
{
if(obj.writeOpt() != IOobject::AUTO_WRITE)
{
continue;
}
else
{
break;
}
case NO_WRITE:
if (obj.writeOpt() != IOobject::NO_WRITE)
{
continue;
}
else
{
break;
}
case ANY_WRITE:
break;
}
case NO_WRITE:
{
if(obj.writeOpt() != IOobject::NO_WRITE)
{
continue;
}
break;
}
case ANY_WRITE:
{
break;
}
default:
continue;
{
FatalErrorInFunction
<< "Unknown writeOption "
<< writeOptionNames_[writeOption_]
<< ". Valid writeOption types are" << writeOptionNames_
<< exit(FatalError);
}
}
if

View File

@ -42,9 +42,11 @@ Description
It also has the ability to write the selected objects that were defined
with the respective write mode for the requested \c writeOption, namely:
- \c autoWrite - objects set to write at output time
- \c noWrite - objects set to not write by default
- \c anyWrite - any option of the previous two
\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
Example of function object specification:
\verbatim
@ -60,10 +62,10 @@ Description
Usage
\table
Property | Description | Required | Default value
type | type name: writeObjects | yes |
objects | objects to write | yes |
writeOption | only those with this write option | no | any
Property | Description | Required | Default value
type | type name: writeObjects | yes |
objects | objects to write | yes |
writeOption | only those with this write option | no | anyWrite
\endtable
Note: Regular expressions can also be used in \c objects.
@ -116,7 +118,7 @@ public:
ANY_WRITE
};
static const NamedEnum<writeOption, 3> writeOptionNames;
static const NamedEnum<writeOption, 3> writeOptionNames_;
private:
@ -125,7 +127,7 @@ private:
//- Reference to Db
const objectRegistry& obr_;
//- Takes over the writing from Db
//- To only write objects of defined writeOption
writeOption writeOption_;
//- Names of objects to control