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  Field<Type>::writeEntry("value", os);
211 }
212 
213 
214 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
215 
216 template<class Type>
218 (
219  const UList<Type>& ul
220 )
221 {
223 }
224 
225 
226 template<class Type>
228 (
229  const fvsPatchField<Type>& ptf
230 )
231 {
234 }
235 
236 
237 template<class Type>
239 (
240  const fvsPatchField<Type>& ptf
241 )
242 {
245 }
246 
247 
248 template<class Type>
250 (
251  const fvsPatchField<Type>& ptf
252 )
253 {
256 }
257 
258 
259 template<class Type>
261 (
262  const fvsPatchField<scalar>& ptf
263 )
264 {
267 }
268 
269 
270 template<class Type>
272 (
273  const fvsPatchField<scalar>& ptf
274 )
275 {
278 }
279 
280 
281 template<class Type>
283 (
284  const Field<Type>& tf
285 )
286 {
288 }
289 
290 
291 template<class Type>
293 (
294  const Field<Type>& tf
295 )
296 {
298 }
299 
300 
301 template<class Type>
303 (
304  const scalarField& tf
305 )
306 {
308 }
309 
310 
311 template<class Type>
313 (
314  const scalarField& tf
315 )
316 {
318 }
319 
320 
321 template<class Type>
323 (
324  const Type& t
325 )
326 {
328 }
329 
330 
331 template<class Type>
333 (
334  const Type& t
335 )
336 {
338 }
339 
340 
341 template<class Type>
343 (
344  const Type& t
345 )
346 {
348 }
349 
350 
351 template<class Type>
353 (
354  const scalar s
355 )
356 {
358 }
359 
360 
361 template<class Type>
363 (
364  const scalar s
365 )
366 {
368 }
369 
370 
371 template<class Type>
373 (
374  const fvsPatchField<Type>& ptf
375 )
376 {
378 }
379 
380 
381 template<class Type>
383 (
384  const Field<Type>& tf
385 )
386 {
388 }
389 
390 
391 template<class Type>
393 (
394  const Type& t
395 )
396 {
398 }
399 
400 
401 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
402 
403 template<class Type>
404 Foam::Ostream& Foam::operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
405 {
406  ptf.write(os);
407 
408  os.check(FUNCTION_NAME);
409 
410  return os;
411 }
412 
413 
414 // ************************************************************************* //
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.
Template invariant parts for fvsPatchField.
Definition: fvsPatchField.H:74
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:627
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
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.