GeometricFieldNew.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) 2017 OpenFOAM Foundation
9  Copyright (C) 2019-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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 template<class Type, template<class> class PatchField, class GeoMesh>
32 template<class... Args>
35 (
37  const word& name,
38  const Mesh& mesh,
39  Args&&... args
40 )
41 {
43  (
44  IOobject
45  (
46  name,
47  mesh.thisDb().time().timeName(),
48  mesh.thisDb(),
49  IOobjectOption::NO_READ,
50  IOobjectOption::NO_WRITE,
51  IOobjectOption::NO_REGISTER
52  ),
53  mesh,
54  std::forward<Args>(args)...
55  );
56 
57  if (IOobjectOption::REGISTER == regOpt)
58  {
59  ptr->checkIn();
60  }
61  else if
62  (
63  // LEGACY_REGISTER: detect if caching is desired
64  (IOobjectOption::LEGACY_REGISTER == regOpt)
65  && ptr->db().is_cacheTemporaryObject(ptr.get())
66  )
67  {
68  ptr.protect(true);
69  ptr->checkIn();
70  }
71  return ptr;
72 }
73 
74 
75 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
76 
77 template<class Type, template<class> class PatchField, class GeoMesh>
80 (
81  const word& name,
83  const Mesh& mesh,
84  const dimensionSet& dims,
85  const word& patchFieldType
86 )
87 {
89  (
90  regOpt,
91  name,
92  mesh,
93  dims,
94  patchFieldType
95  );
96 }
97 
98 
99 template<class Type, template<class> class PatchField, class GeoMesh>
102 (
103  const word& name,
104  const Mesh& mesh,
105  const dimensionSet& dims,
106  const word& patchFieldType
107 )
108 {
110  (
111  IOobjectOption::LEGACY_REGISTER,
112  name,
113  mesh,
114  dims,
115  patchFieldType
116  );
117 }
118 
119 
120 template<class Type, template<class> class PatchField, class GeoMesh>
123 (
124  const word& name,
126  const Mesh& mesh,
127  const dimensionSet& dims,
128  const Field<Type>& iField,
129  const word& patchFieldType
130 )
131 {
133  (
134  regOpt,
135  name,
136  mesh,
137  dims,
138  iField,
139  patchFieldType
140  );
141 }
142 
143 
144 template<class Type, template<class> class PatchField, class GeoMesh>
147 (
148  const word& name,
149  const Mesh& mesh,
150  const dimensionSet& dims,
151  const Field<Type>& iField,
152  const word& patchFieldType
153 )
154 {
156  (
157  IOobjectOption::LEGACY_REGISTER,
158  name,
159  mesh,
160  dims,
161  iField,
162  patchFieldType
163  );
164 }
165 
166 
167 template<class Type, template<class> class PatchField, class GeoMesh>
170 (
171  const word& name,
173  const Mesh& mesh,
174  const dimensionSet& dims,
175  Field<Type>&& iField,
176  const word& patchFieldType
177 )
178 {
180  (
181  regOpt,
182  name,
183  mesh,
184  dims,
185  std::move(iField),
186  patchFieldType
187  );
188 }
189 
190 
191 template<class Type, template<class> class PatchField, class GeoMesh>
194 (
195  const word& name,
196  const Mesh& mesh,
197  const dimensionSet& dims,
198  Field<Type>&& iField,
199  const word& patchFieldType
200 )
201 {
203  (
204  IOobjectOption::LEGACY_REGISTER,
205  name,
206  mesh,
207  dims,
208  std::move(iField),
209  patchFieldType
210  );
211 }
212 
213 
214 template<class Type, template<class> class PatchField, class GeoMesh>
217 (
218  const word& name,
220  const Mesh& mesh,
221  const Type& value,
222  const dimensionSet& dims,
223  const word& patchFieldType
224 )
225 {
227  (
228  regOpt,
229  name,
230  mesh,
231  value,
232  dims,
233  patchFieldType
234  );
235 }
236 
237 
238 template<class Type, template<class> class PatchField, class GeoMesh>
241 (
242  const word& name,
243  const Mesh& mesh,
244  const Type& value,
245  const dimensionSet& dims,
246  const word& patchFieldType
247 )
248 {
250  (
251  IOobjectOption::LEGACY_REGISTER,
252  name,
253  mesh,
254  value,
255  dims,
256  patchFieldType
257  );
258 }
259 
260 
261 template<class Type, template<class> class PatchField, class GeoMesh>
264 (
265  const word& name,
267  const Mesh& mesh,
268  const Type& value,
269  const dimensionSet& dims,
270  const wordList& patchFieldTypes,
271  const wordList& actualPatchTypes
272 )
273 {
275  (
276  regOpt,
277  name,
278  mesh,
279  value,
280  dims,
281  patchFieldTypes,
282  actualPatchTypes
283  );
284 }
285 
286 
287 template<class Type, template<class> class PatchField, class GeoMesh>
290 (
291  const word& name,
292  const Mesh& mesh,
293  const Type& value,
294  const dimensionSet& dims,
295  const wordList& patchFieldTypes,
296  const wordList& actualPatchTypes
297 )
298 {
300  (
301  IOobjectOption::LEGACY_REGISTER,
302  name,
303  mesh,
304  value,
305  dims,
306  patchFieldTypes,
307  actualPatchTypes
308  );
309 }
310 
311 
312 template<class Type, template<class> class PatchField, class GeoMesh>
315 (
316  const word& name,
318  const Mesh& mesh,
319  const dimensioned<Type>& dt,
320  const word& patchFieldType
321 )
322 {
324  (
325  name,
326  regOpt,
327  mesh,
328  dt.value(),
329  dt.dimensions(),
330  patchFieldType
331  );
332 }
333 
334 
335 template<class Type, template<class> class PatchField, class GeoMesh>
338 (
339  const word& name,
340  const Mesh& mesh,
341  const dimensioned<Type>& dt,
342  const word& patchFieldType
343 )
344 {
346  (
347  name,
348  mesh,
349  dt.value(),
350  dt.dimensions(),
351  patchFieldType
352  );
353 }
354 
355 
356 template<class Type, template<class> class PatchField, class GeoMesh>
359 (
360  const word& name,
362  const Mesh& mesh,
363  const dimensioned<Type>& dt,
364  const wordList& patchFieldTypes,
365  const wordList& actualPatchTypes
366 )
367 {
369  (
370  name,
371  regOpt,
372  mesh,
373  dt.value(),
374  dt.dimensions(),
375  patchFieldTypes,
376  actualPatchTypes
377  );
378 }
379 
380 
381 template<class Type, template<class> class PatchField, class GeoMesh>
384 (
385  const word& name,
386  const Mesh& mesh,
387  const dimensioned<Type>& dt,
388  const wordList& patchFieldTypes,
389  const wordList& actualPatchTypes
390 )
391 {
393  (
394  name,
395  mesh,
396  dt.value(),
397  dt.dimensions(),
398  patchFieldTypes,
399  actualPatchTypes
400  );
401 }
402 
403 
404 template<class Type, template<class> class PatchField, class GeoMesh>
407 (
408  const word& name,
410  const word& patchFieldType
411 )
412 {
414  (
415  IOobject
416  (
417  name,
418  tgf().instance(),
419  tgf().local(),
420  tgf().db(),
421  IOobjectOption::NO_READ,
422  IOobjectOption::NO_WRITE,
423  IOobjectOption::NO_REGISTER
424  ),
425  tgf,
426  patchFieldType
427  );
428 
429  if
430  (
431  ptr->db().is_cacheTemporaryObject(ptr.get())
432  )
433  {
434  ptr.protect(true);
435  ptr->checkIn();
436  }
437  return ptr;
438 }
439 
440 
441 template<class Type, template<class> class PatchField, class GeoMesh>
444 (
445  const word& name,
447 )
448 {
450  (
451  IOobject
452  (
453  name,
454  tgf().instance(),
455  tgf().local(),
456  tgf().db(),
457  IOobjectOption::NO_READ,
458  IOobjectOption::NO_WRITE,
459  IOobjectOption::NO_REGISTER
460  ),
461  tgf
462  );
463 
464  if
465  (
466  ptr->db().is_cacheTemporaryObject(ptr.get())
467  )
468  {
469  ptr.protect(true);
470  ptr->checkIn();
471  }
472  return ptr;
473 }
474 
475 
476 template<class Type, template<class> class PatchField, class GeoMesh>
479 (
480  const word& name,
482  const wordList& patchFieldTypes,
483  const wordList& actualPatchTypes
484 )
485 {
487  (
488  IOobject
489  (
490  name,
491  tgf().instance(),
492  tgf().local(),
493  tgf().db(),
494  IOobjectOption::NO_READ,
495  IOobjectOption::NO_WRITE,
496  IOobjectOption::NO_REGISTER
497  ),
498  tgf,
499  patchFieldTypes,
500  actualPatchTypes
501  );
502 
503  if
504  (
505  ptr->db().is_cacheTemporaryObject(ptr.get())
506  )
507  {
508  ptr.protect(true);
509  ptr->checkIn();
510  }
511  return ptr;
512 }
513 
514 
515 template<class Type, template<class> class PatchField, class GeoMesh>
516 template<class AnyType>
519 (
521  const word& name,
522  const dimensionSet& dims,
523  const word& patchFieldType
524 )
525 {
527  (
528  IOobject
529  (
530  name,
531  fld.instance(),
532  fld.db(),
533  IOobjectOption::NO_READ,
534  IOobjectOption::NO_WRITE,
535  IOobjectOption::NO_REGISTER
536  ),
537  fld.mesh(),
538  dims,
539  patchFieldType
540  );
541 
542  if
543  (
544  ptr->db().is_cacheTemporaryObject(ptr.get())
545  )
546  {
547  ptr.protect(true);
548  ptr->checkIn();
549  }
550  return ptr;
551 }
552 
553 
554 template<class Type, template<class> class PatchField, class GeoMesh>
555 template<class AnyType>
558 (
560  const word& name,
561  const dimensioned<Type>& dt,
562  const word& patchFieldType
563 )
564 {
566  (
567  IOobject
568  (
569  name,
570  fld.instance(),
571  fld.db(),
572  IOobjectOption::NO_READ,
573  IOobjectOption::NO_WRITE,
574  IOobjectOption::NO_REGISTER
575  ),
576  fld.mesh(),
577  dt.value(),
578  dt.dimensions(),
579  patchFieldType
580  );
581 
582  if
583  (
584  ptr->db().is_cacheTemporaryObject(ptr.get())
585  )
586  {
587  ptr.protect(true);
588  ptr->checkIn();
589  }
590  return ptr;
591 }
592 
593 
594 // ************************************************************************* //
const Type & value() const noexcept
Return const reference to value.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
Generic dimensioned Type class.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool local
Definition: EEqn.H:20
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
GeoMesh::Mesh Mesh
The mesh type for the DimensionedField.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=PatchField< Type >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172