All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CodedFunction2.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::Function2s::Coded
26 
27 Description
28  Constructs a dynamically compiled function of two variables.
29 
30 See also
31  Foam::dynamicCode
32  Foam::functionEntries::codeStream
33 
34 SourceFiles
35  CodedFunction2I.H
36  CodedFunction2.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef CodedFunction2_H
41 #define CodedFunction2_H
42 
43 #include "Function2.H"
44 #include "codedBase.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace Function2s
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class coded Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class coded
58 {
59 public:
60 
61  ClassNameNoDebug("Function2");
62 };
63 
64 
65 /*---------------------------------------------------------------------------*\
66  Class Coded Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class Type>
70 class Coded
71 :
72  public Function2<Type>,
73  public codedBase
74 {
75  // Private Data
76 
77  //- The dynamically generated Function2 pointer
78  mutable autoPtr<Function2<Type>> redirectFunction2Ptr_;
79 
80 
81  // Private Member Functions
82 
83  //- Get the keywords associated with source code
84  virtual wordList codeKeys() const;
85 
86  //- Adapt the context for the current object
87  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
88 
89  //- Clear the ptr to the redirected object
90  virtual void clearRedirect() const;
91 
92  //- Compile, link and return the now coded Function2
93  autoPtr<Function2<Type>> compileNew();
94 
95 
96 public:
97 
98  // Runtime type information
99  TypeName("coded");
100 
101 
102  // Constructors
103 
104  //- Construct from name and dictionary
105  Coded
106  (
107  const word& name,
108  const dictionary& dict
109  );
110 
111  //- Copy constructor
112  Coded(const Coded<Type>& cf1);
113 
114  //- Construct and return a clone
115  virtual tmp<Function2<Type>> clone() const;
116 
117 
118  //- Destructor
119  virtual ~Coded();
120 
121 
122  // Member Functions
123 
124  //- Return value as a function of two scalars
125  virtual inline Type value(const scalar x, const scalar y) const;
126 
127  //- Return value as a function of two scalar fields
128  virtual tmp<Field<Type>> value
129  (
130  const scalarField& x,
131  const scalarField& y
132  ) const;
133 
134  //- Write data to dictionary stream
135  virtual void write(Ostream& os) const;
136 
137 
138  // Member Operators
139 
140  //- Disallow default bitwise assignment
141  void operator=(const Coded<Type>&) = delete;
142 };
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 } // End namespace Function2s
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #include "CodedFunction2I.H"
153 
154 #ifdef NoRepository
155  #include "CodedFunction2.C"
156 #endif
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar y
T clone(const T &t)
Definition: List.H:54
A class for handling words, derived from string.
Definition: word.H:59
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:53
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:70
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Constructs a dynamically compiled function of two variables.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
Encapsulation of dynamic code dictionaries.
Run-time selectable function of two variables.
Definition: Function2.H:52
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A class for managing temporary objects.
Definition: PtrList.H:53
ClassNameNoDebug("Function2")
Namespace for OpenFOAM.