DistanceFunction_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::DistanceFunction
26 
27 Description
28  Distance function internal and patch field initialisation function
29 
30  The field is initialised by evaluating the specified
31  Foam::Function1 of distance in the given spatial direction.
32 
33 Usage
34  To set a field with a linear ramp from 0 to 1 over the distance 1 starting
35  at 0 in the x-direction:
36  \verbatim
37  internalField
38  {
39  type distanceFunction;
40 
41  direction (1 0 0);
42 
43  function
44  {
45  type linearRamp;
46  duration 1;
47  }
48  }
49  \endverbatim
50 
51 SourceFiles
52  DistanceFunction_DimensionedFieldFunction.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef DistanceFunction_DimensionedFieldFunction_H
57 #define DistanceFunction_DimensionedFieldFunction_H
58 
60 #include "Function1.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 namespace DimensionedFieldFunctions
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class DistanceFunction Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 template<class DimensionedFieldType>
74 class DistanceFunction
75 :
76  public DimensionedFieldFunction<DimensionedFieldType>
77 {
78  // Private Data
79 
80  //- Distance DistanceFunction pointer
82 
83  //- Direction the DistanceFunction is evaluated for
84  vector direction_;
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("distanceFunction");
91 
92 
93  // Constructors
94 
95  //- Construct with dictionary to initialise given field
97  (
98  const dictionary& dict,
99  DimensionedFieldType& field
100  );
101 
102  //- Construct a copy for the given field
104  (
105  const DistanceFunction& dff,
106  DimensionedFieldType& field
107  );
108 
109  //- Construct and return a clone for the specified field
111  clone(DimensionedFieldType& field) const;
112 
113 
114  //- Destructor
115  virtual ~DistanceFunction()
116  {}
117 
118 
119  // Member Functions
120 
121  //- Evaluate the function and set the field
122  virtual void evaluate();
123 
124  //- Write data to dictionary stream
125  virtual void write(Ostream& os) const;
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace DimensionedFieldFunctions
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #ifdef NoRepository
138 #endif
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #endif
143 
144 // ************************************************************************* //
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.
Distance function internal and patch field initialisation function.
DistanceFunction(const dictionary &dict, DimensionedFieldType &field)
Construct with dictionary to initialise given field.
TypeName("distanceFunction")
Runtime type information.
virtual void evaluate()
Evaluate the function and set the field.
virtual void write(Ostream &os) const
Write data to dictionary stream.
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