GeometricField.H
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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-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 Class
28  Foam::GeometricField
29 
30 Description
31  Generic GeometricField class.
32 
33 SourceFiles
34  GeometricFieldI.H
35  GeometricField.C
36  GeometricFieldFunctions.H
37  GeometricFieldFunctions.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_GeometricField_H
42 #define Foam_GeometricField_H
43 
44 #include "regIOobject.H"
45 #include "GeometricBoundaryField.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class dictionary;
54 
55 template<class Type, template<class> class PatchField, class GeoMesh>
56 class GeometricField;
57 
58 template<class Type, template<class> class PatchField, class GeoMesh>
59 Ostream& operator<<
60 (
61  Ostream&,
62  const GeometricField<Type, PatchField, GeoMesh>&
63 );
64 
65 template<class Type, template<class> class PatchField, class GeoMesh>
66 Ostream& operator<<
67 (
68  Ostream&,
69  const tmp<GeometricField<Type, PatchField, GeoMesh>>&
70 );
71 
72 
73 /*---------------------------------------------------------------------------*\
74  Class GeometricField Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type, template<class> class PatchField, class GeoMesh>
78 class GeometricField
79 :
80  public DimensionedField<Type, GeoMesh>
81 {
82 public:
83 
84  // Public Typedefs
85 
86  //- The mesh type for the GeometricField
87  typedef typename GeoMesh::Mesh Mesh;
88 
89  //- The boundary mesh type for the boundary fields
90  typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
91 
92  //- The internal field type from which this GeometricField is derived
94 
95  //- Type of boundary fields
97 
98  //- The patch field type for the GeometricBoundaryField
99  typedef PatchField<Type> Patch;
100 
101  //- Component type of the field elements
102  typedef typename Field<Type>::cmptType cmptType;
103 
105 private:
106 
107  // Private Data
108 
109  //- Current time index.
110  // Used to trigger the storing of the old-time value
111  mutable label timeIndex_;
112 
113  //- Pointer to old time field
114  mutable GeometricField<Type, PatchField, GeoMesh>* field0Ptr_;
115 
116  //- Pointer to previous iteration (used for under-relaxation)
117  mutable GeometricField<Type, PatchField, GeoMesh>* fieldPrevIterPtr_;
118 
119  //- Boundary field containing boundary field values
120  Boundary boundaryField_;
121 
122 
123  // Private Member Functions
124 
125  //- Read from file if it is present
126  bool readIfPresent();
127 
128  //- Read old time field from file if it is present
129  bool readOldTimeIfPresent();
130 
131  //- Read the field from the dictionary
132  void readFields(const dictionary& dict);
133 
134  //- Read the field - create the field dictionary on-the-fly
135  void readFields();
136 
137  //- Implementation for 'New' with specified registerObject preference.
138  // For LEGACY_REGISTER, registration is determined by
139  // objectRegistry::is_cacheTemporaryObject().
140  template<class... Args>
142  (
144  const word& name,
145  const Mesh& mesh,
146  Args&&... args
147  );
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("GeometricField");
153 
154 
155  // Static Member Functions
156 
157  //- Return a null geometric field
158  inline static const GeometricField<Type, PatchField, GeoMesh>& null();
159 
160 
161  // Constructors
162 
163  //- Construct given IOobject, mesh, dimensions and patch type.
164  // This allocates storage for the field but does not set values.
165  // Used only within this class to create TEMPORARY variables
167  (
168  const IOobject& io,
169  const Mesh& mesh,
170  const dimensionSet& dims,
171  const word& patchFieldType = PatchField<Type>::calculatedType()
172  );
173 
174  //- Construct given IOobject, mesh, dimensions and patch types.
175  // This allocates storage for the field but does not set values.
176  // Used only within this class to create TEMPORARY variables
178  (
179  const IOobject& io,
180  const Mesh& mesh,
181  const dimensionSet& dims,
182  const wordList& wantedPatchTypes,
183  const wordList& actualPatchTypes = wordList()
184  );
185 
186  //- Construct given IOobject, mesh, dimensions, initial field value
187  //- and given patch type.
188  // This assigns both dimensions and values.
190  (
191  const IOobject& io,
192  const Mesh& mesh,
193  const Type& value,
194  const dimensionSet& dims,
195  const word& patchFieldType = PatchField<Type>::calculatedType()
196  );
197 
198  //- Construct given IOobject, mesh, dimensions, initial field value
199  //- and given patch types.
200  // This assigns both dimensions and values.
202  (
203  const IOobject& io,
204  const Mesh& mesh,
205  const Type& value,
206  const dimensionSet& dims,
207  const wordList& wantedPatchTypes,
208  const wordList& actualPatchTypes = wordList()
209  );
210 
211  //- Construct given IOobject, mesh, dimensioned<Type> and patch type.
212  // This assigns both dimensions and values.
213  // The name of the dimensioned<Type> has no influence.
215  (
216  const IOobject& io,
217  const Mesh& mesh,
218  const dimensioned<Type>& dt,
219  const word& patchFieldType = PatchField<Type>::calculatedType()
220  );
221 
222  //- Construct given IOobject, mesh, dimensioned<Type> and patch types.
223  // This assigns both dimensions and values.
224  // The name of the dimensioned<Type> has no influence.
226  (
227  const IOobject& io,
228  const Mesh& mesh,
229  const dimensioned<Type>& dt,
230  const wordList& wantedPatchTypes,
231  const wordList& actualPatchTypes = wordList()
232  );
233 
234  //- Copy construct from internal field and a patch list to clone
236  (
237  const IOobject& io,
238  const Internal& diField,
239  const PtrList<PatchField<Type>>& ptfl
240  );
241 
242  //- Move construct from internal field and a patch list to clone
244  (
245  const IOobject& io,
246  Internal&& diField,
247  const PtrList<PatchField<Type>>& ptfl
248  );
249 
250  //- Move construct from internal field and a patch list to clone
252  (
253  const IOobject& io,
254  const tmp<Internal>& tfield,
255  const PtrList<PatchField<Type>>& ptfl
256  );
257 
258  //- Copy construct from internal field and a patch list to clone
260  (
261  const Internal& diField,
262  const PtrList<PatchField<Type>>& ptfl
263  );
264 
265  //- Move construct from internal field and a patch list to clone
267  (
268  Internal&& diField,
269  const PtrList<PatchField<Type>>& ptfl
270  );
271 
272  //- Copy construct from internal field, with specified patch type
274  (
275  const IOobject& io,
276  const Mesh& mesh,
277  const dimensionSet& dims,
278  const Field<Type>& iField,
279  const word& patchFieldType = PatchField<Type>::calculatedType()
280  );
281 
282  //- Move construct from internal field, with specified patch type
284  (
285  const IOobject& io,
286  const Mesh& mesh,
287  const dimensionSet& dims,
288  Field<Type>&& iField,
289  const word& patchFieldType = PatchField<Type>::calculatedType()
290  );
291 
292  //- Copy construct from components
294  (
295  const IOobject& io,
296  const Mesh& mesh,
297  const dimensionSet& dims,
298  const Field<Type>& iField,
299  const PtrList<PatchField<Type>>& ptfl
300  );
301 
302  //- Move construct from internal field and a patch list to clone
304  (
305  const IOobject& io,
306  const Mesh& mesh,
307  const dimensionSet& dims,
308  Field<Type>&& iField,
309  const PtrList<PatchField<Type>>& ptfl
310  );
311 
312  //- Copy construct from components
314  (
315  const IOobject& io,
316  const Mesh& mesh,
317  const dimensionSet& dims,
318  const tmp<Field<Type>>& tiField,
319  const PtrList<PatchField<Type>>& ptfl
320  );
321 
322  //- Read construct using given IOobject. Always reads!
324  (
325  const IOobject& io,
326  const Mesh& mesh,
327  const bool readOldTime = true
328  );
329 
330  //- Construct from dictionary
332  (
333  const IOobject& io,
334  const Mesh& mesh,
335  const dictionary& dict
336  );
337 
338  //- Copy construct
340  (
342  );
343 
344  //- Construct from tmp<GeometricField> deleting argument
346  (
348  );
349 
350  //- Construct as copy resetting IO parameters
352  (
353  const IOobject& io,
355  );
356 
357  //- Construct from tmp<GeometricField> resetting IO parameters
359  (
360  const IOobject& io,
362  );
363 
364  //- Copy construct with a new name
366  (
367  const word& newName,
369  );
370 
371  //- Construct with a new name from tmp<GeometricField>
373  (
374  const word& newName,
376  );
377 
378  //- Construct as copy resetting IO parameters and patch type
380  (
381  const IOobject& io,
383  const word& patchFieldType
384  );
385 
386  //- Construct as copy resetting IO parameters and boundary type
387  //- for selected patchIDs
389  (
390  const IOobject& io,
392  const labelList& patchIDs,
393  const word& patchFieldType
394  );
395 
396  //- Construct as copy resetting IO parameters and boundary types
398  (
399  const IOobject& io,
401  const wordList& patchFieldTypes,
402  const wordList& actualPatchTypes = wordList()
403  );
404 
405  //- Construct as copy resetting IO parameters and boundary types
407  (
408  const IOobject& io,
410  const wordList& patchFieldTypes,
411  const wordList& actualPatchTypes = wordList()
412  );
413 
414  //- Clone
416 
417 
418  // Factory Methods
419 
420  //- Return tmp field (NO_READ, NO_WRITE)
421  //- from name, mesh, dimensions and patch type.
422  //- [Takes current timeName from the mesh registry].
423  // For LEGACY_REGISTER, registration is determined by
424  // objectRegistry::is_cacheTemporaryObject().
426  (
427  const word& name,
429  const Mesh& mesh,
430  const dimensionSet& dims,
431  const word& patchFieldType = PatchField<Type>::calculatedType()
432  );
433 
434  //- Return tmp field (NO_READ, NO_WRITE)
435  //- from name, mesh, dimensions and patch type.
436  //- [Takes current timeName from the mesh registry].
437  // Registration/persistence determined by
438  // objectRegistry::is_cacheTemporaryObject().
440  (
441  const word& name,
442  const Mesh& mesh,
443  const dimensionSet& dims,
444  const word& patchFieldType = PatchField<Type>::calculatedType()
445  );
446 
447  //- Return tmp field (NO_READ, NO_WRITE)
448  //- from name, mesh, dimensions, copy of internal field and patch type.
449  //- [Takes current timeName from the mesh registry].
450  // For LEGACY_REGISTER, registration is determined by
451  // objectRegistry::is_cacheTemporaryObject().
453  (
454  const word& name,
456  const Mesh& mesh,
457  const dimensionSet& dims,
458  const Field<Type>& iField,
459  const word& patchFieldType = PatchField<Type>::calculatedType()
460  );
461 
462  //- Return tmp field (NO_READ, NO_WRITE)
463  //- from name, mesh, dimensions, copy of internal field and patch type.
464  //- [Takes current timeName from the mesh registry].
465  // Registration/persistence determined by
466  // objectRegistry::is_cacheTemporaryObject().
468  (
469  const word& name,
470  const Mesh& mesh,
471  const dimensionSet& dims,
472  const Field<Type>& iField,
473  const word& patchFieldType = PatchField<Type>::calculatedType()
474  );
475 
476  //- Return tmp field (NO_READ, NO_WRITE)
477  //- from name, mesh, dimensions, moved internal field contents
478  //- and patch type.
479  //- [Takes current timeName from the mesh registry].
480  // For LEGACY_REGISTER, registration is determined by
481  // objectRegistry::is_cacheTemporaryObject().
483  (
484  const word& name,
486  const Mesh& mesh,
487  const dimensionSet& dims,
488  Field<Type>&& iField,
489  const word& patchFieldType = PatchField<Type>::calculatedType()
490  );
491 
492  //- Return tmp field (NO_READ, NO_WRITE)
493  //- from name, mesh, dimensions, moved internal field contents
494  //- and patch type.
495  //- [Takes current timeName from the mesh registry].
496  // Registration/persistence determined by
497  // objectRegistry::is_cacheTemporaryObject().
499  (
500  const word& name,
501  const Mesh& mesh,
502  const dimensionSet& dims,
503  Field<Type>&& iField,
504  const word& patchFieldType = PatchField<Type>::calculatedType()
505  );
506 
507  //- Return tmp field (NO_READ, NO_WRITE)
508  //- from name, mesh, field value, dimensions and patch type.
509  //- [Takes current timeName from the mesh registry].
510  // For LEGACY_REGISTER, registration is determined by
511  // objectRegistry::is_cacheTemporaryObject().
513  (
514  const word& name,
516  const Mesh& mesh,
517  const Type& value,
518  const dimensionSet& dims,
519  const word& patchFieldType = PatchField<Type>::calculatedType()
520  );
521 
522  //- Return tmp field (NO_READ, NO_WRITE)
523  //- from name, mesh, field value, dimensions and patch type.
524  //- [Takes current timeName from the mesh registry].
525  // Registration/persistence determined by
526  // objectRegistry::is_cacheTemporaryObject().
528  (
529  const word& name,
530  const Mesh& mesh,
531  const Type& value,
532  const dimensionSet& dims,
533  const word& patchFieldType = PatchField<Type>::calculatedType()
534  );
535 
536  //- Return tmp field (NO_READ, NO_WRITE)
537  //- from name, mesh, field value, dimensions and patch field types.
538  //- [Takes current timeName from the mesh registry].
539  // For LEGACY_REGISTER, registration is determined by
540  // objectRegistry::is_cacheTemporaryObject().
542  (
543  const word& name,
545  const Mesh& mesh,
546  const Type& value,
547  const dimensionSet& dims,
548  const wordList& patchFieldTypes,
549  const wordList& actualPatchTypes = wordList()
550  );
551 
552  //- Return tmp field (NO_READ, NO_WRITE)
553  //- from name, mesh, field value, dimensions and patch field types.
554  //- [Takes current timeName from the mesh registry].
555  // Registration/persistence determined by
556  // objectRegistry::is_cacheTemporaryObject().
558  (
559  const word& name,
560  const Mesh& mesh,
561  const Type& value,
562  const dimensionSet& dims,
563  const wordList& patchFieldTypes,
564  const wordList& actualPatchTypes = wordList()
565  );
566 
567  //- Return tmp field (NO_READ, NO_WRITE)
568  //- from name, mesh, dimensioned-type and patch type.
569  //- [Takes current timeName from the mesh registry].
570  // For LEGACY_REGISTER, registration is determined by
571  // objectRegistry::is_cacheTemporaryObject().
573  (
574  const word& name,
576  const Mesh& mesh,
577  const dimensioned<Type>& dt,
578  const word& patchFieldType = PatchField<Type>::calculatedType()
579  );
580 
581  //- Return tmp field (NO_READ, NO_WRITE)
582  //- from name, mesh, dimensioned-type and patch type.
583  //- [Takes current timeName from the mesh registry].
584  // Registration/persistence determined by
585  // objectRegistry::is_cacheTemporaryObject().
587  (
588  const word& name,
589  const Mesh& mesh,
590  const dimensioned<Type>& dt,
591  const word& patchFieldType = PatchField<Type>::calculatedType()
592  );
593 
594  //- Return tmp field (NO_READ, NO_WRITE)
595  //- from name, mesh, dimensioned-type and patch field types.
596  //- [Takes current timeName from the mesh registry].
597  // For LEGACY_REGISTER, registration is determined by
598  // objectRegistry::is_cacheTemporaryObject().
600  (
601  const word& name,
603  const Mesh& mesh,
604  const dimensioned<Type>& dt,
605  const wordList& patchFieldTypes,
606  const wordList& actualPatchTypes = wordList()
607  );
608 
609  //- Return tmp field (NO_READ, NO_WRITE)
610  //- from name, mesh, dimensioned-type and patch field types.
611  //- [Takes current timeName from the mesh registry].
612  // Registration/persistence determined by
613  // objectRegistry::is_cacheTemporaryObject().
615  (
616  const word& name,
617  const Mesh& mesh,
618  const dimensioned<Type>& dt,
619  const wordList& patchFieldTypes,
620  const wordList& actualPatchTypes = wordList()
621  );
622 
623  //- Return renamed tmp field (NO_READ, NO_WRITE)
624  //- [Takes current timeName from the mesh registry].
625  // Registration/persistence determined by
626  // objectRegistry::is_cacheTemporaryObject().
628  (
629  const word& newName,
631  );
632 
633  //- Return renamed tmp field (NO_READ, NO_WRITE)
634  //- with reset patch field type.
635  //- [Takes current timeName from the mesh registry].
636  // Registration/persistence determined by
637  // objectRegistry::is_cacheTemporaryObject().
639  (
640  const word& newName,
642  const word& patchFieldType
643  );
644 
645  //- Return renamed tmp field (NO_READ, NO_WRITE)
646  //- with reset patch field types.
647  //- [Takes instance from the field].
648  // Registration/persistence determined by
649  // objectRegistry::is_cacheTemporaryObject().
651  (
652  const word& newName,
654  const wordList& patchFieldTypes,
655  const wordList& actualPatchTypes = wordList()
656  );
657 
658  //- Construct tmp field (NO_READ, NO_WRITE)
659  //- based on mesh/registry information from an existing field.
660  //- [Takes instance from the field].
661  // Registration/persistence determined by
662  // objectRegistry::is_cacheTemporaryObject().
663  template<class AnyType>
665  (
667  const word& name,
668  const dimensionSet& dims,
669  const word& patchFieldType = PatchField<Type>::calculatedType()
670  );
671 
672  //- Construct tmp field (NO_READ, NO_WRITE)
673  //- based on mesh/registry information from an existing field.
674  //- and initialise with value.
675  //- [Takes instance from the field].
676  // Registration/persistence determined by
677  // objectRegistry::is_cacheTemporaryObject().
678  template<class AnyType>
680  (
682  const word& name,
683  const dimensioned<Type>& dt,
684  const word& patchFieldType = PatchField<Type>::calculatedType()
685  );
686 
687 
688  //- Destructor
689  virtual ~GeometricField();
690 
691 
692  // Member Functions
693 
694  //- Return a const-reference to the dimensioned internal field.
695  inline const Internal& internalField() const noexcept;
696 
697  //- Return a reference to the dimensioned internal field.
698  // \param updateAccessTime update event counter and check
699  // old-time fields
700  //
701  // \note Should avoid using updateAccessTime = true within loops.
702  Internal& internalFieldRef(const bool updateAccessTime = true);
703 
704  //- Same as internalFieldRef()
705  Internal& ref(const bool updateAccessTime = true)
706  {
707  return this->internalFieldRef(updateAccessTime);
708  }
709 
710  //- Return a const-reference to the dimensioned internal field
711  //- of a "vol" field.
712  // Useful in the formulation of source-terms for FV equations
713  //
714  // \note definition in finiteVolume/fields/volFields/volFieldsI.H
715  inline const Internal& v() const;
716 
717  //- Return a const-reference to the internal field values.
718  inline const typename Internal::FieldType& primitiveField()
719  const noexcept;
720 
721  //- Return a reference to the internal field values.
722  // \param updateAccessTime update event counter and check
723  // old-time fields
724  //
725  // \note Should avoid using updateAccessTime = true within loops.
727  (
728  const bool updateAccessTime = true
729  );
730 
731  //- Return const-reference to the boundary field
732  inline const Boundary& boundaryField() const noexcept;
733 
734  //- Return a reference to the boundary field
735  // \param updateAccessTime update event counter and check
736  // old-time fields
737  //
738  // \note Should avoid using updateAccessTime = true within loops.
739  Boundary& boundaryFieldRef(const bool updateAccessTime = true);
740 
741  //- Return the time index of the field
742  inline label timeIndex() const noexcept;
743 
744  //- Write-access to the time index of the field
745  inline label& timeIndex() noexcept;
746 
747  //- The number of old time fields stored
748  label nOldTimes() const noexcept;
749 
750  //- Store the old-time fields
751  void storeOldTimes() const;
752 
753  //- Store the old-time field
754  void storeOldTime() const;
755 
756  //- Return old time field
757  const GeometricField<Type, PatchField, GeoMesh>& oldTime() const;
758 
759  //- Return non-const old time field
760  // (Not a good idea but it is used for sub-cycling)
761  GeometricField<Type, PatchField, GeoMesh>& oldTime();
762 
763  //- Store the field as the previous iteration value
764  void storePrevIter() const;
765 
766  //- Return previous iteration field
767  const GeometricField<Type, PatchField, GeoMesh>& prevIter() const;
768 
769  //- Remove old-time and prev-iter fields
770  void clearOldTimes();
771 
772  //- Correct boundary field
774 
775  //- Correct boundary conditions after a purely local operation. Is
776  // dummy for e.g. processor boundary conditions
778 
779  //- Does the field need a reference level for solution
780  bool needReference() const;
781 
782  //- Return a component of the field
784  (
785  const direction
786  ) const;
787 
788  //- Return transpose (only if it is a tensor field)
789  tmp<GeometricField<Type, PatchField, GeoMesh>> T() const;
790 
791  //- Relax field (for steady-state solution).
792  // alpha = 1 : no relaxation
793  // alpha < 1 : relaxation
794  // alpha = 0 : do nothing
795  void relax(const scalar alpha);
796 
797  //- Relax field (for steady-state solution).
798  // alpha is read from controlDict
799  void relax();
800 
801  //- Select the final iteration parameters if \c final is true
802  //- by returning the field name + "Final"
803  //- otherwise the standard parameters by returning the field name
804  word select(bool final) const;
805 
806  //- Helper function to write the min and max to an Ostream
807  void writeMinMax(Ostream& os) const;
808 
809 
810  // Member Function *this Operators
811 
812  //- Negate the field inplace. See notes in Field
813  void negate();
814 
815  //- Normalise the field inplace. See notes in Field
816  void normalise();
817 
818  //- Replace specified field component with content from another field
819  void replace
820  (
821  const direction d,
822  const GeometricField<cmptType, PatchField, GeoMesh>& gcf
823  );
824 
825  //- Replace specified field component with specified value
826  void replace
827  (
828  const direction d,
829  const dimensioned<cmptType>& ds
830  );
831 
832  //- Impose lower (floor) clamp on the field values (in-place)
833  void clamp_min(const Type& lower);
834 
835  //- Impose upper (ceiling) clamp on the field values (in-place)
836  void clamp_max(const Type& upper);
837 
838  //- Impose lower (floor) clamp on the field values (in-place)
839  // No dimension checking
840  void clamp_min(const dimensioned<Type>& lower);
841 
842  //- Impose upper (ceiling) clamp on the field values (in-place)
843  // No dimension checking
844  void clamp_max(const dimensioned<Type>& upper);
845 
846  //- Clamp field values (in-place) to the specified range.
847  // Does not check if range is valid or not. No dimension checking.
848  void clamp_range(const dimensioned<MinMax<Type>>& range);
849 
850  //- Clamp field values (in-place) to the specified range.
851  // Does not check if range is valid or not.
852  void clamp_range(const Type& lower, const Type& upper);
853 
854  //- Clamp field values (in-place) to the specified range.
855  // Does not check if range is valid or not.
856  void clamp_range(const MinMax<Type>& range);
857 
858  //- Clamp field values (in-place) to the specified range.
859  // Does not check if range is valid or not. No dimension checking.
860  void clamp_range
861  (
862  const dimensioned<Type>& lower,
863  const dimensioned<Type>& upper
864  );
865 
867  // Member Operators
868 
869  //- Return a const-reference to the dimensioned internal field.
870  //- Same as internalField().
871  // Useful in the formulation of source-terms for FV equations
872  const Internal& operator()() const { return *this; }
873 
876  void operator=(const dimensioned<Type>&);
877 
879  void operator==(const dimensioned<Type>&);
880 
883 
886 
889 
892 
893  void operator+=(const dimensioned<Type>&);
894  void operator-=(const dimensioned<Type>&);
895 
896  void operator*=(const dimensioned<scalar>&);
897  void operator/=(const dimensioned<scalar>&);
898 
899  // Prevent automatic comparison rewriting (c++20)
900  bool operator!=
901  (
903  ) = delete;
904  bool operator!=
905  (
907  ) = delete;
908  bool operator!=(const dimensioned<Type>&) = delete;
909 
910 
911  // Write
912 
913  //- The writeData function (required by regIOobject),
914  //- calls operator<<
915  bool writeData(Ostream& os) const;
916 
917 
918  // Ostream Operators
919 
920  friend Ostream& operator<< <Type, PatchField, GeoMesh>
921  (
922  Ostream&,
924  );
925 
926  friend Ostream& operator<< <Type, PatchField, GeoMesh>
927  (
928  Ostream&,
930  );
931 
932 
933  // Housekeeping
934 
935  //- Clamp field values (in-place) to the specified range.
936  // \deprecated(2023-01) prefer clamp_range() naming
937  void clip(const dimensioned<MinMax<Type>>& range)
938  {
939  this->clamp_range(range);
940  }
941 
942  //- Clamp field values (in-place) to the specified range.
943  // \deprecated(2023-01) prefer clamp_range() naming
944  void clip(const dimensioned<Type>& lo, const dimensioned<Type>& hi)
945  {
946  this->clamp_range(lo.value(), hi.value());
947  }
948 
949  //- Use minimum of the field and specified value. ie, clamp_max().
950  // This sets the \em ceiling on the field values
951  // \deprecated(2023-01) prefer clamp_max()
952  void min(const dimensioned<Type>& upper) { this->clamp_max(upper); }
953 
954  //- Use maximum of the field and specified value. ie, clamp_min().
955  // This sets the \em floor on the field values
956  // \deprecated(2023-01) prefer clamp_min()
957  void max(const dimensioned<Type>& lower) { this->clamp_min(lower); }
958 
959  //- Deprecated(2019-01) identical to clamp_range()
960  // \deprecated(2019-01) identical to clamp_range()
961  FOAM_DEPRECATED_FOR(2019-01, "clamp_range() method")
962  void maxMin(const dimensioned<Type>& lo, const dimensioned<Type>& hi)
963  {
964  return this->clamp_range(lo.value(), hi.value());
965  }
966 };
967 
968 
969 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
970 
971 } // End namespace Foam
972 
973 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
974 
975 #include "GeometricFieldI.H"
976 
977 #ifdef NoRepository
978  #include "GeometricField.C"
979 #endif
980 
981 #include "GeometricFieldFunctions.H"
982 
983 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
984 
985 #endif
986 
987 // ************************************************************************* //
void clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place)
const labelList patchIDs(pbm.indices(polyPatchNames, true))
void clamp_range(const dimensioned< MinMax< Type >> &range)
Clamp field values (in-place) to the specified range.
dictionary dict
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
uint8_t direction
Definition: direction.H:46
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
GeoMesh::BoundaryMesh BoundaryMesh
The boundary mesh type for the boundary fields.
void operator=(const GeometricField< Type, PatchField, GeoMesh > &)
void maxMin(const dimensioned< Type > &lo, const dimensioned< Type > &hi)
Deprecated(2019-01) identical to clamp_range()
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void clearOldTimes()
Remove old-time and prev-iter fields.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
Field< Type >::cmptType cmptType
Component type of the field elements.
MESH::BoundaryMesh BoundaryMesh
Definition: GeoMesh.H:59
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
pTraits< Type >::cmptType cmptType
Component type.
Definition: Field.H:123
A min/max value pair with additional methods. In addition to conveniently storing values...
Definition: HashSet.H:72
GeometricField(const IOobject &io, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=PatchField< Type >::calculatedType())
Construct given IOobject, mesh, dimensions and patch type.
void operator/=(const GeometricField< scalar, PatchField, GeoMesh > &)
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
label nOldTimes() const noexcept
The number of old time fields stored.
GeoMesh::Mesh Mesh
The mesh type for the GeometricField.
void clip(const dimensioned< MinMax< Type >> &range)
Clamp field values (in-place) to the specified range.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Definition: stringOps.C:1187
TypeName("GeometricField")
Runtime type information.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
Type of boundary fields.
Generic dimensioned Type class.
DimensionedField< Type, GeoMesh > Internal
The internal field type from which this GeometricField is derived.
Field< Type > FieldType
Type of the field from which this DimensionedField is derived.
bool writeData(Ostream &os) const
The writeData function (required by regIOobject), calls operator<<.
word select(bool final) const
Select the final iteration parameters if final is true by returning the field name + "Final" otherwis...
scalar range
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:65
const word calculatedType
A calculated patch field type.
bool needReference() const
Does the field need a reference level for solution.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
const Internal & v() const
Return a const-reference to the dimensioned internal field of a "vol" field.
Definition: volFieldsI.H:26
void storeOldTimes() const
Store the old-time fields.
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool operator!=(const GeometricField< Type, PatchField, GeoMesh > &)=delete
void storeOldTime() const
Store the old-time field.
void operator*=(const GeometricField< scalar, PatchField, GeoMesh > &)
void operator+=(const GeometricField< Type, PatchField, GeoMesh > &)
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
void min(const dimensioned< Type > &upper)
Use minimum of the field and specified value. ie, clamp_max().
GeoMesh::Mesh Mesh
The mesh type for the DimensionedField.
void negate()
Negate the field inplace. See notes in Field.
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...
const Mesh & mesh() const noexcept
Return mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
Internal & internalFieldRef(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
void operator-=(const GeometricField< Type, PatchField, GeoMesh > &)
void normalise()
Normalise the field inplace. See notes in Field.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
OBJstream os(runTime.globalPath()/outputName)
MESH Mesh
Definition: GeoMesh.H:58
virtual ~GeometricField()
Destructor.
Generic GeometricBoundaryField class.
Definition: areaFieldsFwd.H:46
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))
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
void clamp_max(const Type &upper)
Impose upper (ceiling) clamp on the field values (in-place)
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
List< word > wordList
List of word.
Definition: fileName.H:59
void operator==(const tmp< GeometricField< Type, PatchField, GeoMesh >> &)
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
label timeIndex() const noexcept
Return the time index of the field.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
Definition: stringOps.C:1171
PatchField< Type > Patch
The patch field type for the GeometricBoundaryField.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
void max(const dimensioned< Type > &lower)
Use maximum of the field and specified value. ie, clamp_min().
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
friend Ostream & operator(Ostream &, const GeometricField< Type, PatchField, GeoMesh > &)
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
void storePrevIter() const
Store the field as the previous iteration value.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
void relax()
Relax field (for steady-state solution).
void correctLocalBoundaryConditions()
Correct boundary conditions after a purely local operation. Is.
Namespace for OpenFOAM.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.