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:
@ -58,7 +58,7 @@ namespace functionObjects
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::functionObjects::writeObjects::writeOption, 3>
|
const Foam::NamedEnum<Foam::functionObjects::writeObjects::writeOption, 3>
|
||||||
Foam::functionObjects::writeObjects::writeOptionNames;
|
Foam::functionObjects::writeObjects::writeOptionNames_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -111,7 +111,7 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
|
|||||||
|
|
||||||
if (dict.found("writeOption"))
|
if (dict.found("writeOption"))
|
||||||
{
|
{
|
||||||
writeOption_ = writeOptionNames.read(dict.lookup("writeOption"));
|
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -162,33 +162,38 @@ bool Foam::functionObjects::writeObjects::write()
|
|||||||
obr_.lookupObject<regIOobject>(allNames[i])
|
obr_.lookupObject<regIOobject>(allNames[i])
|
||||||
);
|
);
|
||||||
|
|
||||||
switch(writeOption_)
|
switch (writeOption_)
|
||||||
{
|
{
|
||||||
case AUTO_WRITE:
|
case AUTO_WRITE:
|
||||||
if (obj.writeOpt() != IOobject::AUTO_WRITE)
|
{
|
||||||
|
if(obj.writeOpt() != IOobject::AUTO_WRITE)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case NO_WRITE:
|
|
||||||
if (obj.writeOpt() != IOobject::NO_WRITE)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ANY_WRITE:
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case NO_WRITE:
|
||||||
|
{
|
||||||
|
if(obj.writeOpt() != IOobject::NO_WRITE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ANY_WRITE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
continue;
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unknown writeOption "
|
||||||
|
<< writeOptionNames_[writeOption_]
|
||||||
|
<< ". Valid writeOption types are" << writeOptionNames_
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
|
|||||||
@ -42,9 +42,11 @@ Description
|
|||||||
|
|
||||||
It also has the ability to write the selected objects that were defined
|
It also has the ability to write the selected objects that were defined
|
||||||
with the respective write mode for the requested \c writeOption, namely:
|
with the respective write mode for the requested \c writeOption, namely:
|
||||||
- \c autoWrite - objects set to write at output time
|
\vartable
|
||||||
- \c noWrite - objects set to not write by default
|
autoWrite | objects set to write at output time
|
||||||
- \c anyWrite - any option of the previous two
|
noWrite | objects set to not write by default
|
||||||
|
anyWrite | any option of the previous two
|
||||||
|
\endvartable
|
||||||
|
|
||||||
Example of function object specification:
|
Example of function object specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
@ -60,10 +62,10 @@ Description
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | type name: writeObjects | yes |
|
type | type name: writeObjects | yes |
|
||||||
objects | objects to write | yes |
|
objects | objects to write | yes |
|
||||||
writeOption | only those with this write option | no | any
|
writeOption | only those with this write option | no | anyWrite
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Note: Regular expressions can also be used in \c objects.
|
Note: Regular expressions can also be used in \c objects.
|
||||||
@ -116,7 +118,7 @@ public:
|
|||||||
ANY_WRITE
|
ANY_WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
static const NamedEnum<writeOption, 3> writeOptionNames;
|
static const NamedEnum<writeOption, 3> writeOptionNames_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ private:
|
|||||||
//- Reference to Db
|
//- Reference to Db
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
//- Takes over the writing from Db
|
//- To only write objects of defined writeOption
|
||||||
writeOption writeOption_;
|
writeOption writeOption_;
|
||||||
|
|
||||||
//- Names of objects to control
|
//- Names of objects to control
|
||||||
|
|||||||
Reference in New Issue
Block a user