functionObject.C
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
00027 #include "functionObject.H"
00028 #include "dictionary.H"
00029 #include "dlLibraryTable.H"
00030
00031
00032
00033 defineRunTimeSelectionTable(Foam::functionObject, dictionary);
00034 int Foam::functionObject::debug(Foam::debug::debugSwitch("functionObject", 0));
00035
00036
00037
00038
00039 Foam::functionObject::functionObject(const word& name)
00040 :
00041 name_(name)
00042 {}
00043
00044
00045
00046
00047 Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
00048 (
00049 const word& name,
00050 const Time& t,
00051 const dictionary& functionDict
00052 )
00053 {
00054 word functionType(functionDict.lookup("type"));
00055
00056 if (debug)
00057 {
00058 Info<< "Selecting function " << functionType << endl;
00059 }
00060
00061 dlLibraryTable::open
00062 (
00063 functionDict,
00064 "functionObjectLibs",
00065 dictionaryConstructorTablePtr_
00066 );
00067
00068 if (!dictionaryConstructorTablePtr_)
00069 {
00070 FatalErrorIn
00071 (
00072 "functionObject::New"
00073 "(const word& name, const Time&, const dictionary&)"
00074 ) << "Unknown function type "
00075 << functionType << nl << nl
00076 << "Table of functionObjects is empty" << endl
00077 << exit(FatalError);
00078 }
00079
00080 dictionaryConstructorTable::iterator cstrIter =
00081 dictionaryConstructorTablePtr_->find(functionType);
00082
00083 if (cstrIter == dictionaryConstructorTablePtr_->end())
00084 {
00085 FatalErrorIn
00086 (
00087 "functionObject::New"
00088 "(const word& name, const Time&, const dictionary&)"
00089 ) << "Unknown function type "
00090 << functionType << nl << nl
00091 << "Valid functions are : " << nl
00092 << dictionaryConstructorTablePtr_->toc() << endl
00093 << exit(FatalError);
00094 }
00095
00096 return autoPtr<functionObject>(cstrIter()(name, t, functionDict));
00097 }
00098
00099
00100
00101
00102 Foam::functionObject::~functionObject()
00103 {}
00104
00105
00106
00107
00108 const Foam::word& Foam::functionObject::name() const
00109 {
00110 return name_;
00111 }
00112
00113
00114 bool Foam::functionObject::end()
00115 {
00116 return execute();
00117 }
00118
00119
00120 Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
00121 (
00122 const word& name,
00123 Istream& is
00124 ) const
00125 {
00126 dictionary dict(is);
00127 return functionObject::New(name, time_, dict);
00128 }
00129
00130
00131
Copyright © 2000-2009 OpenCFD Ltd