faePatchField.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) 2022-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 "faePatchField.H"
30 #include "faPatchFieldMapper.H"
31 
32 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const dictionary& dict,
39 )
40 {
41  if (!IOobjectOption::isAnyRead(readOpt)) return false;
42  const auto& p = faePatchFieldBase::patch();
43 
44 
45  const auto* eptr = dict.findEntry("value", keyType::LITERAL);
46 
47  if (eptr)
48  {
49  Field<Type>::assign(*eptr, p.size());
50  return true;
51  }
52 
53  if (IOobjectOption::isReadRequired(readOpt))
54  {
56  << "Required entry 'value' : missing for patch " << p.name()
57  << " in dictionary " << dict.relativeName() << nl
58  << exit(FatalIOError);
59  }
60 
61  return false;
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
67 template<class Type>
69 (
70  const faPatch& p,
72 )
73 :
75  Field<Type>(p.size()),
76  internalField_(iF)
77 {}
78 
79 
80 template<class Type>
82 (
83  const faPatch& p,
85  const Type& value
86 )
87 :
89  Field<Type>(p.size(), value),
90  internalField_(iF)
91 {}
92 
93 
94 template<class Type>
96 (
97  const faPatch& p,
99  const Field<Type>& pfld
100 )
101 :
103  Field<Type>(pfld),
104  internalField_(iF)
105 {}
106 
107 
108 template<class Type>
110 (
111  const faPatch& p,
113  Field<Type>&& pfld
114 )
115 :
117  Field<Type>(std::move(pfld)),
118  internalField_(iF)
119 {}
120 
121 
122 template<class Type>
124 (
125  const faPatch& p,
127  const dictionary& dict,
128  IOobjectOption::readOption requireValue
129 )
130 :
132  Field<Type>(p.size()),
133  internalField_(iF)
134 {
135  if (!readValueEntry(dict, requireValue))
136  {
137  // Not read (eg, optional and missing): define zero
139  }
140 }
141 
142 
143 template<class Type>
145 (
146  const faePatchField<Type>& ptf,
147  const faPatch& p,
148  const DimensionedField<Type, edgeMesh>& iF,
149  const faPatchFieldMapper& mapper
150 )
151 :
152  faePatchFieldBase(ptf, p),
153  Field<Type>(ptf, mapper),
154  internalField_(iF)
155 {}
156 
157 
158 template<class Type>
160 (
161  const faePatchField<Type>& ptf
162 )
163 :
164  faePatchFieldBase(ptf),
165  Field<Type>(ptf),
166  internalField_(ptf.internalField_)
167 {}
168 
169 
170 template<class Type>
172 (
173  const faePatchField<Type>& ptf,
175 )
176 :
177  faePatchFieldBase(ptf),
178  Field<Type>(ptf),
179  internalField_(iF)
180 {}
181 
182 
183 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
184 
185 template<class Type>
187 {
189 }
190 
191 
192 template<class Type>
194 (
195  const faPatchFieldMapper& m
196 )
197 {
199 }
200 
201 
202 template<class Type>
204 (
205  const faePatchField<Type>& ptf,
206  const labelList& addr
207 )
208 {
209  Field<Type>::rmap(ptf, addr);
210 }
211 
212 
213 template<class Type>
215 {
216  os.writeEntry("type", type());
217 
218  // if (!patchType().empty())
219  // {
220  // os.writeEntry("patchType", patchType());
221  // }
222 }
223 
224 
225 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
226 
227 template<class Type>
229 (
230  const UList<Type>& ul
231 )
232 {
234 }
235 
236 
237 template<class Type>
239 (
240  const faePatchField<Type>& ptf
241 )
242 {
245 }
246 
247 
248 template<class Type>
250 (
251  const faePatchField<Type>& ptf
252 )
253 {
256 }
257 
258 
259 template<class Type>
261 (
262  const faePatchField<Type>& ptf
263 )
264 {
267 }
268 
269 
270 template<class Type>
272 (
273  const faePatchField<scalar>& ptf
274 )
275 {
278 }
279 
280 
281 template<class Type>
283 (
284  const faePatchField<scalar>& ptf
285 )
286 {
289 }
290 
291 
292 template<class Type>
294 (
295  const Field<Type>& tf
296 )
297 {
299 }
300 
301 
302 template<class Type>
304 (
305  const Field<Type>& tf
306 )
307 {
309 }
310 
311 
312 template<class Type>
314 (
315  const scalarField& tf
316 )
317 {
319 }
320 
321 
322 template<class Type>
324 (
325  const scalarField& tf
326 )
327 {
329 }
330 
331 
332 template<class Type>
334 (
335  const Type& t
336 )
337 {
339 }
340 
341 
342 template<class Type>
344 (
345  const Type& t
346 )
347 {
349 }
350 
351 
352 template<class Type>
354 (
355  const Type& t
356 )
357 {
359 }
360 
361 
362 template<class Type>
364 (
365  const scalar s
366 )
367 {
369 }
370 
371 
372 template<class Type>
374 (
375  const scalar s
376 )
377 {
379 }
380 
381 
382 template<class Type>
384 (
385  const faePatchField<Type>& ptf
386 )
387 {
389 }
390 
391 
392 template<class Type>
394 (
395  const Field<Type>& tf
396 )
397 {
399 }
400 
401 
402 template<class Type>
404 (
405  const Type& t
406 )
407 {
409 }
410 
411 
412 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
413 
414 template<class Type>
415 Foam::Ostream& Foam::operator<<(Ostream& os, const faePatchField<Type>& ptf)
416 {
417  ptf.write(os);
418 
420 
421  return os;
422 }
423 
424 
425 // ************************************************************************* //
dictionary dict
virtual void write(Ostream &os) const
Write.
void operator-=(const UList< Type > &)
Definition: Field.C:800
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Template invariant parts for faePatchField.
Definition: faePatchField.H:76
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: faePatchField.C:29
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
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
virtual void rmap(const faePatchField< Type > &, const labelList &)
Reverse map the given faePatchField onto this faePatchField.
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
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:466
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
void check(const faePatchField< Type > &) const
Check against given patch field.
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.
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &)
Construct from patch and internal field.
Definition: faePatchField.C:62
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:46
void operator+=(const UList< Type > &)
Definition: Field.C:799
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))
A FieldMapper for finite-area patch fields.
void operator/=(const UList< scalar > &)
Definition: Field.C:802
void checkPatch(const faePatchFieldBase &rhs) const
Check that patches are identical.
void operator*=(const UList< scalar > &)
Definition: Field.C:801
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.