NoneFunction1.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Function1Types::None
28 
29 Description
30  Templated placeholder function that returns an error message if called.
31 
32  This is principally useful for interfaces that expect a Function1
33  but where it is not necessarily used by a particular submodel.
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_Function1Types_None_H
38 #define Foam_Function1Types_None_H
39 
40 #include "Function1.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace Function1Types
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class None Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
54 class None
55 :
56  public Function1<Type>
57 {
58  // Private Member Data
59 
60  //- Context (eg, dictionary name) for the function
61  string context_;
62 
63 
64 public:
65 
66  //- Runtime type information
67  TypeName("none");
68 
69 
70  // Generated Methods
71 
72  //- Default copy construct
73  None(const None<Type>&) = default;
74 
75  //- No copy assignment
76  void operator=(const None<Type>&) = delete;
77 
78 
79  // Constructors
80 
81  //- Construct from entry name, dictionary and optional registry
82  None
83  (
84  const word& entryName,
85  const dictionary& dict,
86  const objectRegistry* obrPtr = nullptr
87  );
88 
89  //- Construct and return a clone
90  virtual tmp<Function1<Type>> clone() const
91  {
92  return tmp<Function1<Type>>(new None<Type>(*this));
93  }
94 
95 
96  //- Destructor
97  virtual ~None() = default;
98 
99 
100  // Member Functions
101 
102  //- Value is independent of x
103  virtual inline bool constant() const { return true; }
104 
105  //- Function cannot be evaluated
106  virtual inline bool good() const { return false; }
107 
108  //- Placeholder: generates an error if called
109  virtual Type value(const scalar x) const;
110 
111  //- Placeholder: generates an error if called
112  virtual Type integral(const scalar x1, const scalar x2) const;
113 
114  //- Placeholder: generates an error if called
115  virtual tmp<Field<Type>> value(const scalarField& x) const;
116 
117  //- Write as primitive (inline) format
118  virtual void writeData(Ostream& os) const;
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Function1Types
125 } // End namespace Foam
126 
127 #ifdef NoRepository
128  #include "NoneFunction1.C"
129 #endif
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: NoneFunction1.H:95
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const word const dictionary & dict
Definition: Function1.H:140
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
None(const None< Type > &)=default
Default copy construct.
virtual Type value(const scalar x) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:41
const word & entryName
Definition: Function1.H:140
Templated placeholder function that returns an error message if called.
Definition: NoneFunction1.H:47
A class for handling words, derived from Foam::string.
Definition: word.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual void writeData(Ostream &os) const
Write as primitive (inline) format.
Definition: NoneFunction1.C:82
OBJstream os(runTime.globalPath()/outputName)
virtual Type integral(const scalar x1, const scalar x2) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:53
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:140
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
virtual bool good() const
Function cannot be evaluated.
virtual bool constant() const
Value is independent of x.
virtual ~None()=default
Destructor.
void operator=(const None< Type > &)=delete
No copy assignment.
TypeName("none")
Runtime type information.
Namespace for OpenFOAM.