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-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 "dictionary.H"
30 #include "faPatchField.H"
31 #include "faPatchFieldMapper.H"
32 
33 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const dictionary& dict,
40 )
41 {
42  if (!IOobjectOption::isAnyRead(readOpt)) return false;
43  const auto& p = faPatchFieldBase::patch();
44 
45 
46  const auto* eptr = dict.findEntry("value", keyType::LITERAL);
47 
48  if (eptr)
49  {
50  Field<Type>::assign(*eptr, p.size());
51  return true;
52  }
53 
54  if (IOobjectOption::isReadRequired(readOpt))
55  {
57  << "Required entry 'value' : missing for patch " << p.name()
58  << " in dictionary " << dict.relativeName() << nl
59  << exit(FatalIOError);
60  }
61 
62  return false;
63 }
64 
65 
66 template<class Type>
68 {
69  faPatchFieldBase::patch().patchInternalField(internalField_, *this);
70 }
71 
72 
73 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 
75 template<class Type>
77 (
78  const faPatch& p,
80 )
81 :
83  Field<Type>(p.size()),
84  internalField_(iF)
85 {}
86 
87 
88 template<class Type>
90 (
91  const faPatch& p,
93  const Type& value
94 )
95 :
97  Field<Type>(p.size(), value),
98  internalField_(iF)
99 {}
100 
101 
102 template<class Type>
104 (
105  const faPatch& p,
107  const Field<Type>& pfld
108 )
109 :
111  Field<Type>(pfld),
112  internalField_(iF)
113 {}
114 
115 
116 template<class Type>
118 (
119  const faPatch& p,
121  Field<Type>&& pfld
122 )
123 :
125  Field<Type>(std::move(pfld)),
126  internalField_(iF)
127 {}
128 
129 
130 template<class Type>
132 (
133  const faPatch& p,
135  const dictionary& dict,
136  IOobjectOption::readOption requireValue
137 )
138 :
140  Field<Type>(p.size()),
141  internalField_(iF)
142 {
143  if (!readValueEntry(dict, requireValue))
144  {
145  // Not read (eg, optional and missing): define zero
147  }
148 }
149 
150 
151 template<class Type>
153 (
154  const faPatchField<Type>& ptf,
155  const faPatch& p,
156  const DimensionedField<Type, areaMesh>& iF,
157  const faPatchFieldMapper& mapper
158 )
159 :
160  faPatchFieldBase(ptf, p),
161  Field<Type>(ptf, mapper),
162  internalField_(iF)
163 {}
164 
165 
166 template<class Type>
168 (
169  const faPatchField<Type>& ptf
170 )
171 :
172  faPatchFieldBase(ptf),
173  Field<Type>(ptf),
174  internalField_(ptf.internalField_)
175 {}
176 
177 
178 template<class Type>
180 (
181  const faPatchField<Type>& ptf,
183 )
184 :
185  faPatchFieldBase(ptf),
186  Field<Type>(ptf),
187  internalField_(iF)
188 {}
189 
190 
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
192 
193 template<class Type>
195 {
197 }
198 
199 
200 template<class Type>
202 {
203  return (*this - patchInternalField())*patch().deltaCoeffs();
204 }
205 
206 
207 template<class Type>
210 {
211  return patch().patchInternalField(internalField_);
212 }
213 
214 
215 template<class Type>
217 {
218  patch().patchInternalField(internalField_, pfld);
219 }
220 
221 
222 template<class Type>
224 {
226 }
227 
228 
229 template<class Type>
231 (
232  const faPatchField<Type>& ptf,
233  const labelList& addr
234 )
235 {
236  Field<Type>::rmap(ptf, addr);
237 }
238 
239 
240 template<class Type>
242 {
244 }
245 
246 
247 template<class Type>
249 {
250  if (!updated())
251  {
252  updateCoeffs();
253  }
254 
256 }
257 
258 
259 template<class Type>
260 void Foam::faPatchField<Type>::write(Ostream& os) const
261 {
262  os.writeEntry("type", type());
263 
264  if (!patchType().empty())
265  {
266  os.writeEntry("patchType", patchType());
267  }
268 }
269 
270 
271 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
272 
273 template<class Type>
275 (
276  const UList<Type>& ul
277 )
278 {
280 }
281 
282 
283 template<class Type>
285 (
286  const faPatchField<Type>& ptf
287 )
288 {
291 }
292 
293 
294 template<class Type>
296 (
297  const faPatchField<Type>& ptf
298 )
299 {
302 }
303 
304 
305 template<class Type>
307 (
308  const faPatchField<Type>& ptf
309 )
310 {
313 }
314 
315 
316 template<class Type>
318 (
319  const faPatchField<scalar>& ptf
320 )
321 {
324 }
325 
326 
327 template<class Type>
329 (
330  const faPatchField<scalar>& ptf
331 )
332 {
335 }
336 
337 
338 template<class Type>
340 (
341  const Field<Type>& tf
342 )
343 {
345 }
346 
347 
348 template<class Type>
350 (
351  const Field<Type>& tf
352 )
353 {
355 }
356 
357 
358 template<class Type>
360 (
361  const scalarField& tf
362 )
363 {
365 }
366 
367 
368 template<class Type>
370 (
371  const scalarField& tf
372 )
373 {
375 }
376 
377 
378 template<class Type>
380 (
381  const Type& t
382 )
383 {
385 }
386 
387 
388 template<class Type>
390 (
391  const Type& t
392 )
393 {
395 }
396 
397 
398 template<class Type>
400 (
401  const Type& t
402 )
403 {
405 }
406 
407 
408 template<class Type>
410 (
411  const scalar s
412 )
413 {
415 }
416 
417 
418 template<class Type>
420 (
421  const scalar s
422 )
423 {
425 }
426 
427 
428 template<class Type>
430 (
431  const faPatchField<Type>& ptf
432 )
433 {
435 }
436 
437 
438 template<class Type>
440 (
441  const Field<Type>& tf
442 )
443 {
445 }
446 
447 
448 template<class Type>
450 (
451  const Type& t
452 )
453 {
455 }
456 
457 
458 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
459 
460 template<class Type>
461 Foam::Ostream& Foam::operator<<(Ostream& os, const faPatchField<Type>& ptf)
462 {
463  ptf.write(os);
464 
466 
467  return os;
468 }
469 
470 
471 // ************************************************************************* //
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:216
dictionary dict
void operator-=(const UList< Type > &)
Definition: Field.C:800
void check(const faPatchField< Type > &) const
Check against given patch field.
Definition: faPatchField.C:187
virtual void write(Ostream &os) const
Write.
Definition: faPatchField.C:253
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:194
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Template invariant parts for faPatchField.
Definition: faPatchField.H:77
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
void extrapolateInternal()
Assign the patch field from the internal field.
Definition: faPatchField.C:60
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
void setUpdated(bool state) noexcept
Set updated state.
Definition: faPatchField.H:266
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
Generic templated field type.
Definition: Field.H:62
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
void operator=(const Field< Type > &)
Copy assignment.
Definition: Field.C:747
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
Definition: faPatchField.C:202
void checkPatch(const faPatchFieldBase &rhs) const
Check that patches are identical.
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:466
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:224
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets updated() to false.
Definition: faPatchField.C:241
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:529
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:627
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.C:234
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.
void operator+=(const UList< Type > &)
Definition: Field.C:799
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
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))
A FieldMapper for finite-area patch fields.
void operator/=(const UList< scalar > &)
Definition: Field.C:802
void operator*=(const UList< scalar > &)
Definition: Field.C:801
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: faPatchField.C:30
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: faPatchField.C:70
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127
readOption
Enumeration defining read preferences.