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-2021 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  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", dict, p.size())
87  );
88  }
89  else
90  {
92  (
93  dict
94  ) << "Essential entry 'value' missing"
95  << exit(FatalIOError);
96  }
97  }
98 }
99 
100 
101 template<class Type>
103 (
104  const fvPatchField<Type>& ptf,
105  const fvPatch& p,
107  const fvPatchFieldMapper& mapper,
108  const bool mappingRequired
109 )
110 :
111  Field<Type>(p.size()),
112  patch_(p),
113  internalField_(iF),
114  updated_(false),
115  manipulatedMatrix_(false)
116 {
117  if (mappingRequired)
118  {
119  // For unmapped faces set to internal field value (zero-gradient)
120  if (notNull(iF) && mapper.hasUnmapped())
121  {
122  fvPatchField<Type>::operator=(this->patchInternalField());
123  }
124  mapper(*this, ptf);
125  }
126 }
127 
128 
129 template<class Type>
131 (
132  const fvPatchField<Type>& ptf,
134 )
135 :
136  Field<Type>(ptf),
137  patch_(ptf.patch_),
138  internalField_(iF),
139  updated_(false),
140  manipulatedMatrix_(false)
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
146 template<class Type>
148 {
149  return patch_.boundaryMesh().mesh();
150 }
151 
152 
153 template<class Type>
155 {
156  if (&patch_ != &(ptf.patch_))
157  {
159  << "different patches for fvPatchField<Type>s"
160  << abort(FatalError);
161  }
162 }
163 
164 
165 template<class Type>
167 {
168  return patch_.deltaCoeffs()*(*this - patchInternalField());
169 }
170 
171 
172 template<class Type>
175 {
176  return patch_.patchInternalField(internalField_);
177 }
178 
179 
180 template<class Type>
182 {
183  patch_.patchInternalField(internalField_, pif);
184 }
185 
186 
187 template<class Type>
189 (
190  const fvPatchFieldMapper& mapper
191 )
192 {
193  mapper(*this, *this);
194 }
195 
196 
197 template<class Type>
199 (
200  const fvPatchField<Type>& ptf,
201  const labelList& addr
202 )
203 {
204  Field<Type>::rmap(ptf, addr);
205 }
206 
207 
208 template<class Type>
210 {
211  updated_ = true;
212 }
213 
214 
215 template<class Type>
217 {
218  // Default behaviour ignores the weights
219  if (!updated_)
220  {
221  updateCoeffs();
222 
223  updated_ = true;
224  }
225 }
226 
227 
228 template<class Type>
230 {
231  if (!updated_)
232  {
233  updateCoeffs();
234  }
235 
236  updated_ = false;
237  manipulatedMatrix_ = false;
238 }
239 
240 
241 template<class Type>
243 {
244  manipulatedMatrix_ = true;
245 }
246 
247 
248 template<class Type>
250 (
251  fvMatrix<Type>& matrix,
252  const scalarField& weights
253 )
254 {
255  manipulatedMatrix_ = true;
256 }
257 
258 
259 template<class Type>
261 {
262  writeEntry(os, "type", type());
263 
264  if (overridesConstraint())
265  {
266  writeEntry(os, "patchType", patch().type());
267  }
268 }
269 
270 
271 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
272 
273 template<class Type>
274 void Foam::fvPatchField<Type>::operator=
275 (
276  const UList<Type>& ul
277 )
278 {
280 }
281 
282 
283 template<class Type>
284 void Foam::fvPatchField<Type>::operator=
285 (
286  const fvPatchField<Type>& ptf
287 )
288 {
289  check(ptf);
291 }
292 
293 
294 template<class Type>
295 void Foam::fvPatchField<Type>::operator+=
296 (
297  const fvPatchField<Type>& ptf
298 )
299 {
300  check(ptf);
302 }
303 
304 
305 template<class Type>
306 void Foam::fvPatchField<Type>::operator-=
307 (
308  const fvPatchField<Type>& ptf
309 )
310 {
311  check(ptf);
313 }
314 
315 
316 template<class Type>
317 void Foam::fvPatchField<Type>::operator*=
318 (
319  const fvPatchField<scalar>& ptf
320 )
321 {
322  if (&patch_ != &ptf.patch())
323  {
325  << "incompatible patches for patch fields"
326  << abort(FatalError);
327  }
328 
330 }
331 
332 
333 template<class Type>
334 void Foam::fvPatchField<Type>::operator/=
335 (
336  const fvPatchField<scalar>& ptf
337 )
338 {
339  if (&patch_ != &ptf.patch())
340  {
342  << abort(FatalError);
343  }
344 
346 }
347 
348 
349 template<class Type>
350 void Foam::fvPatchField<Type>::operator+=
351 (
352  const Field<Type>& tf
353 )
354 {
356 }
357 
358 
359 template<class Type>
360 void Foam::fvPatchField<Type>::operator-=
361 (
362  const Field<Type>& tf
363 )
364 {
366 }
367 
368 
369 template<class Type>
370 void Foam::fvPatchField<Type>::operator*=
371 (
372  const scalarField& tf
373 )
374 {
376 }
377 
378 
379 template<class Type>
380 void Foam::fvPatchField<Type>::operator/=
381 (
382  const scalarField& tf
383 )
384 {
386 }
387 
388 
389 template<class Type>
390 void Foam::fvPatchField<Type>::operator=
391 (
392  const Type& t
393 )
394 {
396 }
397 
398 
399 template<class Type>
400 void Foam::fvPatchField<Type>::operator+=
401 (
402  const Type& t
403 )
404 {
406 }
407 
408 
409 template<class Type>
410 void Foam::fvPatchField<Type>::operator-=
411 (
412  const Type& t
413 )
414 {
416 }
417 
418 
419 template<class Type>
420 void Foam::fvPatchField<Type>::operator*=
421 (
422  const scalar s
423 )
424 {
426 }
427 
428 
429 template<class Type>
430 void Foam::fvPatchField<Type>::operator/=
431 (
432  const scalar s
433 )
434 {
436 }
437 
438 
439 template<class Type>
440 void Foam::fvPatchField<Type>::operator==
441 (
442  const fvPatchField<Type>& ptf
443 )
444 {
446 }
447 
448 
449 template<class Type>
450 void Foam::fvPatchField<Type>::operator==
451 (
452  const Field<Type>& tf
453 )
454 {
456 }
457 
458 
459 template<class Type>
460 void Foam::fvPatchField<Type>::operator==
461 (
462  const Type& t
463 )
464 {
466 }
467 
468 
469 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
470 
471 template<class Type>
472 Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
473 {
474  ptf.write(os);
475 
476  os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
477 
478  return os;
479 }
480 
481 
482 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
483 
484 #include "fvPatchFieldNew.C"
485 
486 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvPatchField.C:189
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:166
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:260
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:199
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: fvPatchField.C:242
void check(const fvPatchField< Type > &) const
Check fvPatchField<Type> against given fvPatchField<Type>
Definition: fvPatchField.C:154
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:337
virtual label size() const
Return size.
Definition: fvPatch.H:156
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:174
labelList f(nPoints)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:52
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:229
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:335
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:209
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:147
virtual void updateWeightedCoeffs(const scalarField &weights)
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:216
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
fvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fvPatchField.C:36
IOerror FatalIOError