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-2024 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 #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", iF.dimensions(), dict, p.size())
88  );
89  }
90  else
91  {
93  << "Essential entry 'value' missing"
94  << exit(FatalIOError);
95  }
96  }
97 }
98 
99 
100 template<class Type>
102 (
103  const fvPatchField<Type>& ptf,
104  const fvPatch& p,
106  const fieldMapper& mapper,
107  const bool mappingRequired
108 )
109 :
110  Field<Type>(p.size()),
111  libs_(ptf.libs_),
112  patch_(p),
113  internalField_(iF),
114  updated_(false),
115  manipulatedMatrix_(false)
116 {
117  if (mappingRequired)
118  {
119  mapper(*this, ptf);
120  }
121 }
122 
123 
124 template<class Type>
126 (
127  const fvPatchField<Type>& ptf,
129 )
130 :
131  Field<Type>(ptf),
132  libs_(ptf.libs_),
133  patch_(ptf.patch_),
134  internalField_(iF),
135  updated_(false),
136  manipulatedMatrix_(false)
137 {}
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
142 template<class Type>
144 {
145  return patch_.boundaryMesh().mesh();
146 }
147 
148 
149 template<class Type>
151 {
152  if (&patch_ != &(ptf.patch_))
153  {
155  << "different patches for fvPatchField<Type>s"
156  << abort(FatalError);
157  }
158 }
159 
160 
161 template<class Type>
163 {
164  return patch_.deltaCoeffs()*(*this - patchInternalField());
165 }
166 
167 
168 template<class Type>
171 {
172  return patch_.patchInternalField(internalField_);
173 }
174 
175 
176 template<class Type>
178 {
179  patch_.patchInternalField(internalField_, pif);
180 }
181 
182 
183 template<class Type>
185 (
186  const fvPatchField<Type>& ptf,
187  const fieldMapper& mapper
188 )
189 {
190  mapper(*this, ptf);
191 }
192 
193 
194 template<class Type>
196 {
197  Field<Type>::reset(ptf);
198 }
199 
200 
201 template<class Type>
203 {
204  updated_ = true;
205 }
206 
207 
208 template<class Type>
210 {
211  if (!updated_)
212  {
213  updateCoeffs();
214  }
215 
216  updated_ = false;
217  manipulatedMatrix_ = false;
218 }
219 
220 
221 template<class Type>
223 {
224  manipulatedMatrix_ = true;
225 }
226 
227 
228 template<class Type>
230 {
231  writeEntry(os, "type", type());
232 
233  if (overridesConstraint())
234  {
235  writeEntry(os, "patchType", patch().type());
236  }
237 
238  if (libs_.size())
239  {
240  writeEntry(os, "libs", libs_);
241  }
242 }
243 
244 
245 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
246 
247 template<class Type>
249 (
250  const UList<Type>& ul
251 )
252 {
254 }
255 
256 
257 template<class Type>
259 (
260  const fvPatchField<Type>& ptf
261 )
262 {
263  check(ptf);
265 }
266 
267 
268 template<class Type>
270 (
271  const fvPatchField<Type>& ptf
272 )
273 {
274  check(ptf);
276 }
277 
278 
279 template<class Type>
281 (
282  const fvPatchField<Type>& ptf
283 )
284 {
285  check(ptf);
287 }
288 
289 
290 template<class Type>
292 (
293  const fvPatchField<scalar>& ptf
294 )
295 {
296  if (&patch_ != &ptf.patch())
297  {
299  << "incompatible patches for patch fields"
300  << abort(FatalError);
301  }
302 
304 }
305 
306 
307 template<class Type>
309 (
310  const fvPatchField<scalar>& ptf
311 )
312 {
313  if (&patch_ != &ptf.patch())
314  {
316  << abort(FatalError);
317  }
318 
320 }
321 
322 
323 template<class Type>
325 (
326  const Field<Type>& tf
327 )
328 {
330 }
331 
332 
333 template<class Type>
335 (
336  const Field<Type>& tf
337 )
338 {
340 }
341 
342 
343 template<class Type>
345 (
346  const scalarField& tf
347 )
348 {
350 }
351 
352 
353 template<class Type>
355 (
356  const scalarField& tf
357 )
358 {
360 }
361 
362 
363 template<class Type>
365 (
366  const Type& t
367 )
368 {
370 }
371 
372 
373 template<class Type>
375 (
376  const Type& t
377 )
378 {
380 }
381 
382 
383 template<class Type>
385 (
386  const Type& t
387 )
388 {
390 }
391 
392 
393 template<class Type>
395 (
396  const scalar s
397 )
398 {
400 }
401 
402 
403 template<class Type>
405 (
406  const scalar s
407 )
408 {
410 }
411 
412 
413 template<class Type>
415 (
416  const fvPatchField<Type>& ptf
417 )
418 {
420 }
421 
422 
423 template<class Type>
425 (
426  const Field<Type>& tf
427 )
428 {
430 }
431 
432 
433 template<class Type>
435 (
436  const Type& t
437 )
438 {
440 }
441 
442 
443 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
444 
445 template<class Type>
447 {
448  ptf.write(os);
449 
450  os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
451 
452  return os;
453 }
454 
455 
456 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
457 
458 #include "fvPatchFieldNew.C"
459 
460 // ************************************************************************* //
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:550
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: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: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:88
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:209
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:170
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:162
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:143
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:202
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
Definition: fvPatchField.C:195
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: fvPatchField.C:222
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:356
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:185
void check(const fvPatchField< Type > &) const
Check fvPatchField<Type> against given fvPatchField<Type>
Definition: fvPatchField.C:150
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:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
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
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
error FatalError
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