fvPatchField.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-2023 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 "IOobject.H"
27 #include "dictionary.H"
28 #include "fvMesh.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volMesh.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
41  Field<Type>(p.size()),
42  patch_(p),
43  internalField_(iF),
44  updated_(false),
45  manipulatedMatrix_(false)
46 {}
47 
48 
49 template<class Type>
51 (
52  const fvPatch& p,
54  const Field<Type>& f
55 )
56 :
57  Field<Type>(f),
58  patch_(p),
59  internalField_(iF),
60  updated_(false),
61  manipulatedMatrix_(false)
62 {}
63 
64 
65 template<class Type>
67 (
68  const fvPatch& p,
70  const dictionary& dict,
71  const bool valueRequired
72 )
73 :
74  Field<Type>(p.size()),
75  libs_(dict.lookupOrDefault("libs", fileNameList::null())),
76  patch_(p),
77  internalField_(iF),
78  updated_(false),
79  manipulatedMatrix_(false)
80 {
81  if (valueRequired)
82  {
83  if (dict.found("value"))
84  {
86  (
87  Field<Type>("value", dict, p.size())
88  );
89  }
90  else
91  {
93  (
94  dict
95  ) << "Essential entry 'value' missing"
96  << exit(FatalIOError);
97  }
98  }
99 }
100 
101 
102 template<class Type>
104 (
105  const fvPatchField<Type>& ptf,
106  const fvPatch& p,
108  const fvPatchFieldMapper& mapper,
109  const bool mappingRequired
110 )
111 :
112  Field<Type>(p.size()),
113  libs_(ptf.libs_),
114  patch_(p),
115  internalField_(iF),
116  updated_(false),
117  manipulatedMatrix_(false)
118 {
119  if (mappingRequired)
120  {
121  mapper(*this, ptf);
122  }
123 }
124 
125 
126 template<class Type>
128 (
129  const fvPatchField<Type>& ptf,
131 )
132 :
133  Field<Type>(ptf),
134  libs_(ptf.libs_),
135  patch_(ptf.patch_),
136  internalField_(iF),
137  updated_(false),
138  manipulatedMatrix_(false)
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
144 template<class Type>
146 {
147  return patch_.boundaryMesh().mesh();
148 }
149 
150 
151 template<class Type>
153 {
154  if (&patch_ != &(ptf.patch_))
155  {
157  << "different patches for fvPatchField<Type>s"
158  << abort(FatalError);
159  }
160 }
161 
162 
163 template<class Type>
165 {
166  return patch_.deltaCoeffs()*(*this - patchInternalField());
167 }
168 
169 
170 template<class Type>
173 {
174  return patch_.patchInternalField(internalField_);
175 }
176 
177 
178 template<class Type>
180 {
181  patch_.patchInternalField(internalField_, pif);
182 }
183 
184 
185 template<class Type>
187 (
188  const fvPatchField<Type>& ptf,
189  const fvPatchFieldMapper& mapper
190 )
191 {
192  mapper(*this, ptf);
193 }
194 
195 
196 template<class Type>
198 {
199  Field<Type>::reset(ptf);
200 }
201 
202 
203 template<class Type>
205 {
206  updated_ = true;
207 }
208 
209 
210 template<class Type>
212 {
213  if (!updated_)
214  {
215  updateCoeffs();
216  }
217 
218  updated_ = false;
219  manipulatedMatrix_ = false;
220 }
221 
222 
223 template<class Type>
225 {
226  manipulatedMatrix_ = true;
227 }
228 
229 
230 template<class Type>
232 {
233  writeEntry(os, "type", type());
234 
235  if (overridesConstraint())
236  {
237  writeEntry(os, "patchType", patch().type());
238  }
239 
240  if (libs_.size())
241  {
242  writeEntry(os, "libs", libs_);
243  }
244 }
245 
246 
247 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
248 
249 template<class Type>
251 (
252  const UList<Type>& ul
253 )
254 {
256 }
257 
258 
259 template<class Type>
261 (
262  const fvPatchField<Type>& ptf
263 )
264 {
265  check(ptf);
267 }
268 
269 
270 template<class Type>
272 (
273  const fvPatchField<Type>& ptf
274 )
275 {
276  check(ptf);
278 }
279 
280 
281 template<class Type>
283 (
284  const fvPatchField<Type>& ptf
285 )
286 {
287  check(ptf);
289 }
290 
291 
292 template<class Type>
294 (
295  const fvPatchField<scalar>& ptf
296 )
297 {
298  if (&patch_ != &ptf.patch())
299  {
301  << "incompatible patches for patch fields"
302  << abort(FatalError);
303  }
304 
306 }
307 
308 
309 template<class Type>
311 (
312  const fvPatchField<scalar>& ptf
313 )
314 {
315  if (&patch_ != &ptf.patch())
316  {
318  << abort(FatalError);
319  }
320 
322 }
323 
324 
325 template<class Type>
327 (
328  const Field<Type>& tf
329 )
330 {
332 }
333 
334 
335 template<class Type>
337 (
338  const Field<Type>& tf
339 )
340 {
342 }
343 
344 
345 template<class Type>
347 (
348  const scalarField& tf
349 )
350 {
352 }
353 
354 
355 template<class Type>
357 (
358  const scalarField& tf
359 )
360 {
362 }
363 
364 
365 template<class Type>
367 (
368  const Type& t
369 )
370 {
372 }
373 
374 
375 template<class Type>
377 (
378  const Type& t
379 )
380 {
382 }
383 
384 
385 template<class Type>
387 (
388  const Type& t
389 )
390 {
392 }
393 
394 
395 template<class Type>
397 (
398  const scalar s
399 )
400 {
402 }
403 
404 
405 template<class Type>
407 (
408  const scalar s
409 )
410 {
412 }
413 
414 
415 template<class Type>
417 (
418  const fvPatchField<Type>& ptf
419 )
420 {
422 }
423 
424 
425 template<class Type>
427 (
428  const Field<Type>& tf
429 )
430 {
432 }
433 
434 
435 template<class Type>
437 (
438  const Type& t
439 )
440 {
442 }
443 
444 
445 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
446 
447 template<class Type>
449 {
450  ptf.write(os);
451 
452  os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
453 
454  return os;
455 }
456 
457 
458 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
459 
460 #include "fvPatchFieldNew.C"
461 
462 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
void operator=(const Field< Type > &)
Definition: Field.C:526
void operator+=(const UList< Type > &)
Definition: Field.C:631
void operator-=(const UList< Type > &)
Definition: Field.C:632
void operator*=(const UList< scalar > &)
Definition: Field.C:633
void operator/=(const UList< scalar > &)
Definition: Field.C:634
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:432
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:211
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:231
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:172
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:164
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:145
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:204
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
Definition: fvPatchField.C:197
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: fvPatchField.C:224
virtual void map(const fvPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:187
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:355
void check(const fvPatchField< Type > &) const
Check fvPatchField<Type> against given fvPatchField<Type>
Definition: fvPatchField.C:152
fvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fvPatchField.C:36
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const tensorField & tf
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
IOerror FatalIOError
error FatalError
Ostream & operator<<(Ostream &, const ensightPart &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList f(nPoints)
dictionary dict
volScalarField & p