Loading...
Searching...
No Matches
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-2023 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// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
36
37template<class Type>
39(
40 const dictionary& dict,
42)
43{
44 if (!IOobjectOption::isAnyRead(readOpt)) return false;
45 const auto& p = fvsPatchFieldBase::patch();
46
47
48 const auto* eptr = dict.findEntry("value", keyType::LITERAL);
49
50 if (eptr)
51 {
52 Field<Type>::assign(*eptr, p.size());
53 return true;
54 }
55
57 {
59 << "Required entry 'value' : missing for patch " << p.name()
60 << " in dictionary " << dict.relativeName() << nl
62 }
63
64 return false;
65}
66
67
68// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69
70template<class Type>
72(
73 const fvPatch& p,
75)
76:
78 Field<Type>(p.size()),
79 internalField_(iF)
80{}
81
82
83template<class Type>
85(
86 const fvPatch& p,
88 const Type& value
89)
90:
92 Field<Type>(p.size(), value),
93 internalField_(iF)
94{}
95
96
97template<class Type>
99(
100 const fvPatch& p,
102 const Field<Type>& pfld
103)
104:
106 Field<Type>(pfld),
107 internalField_(iF)
108{}
109
110
111template<class Type>
113(
114 const fvPatch& p,
116 Field<Type>&& pfld
117)
118:
120 Field<Type>(std::move(pfld)),
121 internalField_(iF)
122{}
123
124
125template<class Type>
127(
128 const fvPatch& p,
130 const dictionary& dict,
131 IOobjectOption::readOption requireValue
132)
133:
135 Field<Type>(p.size()),
136 internalField_(iF)
137{
138 readValueEntry(dict, requireValue);
139}
140
141
142template<class Type>
144(
145 const fvsPatchField<Type>& ptf,
146 const fvPatch& p,
148 const fvPatchFieldMapper& mapper
149)
150:
152 Field<Type>(ptf, mapper),
153 internalField_(iF)
154{}
155
156
157template<class Type>
159(
160 const fvsPatchField<Type>& pfld,
161 const fvPatch& p,
163 const Type& value
164)
165:
167 Field<Type>(p.size(), value),
168 internalField_(iF)
169{}
170
171
172template<class Type>
174(
175 const fvsPatchField<Type>& pfld,
177)
178:
179 fvsPatchFieldBase(pfld),
180 Field<Type>(pfld),
181 internalField_(iF)
182{}
183
184
185// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
186
187template<class Type>
192
193
194template<class Type>
196{
197 Field<Type>::autoMap(m, internalField_.is_oriented());
198}
199
200
201template<class Type>
203(
204 const fvsPatchField<Type>& ptf,
205 const labelList& addr
207{
208 Field<Type>::rmap(ptf, addr);
209}
210
211
212template<class Type>
214{
215 os.writeEntry("type", type());
216}
217
218
219// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
220
221template<class Type>
223(
224 const UList<Type>& ul
226{
228}
229
230
231template<class Type>
233(
234 const fvsPatchField<Type>& ptf
235)
239}
240
241
242template<class Type>
244(
245 const fvsPatchField<Type>& ptf
246)
250}
251
252
253template<class Type>
255(
256 const fvsPatchField<Type>& ptf
257)
261}
262
263
264template<class Type>
266(
267 const fvsPatchField<scalar>& ptf
268)
272}
273
274
275template<class Type>
277(
278 const fvsPatchField<scalar>& ptf
279)
283}
284
285
286template<class Type>
288(
289 const Field<Type>& tf
291{
293}
294
295
296template<class Type>
298(
299 const Field<Type>& tf
300)
301{
303}
304
305
306template<class Type>
308(
309 const scalarField& tf
310)
311{
312 Field<Type>::operator*=(tf);
313}
314
315
316template<class Type>
318(
319 const scalarField& tf
321{
323}
324
325
326template<class Type>
328(
329 const Type& t
331{
333}
334
335
336template<class Type>
338(
339 const Type& t
341{
343}
344
345
346template<class Type>
348(
349 const Type& t
351{
353}
354
355
356template<class Type>
358(
359 const scalar s
361{
363}
364
365
366template<class Type>
368(
369 const scalar s
371{
373}
374
375
376template<class Type>
378(
379 const fvsPatchField<Type>& ptf
381{
383}
384
385
386template<class Type>
388(
389 const Field<Type>& tf
391{
393}
394
395
396template<class Type>
398(
399 const Type& t
400)
401{
403}
404
405
406// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
407
408template<class Type>
409Foam::Ostream& Foam::operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
410{
411 ptf.write(os);
412
413 os.check(FUNCTION_NAME);
414
415 return os;
416}
417
418
419// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
void operator=(const Field< Type > &)
Copy assignment.
Definition Field.C:781
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition Field.C:465
void operator+=(const UList< Type > &)
Definition Field.C:833
void operator-=(const UList< Type > &)
Definition Field.C:834
constexpr Field() noexcept
Default construct.
Definition FieldI.H:24
void operator*=(const UList< scalar > &)
Definition Field.C:835
void assign(const entry &e, const label len)
Assign from a primitive dictionary entry with the following behaviour:
Definition Field.C:206
void operator/=(const UList< scalar > &)
Definition Field.C:836
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition Field.C:528
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
static bool isAnyRead(readOption opt) noexcept
True if any reading may be required (ie, != NO_READ).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
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:89
void size(const label n)
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
Template invariant parts for fvsPatchField.
const fvPatch & patch() const noexcept
Return the patch.
void checkPatch(const fvsPatchFieldBase &rhs) const
Check that patches are identical.
fvsPatchFieldBase(const fvPatch &p)
Construct from patch.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &os) const
Write the patch "type".
void check(const fvsPatchField< Type > &) const
Check against given patch field.
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
@ LITERAL
String literal.
Definition keyType.H:82
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
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
List< label > labelList
A List of labels.
Definition List.H:62
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict