valuePointPatchField.C
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) 2011-2019 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 \*---------------------------------------------------------------------------*/
25 
26 #include "valuePointPatchField.H"
27 #include "pointPatchFieldMapper.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 {
34  if (this->size() != this->patch().size())
35  {
37  << "field does not correspond to patch. " << endl
38  << "Field size: " << size() << " patch size: "
39  << this->patch().size()
40  << abort(FatalError);
41  }
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
46 
47 template<class Type>
49 (
50  const pointPatch& p,
52 )
53 :
55  Field<Type>(p.size())
56 {}
57 
58 
59 template<class Type>
61 (
62  const pointPatch& p,
64  const dictionary& dict,
65  const bool valueRequired
66 )
67 :
69  Field<Type>(p.size())
70 {
71  if (dict.found("value"))
72  {
74  (
75  Field<Type>("value", dict, p.size())
76  );
77  }
78  else if (!valueRequired)
79  {
81  }
82  else
83  {
85  (
86  dict
87  ) << "Essential entry 'value' missing"
88  << exit(FatalIOError);
89  }
90 }
91 
92 
93 template<class Type>
95 (
96  const valuePointPatchField<Type>& ptf,
97  const pointPatch& p,
99  const pointPatchFieldMapper& mapper
100 )
101 :
102  pointPatchField<Type>(ptf, p, iF, mapper),
103  Field<Type>(mapper(ptf))
104 {}
105 
106 
107 template<class Type>
109 (
110  const valuePointPatchField<Type>& ptf,
112 )
113 :
114  pointPatchField<Type>(ptf, iF),
115  Field<Type>(ptf)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
121 template<class Type>
123 (
124  const pointPatchFieldMapper& m
125 )
126 {
127  m(*this, *this);
128 }
129 
130 
131 template<class Type>
133 (
134  const pointPatchField<Type>& ptf,
135  const labelList& addr
136 )
137 {
139  (
141  (
142  ptf
143  ),
144  addr
145  );
146 }
147 
148 
149 template<class Type>
151 {
152  if (this->updated())
153  {
154  return;
155  }
156 
157  // Get internal field to insert values into
158  Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
159 
160  this->setInInternalField(iF, *this);
161 
163 }
164 
165 
166 template<class Type>
168 {
169  // Get internal field to insert values into
170  Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
171 
172  this->setInInternalField(iF, *this);
173 
175 }
176 
177 
178 template<class Type>
180 {
182  writeEntry(os, "value", static_cast<const Field<Type>&>(*this));
183 }
184 
185 
186 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
187 
188 template<class Type>
189 void Foam::valuePointPatchField<Type>::operator=
190 (
191  const valuePointPatchField<Type>& ptf
192 )
193 {
195 }
196 
197 
198 template<class Type>
199 void Foam::valuePointPatchField<Type>::operator=
200 (
201  const pointPatchField<Type>& ptf
202 )
203 {
204  Field<Type>::operator=(this->patchInternalField());
205 }
206 
207 
208 template<class Type>
209 void Foam::valuePointPatchField<Type>::operator=
210 (
211  const Field<Type>& tf
212 )
213 {
215 }
216 
217 
218 template<class Type>
219 void Foam::valuePointPatchField<Type>::operator=
220 (
221  const Type& t
222 )
223 {
225 }
226 
227 
228 template<class Type>
229 void Foam::valuePointPatchField<Type>::operator==
230 (
231  const valuePointPatchField<Type>& ptf
232 )
233 {
235 }
236 
237 
238 template<class Type>
239 void Foam::valuePointPatchField<Type>::operator==
240 (
241  const pointPatchField<Type>& ptf
242 )
243 {
244  Field<Type>::operator=(this->patchInternalField());
245 }
246 
247 
248 template<class Type>
249 void Foam::valuePointPatchField<Type>::operator==
250 (
251  const Field<Type>& tf
252 )
253 {
255 }
256 
257 
258 template<class Type>
259 void Foam::valuePointPatchField<Type>::operator==
260 (
261  const Type& t
262 )
263 {
265 }
266 
267 
268 // ************************************************************************* //
valuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
Foam::valuePointPatchField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
commsTypes
Types of communications.
Definition: UPstream.H:64
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
Foam::pointPatchFieldMapper.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
const tensorField & tf
Abstract base class for point-mesh patch fields.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Pre-declare SubField and related Field type.
Definition: Field.H:56
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
static const zero Zero
Definition: zero.H:97
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:335
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
label size() const
Return size.
volScalarField & p
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
IOerror FatalIOError