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-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 \*---------------------------------------------------------------------------*/
25 
26 #include "IOobject.H"
27 #include "dictionary.H"
28 #include "fvMesh.H"
29 #include "fieldMapper.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
40  Field<Type>(p.size()),
41  patch_(p),
42  internalField_(iF),
43  updated_(false),
44  manipulatedMatrix_(false)
45 {}
46 
47 
48 template<class Type>
50 (
51  const fvPatch& p,
53  const Field<Type>& f
54 )
55 :
56  Field<Type>(f),
57  patch_(p),
58  internalField_(iF),
59  updated_(false),
60  manipulatedMatrix_(false)
61 {}
62 
63 
64 template<class Type>
66 (
67  const fvPatch& p,
69  const dictionary& dict,
70  const bool valueRequired
71 )
72 :
73  Field<Type>(p.size()),
74  libs_(dict.lookupOrDefault("libs", fileNameList::null())),
75  patch_(p),
76  internalField_(iF),
77  updated_(false),
78  manipulatedMatrix_(false)
79 {
80  if (valueRequired)
81  {
82  if (dict.found("value"))
83  {
85  (
86  Field<Type>("value", iF.dimensions(), dict, p.size())
87  );
88  }
89  else
90  {
92  << "Essential entry 'value' missing"
93  << exit(FatalIOError);
94  }
95  }
96 }
97 
98 
99 template<class Type>
101 (
102  const fvPatchField<Type>& ptf,
103  const fvPatch& p,
105  const fieldMapper& mapper,
106  const bool mappingRequired
107 )
108 :
109  Field<Type>(p.size()),
110  libs_(ptf.libs_),
111  patch_(p),
112  internalField_(iF),
113  updated_(false),
114  manipulatedMatrix_(false)
115 {
116  if (mappingRequired)
117  {
118  mapper(*this, ptf);
119  }
120 }
121 
122 
123 template<class Type>
125 (
126  const fvPatchField<Type>& ptf,
128 )
129 :
130  Field<Type>(ptf),
131  libs_(ptf.libs_),
132  patch_(ptf.patch_),
133  internalField_(iF),
134  updated_(false),
135  manipulatedMatrix_(false)
136 {}
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class Type>
143 {
144  return patch_.mesh();
145 }
146 
147 
148 template<class Type>
150 {
151  return patch_.time();
152 }
153 
154 
155 template<class Type>
157 {
158  if (&patch_ != &(ptf.patch_))
159  {
161  << "different patches for fvPatchField<Type>s"
162  << abort(FatalError);
163  }
164 }
165 
166 
167 template<class Type>
169 {
170  return patch_.deltaCoeffs()*(*this - patchInternalField());
171 }
172 
173 
174 template<class Type>
177 {
178  return patch_.patchInternalField(internalField_);
179 }
180 
181 
182 template<class Type>
184 {
185  patch_.patchInternalField(internalField_, pif);
186 }
187 
188 
189 template<class Type>
191 (
192  const fvPatchField<Type>& ptf,
193  const fieldMapper& mapper
194 )
195 {
196  mapper(*this, ptf);
197 }
198 
199 
200 template<class Type>
202 {
203  Field<Type>::reset(ptf);
204 }
205 
206 
207 template<class Type>
209 {
210  updated_ = true;
211 }
212 
213 
214 template<class Type>
216 {
217  if (!updated_)
218  {
219  updateCoeffs();
220  }
221 
222  updated_ = false;
223  manipulatedMatrix_ = false;
224 }
225 
226 
227 template<class Type>
229 {
230  manipulatedMatrix_ = true;
231 }
232 
233 
234 template<class Type>
236 {
237  writeEntry(os, "type", type());
238 
239  if (overridesConstraint())
240  {
241  writeEntry(os, "patchType", patch().type());
242  }
243 
244  if (libs_.size())
245  {
246  writeEntry(os, "libs", libs_);
247  }
248 }
249 
250 
251 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
252 
253 template<class Type>
255 (
256  const UList<Type>& ul
257 )
258 {
260 }
261 
262 
263 template<class Type>
265 (
266  const fvPatchField<Type>& ptf
267 )
268 {
269  check(ptf);
271 }
272 
273 
274 template<class Type>
276 (
277  const fvPatchField<Type>& ptf
278 )
279 {
280  check(ptf);
282 }
283 
284 
285 template<class Type>
287 (
288  const fvPatchField<Type>& ptf
289 )
290 {
291  check(ptf);
293 }
294 
295 
296 template<class Type>
298 (
299  const fvPatchField<scalar>& ptf
300 )
301 {
302  if (&patch_ != &ptf.patch())
303  {
305  << "incompatible patches for patch fields"
306  << abort(FatalError);
307  }
308 
310 }
311 
312 
313 template<class Type>
315 (
316  const fvPatchField<scalar>& ptf
317 )
318 {
319  if (&patch_ != &ptf.patch())
320  {
322  << abort(FatalError);
323  }
324 
326 }
327 
328 
329 template<class Type>
331 (
332  const Field<Type>& tf
333 )
334 {
336 }
337 
338 
339 template<class Type>
341 (
342  const Field<Type>& tf
343 )
344 {
346 }
347 
348 
349 template<class Type>
351 (
352  const scalarField& tf
353 )
354 {
356 }
357 
358 
359 template<class Type>
361 (
362  const scalarField& tf
363 )
364 {
366 }
367 
368 
369 template<class Type>
371 (
372  const Type& t
373 )
374 {
376 }
377 
378 
379 template<class Type>
381 (
382  const Type& t
383 )
384 {
386 }
387 
388 
389 template<class Type>
391 (
392  const Type& t
393 )
394 {
396 }
397 
398 
399 template<class Type>
401 (
402  const scalar s
403 )
404 {
406 }
407 
408 
409 template<class Type>
411 (
412  const scalar s
413 )
414 {
416 }
417 
418 
419 template<class Type>
421 (
422  const fvPatchField<Type>& ptf
423 )
424 {
426 }
427 
428 
429 template<class Type>
431 (
432  const Field<Type>& tf
433 )
434 {
436 }
437 
438 
439 template<class Type>
441 (
442  const Type& t
443 )
444 {
446 }
447 
448 
449 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
450 
451 template<class Type>
453 {
454  ptf.write(os);
455 
456  os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
457 
458  return os;
459 }
460 
461 
462 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
463 
464 #include "fvPatchFieldNew.C"
465 
466 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:83
void operator=(const Field< Type > &)
Definition: Field.C:557
void operator+=(const UList< Type > &)
Definition: Field.C:655
void operator-=(const UList< Type > &)
Definition: Field.C:656
void operator*=(const UList< scalar > &)
Definition: Field.C:657
void operator/=(const UList< scalar > &)
Definition: Field.C:658
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:456
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:108
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
commsTypes
Types of communications.
Definition: UPstream.H:65
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:215
const Time & time() const
Return time.
Definition: fvPatchField.C:149
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:176
fvPatchField(const fvPatch &, const DimensionedField< Type, fvMesh > &)
Construct from patch and internal field.
Definition: fvPatchField.C:35
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:168
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:142
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:208
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
Definition: fvPatchField.C:201
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: fvPatchField.C:228
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:370
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:191
void check(const fvPatchField< Type > &) const
Check fvPatchField<Type> against given fvPatchField<Type>
Definition: fvPatchField.C:156
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
Registry of regIOobjects.
const Time & time() const
Return time.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const tensorField & tf
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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
IOerror FatalIOError
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
error FatalError
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
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