unknownTypeFunction1.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) 2021-2024 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::unknownTypeFunction1
26 
27 Description
28  Wrapper around Function1 that constructs a function for an as yet
29  unknown primitive type. It stores the location of the user input and
30  actually constructs the function on demand at the point at which a value is
31  requested for a specific type.
32 
33 SourceFiles
34  unknownTypeFunction1.C
35  unknownTypeFunction1Templates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef unknownTypeFunction1_H
40 #define unknownTypeFunction1_H
41 
42 #include "Function1.H"
43 #include "fieldTypes.H"
44 #include "nil.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class unknownTypeFunction1 Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57  // Private Classes
58 
59  //- Convenient grouping of Function1s of all primitive types
60  struct functionPtr
61  :
62  #define PublicAutoPtrFunction1Type(Type, nullArg) \
63  public autoPtr<Function1<Type>>,
64  FOR_ALL_FIELD_TYPES(PublicAutoPtrFunction1Type)
65  #undef InheritAutoPtrFunction1Type
66  private nil
67  {};
68 
69 
70  // Private Data
71 
72  //- Name of the function
73  const word name_;
74 
75  //- Unit conversion for x-axis values
76  const unitConversion xUnits_;
77 
78  //- Top-level dictionary from which to read the function
79  const dictionary& topDict_;
80 
81  //- Keyword within the top-level dictionary to the sub-dictionary in
82  // which this function is defined
83  const word topDictKeyword_;
84 
85  //- Pointer to the Function1
86  mutable functionPtr functionPtr_;
87 
88 
89  // Private Member Functions
90 
91  //- Build the function of a given primitive type
92  template<class Type>
93  void build(const unitConversion& valueUnits) const;
94 
95 
96 public:
97 
98  // Constructors
99 
100  //- Construct from a name and a dictionary
102  (
103  const word& name,
104  const unitConversion& xUnits,
105  const dictionary& dict
106  );
107 
108  //- Disallow default bitwise copy construction
110 
111 
112  //- Destructor
114 
115 
116  // Member Functions
117 
118  //- Set the value units
119  template<class Type>
120  void setValueUnits(const unitConversion&) const;
121 
122  //- Return value as a function of scalar x
123  template<class Type>
124  Type value(const scalar x) const;
125 
126  //- Return value as a function of scalarField x
127  template<class Type>
128  tmp<Field<Type>> value(const scalarField& x) const;
129 
130  //- Integrate between two scalars
131  template<class Type>
132  Type integral(const scalar x1, const scalar x2) const;
133 
134  //- Integrate between two scalar fields
135  template<class Type>
137  (
138  const scalarField& x1,
139  const scalarField& x2
140  ) const;
141 
142 
143  // Member Operators
144 
145  //- Disallow default bitwise assignment
146  void operator=(const unknownTypeFunction1&) = delete;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #ifdef NoRepository
158 #endif
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A zero-sized class without any storage. Used, for example, in HashSet.
Definition: nil.H:59
A class for managing temporary objects.
Definition: tmp.H:55
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
Wrapper around Function1 that constructs a function for an as yet unknown primitive type....
unknownTypeFunction1(const word &name, const unitConversion &xUnits, const dictionary &dict)
Construct from a name and a dictionary.
Type integral(const scalar x1, const scalar x2) const
Integrate between two scalars.
Type value(const scalar x) const
Return value as a function of scalar x.
void setValueUnits(const unitConversion &) const
Set the value units.
void operator=(const unknownTypeFunction1 &)=delete
Disallow default bitwise assignment.
A class for handling words, derived from string.
Definition: word.H:62
Include the header files for all the primitive types that Fields are instantiated for.
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
dictionary dict