fvsPatchField.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) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2017 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 "IOobject.H"
30#include "dictionary.H"
31#include "fvMesh.H"
32#include "surfaceMesh.H"
33#include "fvPatchFieldMapper.H"
34
35// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36
37template<class Type>
39(
40 const fvPatch& p,
42)
43:
44 Field<Type>(p.size()),
45 patch_(p),
46 internalField_(iF)
47{}
48
49
50template<class Type>
52(
53 const fvPatch& p,
55 const Field<Type>& f
56)
57:
58 Field<Type>(f),
59 patch_(p),
60 internalField_(iF)
61{}
62
63
64template<class Type>
66(
67 const fvsPatchField<Type>& ptf,
68 const fvPatch& p,
70 const fvPatchFieldMapper& mapper
71)
72:
73 Field<Type>(ptf, mapper),
74 patch_(p),
75 internalField_(iF)
76{}
77
78
79template<class Type>
81(
82 const fvPatch& p,
84 const dictionary& dict,
85 const bool valueRequired
86)
87:
88 Field<Type>(p.size()),
89 patch_(p),
90 internalField_(iF)
91{
92 if (valueRequired)
93 {
94 if (dict.found("value"))
95 {
97 (
98 Field<Type>("value", dict, p.size())
99 );
100 }
101 else
102 {
104 << "Essential entry 'value' missing on patch "
105 << p.name() << endl
106 << exit(FatalIOError);
107 }
108 }
109}
110
111
112template<class Type>
114:
115 Field<Type>(ptf),
116 patch_(ptf.patch_),
117 internalField_(ptf.internalField_)
118{}
119
120
121template<class Type>
123(
124 const fvsPatchField<Type>& ptf,
126)
127:
128 Field<Type>(ptf),
129 patch_(ptf.patch_),
130 internalField_(iF)
131{}
132
133
134// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135
136template<class Type>
138{
139 return patch_.boundaryMesh().mesh();
140}
141
142
143template<class Type>
145{
146 if (&patch_ != &(ptf.patch_))
147 {
149 << "different patches for fvsPatchField<Type>s"
150 << abort(FatalError);
151 }
152}
154
155template<class Type>
157{
158 const bool oriented = internalField_.oriented()();
159 Field<Type>::autoMap(m, oriented);
161
162
163template<class Type>
165(
166 const fvsPatchField<Type>& ptf,
167 const labelList& addr
169{
170 Field<Type>::rmap(ptf, addr);
171}
172
173
174template<class Type>
176{
177 os.writeEntry("type", type());
178 this->writeEntry("value", os);
179}
180
181
182// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
183
184template<class Type>
187 const UList<Type>& ul
188)
189{
191}
192
193
194template<class Type>
196(
197 const fvsPatchField<Type>& ptf
198)
199{
200 check(ptf);
202}
203
204
205template<class Type>
207(
208 const fvsPatchField<Type>& ptf
209)
210{
211 check(ptf);
213}
214
215
216template<class Type>
218(
219 const fvsPatchField<Type>& ptf
220)
221{
222 check(ptf);
224}
225
226
227template<class Type>
229(
230 const fvsPatchField<scalar>& ptf
231)
232{
233 if (&patch_ != &ptf.patch())
234 {
236 << "incompatible patches for patch fields"
237 << abort(FatalError);
238 }
239
241}
242
243
244template<class Type>
246(
247 const fvsPatchField<scalar>& ptf
248)
249{
250 if (&patch_ != &ptf.patch())
251 {
253 << abort(FatalError);
254 }
255
257}
258
259
260template<class Type>
262(
263 const Field<Type>& tf
264)
265{
267}
268
269
270template<class Type>
272(
273 const Field<Type>& tf
274)
275{
277}
278
280template<class Type>
282(
283 const scalarField& tf
284)
285{
287}
288
289
290template<class Type>
292(
293 const scalarField& tf
294)
295{
297}
298
299
300template<class Type>
302(
303 const Type& t
304)
305{
307}
308
309
310template<class Type>
312(
313 const Type& t
314)
315{
317}
318
319
320template<class Type>
322(
323 const Type& t
324)
325{
327}
328
329
330template<class Type>
332(
333 const scalar s
335{
337}
338
339
340template<class Type>
342(
343 const scalar s
344)
350template<class Type>
352(
355{
358
360template<class Type>
363 const Field<Type>& tf
364)
365{
367}
370template<class Type>
372(
373 const Type& t
374)
375{
377}
378
379
380// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
381
382template<class Type>
384{
385 ptf.write(os);
386
388
389 return os;
390}
391
392
393// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394
395#include "fvsPatchFieldNew.C"
396
397// ************************************************************************* //
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
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
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
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
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:79
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void write(Ostream &) const
Write.
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
const objectRegistry & db() const
Return local objectRegistry.
const fvPatch & patch() const
Return patch.
Registry of regIOobjects.
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
IOerror FatalIOError
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
labelList f(nPoints)
dictionary dict