faPatchField.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2017 Wikki Ltd
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "faPatchField.H"
30#include "faPatchFieldMapper.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class Type>
36(
37 const faPatch& p,
39)
40:
41 Field<Type>(p.size()),
42 patch_(p),
43 internalField_(iF),
44 updated_(false),
45 patchType_()
46{}
47
48
49template<class Type>
51(
52 const faPatch& p,
54 const Field<Type>& f
55)
56:
57 Field<Type>(f),
58 patch_(p),
59 internalField_(iF),
60 updated_(false),
61 patchType_()
62{}
63
64
65template<class Type>
67(
68 const faPatchField<Type>& ptf,
69 const faPatch& p,
71 const faPatchFieldMapper& mapper
72)
73:
74 Field<Type>(ptf, mapper),
75 patch_(p),
76 internalField_(iF),
77 updated_(false),
78 patchType_()
79{}
80
81
82template<class Type>
84(
85 const faPatch& p,
87 const dictionary& dict,
88 const bool valueRequired
89)
90:
91 Field<Type>(p.size()),
92 patch_(p),
93 internalField_(iF),
94 updated_(false),
95 patchType_()
96{
97 dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
98
100
101 if (dict.found("value"))
102 {
104 (
105 Field<Type>("value", dict, p.size())
106 );
107 }
108 else
109 {
111 }
112}
113
114
115template<class Type>
117(
118 const faPatchField<Type>& ptf
119)
120:
121 Field<Type>(ptf),
122 patch_(ptf.patch_),
123 internalField_(ptf.internalField_),
124 updated_(false),
125 patchType_(ptf.patchType_)
126{}
127
128
129template<class Type>
131(
132 const faPatchField<Type>& ptf,
134)
135:
136 Field<Type>(ptf),
137 patch_(ptf.patch_),
138 internalField_(iF),
139 updated_(false),
140 patchType_(ptf.patchType_)
141{}
142
143
144// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145
146template<class Type>
148{
149 // Note: Lookup fields from the field DB rather than the mesh
150 return internalField_.db();
151}
152
153
154template<class Type>
156{
157 if (&patch_ != &(ptf.patch_))
158 {
160 << "different patches for faPatchField<Type>s"
161 << abort(FatalError);
162 }
163}
164
166template<class Type>
168{
169 return (*this - patchInternalField())*patch_.deltaCoeffs();
170}
171
173template<class Type>
176{
177 return patch_.patchInternalField(internalField_);
178}
179
181template<class Type>
183{
185}
186
187
188template<class Type>
190(
191 const faPatchField<Type>& ptf,
192 const labelList& addr
193)
194{
195 Field<Type>::rmap(ptf, addr);
196}
197
199template<class Type>
201{
202 if (!updated_)
203 {
204 updateCoeffs();
205 }
206
207 updated_ = false;
208}
209
210
211template<class Type>
213{
214 os.writeEntry("type", type());
215
216 if (!patchType_.empty())
217 {
218 os.writeEntry("patchType", patchType_);
219 }
220}
221
222
223// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
224
225template<class Type>
227(
228 const UList<Type>& ul
229)
230{
232}
233
234
235template<class Type>
237(
238 const faPatchField<Type>& ptf
239)
240{
241 check(ptf);
243}
244
245
246template<class Type>
248(
249 const faPatchField<Type>& ptf
250)
251{
252 check(ptf);
254}
255
256
257template<class Type>
259(
260 const faPatchField<Type>& ptf
261)
262{
263 check(ptf);
265}
266
267
268template<class Type>
270(
271 const faPatchField<scalar>& ptf
272)
273{
274 if (&patch_ != &ptf.patch())
275 {
277 << "incompatible patches for patch fields"
278 << abort(FatalError);
279 }
280
282}
284
285template<class Type>
287(
288 const faPatchField<scalar>& ptf
289)
290{
291 if (&patch_ != &ptf.patch())
292 {
294 << " incompatible patches for patch fields"
295 << abort(FatalError);
296 }
297
299}
300
301
302template<class Type>
304(
305 const Field<Type>& tf
306)
307{
309}
310
311
312template<class Type>
314(
315 const Field<Type>& tf
316)
317{
319}
320
321
322template<class Type>
324(
325 const scalarField& tf
326)
327{
329}
330
331
332template<class Type>
334(
335 const scalarField& tf
336)
337{
339}
340
341
342template<class Type>
344(
345 const Type& t
346)
347{
349}
350
351
352template<class Type>
354(
355 const Type& t
356)
357{
359}
360
361
362template<class Type>
364(
365 const Type& t
366)
367{
369}
370
371
372template<class Type>
374(
375 const scalar s
376)
377{
379}
380
381
382template<class Type>
384(
385 const scalar s
387{
389}
390
391
392template<class Type>
394(
395 const faPatchField<Type>& ptf
396)
397{
399}
400
401
402template<class Type>
404(
405 const Field<Type>& tf
406)
407{
409}
410
411
412template<class Type>
414(
415 const Type& t
416)
417{
419}
420
421
422// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
423
424template<class Type>
426{
427 ptf.write(os);
428
430
431 return os;
432}
433
435// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
436
437#include "faPatchFieldNew.C"
438
439// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
void operator=(const Field< Type > &)
Copy assignment.
Definition: Field.C:641
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:403
void operator+=(const UList< Type > &)
Definition: Field.C:693
void operator-=(const UList< Type > &)
Definition: Field.C:694
void operator*=(const UList< scalar > &)
Definition: Field.C:695
void operator/=(const UList< scalar > &)
Definition: Field.C:696
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:466
void evaluate()
Evaluate boundary conditions.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
commsTypes
Types of communications.
Definition: UPstream.H:67
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
A FieldMapper for finite-area patch fields.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
virtual void write(Ostream &) const
Write.
Definition: faPatchField.C:212
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: faPatchField.C:175
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:190
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:286
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:167
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:147
virtual void operator=(const UList< Type > &)
Definition: faPatchField.C:227
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:182
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
virtual bool write()
Write the output fields.
@ LITERAL
String literal.
Definition: keyType.H:81
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
#define FUNCTION_NAME
static void check(const int retVal, const char *what)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
labelList f(nPoints)
dictionary dict
A non-counting (dummy) refCount.
Definition: refCount.H:59