Add.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) 2024 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::Function1s::Add
26 
27 Description
28  Function1 which adds the value of two Function1-s.
29 
30 Usage
31  Example, to add an offset to a table:
32  \verbatim
33  <name>
34  {
35  type add;
36 
37  value1
38  {
39  type table;
40  format csv;
41  nHeaderLine 1;
42  units ([CAD] [kPa]);
43  columns (0 1);
44  mergeSeparators no;
45  file "constant/expData/pInlet";
46  }
47 
48  value2 constant 1 [bar];
49  }
50  \endverbatim
51 
52  Where:
53  \table
54  Property | Description | Required
55  value1 | Function of type Function1<Type> | yes
56  value2 | Function of type Function1<Type> | yes
57  \endtable
58 
59 SourceFiles
60  Add.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef Add_H
65 #define Add_H
66 
67 #include "Function1.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 namespace Function1s
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class Add Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Type>
81 class Add
82 :
83  public FieldFunction1<Type, Add<Type>>
84 {
85  // Private Data
86 
87  //- Value1 function
88  const autoPtr<Function1<Type>> value1_;
89 
90  //- Value2 function
91  const autoPtr<Function1<Type>> value2_;
92 
93 
94 public:
95 
96  // Runtime type information
97  TypeName("add");
98 
99 
100  // Constructors
101 
102  //- Construct from name and dictionary
103  Add
104  (
105  const word& name,
106  const unitConversions& units,
107  const dictionary& dict
108  );
109 
110  //- Copy constructor
111  Add(const Add<Type>& se);
112 
113 
114  //- Destructor
115  virtual ~Add();
116 
117 
118  // Member Functions
119 
120  //- Return value
121  virtual inline Type value(const scalar x) const;
122 
123  //- Integrate between two values
124  virtual inline Type integral(const scalar x1, const scalar x2) const;
125 
126  //- Is this function guaranteed to be constant?
127  virtual inline bool constant() const;
128 
129  //- Write data to dictionary stream
130  virtual void write(Ostream& os, const unitConversions& units) const;
131 
132 
133  // Member Operators
134 
135  //- Disallow default bitwise assignment
136  void operator=(const Add<Type>&) = delete;
137 };
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Function1s
143 } // End namespace Foam
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #include "AddI.H"
148 
149 #ifdef NoRepository
150  #include "Add.C"
151 #endif
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
Function1 which adds the value of two Function1-s.
Definition: Add.H:95
Add(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: Add.C:32
virtual ~Add()
Destructor.
Definition: Add.C:56
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: AddI.H:39
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: Add.C:64
virtual Type value(const scalar x) const
Return value.
Definition: AddI.H:31
virtual bool constant() const
Is this function guaranteed to be constant?
Definition: AddI.H:49
void operator=(const Add< Type > &)=delete
Disallow default bitwise assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dictionary dict