GeometricField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "GeometricField.H"
27 #include "Time.H"
28 #include "demandDrivenData.H"
29 #include "dictionary.H"
30 #include "localIOdictionary.H"
31 #include "solutionControl.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 #define checkFieldAssignment(gf1, gf2) \
36  \
37  if \
38  ( \
39  static_cast<const regIOobject*>(&gf1) \
40  == static_cast<const regIOobject*>(&gf2) \
41  ) \
42  { \
43  FatalErrorInFunction \
44  << "attempted assignment to self for field " \
45  << (gf1).name() << abort(FatalError); \
46  }
47 
48 
49 #define checkFieldOperation(gf1, gf2, op) \
50  \
51  if ((gf1).mesh() != (gf2).mesh()) \
52  { \
53  FatalErrorInFunction \
54  << "different mesh for fields " \
55  << (gf1).name() << " and " << (gf2).name() \
56  << " during operation " << op \
57  << abort(FatalError); \
58  }
59 
60 
61 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
62 
63 template<class Type, class GeoMesh, template<class> class PrimitiveField>
65 (
66  const dictionary& dict
67 )
68 {
69  printDictionary print(dict);
70 
71  Internal::readField(dict, "internalField");
72 
73  boundaryField_.readField(*this, dict.subDict("boundaryField"));
74 
75  // Don't use subOrEmptyDict here, or line numbers will be lost from any IO
76  // error messages. Use an actual sub-dict reference here if possible.
77  if (dict.found("sources"))
78  {
79  sources_.readField(*this, dict.subDict("sources"));
80  }
81  else
82  {
83  sources_.readField(*this, dictionary("sources", dict));
84  }
85 
86  if (dict.found("referenceLevel"))
87  {
88  Type fieldAverage(pTraits<Type>(dict.lookup("referenceLevel")));
89 
90  Field<Type>::operator+=(fieldAverage);
91 
92  forAll(boundaryField_, patchi)
93  {
94  boundaryField_[patchi] == boundaryField_[patchi] + fieldAverage;
95  }
96  }
97 }
98 
99 
100 template<class Type, class GeoMesh, template<class> class PrimitiveField>
102 {
103  const localIOdictionary dict
104  (
105  IOobject
106  (
107  this->name(),
108  this->instance(),
109  this->local(),
110  this->db(),
111  IOobject::MUST_READ,
112  IOobject::NO_WRITE,
113  false
114  ),
115  typeName
116  );
117 
118  this->close();
119 
120  readFields(dict);
121 }
122 
123 
124 template<class Type, class GeoMesh, template<class> class PrimitiveField>
126 {
127  if
128  (
129  this->readOpt() == IOobject::MUST_READ
130  || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
131  || (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
132  )
133  {
134  readFields();
135 
136  // Check compatibility between field and mesh
137  if (this->size() != this->mesh().size())
138  {
139  FatalIOErrorInFunction(this->readStream(typeName))
140  << " number of field elements = " << this->size()
141  << " number of mesh elements = "
142  << this->mesh().size()
143  << exit(FatalIOError);
144  }
145 
146  readOldTimeIfPresent();
147 
148  return true;
149  }
150 
151  return false;
152 }
153 
154 
155 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
156 
157 template<class Type, class GeoMesh, template<class> class PrimitiveField>
159 (
160  const IOobject& io,
161  const GeoMesh& mesh,
162  const dimensionSet& ds,
163  const word& patchFieldType
164 )
165 :
166  Internal(io, mesh, ds, false),
168  fieldPrevIterPtr_(nullptr),
169  boundaryField_(mesh.boundary(), *this, patchFieldType),
170  sources_()
171 {
172  if (debug)
173  {
175  << "Constructing field" << endl << this->info() << endl;
176  }
177 
178  readIfPresent();
179 }
180 
181 
182 template<class Type, class GeoMesh, template<class> class PrimitiveField>
184 (
185  const IOobject& io,
186  const GeoMesh& mesh,
187  const dimensionSet& ds,
188  const wordList& patchFieldTypes,
189  const wordList& actualPatchTypes,
190  const HashTable<word>& fieldSourceTypes,
191  const IOerrorLocation& fieldSourceErrorLocation
192 )
193 :
194  Internal(io, mesh, ds, false),
196  fieldPrevIterPtr_(nullptr),
197  boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes),
198  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
199 {
200  if (debug)
201  {
203  << "Constructing field" << endl << this->info() << endl;
204  }
205 
206  readIfPresent();
207 }
208 
209 
210 template<class Type, class GeoMesh, template<class> class PrimitiveField>
212 (
213  const IOobject& io,
214  const GeoMesh& mesh,
215  const dimensioned<Type>& dt,
217 )
218 :
219  Internal(io, mesh, dt, false),
221  fieldPrevIterPtr_(nullptr),
222  boundaryField_(mesh.boundary(), *this, patchFieldType),
223  sources_()
224 {
225  if (debug)
226  {
228  << "Constructing field" << endl << this->info() << endl;
229  }
230 
231  boundaryField_ == dt.value();
232 
233  readIfPresent();
234 }
235 
236 
237 template<class Type, class GeoMesh, template<class> class PrimitiveField>
239 (
240  const IOobject& io,
241  const GeoMesh& mesh,
242  const dimensioned<Type>& dt,
243  const wordList& patchFieldTypes,
244  const wordList& actualPatchTypes,
245  const HashTable<word>& fieldSourceTypes,
246  const IOerrorLocation& fieldSourceErrorLocation
247 )
248 :
249  Internal(io, mesh, dt, false),
251  fieldPrevIterPtr_(nullptr),
252  boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes),
253  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
254 {
255  if (debug)
256  {
258  << "Constructing field" << endl << this->info() << endl;
259  }
260 
261  boundaryField_ == dt.value();
262 
263  readIfPresent();
264 }
265 
266 
267 template<class Type, class GeoMesh, template<class> class PrimitiveField>
269 (
270  const IOobject& io,
271  const Internal& diField,
272  const PtrList<Patch>& ptfl,
273  const HashPtrTable<Source>& stft
274 )
275 :
276  Internal(io, diField, false),
278  fieldPrevIterPtr_(nullptr),
279  boundaryField_(this->mesh().boundary(), *this, ptfl),
280  sources_(*this, stft)
281 {
282  if (debug)
283  {
285  << "Constructing field from components" << endl
286  << this->info() << endl;
287  }
288 
289  readIfPresent();
290 }
291 
292 
293 template<class Type, class GeoMesh, template<class> class PrimitiveField>
295 (
296  const IOobject& io,
297  const GeoMesh& mesh,
298  const dimensionSet& ds,
299  const PrimitiveField<Type>& iField,
300  const PtrList<Patch>& ptfl,
301  const HashPtrTable<Source>& stft
302 )
303 :
304  Internal(io, mesh, ds, iField),
306  fieldPrevIterPtr_(nullptr),
307  boundaryField_(mesh.boundary(), *this, ptfl),
308  sources_(*this, stft)
309 {
310  if (debug)
311  {
313  << "Constructing field from components" << endl
314  << this->info() << endl;
315  }
316 }
317 
318 
319 template<class Type, class GeoMesh, template<class> class PrimitiveField>
321 (
322  const IOobject& io,
323  const GeoMesh& mesh,
324  const dimensionSet& dims
325 )
326 :
327  Internal(io, mesh, dims, false),
329  fieldPrevIterPtr_(nullptr),
330  boundaryField_(mesh.boundary()),
331  sources_()
332 {
333  readFields();
334 
335  // Check compatibility between field and mesh
336 
337  if (this->size() != this->mesh().size())
338  {
339  FatalIOErrorInFunction(this->readStream(typeName))
340  << " number of field elements = " << this->size()
341  << " number of mesh elements = " << this->mesh().size()
342  << exit(FatalIOError);
343  }
344 
345  readOldTimeIfPresent();
346 
347  if (debug)
348  {
350  << "Finishing read-construction of" << endl << this->info() << endl;
351  }
352 }
353 
354 
355 template<class Type, class GeoMesh, template<class> class PrimitiveField>
357 (
358  const IOobject& io,
359  const GeoMesh& mesh,
360  const dictionary& dict,
361  const dimensionSet& dims
362 )
363 :
364  Internal(io, mesh, dims, false),
366  fieldPrevIterPtr_(nullptr),
367  boundaryField_(mesh.boundary()),
368  sources_()
369 {
370  readFields(dict);
371 
372  // Check compatibility between field and mesh
373 
374  if (this->size() != this->mesh().size())
375  {
377  << " number of field elements = " << this->size()
378  << " number of mesh elements = " << this->mesh().size()
380  }
381 
382  if (debug)
383  {
385  << "Finishing dictionary-construct of "
386  << endl << this->info() << endl;
387  }
388 }
389 
390 
391 template<class Type, class GeoMesh, template<class> class PrimitiveField>
393 (
395 )
396 :
397  Internal(gf),
399  fieldPrevIterPtr_(nullptr),
400  boundaryField_(*this, gf.boundaryField_),
401  sources_(*this, gf.sources_)
402 {
403  if (debug)
404  {
406  << "Constructing field as copy" << endl << this->info() << endl;
407  }
408 
409  this->writeOpt() = IOobject::NO_WRITE;
410 }
411 
412 
413 template<class Type, class GeoMesh, template<class> class PrimitiveField>
414 template<template<class> class PrimitiveField2>
416 (
418 )
419 :
420  Internal(gf),
422  fieldPrevIterPtr_(nullptr),
423  boundaryField_(*this, gf.boundaryField_),
424  sources_(*this, gf.sources_)
425 {
426  if (debug)
427  {
429  << "Constructing field as copy" << endl << this->info() << endl;
430  }
431 
432  this->writeOpt() = IOobject::NO_WRITE;
433 }
434 
435 
436 template<class Type, class GeoMesh, template<class> class PrimitiveField>
438 (
440 )
441 :
442  Internal(move(gf)),
443  OldTimeField<GeometricField>(move(gf)),
444  fieldPrevIterPtr_(nullptr),
445  boundaryField_(*this, gf.boundaryField_),
446  sources_(*this, gf.sources_)
447 {
448  if (debug)
449  {
451  << "Constructing field by moving" << endl << this->info() << endl;
452  }
453 
454  this->writeOpt() = IOobject::NO_WRITE;
455 }
456 
457 
458 template<class Type, class GeoMesh, template<class> class PrimitiveField>
460 (
462 )
463 :
464  Internal
465  (
467  tgf.isTmp()
468  ),
470  fieldPrevIterPtr_(nullptr),
471  boundaryField_(*this, tgf().boundaryField_),
472  sources_(*this, tgf().sources_)
473 {
474  if (debug)
475  {
477  << "Constructing field from tmp" << endl << this->info() << endl;
478  }
479 
480  this->writeOpt() = IOobject::NO_WRITE;
481 
482  tgf.clear();
483 }
484 
485 
486 template<class Type, class GeoMesh, template<class> class PrimitiveField>
487 template<template<class> class PrimitiveField2>
489 (
490  const IOobject& io,
492 )
493 :
494  Internal(io, gf, false),
496  fieldPrevIterPtr_(nullptr),
497  boundaryField_(*this, gf.boundaryField_),
498  sources_(*this, gf.sources_)
499 {
500  if (debug)
501  {
503  << "Constructing field as copy resetting IO params"
504  << endl << this->info() << endl;
505  }
506 
507  if (!readIfPresent())
508  {
509  copyOldTimes(io, gf);
510  }
511 }
512 
513 
514 template<class Type, class GeoMesh, template<class> class PrimitiveField>
516 (
517  const IOobject& io,
519 )
520 :
521  Internal
522  (
523  io,
524  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
525  tgf.isTmp(),
526  false
527  ),
529  fieldPrevIterPtr_(nullptr),
530  boundaryField_(*this, tgf().boundaryField_),
531  sources_(*this, tgf().sources_)
532 {
533  if (debug)
534  {
536  << "Constructing field from tmp resetting IO params"
537  << endl << this->info() << endl;
538  }
539 
540  tgf.clear();
541 
542  readIfPresent();
543 }
544 
545 
546 template<class Type, class GeoMesh, template<class> class PrimitiveField>
547 template<template<class> class PrimitiveField2>
549 (
550  const word& newName,
552 )
553 :
554  Internal(newName, gf),
556  fieldPrevIterPtr_(nullptr),
557  boundaryField_(*this, gf.boundaryField_),
558  sources_(*this, gf.sources_)
559 {
560  if (debug)
561  {
563  << "Constructing field as copy resetting name"
564  << endl << this->info() << endl;
565  }
566 
567  copyOldTimes(newName, gf);
568 }
569 
570 
571 template<class Type, class GeoMesh, template<class> class PrimitiveField>
573 (
574  const word& newName,
576 )
577 :
578  Internal
579  (
580  newName,
581  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
582  tgf.isTmp()
583  ),
585  fieldPrevIterPtr_(nullptr),
586  boundaryField_(*this, tgf().boundaryField_),
587  sources_(*this, tgf().sources_)
588 {
589  if (debug)
590  {
592  << "Constructing field from tmp resetting name"
593  << endl << this->info() << endl;
594  }
595 
596  tgf.clear();
597 }
598 
599 
600 template<class Type, class GeoMesh, template<class> class PrimitiveField>
601 template<template<class> class PrimitiveField2>
603 (
604  const IOobject& io,
606  const word& patchFieldType
607 )
608 :
609  Internal(io, gf, false),
611  fieldPrevIterPtr_(nullptr),
612  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
613  sources_(*this, gf.sources_)
614 {
615  if (debug)
616  {
618  << "Constructing field as copy resetting IO params"
619  << endl << this->info() << endl;
620  }
621 
622  boundaryField_ == gf.boundaryField_;
623 
624  if (!readIfPresent())
625  {
626  copyOldTimes(io, gf);
627  }
628 }
629 
630 
631 template<class Type, class GeoMesh, template<class> class PrimitiveField>
633 (
634  const IOobject& io,
636  const word& patchFieldType
637 )
638 :
639  Internal
640  (
641  io,
643  tgf.isTmp(),
644  false
645  ),
647  fieldPrevIterPtr_(nullptr),
648  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
649  sources_(*this, tgf().sources_)
650 {
651  if (debug)
652  {
654  << "Constructing field as copy resetting IO params"
655  << endl << this->info() << endl;
656  }
657 
658  boundaryField_ == tgf().boundaryField_;
659 
660  tgf.clear();
661 
662  readIfPresent();
663 }
664 
665 
666 template<class Type, class GeoMesh, template<class> class PrimitiveField>
667 template<template<class> class PrimitiveField2>
669 (
670  const IOobject& io,
672  const word& patchFieldType
673 )
674 :
675  Internal(io, df, false),
677  fieldPrevIterPtr_(nullptr),
678  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
679  sources_()
680 {
681  if (debug)
682  {
684  << "Constructing field from components" << endl
685  << this->info() << endl;
686  }
687 
688  if (!readIfPresent())
689  {
690  boundaryField_.evaluate();
691  }
692 }
693 
694 
695 template<class Type, class GeoMesh, template<class> class PrimitiveField>
697 (
698  const IOobject& io,
699  const tmp<Internal>& tdf,
700  const word& patchFieldType
701 )
702 :
703  Internal(io, const_cast<Internal&>(tdf()), tdf.isTmp(), false),
705  fieldPrevIterPtr_(nullptr),
706  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
707  sources_()
708 {
709  if (debug)
710  {
712  << "Constructing field from components" << endl
713  << this->info() << endl;
714  }
715 
716  if (!readIfPresent())
717  {
718  boundaryField_.evaluate();
719  }
720 }
721 
722 
723 template<class Type, class GeoMesh, template<class> class PrimitiveField>
724 template<template<class> class PrimitiveField2>
726 (
727  const IOobject& io,
729  const wordList& patchFieldTypes,
730  const wordList& actualPatchTypes,
731  const HashTable<word>& fieldSourceTypes,
732  const IOerrorLocation& fieldSourceErrorLocation
733 )
734 :
735  Internal(io, gf, false),
737  fieldPrevIterPtr_(nullptr),
738  boundaryField_
739  (
740  this->mesh().boundary(),
741  *this,
742  patchFieldTypes,
743  actualPatchTypes
744  ),
745  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
746 {
747  if (debug)
748  {
750  << "Constructing field as copy resetting IO params and patch types"
751  << endl << this->info() << endl;
752  }
753 
754  boundaryField_ == gf.boundaryField_;
755 
756  if (!readIfPresent())
757  {
758  copyOldTimes(io, gf);
759  }
760 }
761 
762 
763 template<class Type, class GeoMesh, template<class> class PrimitiveField>
765 (
766  const IOobject& io,
768  const wordList& patchFieldTypes,
769  const wordList& actualPatchTypes,
770  const HashTable<word>& fieldSourceTypes,
771  const IOerrorLocation& fieldSourceErrorLocation
772 )
773 :
774  Internal
775  (
776  io,
777  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
778  tgf.isTmp(),
779  false
780  ),
782  fieldPrevIterPtr_(nullptr),
783  boundaryField_
784  (
785  this->mesh().boundary(),
786  *this,
787  patchFieldTypes,
788  actualPatchTypes
789  ),
790  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
791 {
792  if (debug)
793  {
795  << "Constructing field from tmp resetting IO params and patch types"
796  << endl << this->info() << endl;
797  }
798 
799  boundaryField_ == tgf().boundaryField_;
800 
801  tgf.clear();
802 
803  readIfPresent();
804 }
805 
806 
807 template<class Type, class GeoMesh, template<class> class PrimitiveField>
808 template<template<class> class PrimitiveField2>
810 (
811  const IOobject& io,
813  const wordList& patchFieldTypes,
814  const wordList& actualPatchTypes,
815  const HashTable<word>& fieldSourceTypes,
816  const IOerrorLocation& fieldSourceErrorLocation
817 )
818 :
819  Internal(io, df, false),
821  fieldPrevIterPtr_(nullptr),
822  boundaryField_
823  (
824  this->mesh().boundary(),
825  *this,
826  patchFieldTypes,
827  actualPatchTypes
828  ),
829  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
830 {
831  if (debug)
832  {
834  << "Constructing field from internal field and patch types"
835  << endl << this->info() << endl;
836  }
837 
838  readIfPresent();
839 }
840 
841 
842 template<class Type, class GeoMesh, template<class> class PrimitiveField>
844 (
845  const IOobject& io,
846  const tmp<Internal>& tdf,
847  const wordList& patchFieldTypes,
848  const wordList& actualPatchTypes,
849  const HashTable<word>& fieldSourceTypes,
850  const IOerrorLocation& fieldSourceErrorLocation
851 )
852 :
853  Internal(io, const_cast<Internal&>(tdf()), tdf.isTmp(), false),
855  fieldPrevIterPtr_(nullptr),
856  boundaryField_
857  (
858  this->mesh().boundary(),
859  *this,
860  patchFieldTypes,
861  actualPatchTypes
862  ),
863  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
864 {
865  if (debug)
866  {
868  << "Constructing field from tmp internal field and patch types"
869  << endl << this->info() << endl;
870  }
871 
872  tdf.clear();
873 
874  readIfPresent();
875 }
876 
877 
878 template<class Type, class GeoMesh, template<class> class PrimitiveField>
881 {
883  (
885  );
886 }
887 
888 
889 template<class Type, class GeoMesh, template<class> class PrimitiveField>
892 {
894  (
896  (
897  IOobject
898  (
899  this->name(),
900  this->mesh().db().time().name(),
901  this->mesh().db(),
904  false
905  ),
906  *this,
907  Patch::calculatedType()
908  )
909  );
910 }
911 
912 
913 template<class Type, class GeoMesh, template<class> class PrimitiveField>
916 (
917  const word& name,
918  const Internal& diField,
919  const PtrList<Patch>& ptfl,
920  const HashPtrTable<Source>& stft
921 )
922 {
923  const bool cacheTmp = diField.mesh().db().temporaryObjectCached(name);
924 
926  (
928  (
929  IOobject
930  (
931  name,
932  diField.mesh().db().time().name(),
933  diField.mesh().db(),
936  cacheTmp
937  ),
938  diField,
939  ptfl,
940  stft
941  ),
942  cacheTmp
943  );
944 }
945 
946 
947 template<class Type, class GeoMesh, template<class> class PrimitiveField>
950 (
951  const word& name,
952  const GeoMesh& mesh,
953  const dimensionSet& ds,
954  const word& patchFieldType
955 )
956 {
957  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
958 
960  (
962  (
963  IOobject
964  (
965  name,
966  mesh.db().time().name(),
967  mesh.db(),
970  cacheTmp
971  ),
972  mesh,
973  ds,
975  ),
976  cacheTmp
977  );
978 }
979 
980 
981 template<class Type, class GeoMesh, template<class> class PrimitiveField>
984 (
985  const word& name,
986  const GeoMesh& mesh,
987  const dimensioned<Type>& dt,
988  const word& patchFieldType
989 )
990 {
991  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
992 
994  (
996  (
997  IOobject
998  (
999  name,
1000  mesh.db().time().name(),
1001  mesh.db(),
1004  cacheTmp
1005  ),
1006  mesh,
1007  dt,
1009  ),
1010  cacheTmp
1011  );
1012 }
1013 
1014 
1015 
1016 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1019 (
1020  const word& name,
1021  const GeoMesh& mesh,
1022  const dimensioned<Type>& dt,
1023  const wordList& patchFieldTypes,
1024  const wordList& actualPatchTypes,
1025  const HashTable<word>& fieldSourceTypes,
1026  const IOerrorLocation& fieldSourceErrorLocation
1027 )
1028 {
1029  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
1030 
1032  (
1034  (
1035  IOobject
1036  (
1037  name,
1038  mesh.db().time().name(),
1039  mesh.db(),
1042  cacheTmp
1043  ),
1044  mesh,
1045  dt,
1046  patchFieldTypes,
1047  actualPatchTypes,
1048  fieldSourceTypes,
1049  fieldSourceErrorLocation
1050  ),
1051  cacheTmp
1052  );
1053 }
1054 
1055 
1056 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1059 (
1060  const word& newName,
1062 )
1063 {
1064  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1065 
1067  (
1069  (
1070  IOobject
1071  (
1072  newName,
1073  tgf().instance(),
1074  tgf().local(),
1075  tgf().db(),
1078  cacheTmp
1079  ),
1080  tgf
1081  ),
1082  cacheTmp
1083  );
1084 }
1085 
1086 
1087 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1088 template<template<class> class PrimitiveField2>
1091 (
1092  const word& newName,
1094  const word& patchFieldType
1095 )
1096 {
1097  const bool cacheTmp = gf.db().temporaryObjectCached(newName);
1098 
1100  (
1102  (
1103  IOobject
1104  (
1105  newName,
1106  gf.instance(),
1107  gf.local(),
1108  gf.db(),
1111  cacheTmp
1112  ),
1113  gf,
1115  ),
1116  cacheTmp
1117  );
1118 }
1119 
1120 
1121 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1124 (
1125  const word& newName,
1127  const word& patchFieldType
1128 )
1129 {
1130  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1131 
1133  (
1135  (
1136  IOobject
1137  (
1138  newName,
1139  tgf().instance(),
1140  tgf().local(),
1141  tgf().db(),
1144  cacheTmp
1145  ),
1146  tgf,
1148  ),
1149  cacheTmp
1150  );
1151 }
1152 
1153 
1154 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1155 template<template<class> class PrimitiveField2>
1158 (
1159  const word& newName,
1161  const word& patchFieldType
1162 )
1163 {
1164  const bool cacheTmp = df.db().temporaryObjectCached(newName);
1165 
1167  (
1169  (
1170  IOobject
1171  (
1172  newName,
1173  df.instance(),
1174  df.local(),
1175  df.db(),
1178  cacheTmp
1179  ),
1180  df,
1182  ),
1183  cacheTmp
1184  );
1185 }
1186 
1187 
1188 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1191 (
1192  const word& newName,
1193  const tmp<Internal>& tdf,
1194  const word& patchFieldType
1195 )
1196 {
1197  const bool cacheTmp = tdf().db().temporaryObjectCached(newName);
1198 
1200  (
1202  (
1203  IOobject
1204  (
1205  newName,
1206  tdf().instance(),
1207  tdf().local(),
1208  tdf().db(),
1211  cacheTmp
1212  ),
1213  tdf,
1215  ),
1216  cacheTmp
1217  );
1218 }
1219 
1220 
1221 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1222 template<template<class> class PrimitiveField2>
1225 (
1226  const word& newName,
1228  const wordList& patchFieldTypes,
1229  const wordList& actualPatchTypes,
1230  const HashTable<word>& fieldSourceTypes,
1231  const IOerrorLocation& fieldSourceErrorLocation
1232 )
1233 {
1234  const bool cacheTmp = gf.db().temporaryObjectCached(newName);
1235 
1237  (
1239  (
1240  IOobject
1241  (
1242  newName,
1243  gf.instance(),
1244  gf.local(),
1245  gf.db(),
1248  cacheTmp
1249  ),
1250  gf,
1251  patchFieldTypes,
1252  actualPatchTypes,
1253  fieldSourceTypes,
1254  fieldSourceErrorLocation
1255  ),
1256  cacheTmp
1257  );
1258 }
1259 
1260 
1261 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1264 (
1265  const word& newName,
1267  const wordList& patchFieldTypes,
1268  const wordList& actualPatchTypes,
1269  const HashTable<word>& fieldSourceTypes,
1270  const IOerrorLocation& fieldSourceErrorLocation
1271 )
1272 {
1273  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1274 
1276  (
1278  (
1279  IOobject
1280  (
1281  newName,
1282  tgf().instance(),
1283  tgf().local(),
1284  tgf().db(),
1287  cacheTmp
1288  ),
1289  tgf,
1290  patchFieldTypes,
1291  actualPatchTypes,
1292  fieldSourceTypes,
1293  fieldSourceErrorLocation
1294  ),
1295  cacheTmp
1296  );
1297 }
1298 
1299 
1300 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1301 template<template<class> class PrimitiveField2>
1304 (
1305  const word& newName,
1307  const wordList& patchFieldTypes,
1308  const wordList& actualPatchTypes,
1309  const HashTable<word>& fieldSourceTypes,
1310  const IOerrorLocation& fieldSourceErrorLocation
1311 )
1312 {
1313  const bool cacheTmp = df.db().temporaryObjectCached(newName);
1314 
1316  (
1318  (
1319  IOobject
1320  (
1321  newName,
1322  df.instance(),
1323  df.local(),
1324  df.db(),
1327  cacheTmp
1328  ),
1329  df,
1330  patchFieldTypes,
1331  actualPatchTypes,
1332  fieldSourceTypes,
1333  fieldSourceErrorLocation
1334  ),
1335  cacheTmp
1336  );
1337 }
1338 
1339 
1340 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1343 (
1344  const word& newName,
1345  const tmp<Internal>& tdf,
1346  const wordList& patchFieldTypes,
1347  const wordList& actualPatchTypes,
1348  const HashTable<word>& fieldSourceTypes,
1349  const IOerrorLocation& fieldSourceErrorLocation
1350 )
1351 {
1352  const bool cacheTmp = tdf().db().temporaryObjectCached(newName);
1353 
1355  (
1357  (
1358  IOobject
1359  (
1360  newName,
1361  tdf().instance(),
1362  tdf().local(),
1363  tdf().db(),
1366  cacheTmp
1367  ),
1368  tdf,
1369  patchFieldTypes,
1370  actualPatchTypes,
1371  fieldSourceTypes,
1372  fieldSourceErrorLocation
1373  ),
1374  cacheTmp
1375  );
1376 }
1377 
1378 
1379 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
1380 
1381 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1383 {
1384  this->db().cacheTemporaryObject(*this);
1385 
1386  clearPrevIter();
1387 }
1388 
1389 
1390 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1391 
1392 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1395 {
1396  this->setUpToDate();
1397  storeOldTimes();
1398  return *this;
1399 }
1400 
1401 
1402 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1403 typename
1406 {
1407  this->setUpToDate();
1408  storeOldTimes();
1409  return *this;
1410 }
1411 
1412 
1413 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1414 typename
1417 {
1418  this->setUpToDate();
1419  storeOldTimes();
1420  return boundaryField_;
1421 }
1422 
1423 
1424 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1425 typename
1429 {
1430  this->setUpToDate();
1431  return boundaryField_;
1432 }
1433 
1434 
1435 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1436 typename
1439 {
1440  this->setUpToDate();
1441  storeOldTimes();
1442  return sources_;
1443 }
1444 
1445 
1446 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1448 {
1449  if (!fieldPrevIterPtr_)
1450  {
1451  if (debug)
1452  {
1454  << "Allocating previous iteration field" << endl
1455  << this->info() << endl;
1456  }
1457 
1458  fieldPrevIterPtr_ =
1460  (
1461  this->name() + "PrevIter",
1462  *this
1463  );
1464  }
1465  else
1466  {
1467  *fieldPrevIterPtr_ == *this;
1468  }
1469 }
1470 
1471 
1472 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1474 {
1475  deleteDemandDrivenData(fieldPrevIterPtr_);
1476 }
1477 
1478 
1479 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1482 {
1483  if (!fieldPrevIterPtr_)
1484  {
1486  << "previous iteration field" << endl << this->info() << endl
1487  << " not stored."
1488  << " Use field.storePrevIter() at start of iteration."
1489  << abort(FatalError);
1490  }
1491 
1492  return *fieldPrevIterPtr_;
1493 }
1494 
1495 
1496 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1499 {
1500  this->setUpToDate();
1501  storeOldTimes();
1502  boundaryField_.evaluate();
1503 }
1504 
1505 
1506 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1507 template<template<class> class PrimitiveField2>
1509 (
1511 )
1512 {
1513  Internal::reset(gf);
1514 
1515  boundaryField_.reset(gf.boundaryField());
1516  sources_.reset(*this, gf.sources());
1517 }
1518 
1519 
1520 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1522 (
1524 )
1525 {
1527 
1528  checkFieldAssignment(*this, gf);
1529 
1530  this->dimensions() = gf.dimensions();
1531 
1532  if (tgf.isTmp())
1533  {
1534  PrimitiveField<Type>::transfer(tgf.ref());
1535  }
1536  else
1537  {
1538  PrimitiveField<Type>::operator=(gf.primitiveField());
1539  }
1540 
1541  boundaryField_.reset(gf.boundaryField());
1542  sources_.reset(*this, gf.sources());
1543 
1544  tgf.clear();
1545 }
1546 
1547 
1548 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1549 template<template<class> class PrimitiveField2>
1551 (
1553 )
1554 {
1555  reset(tgf());
1556 
1557  tgf.clear();
1558 }
1559 
1560 
1561 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1563 {
1564  // Search all boundary conditions, if any are
1565  // fixed-value or mixed (Robin) do not set reference level for solution.
1566 
1567  bool needRef = true;
1568 
1569  forAll(boundaryField_, patchi)
1570  {
1571  if (boundaryField_[patchi].fixesValue())
1572  {
1573  needRef = false;
1574  break;
1575  }
1576  }
1577 
1578  reduce(needRef, andOp<bool>());
1579 
1580  return needRef;
1581 }
1582 
1583 
1584 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1586 (
1587  const scalar alpha
1588 )
1589 {
1590  if (alpha < 1)
1591  {
1592  if (debug)
1593  {
1595  << "Relaxing" << endl << this->info()
1596  << " by " << alpha << endl;
1597  }
1598 
1599  operator==(prevIter() + alpha*(*this - prevIter()));
1600  }
1601 }
1602 
1603 
1604 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1605 Foam::scalar
1607 {
1608  if
1609  (
1611  && this->mesh().solution().relaxField(this->name() + "Final")
1612  )
1613  {
1614  return this->mesh().solution().fieldRelaxationFactor
1615  (
1616  this->name() + "Final"
1617  );
1618  }
1619  else if (this->mesh().solution().relaxField(this->name()))
1620  {
1621  return this->mesh().solution().fieldRelaxationFactor(this->name());
1622  }
1623  else
1624  {
1625  return 1;
1626  }
1627 }
1628 
1629 
1630 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1632 {
1633  relax(relaxationFactor());
1634 }
1635 
1636 
1637 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1638 template<template<class> class PrimitiveField2>
1640 (
1642  const scalar alpha
1643 )
1644 {
1645  if (alpha < 1)
1646  {
1647  if (debug)
1648  {
1650  << "Relaxing" << endl << this->info()
1651  << " by " << alpha << endl;
1652  }
1653 
1654  operator==(*this + alpha*(tgf - *this));
1655  }
1656  else
1657  {
1658  operator==(tgf);
1659  }
1660 }
1661 
1662 
1663 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1664 template<template<class> class PrimitiveField2>
1666 (
1668 )
1669 {
1670  relax(tgf, relaxationFactor());
1671 }
1672 
1673 
1674 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1676 (
1677  bool final
1678 ) const
1679 {
1680  if (final)
1681  {
1682  return this->name() + "Final";
1683  }
1684  else
1685  {
1686  return this->name();
1687  }
1688 }
1689 
1690 
1691 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1693 (
1694  Ostream& os
1695 ) const
1696 {
1697  os << "min/max(" << this->name() << ") = "
1698  << Foam::min(*this).value() << ", "
1699  << Foam::max(*this).value()
1700  << endl;
1701 }
1702 
1703 
1704 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1706 (
1707  Ostream& os
1708 ) const
1709 {
1710  os << *this;
1711  return os.good();
1712 }
1713 
1714 
1715 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1716 
1717 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1720 {
1722  (
1724  (
1725  this->name() + ".T()",
1726  this->mesh(),
1727  this->dimensions()
1728  )
1729  );
1730 
1731  Foam::T(result.ref().primitiveFieldRef(), primitiveField());
1732  Foam::T(result.ref().boundaryFieldRef(), boundaryField());
1733 
1734  return result;
1735 }
1736 
1737 
1738 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1739 Foam::tmp
1740 <
1742  <
1744  GeoMesh,
1745  Foam::Field
1746  >
1747 >
1749 (
1750  const direction d
1751 ) const
1752 {
1754  (
1756  (
1757  this->name() + ".component(" + Foam::name(d) + ')',
1758  this->mesh(),
1759  this->dimensions()
1760  )
1761  );
1762 
1763  Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
1764  Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
1765 
1766  return Component;
1767 }
1768 
1769 
1770 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1771 template<template<class> class PrimitiveField2>
1773 (
1774  const direction d,
1775  const GeometricField
1776  <
1778  GeoMesh,
1779  PrimitiveField2
1780  >& gcf
1781 )
1782 {
1783  primitiveFieldRef().replace(d, gcf.primitiveField());
1784  boundaryFieldRef().replace(d, gcf.boundaryField());
1785 }
1786 
1787 
1788 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1789 template<template<class> class PrimitiveField2>
1791 (
1792  const direction d,
1793  const tmp
1794  <
1796  <
1798  GeoMesh,
1799  PrimitiveField2
1800  >
1801  >& gcf
1802 )
1803 {
1804  replace(d, gcf());
1805  gcf.clear();
1806 }
1807 
1808 
1809 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1811 (
1812  const direction d,
1813  const dimensioned<cmptType>& ds
1814 )
1815 {
1816  primitiveFieldRef().replace(d, ds.value());
1817  boundaryFieldRef().replace(d, ds.value());
1818 }
1819 
1820 
1821 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1823 (
1824  const dimensioned<Type>& dt
1825 )
1826 {
1827  Foam::max(primitiveFieldRef(), primitiveField(), dt.value());
1828  Foam::max(boundaryFieldRef(), boundaryField(), dt.value());
1829 }
1830 
1831 
1832 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1834 (
1835  const dimensioned<Type>& dt
1836 )
1837 {
1838  Foam::min(primitiveFieldRef(), primitiveField(), dt.value());
1839  Foam::min(boundaryFieldRef(), boundaryField(), dt.value());
1840 }
1841 
1842 
1843 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1845 (
1846  const dimensioned<Type>& minDt,
1847  const dimensioned<Type>& maxDt
1848 )
1849 {
1850  Foam::max(primitiveFieldRef(), primitiveField(), minDt.value());
1851  Foam::max(boundaryFieldRef(), boundaryField(), minDt.value());
1852  Foam::min(primitiveFieldRef(), primitiveField(), maxDt.value());
1853  Foam::min(boundaryFieldRef(), boundaryField(), maxDt.value());
1854 }
1855 
1856 
1857 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1859 {
1860  primitiveFieldRef().negate();
1861  boundaryFieldRef().negate();
1862 }
1863 
1864 
1865 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1866 
1867 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1869 (
1871 )
1872 {
1873  checkFieldAssignment(*this, gf);
1874  checkFieldOperation(*this, gf, "=");
1875 
1876  internalFieldRef() = gf.internalField();
1877  boundaryFieldRef() = gf.boundaryField();
1878 }
1879 
1880 
1881 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1883 (
1885 )
1886 {
1887  checkFieldAssignment(*this, gf);
1888  checkFieldOperation(*this, gf, "=");
1889 
1890  internalFieldRef() = move(gf.internalField());
1891  boundaryFieldRef() = move(gf.boundaryField());
1892 }
1893 
1894 
1895 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1896 template<template<class> class PrimitiveField2>
1898 (
1900 )
1901 {
1902  checkFieldOperation(*this, gf, "=");
1903 
1904  internalFieldRef() = gf.internalField();
1905  boundaryFieldRef() = gf.boundaryField();
1906 }
1907 
1908 
1909 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1911 (
1913 )
1914 {
1916 
1917  checkFieldAssignment(*this, gf);
1918  checkFieldOperation(*this, gf, "=");
1919 
1920  this->dimensions() = gf.dimensions();
1921 
1922  if (tgf.isTmp())
1923  {
1924  primitiveFieldRef().transfer(tgf.ref());
1925  }
1926  else
1927  {
1929  }
1930 
1931  boundaryFieldRef() = gf.boundaryField();
1932 
1933  tgf.clear();
1934 }
1935 
1936 
1937 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1938 template<template<class> class PrimitiveField2>
1940 (
1942 )
1943 {
1945 
1946  checkFieldOperation(*this, gf, "=");
1947 
1948  internalFieldRef() = gf.internalField();
1949  boundaryFieldRef() = gf.boundaryField();
1950 
1951  tgf.clear();
1952 }
1953 
1954 
1955 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1957 (
1958  const dimensioned<Type>& dt
1959 )
1960 {
1961  internalFieldRef() = dt;
1962  boundaryFieldRef() = dt.value();
1963 }
1964 
1965 
1966 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1968 (
1969  const zero&
1970 )
1971 {
1972  internalFieldRef() = Zero;
1973  boundaryFieldRef() = Zero;
1974 }
1975 
1976 
1977 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1978 template<template<class> class PrimitiveField2>
1980 (
1982 )
1983 {
1984  checkFieldOperation(*this, gf, "==");
1985 
1986  internalFieldRef() = gf.internalField();
1987  boundaryFieldRef() == gf.boundaryField();
1988 }
1989 
1990 
1991 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1993 (
1995 )
1996 {
1998 
1999  checkFieldOperation(*this, gf, "==");
2000 
2001  this->dimensions() = gf.dimensions();
2002 
2003  if (tgf.isTmp())
2004  {
2005  primitiveFieldRef().transfer(tgf.ref());
2006  }
2007  else
2008  {
2010  }
2011 
2012  boundaryFieldRef() == gf.boundaryField();
2013 
2014  tgf.clear();
2015 }
2016 
2017 
2018 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2019 template<template<class> class PrimitiveField2>
2021 (
2023 )
2024 {
2026 
2027  checkFieldOperation(*this, gf, "=");
2028 
2029  internalFieldRef() = gf.internalField();
2030  boundaryFieldRef() == gf.boundaryField();
2031 
2032  tgf.clear();
2033 }
2034 
2035 
2036 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2038 (
2039  const dimensioned<Type>& dt
2040 )
2041 {
2042  internalFieldRef() = dt;
2043  boundaryFieldRef() == dt.value();
2044 }
2045 
2046 
2047 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2049 (
2050  const zero&
2051 )
2052 {
2053  internalFieldRef() = Zero;
2054  boundaryFieldRef() == Zero;
2055 }
2056 
2057 
2058 #define COMPUTED_ASSIGNMENT(TYPE, op) \
2059  \
2060 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2061 template<template<class> class PrimitiveField2> \
2062 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2063 ( \
2064  const GeometricField<TYPE, GeoMesh, PrimitiveField2>& gf \
2065 ) \
2066 { \
2067  checkFieldOperation(*this, gf, #op); \
2068  \
2069  internalFieldRef() op gf.internalField(); \
2070  boundaryFieldRef() op gf.boundaryField(); \
2071 } \
2072  \
2073 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2074 template<template<class> class PrimitiveField2> \
2075 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2076 ( \
2077  const tmp<GeometricField<TYPE, GeoMesh, PrimitiveField2>>& tgf \
2078 ) \
2079 { \
2080  operator op(tgf()); \
2081  tgf.clear(); \
2082 } \
2083  \
2084 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2085 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2086 ( \
2087  const dimensioned<TYPE>& dt \
2088 ) \
2089 { \
2090  internalFieldRef() op dt; \
2091  boundaryFieldRef() op dt.value(); \
2092 }
2093 
2098 
2099 #undef COMPUTED_ASSIGNMENT
2100 
2101 
2102 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
2103 
2104 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2105 Foam::Ostream& Foam::operator<<
2106 (
2107  Ostream& os,
2109 )
2110 {
2111  gf().writeData(os, "internalField");
2112  os << nl;
2113  gf.boundaryField().writeEntry("boundaryField", os);
2114 
2115  if (!gf.sources_.empty())
2116  {
2117  os << nl;
2118  gf.sources().writeEntry("sources", os);
2119  }
2120 
2121  // Check state of IOstream
2122  os.check
2123  (
2124  "Ostream& operator<<(Ostream&, "
2125  "const GeometricField<Type, GeoMesh, PrimitiveField>&)"
2126  );
2127 
2128  return (os);
2129 }
2130 
2131 
2132 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2133 Foam::Ostream& Foam::operator<<
2134 (
2135  Ostream& os,
2137 )
2138 {
2139  os << tgf();
2140  tgf.clear();
2141  return os;
2142 }
2143 
2144 
2145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2146 
2147 #undef checkFieldAssignment
2148 #undef checkFieldOperation
2149 
2150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2151 
2152 #include "GeometricFieldFunctions.C"
2153 
2154 // ************************************************************************* //
EaEqn relax()
#define checkFieldOperation(gf1, gf2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
#define checkFieldAssignment(gf1, gf2)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
PrimitiveField< Type > FieldType
Type of the field from which this DimensionedField is derived.
const GeoMesh & mesh() const
Return mesh.
Pre-declare SubField and related Field type.
Definition: Field.H:83
Generic GeometricBoundaryField class.
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
Part of a geometric field used for setting the values associated with optional sources.
void writeEntry(const word &keyword, Ostream &os) const
Write sources as dictionary entry.
Generic GeometricField class.
void max(const dimensioned< Type > &)
tmp< GeometricField< Type, GeoMesh, Field > > T() const
Return transpose (only if it is a tensor field)
Sources & sourcesRef()
Return a reference to the sources.
PrimitiveField< Type >::cmptType cmptType
Component type of the elements of the field.
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
void relax()
Relax current field with respect to the cached previous iteration.
void maxMin(const dimensioned< Type > &minDt, const dimensioned< Type > &maxDt)
const GeometricField< Type, GeoMesh, Field > & prevIter() const
Return previous iteration field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Internal::FieldType & primitiveFieldRef()
Return a reference to the primitive field.
Boundary & boundaryFieldRefNoStoreOldTimes()
Return a reference to the boundary field without storing old times.
tmp< GeometricField< cmptType, GeoMesh, Field > > component(const direction) const
Return a component of the field.
const Sources & sources() const
Return const-reference to the sources.
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
void min(const dimensioned< Type > &)
friend class GeometricField
Declare friendship with other geometric fields.
Internal & internalFieldRef()
Return a reference to the dimensioned internal field.
void replace(const direction, const GeometricField< cmptType, GeoMesh, PrimitiveField2 > &)
Replace a component field of the field.
tmp< GeometricField< Type, GeoMesh, PrimitiveField > > clone() const
Clone.
bool needReference() const
Does the field need a reference level for solution.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
virtual ~GeometricField()
Destructor.
const Internal::FieldType & primitiveField() const
Return a const-reference to the primitive field.
void reset(const GeometricField< Type, GeoMesh, PrimitiveField2 > &)
Reset the field contents to the given field.
scalar relaxationFactor() const
Return the field relaxation factor read from fvSolution.
void clearPrevIter()
Delete the previous iteration field.
void storePrevIter() const
Store the field as the previous iteration value.
word select(bool final) const
Select the final iteration parameters if `final' is true.
void correctBoundaryConditions()
Correct boundary field.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
tmp< GeometricField< Type, GeoMesh, PrimitiveField > > cloneUnSliced() const
Clone un-sliced.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:68
An STL-conforming hash table.
Definition: HashTable.H:127
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const fileName & local() const
Definition: IOobject.H:400
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
Definition: IOobject.C:352
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:309
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:500
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Class to add into field types to provide old-time storage and retrieval.
Definition: OldTimeField.H:115
void copyOldTimes(const IOobject &io, const OtherOldTime< OtherPrimitiveField > &)
Copy the old-times from the given field.
Definition: OldTimeField.C:162
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:198
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
Generic dimensioned Type class.
const Type & value() const
Return const reference to value.
const word & name() const
Return const reference to name.
virtual const objectRegistry & db() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:439
const fvSolution & solution() const
Return the fvSolution.
Definition: fvMesh.C:1806
label size() const
Return fvMesh size.
Definition: fvMesh.H:468
const Time & time() const
Return time.
bool temporaryObjectCached(const word &name) const
Return true if given name is in the cacheTemporaryObjects set.
static bool finalIteration(const objectRegistry &registry)
Lookup solutionControl from the objectRegistry and return finalIter.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:51
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:174
A class for managing temporary objects.
Definition: tmp.H:55
bool isTmp() const
Return true if this is really a temporary object.
Definition: tmpI.H:169
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:253
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Definition: word.H:63
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Template functions to aid in the implementation of demand driven data.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define InfoInFunction
Report an information message using Foam::Info.
const dimensionSet time
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
void deleteDemandDrivenData(DataType *&dataPtr)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void component(GeometricField< typename GeometricField< Type, GeoMesh, PrimitiveField1 >::cmptType, GeoMesh, PrimitiveField1 > &gcf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf, const direction d)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word patchFieldType(const PatchField &pf)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
void operator+=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Add to a finite-volume equation.
Definition: CarrierEqn.C:271
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
static const char nl
Definition: Ostream.H:297
uint8_t direction
Definition: direction.H:45
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
label timeIndex
Definition: getTimeIndex.H:4
faceListList boundary(nPatches)
dictionary dict
conserve primitiveFieldRef()+