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-2025 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  const auto& p = faPatchFieldBase::patch();
70  this->resize_nocopy(p.size()); // In general this is a no-op
71  p.patchInternalField(internalField_, *this);
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
77 template<class Type>
79 (
80  const faPatch& p,
82 )
83 :
85  Field<Type>(p.size()),
86  internalField_(iF)
87 {}
88 
89 
90 template<class Type>
92 (
93  const faPatch& p,
95  const Type& value
96 )
97 :
99  Field<Type>(p.size(), value),
100  internalField_(iF)
101 {}
102 
103 
104 template<class Type>
106 (
107  const faPatch& p,
109  const Field<Type>& pfld
110 )
111 :
113  Field<Type>(pfld),
114  internalField_(iF)
115 {}
116 
117 
118 template<class Type>
120 (
121  const faPatch& p,
123  Field<Type>&& pfld
124 )
125 :
127  Field<Type>(std::move(pfld)),
128  internalField_(iF)
129 {}
130 
131 
132 template<class Type>
134 (
135  const faPatch& p,
137  const dictionary& dict,
138  IOobjectOption::readOption requireValue
139 )
140 :
142  Field<Type>(p.size()),
143  internalField_(iF)
144 {
145  if (!readValueEntry(dict, requireValue))
146  {
147  // Not read (eg, optional and missing): define zero
149  }
150 }
151 
152 
153 template<class Type>
155 (
156  const faPatchField<Type>& ptf,
157  const faPatch& p,
158  const DimensionedField<Type, areaMesh>& iF,
159  const faPatchFieldMapper& mapper
160 )
161 :
162  faPatchFieldBase(ptf, p),
163  Field<Type>(ptf, mapper),
164  internalField_(iF)
165 {}
166 
167 
168 template<class Type>
170 (
171  const faPatchField<Type>& ptf
172 )
173 :
174  faPatchFieldBase(ptf),
175  Field<Type>(ptf),
176  internalField_(ptf.internalField_)
177 {}
178 
179 
180 template<class Type>
182 (
183  const faPatchField<Type>& ptf,
185 )
186 :
187  faPatchFieldBase(ptf),
188  Field<Type>(ptf),
189  internalField_(iF)
190 {}
191 
192 
193 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
194 
195 template<class Type>
197 {
199 }
200 
201 
202 template<class Type>
204 {
205  return (*this - patchInternalField())*patch().deltaCoeffs();
206 }
207 
208 
209 template<class Type>
212 {
213  return patch().patchInternalField(internalField_);
214 }
215 
216 
217 template<class Type>
219 {
220  patch().patchInternalField(internalField_, pfld);
221 }
222 
223 
224 template<class Type>
226 {
228 }
229 
230 
231 template<class Type>
233 (
234  const faPatchField<Type>& ptf,
235  const labelList& addr
236 )
237 {
238  Field<Type>::rmap(ptf, addr);
239 }
240 
241 
242 template<class Type>
244 {
246 }
247 
248 
249 template<class Type>
251 {
252  if (!updated())
253  {
254  updateCoeffs();
255  }
259 }
260 
261 
262 template<class Type>
264 {
265  os.writeEntry("type", type());
266 
267  if (!patchType().empty())
268  {
269  os.writeEntry("patchType", patchType());
270  }
271 }
272 
273 
274 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
275 
276 template<class Type>
278 (
279  const UList<Type>& ul
280 )
281 {
283 }
284 
285 
286 template<class Type>
288 (
289  const faPatchField<Type>& ptf
290 )
291 {
294 }
295 
296 
297 template<class Type>
299 (
300  const faPatchField<Type>& ptf
301 )
302 {
305 }
306 
307 
308 template<class Type>
310 (
311  const faPatchField<Type>& ptf
312 )
313 {
316 }
317 
318 
319 template<class Type>
321 (
322  const faPatchField<scalar>& ptf
323 )
324 {
327 }
328 
329 
330 template<class Type>
332 (
333  const faPatchField<scalar>& ptf
334 )
335 {
338 }
339 
340 
341 template<class Type>
343 (
344  const Field<Type>& tf
345 )
346 {
348 }
349 
350 
351 template<class Type>
353 (
354  const Field<Type>& tf
355 )
356 {
358 }
359 
360 
361 template<class Type>
363 (
364  const scalarField& tf
365 )
366 {
368 }
369 
370 
371 template<class Type>
373 (
374  const scalarField& tf
375 )
376 {
378 }
379 
380 
381 template<class Type>
383 (
384  const Type& t
385 )
386 {
388 }
389 
390 
391 template<class Type>
393 (
394  const Type& t
395 )
396 {
398 }
399 
400 
401 template<class Type>
403 (
404  const Type& t
405 )
406 {
408 }
409 
410 
411 template<class Type>
413 (
414  const scalar s
415 )
416 {
418 }
419 
420 
421 template<class Type>
423 (
424  const scalar s
425 )
426 {
428 }
429 
430 
431 template<class Type>
433 (
434  const faPatchField<Type>& ptf
435 )
436 {
438 }
439 
440 
441 template<class Type>
443 (
444  const Field<Type>& tf
445 )
446 {
448 }
449 
450 
451 template<class Type>
453 (
454  const Type& t
455 )
456 {
458 }
459 
460 
461 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
462 
463 template<class Type>
464 Foam::Ostream& Foam::operator<<(Ostream& os, const faPatchField<Type>& ptf)
465 {
466  ptf.write(os);
467 
469 
470  return os;
471 }
472 
473 
474 // ************************************************************************* //
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:218
dictionary dict
void operator-=(const UList< Type > &)
Definition: Field.C:834
void check(const faPatchField< Type > &) const
Check against given patch field.
Definition: faPatchField.C:189
virtual void write(Ostream &os) const
Write.
Definition: faPatchField.C:256
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Communications types.
Definition: UPstream.H:77
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:196
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
Definition: faPatchField.C:243
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 setManipulated(bool state) noexcept
Set matrix manipulated state. Currently a no-op for faPatchField.
Definition: faPatchField.H:291
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:46
void setUpdated(bool state) noexcept
Set updated state.
Definition: faPatchField.H:274
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
Generic templated field type.
Definition: Field.H:63
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:781
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:204
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:465
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:226
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:528
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:629
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.C:236
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.
void operator+=(const UList< Type > &)
Definition: Field.C:833
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:836
void operator*=(const UList< scalar > &)
Definition: Field.C:835
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:72
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.