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 -------------------------------------------------------------------------------
11 License
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 
37 template<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 
56  if (IOobjectOption::isReadRequired(readOpt))
57  {
59  << "Required entry 'value' : missing for patch " << p.name()
60  << " in dictionary " << dict.relativeName() << nl
61  << exit(FatalIOError);
62  }
63 
64  return false;
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
70 template<class Type>
72 (
73  const fvPatch& p,
75 )
76 :
78  Field<Type>(p.size()),
79  internalField_(iF)
80 {}
81 
82 
83 template<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 
97 template<class Type>
99 (
100  const fvPatch& p,
102  const Field<Type>& pfld
103 )
104 :
106  Field<Type>(pfld),
107  internalField_(iF)
108 {}
109 
110 
111 template<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 
125 template<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 
142 template<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 
157 template<class Type>
159 :
160  fvsPatchFieldBase(ptf),
161  Field<Type>(ptf),
162  internalField_(ptf.internalField_)
163 {}
164 
165 
166 template<class Type>
168 (
169  const fvsPatchField<Type>& ptf,
171 )
172 :
173  fvsPatchFieldBase(ptf),
174  Field<Type>(ptf),
175  internalField_(iF)
176 {}
177 
178 
179 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
180 
181 template<class Type>
183 {
185 }
186 
187 
188 template<class Type>
190 {
191  Field<Type>::autoMap(m, internalField_.is_oriented());
192 }
193 
194 
195 template<class Type>
197 (
198  const fvsPatchField<Type>& ptf,
199  const labelList& addr
200 )
201 {
202  Field<Type>::rmap(ptf, addr);
203 }
204 
205 
206 template<class Type>
208 {
209  os.writeEntry("type", type());
210 }
211 
212 
213 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
214 
215 template<class Type>
217 (
218  const UList<Type>& ul
219 )
220 {
222 }
223 
224 
225 template<class Type>
227 (
228  const fvsPatchField<Type>& ptf
229 )
230 {
233 }
234 
235 
236 template<class Type>
238 (
239  const fvsPatchField<Type>& ptf
240 )
241 {
244 }
245 
246 
247 template<class Type>
249 (
250  const fvsPatchField<Type>& ptf
251 )
252 {
255 }
256 
257 
258 template<class Type>
260 (
261  const fvsPatchField<scalar>& ptf
262 )
263 {
266 }
267 
268 
269 template<class Type>
271 (
272  const fvsPatchField<scalar>& ptf
273 )
274 {
277 }
278 
279 
280 template<class Type>
282 (
283  const Field<Type>& tf
284 )
285 {
287 }
288 
289 
290 template<class Type>
292 (
293  const Field<Type>& tf
294 )
295 {
297 }
298 
299 
300 template<class Type>
302 (
303  const scalarField& tf
304 )
305 {
307 }
308 
309 
310 template<class Type>
312 (
313  const scalarField& tf
314 )
315 {
317 }
318 
319 
320 template<class Type>
322 (
323  const Type& t
324 )
325 {
327 }
328 
329 
330 template<class Type>
332 (
333  const Type& t
334 )
335 {
337 }
338 
339 
340 template<class Type>
342 (
343  const Type& t
344 )
345 {
347 }
348 
349 
350 template<class Type>
352 (
353  const scalar s
354 )
355 {
357 }
358 
359 
360 template<class Type>
362 (
363  const scalar s
364 )
365 {
367 }
368 
369 
370 template<class Type>
372 (
373  const fvsPatchField<Type>& ptf
374 )
375 {
377 }
378 
379 
380 template<class Type>
382 (
383  const Field<Type>& tf
384 )
385 {
387 }
388 
389 
390 template<class Type>
392 (
393  const Type& t
394 )
395 {
397 }
398 
399 
400 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
401 
402 template<class Type>
403 Foam::Ostream& Foam::operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
404 {
405  ptf.write(os);
406 
407  os.check(FUNCTION_NAME);
408 
409  return os;
410 }
411 
412 
413 // ************************************************************************* //
dictionary dict
type
Types of root.
Definition: Roots.H:52
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: fvsPatchField.C:32
Generic templated field type.
Definition: Field.H:62
void check(const fvsPatchField< Type > &) const
Check against given patch field.
A FieldMapper for finite-volume patch fields.
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Definition: fvsPatchField.C:65
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
Definition: FieldOps.C:28
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
virtual void write(Ostream &os) const
Write the patch "type".
Template invariant parts for fvsPatchField.
Definition: fvsPatchField.H:74
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:637
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
volScalarField & p
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))
bool checkPatch(const bool allGeometry, const std::string &name, const polyMesh &mesh, const PatchType &pp, const labelUList &meshEdges, labelHashSet *pointSetPtr=nullptr, labelHashSet *badEdgesPtr=nullptr)
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
readOption
Enumeration defining read preferences.