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-2023 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.C
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  // Generated Methods
88 
89  //- Copy construct
91 
92 
93  // Constructors
94 
95  //- Construct from patch and internal field
97  (
98  const pointPatch&,
100  );
101 
102  //- Construct from patch, internal field and value
104  (
105  const pointPatch&,
107  const Type& value
108  );
109 
110  //- Construct from patch, internal field and dictionary
112  (
113  const pointPatch&,
115  const dictionary& dict,
118  );
119 
120  //- Construct, forwarding to readOption variant
122  (
123  const pointPatch& p,
125  const dictionary& dict,
126  const bool needValue
127  )
128  :
130  (
131  p, iF, dict,
132  (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
133  )
134  {}
135 
136  //- Construct by mapping given patch field onto a new patch
138  (
140  const pointPatch&,
142  const pointPatchFieldMapper&
143  );
144 
145  //- Construct as copy setting internal field reference
147  (
150  );
151 
152  //- Return a clone
153  virtual autoPtr<pointPatchField<Type>> clone() const
154  {
155  return pointPatchField<Type>::Clone(*this);
156  }
157 
158  //- Construct and return a clone setting internal field reference
160  (
162  ) const
163  {
164  return pointPatchField<Type>::Clone(*this, iF);
165  }
166 
167 
168  // Member Functions
169 
170  // Access
171 
172  //- Return size
173  label size() const
174  {
175  return Field<Type>::size();
176  }
177 
178 
179  // Mapping functions
180 
181  //- Map (and resize as needed) from self given a mapping object
182  virtual void autoMap
183  (
184  const pointPatchFieldMapper&
185  );
186 
187  //- Reverse map the given PointPatchField onto
188  // this PointPatchField
189  virtual void rmap
190  (
191  const pointPatchField<Type>&,
192  const labelList&
193  );
194 
195 
196  // Evaluation functions
198  //- Update the coefficients associated with the patch field
199  virtual void updateCoeffs();
200 
201  //- Evaluate the patch field
202  virtual void evaluate
203  (
204  const Pstream::commsTypes commsType =
206  );
207 
208 
209  //- Write
210  virtual void write(Ostream&) const;
211 
212 
213  // Member Operators
214 
215  // Assignment operators
216 
217  virtual void operator=(const valuePointPatchField<Type>&);
218  virtual void operator=(const pointPatchField<Type>&);
219  virtual void operator=(const Field<Type>&);
220  virtual void operator=(const Type&);
221 
222  // Force an assignment irrespective of form of patch
223 
224  virtual void operator==(const valuePointPatchField<Type>&);
225  virtual void operator==(const pointPatchField<Type>&);
226  virtual void operator==(const Field<Type>&);
227  virtual void operator==(const Type&);
228 
229  // Prevent automatic comparison rewriting (c++20)
230  bool operator!=(const valuePointPatchField<Type>&) const = delete;
231  bool operator!=(const pointPatchField<Type>&) const = delete;
232  bool operator!=(const Field<Type>&) const = delete;
233  bool operator!=(const Type&) const = delete;
234 };
235 
236 
237 // This function is added to override the hack in pointPatchField.H
238 // which enables simple backward compatibility with versions using
239 // referenceLevel in GeometricField
240 template<class Type>
241 tmp<Field<Type>> operator+
242 (
243  const valuePointPatchField<Type>& vsppf,
244  const Type& t
245 )
246 {
247  return static_cast<const Field<Type>&>(vsppf) + t;
248 }
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #ifdef NoRepository
258  #include "valuePointPatchField.C"
259 #endif
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
void extrapolateInternal()
Assign the patch field from the internal field.
dictionary dict
virtual autoPtr< pointPatchField< Type > > clone() const
Return a clone.
Foam::valuePointPatchField.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
Foam::pointPatchFieldMapper.
virtual void operator=(const valuePointPatchField< Type > &)
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:720
label size() const
Return size.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
Abstract base class for point-mesh patch fields.
bool operator!=(const valuePointPatchField< Type > &) const =delete
valuePointPatchField(const valuePointPatchField &)=default
Copy construct.
Generic templated field type.
Definition: Field.H:62
static autoPtr< pointPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
TypeName("value")
Declare type-name, virtual type (with debug switch)
label size() const noexcept
The number of elements in the container.
Definition: UList.H:680
OBJstream os(runTime.globalPath()/outputName)
virtual void operator==(const valuePointPatchField< Type > &)
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
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].
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
"buffered" : (MPI_Bsend, MPI_Recv)
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.