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 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  //- Top-level dictionary from which to read the function
76  const dictionary& topDict_;
77 
78  //- Keyword within the top-level dictionary to the sub-dictionary in
79  // which this function is defined
80  const word topDictKeyword_;
81 
82  //- Pointer to the Function1
83  mutable functionPtr functionPtr_;
84 
85 
86  // Private Member Functions
87 
88  //- Build the function of a given primitive type
89  template<class Type>
90  void build() const;
91 
92 
93 public:
94 
95  // Constructors
96 
97  //- Construct from an name and a dictionary
99 
100  //- Disallow default bitwise copy construction
102 
103 
104  //- Destructor
106 
107 
108  // Member Functions
109 
110  //- Return value as a function of scalar x
111  template<class Type>
112  Type value(const scalar x) const;
113 
114  //- Return value as a function of scalarField x
115  template<class Type>
116  tmp<Field<Type>> value(const scalarField& x) const;
117 
118  //- Integrate between two scalars
119  template<class Type>
120  Type integral(const scalar x1, const scalar x2) const;
121 
122  //- Integrate between two scalar fields
123  template<class Type>
125  (
126  const scalarField& x1,
127  const scalarField& x2
128  ) const;
129 
130 
131  // Member Operators
132 
133  //- Disallow default bitwise assignment
134  void operator=(const unknownTypeFunction1&) = delete;
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #ifdef NoRepository
146 #endif
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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
Wrapper around Function1 that constructs a function for an as yet unknown primitive type....
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 operator=(const unknownTypeFunction1 &)=delete
Disallow default bitwise assignment.
unknownTypeFunction1(const word &name, const dictionary &dict)
Construct from an name and a dictionary.
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(DefineContiguousFvWallLocationDataType)
dictionary dict