Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "functionObject.H"
00027 #include <OpenFOAM/dictionary.H>
00028 #include <OpenFOAM/dlLibraryTable.H>
00029
00030
00031
00032 defineRunTimeSelectionTable(Foam::functionObject, dictionary);
00033 int Foam::functionObject::debug(Foam::debug::debugSwitch("functionObject", 0));
00034
00035
00036
00037
00038 Foam::functionObject::functionObject(const word& name)
00039 :
00040 name_(name)
00041 {}
00042
00043
00044
00045
00046 Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
00047 (
00048 const word& name,
00049 const Time& t,
00050 const dictionary& functionDict
00051 )
00052 {
00053 word functionType(functionDict.lookup("type"));
00054
00055 if (debug)
00056 {
00057 Info<< "Selecting function " << functionType << endl;
00058 }
00059
00060 dlLibraryTable::open
00061 (
00062 functionDict,
00063 "functionObjectLibs",
00064 dictionaryConstructorTablePtr_
00065 );
00066
00067 if (!dictionaryConstructorTablePtr_)
00068 {
00069 FatalErrorIn
00070 (
00071 "functionObject::New"
00072 "(const word& name, const Time&, const dictionary&)"
00073 ) << "Unknown function type "
00074 << functionType << nl << nl
00075 << "Table of functionObjects is empty" << endl
00076 << exit(FatalError);
00077 }
00078
00079 dictionaryConstructorTable::iterator cstrIter =
00080 dictionaryConstructorTablePtr_->find(functionType);
00081
00082 if (cstrIter == dictionaryConstructorTablePtr_->end())
00083 {
00084 FatalErrorIn
00085 (
00086 "functionObject::New"
00087 "(const word& name, const Time&, const dictionary&)"
00088 ) << "Unknown function type "
00089 << functionType << nl << nl
00090 << "Valid functions are : " << nl
00091 << dictionaryConstructorTablePtr_->sortedToc() << endl
00092 << exit(FatalError);
00093 }
00094
00095 return autoPtr<functionObject>(cstrIter()(name, t, functionDict));
00096 }
00097
00098
00099
00100
00101 Foam::functionObject::~functionObject()
00102 {}
00103
00104
00105
00106
00107 const Foam::word& Foam::functionObject::name() const
00108 {
00109 return name_;
00110 }
00111
00112
00113 bool Foam::functionObject::end()
00114 {
00115 return execute();
00116 }
00117
00118
00119 Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
00120 (
00121 const word& name,
00122 Istream& is
00123 ) const
00124 {
00125 dictionary dict(is);
00126 return functionObject::New(name, time_, dict);
00127 }
00128
00129
00130