UFunctionalDimensionedField.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::UFunctionalDimensionedField
26 
27 Description
28  Combined class containing a field reference, a dimensionedField wrapper
29  providing the corresponding mesh and dimensions and a run-time selected
30  function to evaluate and update the field.
31 
32  Particularly applicable to time and/or space varying boundary conditions.
33 
34 See also
35  Foam::DimensionedField
36  Foam::DimensionedFieldFunction
37  Foam::FunctionalDimensionedField
38 
39 SourceFiles
40  UFunctionalDimensionedField.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef UFunctionalDimensionedField_H
45 #define UFunctionalDimensionedField_H
46 
48 #include "SlicedDimensionedField.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of friend functions
57 template<class Type, class GeoMesh>
58 void writeEntry
59 (
60  Ostream& os,
61  const UFunctionalDimensionedField<Type, GeoMesh>& udff
62 );
63 
64 /*---------------------------------------------------------------------------*\
65  Class UFunctionalDimensionedField Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 template<class Type, class GeoMesh>
70 :
71  public SlicedDimensionedField<Type, GeoMesh>
72 {
73  // Private Data
74 
75  //- Reference to field
76  Field<Type>& field_;
77 
78  //- Name of the function entry/sub dictionary
79  const word funcName_;
80 
81  //- Optional function pointer
83  funcPtr_;
84 
85 
86 public:
87 
88  // Constructors
89 
90  //- Construct from name, mesh, dimensions, field and dictionary
92  (
93  const word& name,
94  const word& funcName,
95  const GeoMesh&,
96  const dimensionSet& dimensions,
97  Field<Type>&,
98  const dictionary&
99  );
100 
101  //- Construct from name, mesh, dimensions, field, dictionary
102  // and default value
104  (
105  const word& name,
106  const word& funcName,
107  const GeoMesh&,
108  const dimensionSet& dimensions,
109  Field<Type>&,
110  const dictionary&,
111  const Type& defaultValue
112  );
113 
114  //- Construct from given UFunctionalDimensionedField
115  // with new mesh and field
117  (
119  const GeoMesh&,
120  Field<Type>&
121  );
122 
123  //- Disallow copy
125  (
127  ) = delete;
128 
129  //- Copy constructor setting field reference
131  (
133  Field<Type>&
134  );
135 
136 
137  // Member Functions
138 
139  //- Map and optionally evaluate
140  void map(const bool evaluate);
141 
142  //- Reset
143  void reset();
144 
145  //- Update
146  bool update();
147 
148  using regIOobject::write;
149 
150  //- Write
151  void write(Ostream&) const;
152 
153 
154  // Global functions
155 
156  friend void writeEntry <Type, GeoMesh>
157  (
158  Ostream& os,
160  );
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #ifdef NoRepository
172 #endif
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:83
const word & name() const
Return name.
Definition: IOobject.H:307
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Specialisation of DimensionedField which holds a slice of a given complete field in such a form that ...
Combined class containing a field reference, a dimensionedField wrapper providing the corresponding m...
UFunctionalDimensionedField(const word &name, const word &funcName, const GeoMesh &, const dimensionSet &dimensions, Field< Type > &, const dictionary &)
Construct from name, mesh, dimensions, field and dictionary.
virtual bool write(const bool write=true) const
Write using setting from DB.
void map(const bool evaluate)
Map and optionally evaluate.
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
Dimension set for the base types.
Definition: dimensionSet.H:125
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)