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-2026 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  //- Keywords associated with source code
78  static const wordList codeKeys;
79 
80  //- Name of the dictionary variables in the source code
81  static const wordList codeDictVars;
82 
83  // Name of the code options template file
84  static const word codeOptions;
85 
86  // Names of the source files to compile
87  static const wordList compileFiles;
88 
89  // Names of the source files to copy (header files)
90  static const wordList copyFiles;
91 
92  //- Cache of the unit conversions
93  const unitSets units_;
94 
95  //- The dynamically generated Function2 pointer
96  mutable autoPtr<Function2<Type>> redirectFunction2Ptr_;
97 
98 
99 public:
100 
101  // Runtime type information
102  TypeName("coded");
103 
104 
105  // Constructors
106 
107  //- Construct from name and dictionary
108  Coded
109  (
110  const word& name,
111  const unitSets& units,
112  const dictionary& dict
113  );
114 
115  //- Copy constructor
116  Coded(const Coded<Type>& cf1);
117 
118  //- Construct and return a clone
119  virtual tmp<Function2<Type>> clone() const;
120 
121 
122  //- Destructor
123  virtual ~Coded();
124 
125 
126  // Member Functions
127 
128  //- Return value as a function of two scalars
129  virtual inline Type value(const scalar x, const scalar y) const;
130 
131  //- Return value as a function of two scalar fields
132  virtual tmp<Field<Type>> value
133  (
134  const scalarField& x,
135  const scalarField& y
136  ) const;
137 
138  //- Write data to dictionary stream
139  virtual void write(Ostream& os, const unitSets& units) const;
140 
141 
142  // Member Operators
143 
144  //- Disallow default bitwise assignment
145  void operator=(const Coded<Type>&) = delete;
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Function2s
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #include "CodedFunction2I.H"
157 
158 #ifdef NoRepository
159  #include "CodedFunction2.C"
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
scalar y
Run-time selectable function of two variables.
Definition: Function2.H:62
const word & name() const
Return the name of the entry.
Definition: Function2.C:78
Constructs a dynamically compiled function of two variables.
virtual tmp< Function2< Type > > clone() const
Construct and return a clone.
Coded(const word &name, const unitSets &units, const dictionary &dict)
Construct from name and dictionary.
virtual void write(Ostream &os, const unitSets &units) const
Write data to dictionary stream.
virtual ~Coded()
Destructor.
virtual Type value(const scalar x, const scalar y) const
Return value as a function of two scalars.
void operator=(const Coded< Type > &)=delete
Disallow default bitwise assignment.
ClassNameNoDebug("Function2")
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Base class for coded functionObjects, fvModels, Function1, Function2.
Definition: codedBase.H:53
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
dictionary dict