valuePointPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020-2025 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::valuePointPatchField
29 
30 Description
31  Foam::valuePointPatchField
32 
33 SourceFiles
34  valuePointPatchField.txx
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_valuePointPatchField_H
39 #define Foam_valuePointPatchField_H
40 
41 #include "pointPatchField.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class valuePointPatchField Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
54 :
55  public pointPatchField<Type>,
56  public Field<Type>
57 {
58 protected:
59 
60  // Protected Member Functions
61 
62  //- Read the "value" entry into \c *this.
63  // The reading can be optional (default), mandatory etc.
64  // \returns True on success
65  bool readValueEntry
66  (
67  const dictionary& dict,
69  );
70 
71  //- Write \c *this field as a "value" entry
72  void writeValueEntry(Ostream& os) const
73  {
74  Field<Type>::writeEntry("value", os);
75  }
76 
77  //- Assign the patch field from the internal field
78  void extrapolateInternal();
79 
80 
81 public:
82 
83  //- Declare type-name, virtual type (with debug switch)
84  TypeName("value");
85 
86 
87  // Constructors
88 
89  //- Construct from patch and internal field
91  (
92  const pointPatch&,
94  );
95 
96  //- Construct from patch, internal field and value
98  (
99  const pointPatch&,
101  const Type& value
102  );
103 
104  //- Construct from patch, internal field and dictionary
106  (
107  const pointPatch&,
109  const dictionary& dict,
112  );
113 
114  //- Construct, forwarding to readOption variant
116  (
117  const pointPatch& p,
119  const dictionary& dict,
120  const bool needValue
121  )
122  :
124  (
125  p, iF, dict,
126  (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
127  )
128  {}
129 
130  //- Construct by mapping onto a new patch
132  (
134  const pointPatch&,
136  const pointPatchFieldMapper&
137  );
138 
139  //- Copy construct onto patch with internal field reference
140  //- and specified value
142  (
143  const valuePointPatchField<Type>& pfld,
144  const pointPatch& p,
146  const Type& value
147  );
148 
149  //- Copy construct with internal field reference
151  (
152  const valuePointPatchField<Type>& pfld,
154  );
155 
156  //- No copy without an internal field
157  [[deprecated("2026-03: soon = delete")]]
159  #ifdef Foam_pointPatchField_copyConstruct
160  : valuePointPatchField(pfld, pfld.internalField()) {}
161  #else
162  = delete;
163  #endif
164 
165  //- Clone with an internal field reference
166  virtual autoPtr<pointPatchField<Type>> clone
167  (
168  const DimensionedField<Type, pointMesh>& iF
169  ) const
170  {
171  return pointPatchField<Type>::Clone(*this, iF);
172  }
173 
174 
175  // Member Functions
176 
177  // Attributes
178 
179  //- True: this patch field is altered by assignment by default.
180  virtual bool assignable() const
181  {
182  return true;
183  }
184 
185 
186  // Access
187 
188  //- Return the field size
189  label size() const noexcept
190  {
191  return Field<Type>::size();
192  }
193 
194 
195  // Mapping functions
196 
197  //- Map (and resize as needed) from self given a mapping object
198  virtual void autoMap
199  (
200  const pointPatchFieldMapper&
201  );
202 
203  //- Reverse map the given PointPatchField onto
204  // this PointPatchField
205  virtual void rmap
206  (
207  const pointPatchField<Type>&,
208  const labelList&
209  );
210 
211 
212  // Evaluation functions
213 
214  //- Update the coefficients associated with the patch field
215  virtual void updateCoeffs();
216 
217  //- Evaluate the patch field
218  virtual void evaluate
219  (
220  const Pstream::commsTypes commsType =
222  );
223 
224 
225  //- Write
226  virtual void write(Ostream&) const;
227 
228 
229  // Member Operators
230 
231  // Assignment operators
232 
233  virtual void operator=(const valuePointPatchField<Type>&);
234  virtual void operator=(const pointPatchField<Type>&);
235  virtual void operator=(const Field<Type>&);
236  virtual void operator=(const Type&);
237 
238  // Force an assignment irrespective of form of patch
239 
240  virtual void operator==(const valuePointPatchField<Type>&);
241  virtual void operator==(const pointPatchField<Type>&);
242  virtual void operator==(const Field<Type>&);
243  virtual void operator==(const Type&);
244 
245  // Prevent automatic comparison rewriting (c++20)
246  bool operator!=(const valuePointPatchField<Type>&) const = delete;
247  bool operator!=(const pointPatchField<Type>&) const = delete;
248  bool operator!=(const Field<Type>&) const = delete;
249  bool operator!=(const Type&) const = delete;
250 };
251 
252 
253 // This function is added to override the hack in pointPatchField.H
254 // which enables simple backward compatibility with versions using
255 // referenceLevel in GeometricField
256 template<class Type>
257 tmp<Field<Type>> operator+
258 (
259  const valuePointPatchField<Type>& vsppf,
260  const Type& t
261 )
262 {
263  return static_cast<const Field<Type>&>(vsppf) + t;
264 }
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace Foam
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #ifdef NoRepository
274  #include "valuePointPatchField.txx"
275 #endif
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
void extrapolateInternal()
Assign the patch field from the internal field.
valuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
dictionary dict
virtual void operator==(const valuePointPatchField< Type > &)
Foam::valuePointPatchField.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
commsTypes
Communications types.
Definition: UPstream.H:81
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
Foam::pointPatchFieldMapper.
label size() const noexcept
Return the field size.
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:754
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
Abstract base class for point-mesh patch fields.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
bool operator!=(const valuePointPatchField< Type > &) const =delete
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition: Field.H:69
tmp< Field< Type > > clone() const
Clone.
Definition: FieldI.H:140
virtual void operator=(const valuePointPatchField< Type > &)
static autoPtr< pointPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: scalarImpl.H:265
TypeName("value")
Declare type-name, virtual type (with debug switch)
label size() const noexcept
The number of elements in the container.
Definition: UList.H:707
virtual void write(Ostream &) const
Write.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Reading is optional [identical to READ_IF_PRESENT].
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
"buffered" : (MPI_Bsend, MPI_Recv)
virtual bool assignable() const
True: this patch field is altered by assignment by default.
const DimensionedField< Type, pointMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.