1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Foam::codedFunctionObject
28 functionObject using dynamic code compilation.
33 \*---------------------------------------------------------------------------*/
35 #ifndef codedFunctionObject_H
36 #define codedFunctionObject_H
38 #include "functionObject.H"
39 #include "codedBase.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 /*---------------------------------------------------------------------------*\
47 Class codedFunctionObject Declaration
48 \*---------------------------------------------------------------------------*/
50 class codedFunctionObject
52 public functionObject,
59 //- Reference to the time database
71 //- Underlying functionObject
72 mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
75 // Protected Member Functions
77 //- get the loaded dynamic libraries
78 virtual dlLibraryTable& libs() const;
80 //- adapt the context for the current object
81 virtual void prepare(dynamicCode &,const dynamicCodeContext&) const;
83 // Return a description (type + name) for the output
84 virtual string description() const;
86 // Clear any redirected objects
87 virtual void clearRedirect() const;
89 // Get the dictionary to initialize the codeContext
90 virtual const dictionary& codeDict() const;
94 //- Disallow default bitwise copy construct
95 codedFunctionObject(const codedFunctionObject&);
97 //- Disallow default bitwise assignment
98 void operator=(const codedFunctionObject&);
103 //- Runtime type information
109 //- Construct for given objectRegistry and dictionary.
110 // Allow the possibility to load fields from files
115 const dictionary& dict,
116 bool readNow=true // allow child-classes to avoid compilation
121 virtual ~codedFunctionObject();
126 //- Dynamically compiled functionObject
127 functionObject& redirectFunctionObject() const;
129 //- Called at the start of the time-loop
130 virtual bool start();
132 //- Called at each ++ or += of the time-loop. forceWrite overrides the
133 // outputControl behaviour.
134 virtual bool execute(const bool forceWrite);
136 //- Called when Time::run() determines that the time-loop exits.
137 // By default it simply calls execute().
140 //- Read and set the function object if its data have changed
141 virtual bool read(const dictionary&);
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 // ************************************************************************* //