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-2024 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  // == mesh.thisDb().newIOobject(name)
45  IOobject
46  (
47  name,
48  mesh.thisDb().time().timeName(),
49  mesh.thisDb(),
50  IOobjectOption::NO_READ,
51  IOobjectOption::NO_WRITE,
52  IOobjectOption::NO_REGISTER
53  ),
54  mesh,
55  std::forward<Args>(args)...
56  );
57 
58  // Registration
59  {
60  if (IOobjectOption::REGISTER == regOpt)
61  {
62  ptr->checkIn();
63  }
64  else if
65  (
66  // LEGACY_REGISTER: detect if caching is desired
67  (IOobjectOption::LEGACY_REGISTER == regOpt)
68  && ptr->db().is_cacheTemporaryObject(ptr.get())
69  )
70  {
71  ptr.protect(true);
72  ptr->checkIn();
73  }
74  }
75  return ptr;
76 }
77 
78 
79 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
80 
81 template<class Type, template<class> class PatchField, class GeoMesh>
84 (
85  const word& name,
87  const Mesh& mesh,
88  const dimensionSet& dims,
89  const word& patchFieldType
90 )
91 {
93  (
94  regOpt,
95  name,
96  mesh,
97  dims,
98  patchFieldType
99  );
100 }
101 
102 
103 template<class Type, template<class> class PatchField, class GeoMesh>
106 (
107  const word& name,
108  const Mesh& mesh,
109  const dimensionSet& dims,
110  const word& patchFieldType
111 )
112 {
114  (
115  IOobjectOption::LEGACY_REGISTER,
116  name,
117  mesh,
118  dims,
119  patchFieldType
120  );
121 }
122 
123 
124 template<class Type, template<class> class PatchField, class GeoMesh>
127 (
128  const word& name,
130  const Mesh& mesh,
131  const dimensionSet& dims,
132  const Field<Type>& iField,
133  const word& patchFieldType
134 )
135 {
137  (
138  regOpt,
139  name,
140  mesh,
141  dims,
142  iField,
143  patchFieldType
144  );
145 }
146 
147 
148 template<class Type, template<class> class PatchField, class GeoMesh>
151 (
152  const word& name,
153  const Mesh& mesh,
154  const dimensionSet& dims,
155  const Field<Type>& iField,
156  const word& patchFieldType
157 )
158 {
160  (
161  IOobjectOption::LEGACY_REGISTER,
162  name,
163  mesh,
164  dims,
165  iField,
166  patchFieldType
167  );
168 }
169 
170 
171 template<class Type, template<class> class PatchField, class GeoMesh>
174 (
175  const word& name,
177  const Mesh& mesh,
178  const dimensionSet& dims,
179  Field<Type>&& iField,
180  const word& patchFieldType
181 )
182 {
184  (
185  regOpt,
186  name,
187  mesh,
188  dims,
189  std::move(iField),
190  patchFieldType
191  );
192 }
193 
194 
195 template<class Type, template<class> class PatchField, class GeoMesh>
198 (
199  const word& name,
200  const Mesh& mesh,
201  const dimensionSet& dims,
202  Field<Type>&& iField,
203  const word& patchFieldType
204 )
205 {
207  (
208  IOobjectOption::LEGACY_REGISTER,
209  name,
210  mesh,
211  dims,
212  std::move(iField),
213  patchFieldType
214  );
215 }
216 
217 
218 template<class Type, template<class> class PatchField, class GeoMesh>
221 (
222  const word& name,
224  const Mesh& mesh,
225  const dimensionSet& dims,
226  const Field<Type>& iField,
227  const PtrList<PatchField<Type>>& pflds
228 )
229 {
231  (
232  regOpt,
233  name,
234  mesh,
235  dims,
236  iField,
237  pflds
238  );
239 }
240 
241 
242 template<class Type, template<class> class PatchField, class GeoMesh>
245 (
246  const word& name,
247  const Mesh& mesh,
248  const dimensionSet& dims,
249  const Field<Type>& iField,
250  const PtrList<PatchField<Type>>& pflds
251 )
252 {
254  (
255  IOobjectOption::LEGACY_REGISTER,
256  name,
257  mesh,
258  dims,
259  iField,
260  pflds
261  );
262 }
263 
264 
265 template<class Type, template<class> class PatchField, class GeoMesh>
268 (
269  const word& name,
271  const Mesh& mesh,
272  const dimensionSet& dims,
273  Field<Type>&& iField,
274  const PtrList<PatchField<Type>>& pflds
275 )
276 {
278  (
279  regOpt,
280  name,
281  mesh,
282  dims,
283  std::move(iField),
284  pflds
285  );
286 }
287 
288 
289 template<class Type, template<class> class PatchField, class GeoMesh>
292 (
293  const word& name,
294  const Mesh& mesh,
295  const dimensionSet& dims,
296  Field<Type>&& iField,
297  const PtrList<PatchField<Type>>& pflds
298 )
299 {
301  (
302  IOobjectOption::LEGACY_REGISTER,
303  name,
304  mesh,
305  dims,
306  std::move(iField),
307  pflds
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 Type& value,
320  const dimensionSet& dims,
321  const word& patchFieldType
322 )
323 {
325  (
326  regOpt,
327  name,
328  mesh,
329  value,
330  dims,
331  patchFieldType
332  );
333 }
334 
335 
336 template<class Type, template<class> class PatchField, class GeoMesh>
339 (
340  const word& name,
341  const Mesh& mesh,
342  const Type& value,
343  const dimensionSet& dims,
344  const word& patchFieldType
345 )
346 {
348  (
349  IOobjectOption::LEGACY_REGISTER,
350  name,
351  mesh,
352  value,
353  dims,
354  patchFieldType
355  );
356 }
357 
358 
359 template<class Type, template<class> class PatchField, class GeoMesh>
362 (
363  const word& name,
365  const Mesh& mesh,
366  const Type& value,
367  const dimensionSet& dims,
368  const wordList& patchFieldTypes,
369  const wordList& actualPatchTypes
370 )
371 {
373  (
374  regOpt,
375  name,
376  mesh,
377  value,
378  dims,
379  patchFieldTypes,
380  actualPatchTypes
381  );
382 }
383 
384 
385 template<class Type, template<class> class PatchField, class GeoMesh>
388 (
389  const word& name,
390  const Mesh& mesh,
391  const Type& value,
392  const dimensionSet& dims,
393  const wordList& patchFieldTypes,
394  const wordList& actualPatchTypes
395 )
396 {
398  (
399  IOobjectOption::LEGACY_REGISTER,
400  name,
401  mesh,
402  value,
403  dims,
404  patchFieldTypes,
405  actualPatchTypes
406  );
407 }
408 
409 
410 template<class Type, template<class> class PatchField, class GeoMesh>
413 (
414  const word& name,
416  const Mesh& mesh,
417  const dimensioned<Type>& dt,
418  const word& patchFieldType
419 )
420 {
422  (
423  name,
424  regOpt,
425  mesh,
426  dt.value(),
427  dt.dimensions(),
428  patchFieldType
429  );
430 }
431 
432 
433 template<class Type, template<class> class PatchField, class GeoMesh>
436 (
437  const word& name,
438  const Mesh& mesh,
439  const dimensioned<Type>& dt,
440  const word& patchFieldType
441 )
442 {
444  (
445  name,
446  mesh,
447  dt.value(),
448  dt.dimensions(),
449  patchFieldType
450  );
451 }
452 
453 
454 template<class Type, template<class> class PatchField, class GeoMesh>
457 (
458  const word& name,
460  const Mesh& mesh,
461  const dimensioned<Type>& dt,
462  const wordList& patchFieldTypes,
463  const wordList& actualPatchTypes
464 )
465 {
467  (
468  name,
469  regOpt,
470  mesh,
471  dt.value(),
472  dt.dimensions(),
473  patchFieldTypes,
474  actualPatchTypes
475  );
476 }
477 
478 
479 template<class Type, template<class> class PatchField, class GeoMesh>
482 (
483  const word& name,
484  const Mesh& mesh,
485  const dimensioned<Type>& dt,
486  const wordList& patchFieldTypes,
487  const wordList& actualPatchTypes
488 )
489 {
491  (
492  name,
493  mesh,
494  dt.value(),
495  dt.dimensions(),
496  patchFieldTypes,
497  actualPatchTypes
498  );
499 }
500 
501 
502 template<class Type, template<class> class PatchField, class GeoMesh>
505 (
506  const word& name,
509 )
510 {
512  (
513  IOobject
514  (
515  name,
516  tfld().instance(),
517  tfld().local(),
518  tfld().db(),
519  IOobjectOption::NO_READ,
520  IOobjectOption::NO_WRITE,
521  IOobjectOption::NO_REGISTER
522  ),
523  tfld
524  );
525 
526  // Registration
527  {
528  if (IOobjectOption::REGISTER == regOpt)
529  {
530  ptr->checkIn();
531  }
532  else if
533  (
534  // LEGACY_REGISTER: detect if caching is desired
535  (IOobjectOption::LEGACY_REGISTER == regOpt)
536  && ptr->db().is_cacheTemporaryObject(ptr.get())
537  )
538  {
539  ptr.protect(true);
540  ptr->checkIn();
541  }
542  }
543  return ptr;
544 }
545 
546 
547 template<class Type, template<class> class PatchField, class GeoMesh>
550 (
551  const word& name,
553 )
554 {
556  (
557  name,
558  IOobjectOption::LEGACY_REGISTER,
559  tfld
560  );
561 }
562 
563 
564 template<class Type, template<class> class PatchField, class GeoMesh>
567 (
568  const word& name,
571  const word& patchFieldType
572 )
573 {
575  (
576  IOobject
577  (
578  name,
579  tfld().instance(),
580  tfld().local(),
581  tfld().db(),
582  IOobjectOption::NO_READ,
583  IOobjectOption::NO_WRITE,
584  IOobjectOption::NO_REGISTER
585  ),
586  tfld,
587  patchFieldType
588  );
589 
590  // Registration
591  {
592  if (IOobjectOption::REGISTER == regOpt)
593  {
594  ptr->checkIn();
595  }
596  else if
597  (
598  // LEGACY_REGISTER: detect if caching is desired
599  (IOobjectOption::LEGACY_REGISTER == regOpt)
600  && ptr->db().is_cacheTemporaryObject(ptr.get())
601  )
602  {
603  ptr.protect(true);
604  ptr->checkIn();
605  }
606  }
607  return ptr;
608 }
609 
610 
611 template<class Type, template<class> class PatchField, class GeoMesh>
614 (
615  const word& name,
617  const word& patchFieldType
618 )
619 {
621  (
622  name,
623  IOobjectOption::LEGACY_REGISTER,
624  tfld,
625  patchFieldType
626  );
627 }
628 
629 
630 template<class Type, template<class> class PatchField, class GeoMesh>
633 (
634  const word& name,
637  const wordList& patchFieldTypes,
638  const wordList& actualPatchTypes
639 )
640 {
642  (
643  IOobject
644  (
645  name,
646  tfld().instance(),
647  tfld().local(),
648  tfld().db(),
649  IOobjectOption::NO_READ,
650  IOobjectOption::NO_WRITE,
651  IOobjectOption::NO_REGISTER
652  ),
653  tfld,
654  patchFieldTypes,
655  actualPatchTypes
656  );
657 
658  // Registration
659  {
660  if (IOobjectOption::REGISTER == regOpt)
661  {
662  ptr->checkIn();
663  }
664  else if
665  (
666  // LEGACY_REGISTER: detect if caching is desired
667  (IOobjectOption::LEGACY_REGISTER == regOpt)
668  && ptr->db().is_cacheTemporaryObject(ptr.get())
669  )
670  {
671  ptr.protect(true);
672  ptr->checkIn();
673  }
674  }
675  return ptr;
676 }
677 
678 
679 template<class Type, template<class> class PatchField, class GeoMesh>
682 (
683  const word& name,
685  const wordList& patchFieldTypes,
686  const wordList& actualPatchTypes
687 )
688 {
690  (
691  name,
692  IOobjectOption::LEGACY_REGISTER,
693  tfld,
694  patchFieldTypes,
695  actualPatchTypes
696  );
697 }
698 
699 
700 template<class Type, template<class> class PatchField, class GeoMesh>
701 template<class AnyType>
704 (
706  const word& name,
707  const dimensionSet& dims,
708  const word& patchFieldType
709 )
710 {
712  (
713  IOobject
714  (
715  name,
716  fld.instance(),
717  fld.db(),
718  IOobjectOption::NO_READ,
719  IOobjectOption::NO_WRITE,
720  IOobjectOption::NO_REGISTER
721  ),
722  fld.mesh(),
723  dims,
724  patchFieldType
725  );
726 
727  // Registration
728  {
729  if
730  (
731  // LEGACY_REGISTER: detect if caching is desired
732  ptr->db().is_cacheTemporaryObject(ptr.get())
733  )
734  {
735  ptr.protect(true);
736  ptr->checkIn();
737  }
738  }
739  return ptr;
740 }
741 
742 
743 template<class Type, template<class> class PatchField, class GeoMesh>
744 template<class AnyType>
747 (
749  const word& name,
750  const dimensioned<Type>& dt,
751  const word& patchFieldType
752 )
753 {
755  (
756  IOobject
757  (
758  name,
759  fld.instance(),
760  fld.db(),
761  IOobjectOption::NO_READ,
762  IOobjectOption::NO_WRITE,
763  IOobjectOption::NO_REGISTER
764  ),
765  fld.mesh(),
766  dt.value(),
767  dt.dimensions(),
768  patchFieldType
769  );
770 
771  // Registration
772  {
773  if
774  (
775  // LEGACY_REGISTER: detect if caching is desired
776  ptr->db().is_cacheTemporaryObject(ptr.get())
777  )
778  {
779  ptr.protect(true);
780  ptr->checkIn();
781  }
782  }
783  return ptr;
784 }
785 
786 
787 // ************************************************************************* //
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.
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)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
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:180