Commit 901f6cde authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects: Removed the redundant "viable" member function

Construction failure and recovery is not handled with exceptions in functionObjectList
parent 6960d664
......@@ -54,20 +54,13 @@ Foam::functionObjects::writeVTK::writeVTK
obr_(obr),
objectNames_()
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::writeVTK::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
......@@ -131,16 +131,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~writeVTK();
......
......@@ -76,18 +76,6 @@ ${typeName}FunctionObject::${typeName}FunctionObject
}
bool ${typeName}FunctionObject::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool
)
{
return true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
${typeName}FunctionObject::~${typeName}FunctionObject()
......
......@@ -102,16 +102,6 @@ public:
const bool loadFromFilesUnused = false
);
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
static bool viable
(
const word& name,
const objectRegistry& unused,
const dictionary&,
const bool loadFromFilesUnused = false
);
//- Destructor
virtual ~${typeName}FunctionObject();
......
......@@ -30,7 +30,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(FUNCTIONOBJECT, 0);
defineTypeNameAndDebug(FUNCTIONOBJECT, 0);
}
......@@ -83,8 +83,7 @@ void Foam::FUNCTIONOBJECT::timeSet()
void Foam::FUNCTIONOBJECT::write()
{
}
{}
// ************************************************************************* //
......@@ -134,7 +134,7 @@ public:
// Member Functions
//- Return name of the FUNCTIONOBJECT
virtual const word& name() const
const word& name() const
{
return name_;
}
......
......@@ -66,32 +66,6 @@ Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
{}
template<class OutputFilter>
bool Foam::IOOutputFilter<OutputFilter>::viable
(
const word& outputFilterName,
const objectRegistry& obr,
const word& dictName,
const IOobject::readOption rOpt,
const bool readFromFiles
)
{
IOdictionary dict
(
IOobject
(
dictName,
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
)
);
return OutputFilter::viable(outputFilterName, obr, dict, readFromFiles);
}
template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
(
......
......@@ -94,16 +94,6 @@ public:
const bool loadFromFile = false
);
//- Return true if the construction of this functionObject is viable
static bool viable
(
const word& outputFilterName,
const objectRegistry&,
const word& dictName = OutputFilter::typeName() + "Dict",
const IOobject::readOption rOpt = IOobject::MUST_READ_IF_MODIFIED,
const bool loadFromFiles = false
);
//- Construct for given objectRegistry and dictionary
// Dictionary read from full path.
// Allow the possibility to load fields from files
......
......@@ -56,49 +56,27 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
if (dictName_.size())
{
if
ptr_.reset
(
IOOutputFilter<OutputFilter>::viable
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
)
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
);
}
else
{
if
ptr_.reset
(
OutputFilter::viable
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
)
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
);
}
return ptr_.valid();
......
......@@ -92,20 +92,13 @@ Foam::functionObjects::div::div
fieldName_("undefined-fieldName"),
resultName_("undefined-resultName")
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::div::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
......@@ -125,16 +125,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~div();
......
......@@ -277,20 +277,13 @@ Foam::functionObjects::fieldAverage::fieldAverage
totalTime_(),
periodIndex_(1)
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::fieldAverage::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
......@@ -301,16 +301,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldAverage();
......
......@@ -53,6 +53,12 @@ fieldCoordinateSystemTransform
fieldSet_(),
coordSys_(obr, dict)
{
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict);
Info<< type() << " " << name_ << ":" << nl
......@@ -61,19 +67,6 @@ fieldCoordinateSystemTransform
}
bool Foam::functionObjects::fieldCoordinateSystemTransform::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fieldCoordinateSystemTransform::
......
......@@ -155,16 +155,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldCoordinateSystemTransform();
......
......@@ -68,20 +68,13 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
mode_(mdMag),
fieldSet_()
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::fieldMinMax::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
......@@ -181,16 +181,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldMinMax();
......
......@@ -218,20 +218,13 @@ Foam::functionObjects::fieldValues::cellSource::cellSource
weightFieldName_("none"),
writeVolume_(dict.lookupOrDefault("writeVolume", false))
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::fieldValues::cellSource::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
......@@ -250,16 +250,6 @@ public:
const bool loadFromFiles = false
);
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~cellSource();
......
......@@ -660,20 +660,13 @@ Foam::functionObjects::fieldValues::faceSource::faceSource
facePatchId_(),
faceSign_()
{
read(dict);
}
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
bool Foam::functionObjects::fieldValues::faceSource::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
read(dict);
}
......
Supports Markdown
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