TimeFunction_DimensionedFieldFunction.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) 2026 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::DimensionedFieldFunctions::TimeFunction
26 
27 Description
28  Time dependent internal and patch field initialisation and update function
29 
30  The field is initialised by evaluating the specified Foam::Function1
31  for the current time.
32 
33 Usage
34  To coded pulsed inlet using the \c functionalFixedValue boundary condition:
35  \verbatim
36  inlet
37  {
38  type functionalFixedValue;
39 
40  value
41  {
42  type timeFunction;
43 
44  function
45  {
46  type coded;
47 
48  name pulse;
49 
50  codeInclude
51  #{
52  #include "mathematicalConstants.H"
53  #};
54 
55  code
56  #{
57  return vector
58  (
59  0.5
60  *(1 - cos(constant::mathematical::twoPi*min(x/0.3, 1))),
61  0,
62  0
63  );
64  #};
65  }
66  }
67  }
68  \endverbatim
69 
70 SourceFiles
71  TimeFunction_DimensionedFieldFunction.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef TimeFunction_DimensionedFieldFunction_H
76 #define TimeFunction_DimensionedFieldFunction_H
77 
79 #include "Function1.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 namespace DimensionedFieldFunctions
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class TimeFunction Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 template<class DimensionedFieldType>
93 class TimeFunction
94 :
95  public DimensionedFieldFunction<DimensionedFieldType>
96 {
97  // Private Data
98 
99  //- Time Function1 pointer
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("timeFunction");
107 
108 
109  // Constructors
110 
111  //- Construct with dictionary to initialise given field
113  (
114  const dictionary& dict,
115  DimensionedFieldType& field
116  );
117 
118  //- Construct a copy for the given field
120  (
121  const TimeFunction& dff,
122  DimensionedFieldType& field
123  );
124 
125  //- Construct and return a clone for the specified field
127  clone(DimensionedFieldType& field) const;
128 
129 
130  //- Destructor
131  virtual ~TimeFunction()
132  {}
133 
134 
135  // Member Functions
136 
137  //- Evaluate the function and set the field
138  virtual void evaluate();
139 
140  //- Update the field for the current time
141  virtual bool update();
142 
143  //- Write data to dictionary stream
144  virtual void write(Ostream& os) const;
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace DimensionedFieldFunctions
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
Base class for run-time selectable internal and patch field initialisation evaluation and update with...
virtual autoPtr< DimensionedFieldFunction< DimensionedFieldType > > clone() const
Construct and return a clone for the specified field.
Time dependent internal and patch field initialisation and update function.
TypeName("timeFunction")
Runtime type information.
virtual void evaluate()
Evaluate the function and set the field.
virtual void write(Ostream &os) const
Write data to dictionary stream.
TimeFunction(const dictionary &dict, DimensionedFieldType &field)
Construct with dictionary to initialise given field.
virtual bool update()
Update the field for the current time.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Namespace for OpenFOAM.
dictionary dict