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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::Function1Types::None
28
29Description
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
44namespace Foam
45{
46namespace Function1Types
47{
48
49/*---------------------------------------------------------------------------*\
50 Class None Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
54class 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
64public:
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// ************************************************************************* //
Templated placeholder function that returns an error message if called.
Definition: NoneFunction1.H:56
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: NoneFunction1.H:89
virtual void writeData(Ostream &os) const
Write as primitive (inline) format.
Definition: NoneFunction1.C:89
virtual bool constant() const
Value is independent of x.
virtual Type integral(const scalar x1, const scalar x2) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:60
TypeName("none")
Runtime type information.
virtual bool good() const
Function cannot be evaluated.
None(const None< Type > &)=default
Default copy construct.
virtual Type value(const scalar x) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:48
virtual ~None()=default
Destructor.
void operator=(const None< Type > &)=delete
No copy assignment.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
const word & entryName
Definition: Function1.H:133
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73