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 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 Function1Types_None_H
38 #define 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 constructor
73  None(const None<Type>& rhs) = 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  //- Placeholder: generates an error if called
106  virtual Type value(const scalar x) const;
107 
108  //- Placeholder: generates an error if called
109  virtual Type integral(const scalar x1, const scalar x2) const;
110 
111  //- Placeholder: generates an error if called
112  virtual tmp<Field<Type>> value(const scalarField& x) const;
113 
114  //- Write as primitive (inline) format
115  virtual void writeData(Ostream& os) const;
116 };
117 
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 } // End namespace Function1Types
122 } // End namespace Foam
123 
124 #ifdef NoRepository
125  #include "NoneFunction1.C"
126 #endif
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Function1.H
Foam::Function1Types::None::TypeName
TypeName("none")
Runtime type information.
Foam::Function1Types::None::operator=
void operator=(const None< Type > &)=delete
No copy assignment.
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:134
NoneFunction1.C
Foam::Function1Types::None
Templated placeholder function that returns an error message if called.
Definition: NoneFunction1.H:53
Foam::Function1Types::None::integral
virtual Type integral(const scalar x1, const scalar x2) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:60
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::Field< scalar >
Foam::Function1::obrPtr
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
Foam::Function1Types::None::value
virtual Type value(const scalar x) const
Placeholder: generates an error if called.
Definition: NoneFunction1.C:48
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Function1Types::None::constant
virtual bool constant() const
Value is independent of x.
Definition: NoneFunction1.H:102
Foam::Function1Types::None::~None
virtual ~None()=default
Destructor.
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Function1Types::None::writeData
virtual void writeData(Ostream &os) const
Write as primitive (inline) format.
Definition: NoneFunction1.C:89
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::None::None
None(const None< Type > &rhs)=default
Default copy constructor.
Foam::Function1Types::None::clone
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: NoneFunction1.H:89