OneConstant.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) 2017-2019 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::Function1Types::OneConstant
26 
27 Description
28  Templated function that returns the corresponding 1 (one).
29 
30  Usage:
31  \verbatim
32  <entryName> one;
33  \endverbatim
34 
35 SourceFiles
36  OneConstant.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef OneConstant_H
41 #define OneConstant_H
42 
43 #include "Function1.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace Function1Types
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class OneConstant Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type>
57 class OneConstant
58 :
59  public Function1<Type>
60 {
61 
62 public:
63 
64  // Runtime type information
65  TypeName("one");
66 
67 
68  // Constructors
69 
70  //- Construct from entry name
71  OneConstant(const word& entryName);
72 
73  //- Construct from entry name and dictionary
74  OneConstant(const word& entryName, const dictionary& dict);
75 
76  //- Construct and return a clone
77  virtual tmp<Function1<Type>> clone() const
78  {
79  return tmp<Function1<Type>>(new OneConstant<Type>(*this));
80  }
81 
82 
83  //- Destructor
84  virtual ~OneConstant();
85 
86 
87  // Member Functions
88 
89  //- Return constant value
90  virtual inline Type value(const scalar) const;
91 
92  //- Integrate between two values
93  virtual inline Type integrate(const scalar x1, const scalar x2) const;
94 
95  //- Return value as a function of (scalar) independent variable
96  virtual tmp<Field<Type>> value(const scalarField& x) const;
97 
98  //- Integrate between two (scalar) values
99  virtual tmp<Field<Type>> integrate
100  (
101  const scalarField& x1,
102  const scalarField& x2
103  ) const;
104 
105  //- Write in dictionary format
106  virtual void writeData(Ostream& os) const;
107 
108 
109  // Member Operators
110 
111  //- Disallow default bitwise assignment
112  void operator=(const OneConstant<Type>&) = delete;
113 };
114 
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 } // End namespace Function1Types
119 } // End namespace Foam
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 #include "OneConstantI.H"
124 
125 #ifdef NoRepository
126  #include "OneConstant.C"
127 #endif
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 #endif
132 
133 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: OneConstant.H:76
const word const dictionary & dict
Definition: Function1.H:85
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual Type value(const scalar) const
Return constant value.
Definition: OneConstantI.H:31
void operator=(const OneConstant< Type > &)=delete
Disallow default bitwise assignment.
const word & entryName
Definition: Function1.H:85
Templated function that returns the corresponding 1 (one).
Definition: OneConstant.H:56
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: OneConstantI.H:39
virtual ~OneConstant()
Destructor.
Definition: OneConstant.C:51
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: OneConstant.C:79
OneConstant(const word &entryName)
Construct from entry name.
Definition: OneConstant.C:31
Namespace for OpenFOAM.