FieldFunction_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::FieldFunction
26 
27 Description
28  Field function which looks up another field and uses it as the argument to
29  evaluate a given Foam::Function1. The user must specify both the name of
30  the looked-up field and the function1.
31 
32 Usage
33  To create a temperature dependent electrical conductivity in the
34  \c solidElectricalConduction fvModel:
35  \verbatim
36  solidElectricalConduction
37  {
38  type solidElectricalConduction;
39 
40  sigma
41  {
42  type fieldFunction;
43  field T;
44  function
45  {
46  type polynomial;
47  coeffs (7.61e7 -1.38e5);
48  }
49  }
50  }
51  \endverbatim
52 
53 SourceFiles
54  FieldFunction_DimensionedFieldFunction.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef FieldFunction_DimensionedFieldFunction_H
59 #define FieldFunction_DimensionedFieldFunction_H
60 
62 #include "Function1.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace DimensionedFieldFunctions
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class FieldFunction Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 template<class DimensionedFieldType>
76 class FieldFunction
77 :
78  public DimensionedFieldFunction<DimensionedFieldType>
79 {
80  // Private Data
81 
82  //- Field name
83  const word fieldName_;
84 
85  //- Field Function1 pointer
87 
88  //- Cached dictionary
89  autoPtr<dictionary> dictPtr_;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("fieldFunction");
96 
97 
98  // Constructors
99 
100  //- Construct with dictionary to initialise given field
102  (
103  const dictionary& dict,
104  DimensionedFieldType& field
105  );
106 
107  //- Construct a copy for the given field
109  (
110  const FieldFunction& dff,
111  DimensionedFieldType& field
112  );
113 
114  //- Construct and return a clone for the specified field
116  clone(DimensionedFieldType& field) const;
117 
118 
119  //- Destructor
120  virtual ~FieldFunction()
121  {}
122 
123 
124  // Member Functions
125 
126  //- Evaluate the function and set the field
127  virtual void evaluate();
128 
129  //- Update the field for the current time
130  virtual bool update();
131 
132  //- Write data to dictionary stream
133  virtual void write(Ostream& os) const;
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace DimensionedFieldFunctions
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #ifdef NoRepository
146 #endif
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
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.
Field function which looks up another field and uses it as the argument to evaluate a given Foam::Fun...
virtual void evaluate()
Evaluate the function and set the field.
virtual void write(Ostream &os) const
Write data to dictionary stream.
virtual bool update()
Update the field for the current time.
FieldFunction(const dictionary &dict, DimensionedFieldType &field)
Construct with dictionary to initialise given field.
TypeName("fieldFunction")
Runtime type information.
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
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
dictionary dict