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,
216  const word& patchFieldType
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 )
325 :
326  Internal(io, mesh, dimless, false),
328  fieldPrevIterPtr_(nullptr),
329  boundaryField_(mesh.boundary()),
330  sources_()
331 {
332  readFields();
333 
334  // Check compatibility between field and mesh
335 
336  if (this->size() != this->mesh().size())
337  {
338  FatalIOErrorInFunction(this->readStream(typeName))
339  << " number of field elements = " << this->size()
340  << " number of mesh elements = " << this->mesh().size()
341  << exit(FatalIOError);
342  }
343 
344  readOldTimeIfPresent();
345 
346  if (debug)
347  {
349  << "Finishing read-construction of" << endl << this->info() << endl;
350  }
351 }
352 
353 
354 template<class Type, class GeoMesh, template<class> class PrimitiveField>
356 (
357  const IOobject& io,
358  const GeoMesh& mesh,
359  const dictionary& dict
360 )
361 :
362  Internal(io, mesh, dimless, false),
364  fieldPrevIterPtr_(nullptr),
365  boundaryField_(mesh.boundary()),
366  sources_()
367 {
369 
370  // Check compatibility between field and mesh
371 
372  if (this->size() != this->mesh().size())
373  {
375  << " number of field elements = " << this->size()
376  << " number of mesh elements = " << this->mesh().size()
377  << exit(FatalIOError);
378  }
379 
380  if (debug)
381  {
383  << "Finishing dictionary-construct of "
384  << endl << this->info() << endl;
385  }
386 }
387 
388 
389 template<class Type, class GeoMesh, template<class> class PrimitiveField>
391 (
393 )
394 :
395  Internal(gf),
397  fieldPrevIterPtr_(nullptr),
398  boundaryField_(*this, gf.boundaryField_),
399  sources_(*this, gf.sources_)
400 {
401  if (debug)
402  {
404  << "Constructing field as copy" << endl << this->info() << endl;
405  }
406 
407  this->writeOpt() = IOobject::NO_WRITE;
408 }
409 
410 
411 template<class Type, class GeoMesh, template<class> class PrimitiveField>
412 template<template<class> class PrimitiveField2>
414 (
416 )
417 :
418  Internal(gf),
420  fieldPrevIterPtr_(nullptr),
421  boundaryField_(*this, gf.boundaryField_),
422  sources_(*this, gf.sources_)
423 {
424  if (debug)
425  {
427  << "Constructing field as copy" << endl << this->info() << endl;
428  }
429 
430  this->writeOpt() = IOobject::NO_WRITE;
431 }
432 
433 
434 template<class Type, class GeoMesh, template<class> class PrimitiveField>
436 (
438 )
439 :
440  Internal(move(gf)),
441  OldTimeField<GeometricField>(move(gf)),
442  fieldPrevIterPtr_(nullptr),
443  boundaryField_(*this, gf.boundaryField_),
444  sources_(*this, gf.sources_)
445 {
446  if (debug)
447  {
449  << "Constructing field by moving" << endl << this->info() << endl;
450  }
451 
452  this->writeOpt() = IOobject::NO_WRITE;
453 }
454 
455 
456 template<class Type, class GeoMesh, template<class> class PrimitiveField>
458 (
460 )
461 :
462  Internal
463  (
464  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
465  tgf.isTmp()
466  ),
468  fieldPrevIterPtr_(nullptr),
469  boundaryField_(*this, tgf().boundaryField_),
470  sources_(*this, tgf().sources_)
471 {
472  if (debug)
473  {
475  << "Constructing field from tmp" << endl << this->info() << endl;
476  }
477 
478  this->writeOpt() = IOobject::NO_WRITE;
479 
480  tgf.clear();
481 }
482 
483 
484 template<class Type, class GeoMesh, template<class> class PrimitiveField>
485 template<template<class> class PrimitiveField2>
487 (
488  const IOobject& io,
490 )
491 :
492  Internal(io, gf, false),
494  fieldPrevIterPtr_(nullptr),
495  boundaryField_(*this, gf.boundaryField_),
496  sources_(*this, gf.sources_)
497 {
498  if (debug)
499  {
501  << "Constructing field as copy resetting IO params"
502  << endl << this->info() << endl;
503  }
504 
505  if (!readIfPresent())
506  {
507  copyOldTimes(io, gf);
508  }
509 }
510 
511 
512 template<class Type, class GeoMesh, template<class> class PrimitiveField>
514 (
515  const IOobject& io,
517 )
518 :
519  Internal
520  (
521  io,
522  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
523  tgf.isTmp(),
524  false
525  ),
527  fieldPrevIterPtr_(nullptr),
528  boundaryField_(*this, tgf().boundaryField_),
529  sources_(*this, tgf().sources_)
530 {
531  if (debug)
532  {
534  << "Constructing field from tmp resetting IO params"
535  << endl << this->info() << endl;
536  }
537 
538  tgf.clear();
539 
540  readIfPresent();
541 }
542 
543 
544 template<class Type, class GeoMesh, template<class> class PrimitiveField>
545 template<template<class> class PrimitiveField2>
547 (
548  const word& newName,
550 )
551 :
552  Internal(newName, gf),
554  fieldPrevIterPtr_(nullptr),
555  boundaryField_(*this, gf.boundaryField_),
556  sources_(*this, gf.sources_)
557 {
558  if (debug)
559  {
561  << "Constructing field as copy resetting name"
562  << endl << this->info() << endl;
563  }
564 
565  copyOldTimes(newName, gf);
566 }
567 
568 
569 template<class Type, class GeoMesh, template<class> class PrimitiveField>
571 (
572  const word& newName,
574 )
575 :
576  Internal
577  (
578  newName,
579  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
580  tgf.isTmp()
581  ),
583  fieldPrevIterPtr_(nullptr),
584  boundaryField_(*this, tgf().boundaryField_),
585  sources_(*this, tgf().sources_)
586 {
587  if (debug)
588  {
590  << "Constructing field from tmp resetting name"
591  << endl << this->info() << endl;
592  }
593 
594  tgf.clear();
595 }
596 
597 
598 template<class Type, class GeoMesh, template<class> class PrimitiveField>
599 template<template<class> class PrimitiveField2>
601 (
602  const IOobject& io,
604  const word& patchFieldType
605 )
606 :
607  Internal(io, gf, false),
609  fieldPrevIterPtr_(nullptr),
610  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
611  sources_(*this, gf.sources_)
612 {
613  if (debug)
614  {
616  << "Constructing field as copy resetting IO params"
617  << endl << this->info() << endl;
618  }
619 
620  boundaryField_ == gf.boundaryField_;
621 
622  if (!readIfPresent())
623  {
624  copyOldTimes(io, gf);
625  }
626 }
627 
628 
629 template<class Type, class GeoMesh, template<class> class PrimitiveField>
631 (
632  const IOobject& io,
635 )
636 :
637  Internal
638  (
639  io,
641  tgf.isTmp(),
642  false
643  ),
645  fieldPrevIterPtr_(nullptr),
646  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
647  sources_(*this, tgf().sources_)
648 {
649  if (debug)
650  {
652  << "Constructing field as copy resetting IO params"
653  << endl << this->info() << endl;
654  }
655 
656  boundaryField_ == tgf().boundaryField_;
657 
658  tgf.clear();
659 
660  readIfPresent();
661 }
662 
663 
664 template<class Type, class GeoMesh, template<class> class PrimitiveField>
665 template<template<class> class PrimitiveField2>
667 (
668  const IOobject& io,
670  const word& patchFieldType
671 )
672 :
673  Internal(io, df, false),
675  fieldPrevIterPtr_(nullptr),
676  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
677  sources_()
678 {
679  if (debug)
680  {
682  << "Constructing field from components" << endl
683  << this->info() << endl;
684  }
685 
686  if (!readIfPresent())
687  {
688  boundaryField_.evaluate();
689  }
690 }
691 
692 
693 template<class Type, class GeoMesh, template<class> class PrimitiveField>
695 (
696  const IOobject& io,
697  const tmp<Internal>& tdf,
698  const word& patchFieldType
699 )
700 :
701  Internal(io, const_cast<Internal&>(tdf()), tdf.isTmp(), false),
703  fieldPrevIterPtr_(nullptr),
704  boundaryField_(this->mesh().boundary(), *this, patchFieldType),
705  sources_()
706 {
707  if (debug)
708  {
710  << "Constructing field from components" << endl
711  << this->info() << endl;
712  }
713 
714  if (!readIfPresent())
715  {
716  boundaryField_.evaluate();
717  }
718 }
719 
720 
721 template<class Type, class GeoMesh, template<class> class PrimitiveField>
722 template<template<class> class PrimitiveField2>
724 (
725  const IOobject& io,
727  const wordList& patchFieldTypes,
728  const wordList& actualPatchTypes,
729  const HashTable<word>& fieldSourceTypes,
730  const IOerrorLocation& fieldSourceErrorLocation
731 )
732 :
733  Internal(io, gf, false),
735  fieldPrevIterPtr_(nullptr),
736  boundaryField_
737  (
738  this->mesh().boundary(),
739  *this,
740  patchFieldTypes,
741  actualPatchTypes
742  ),
743  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
744 {
745  if (debug)
746  {
748  << "Constructing field as copy resetting IO params and patch types"
749  << endl << this->info() << endl;
750  }
751 
752  boundaryField_ == gf.boundaryField_;
753 
754  if (!readIfPresent())
755  {
756  copyOldTimes(io, gf);
757  }
758 }
759 
760 
761 template<class Type, class GeoMesh, template<class> class PrimitiveField>
763 (
764  const IOobject& io,
766  const wordList& patchFieldTypes,
767  const wordList& actualPatchTypes,
768  const HashTable<word>& fieldSourceTypes,
769  const IOerrorLocation& fieldSourceErrorLocation
770 )
771 :
772  Internal
773  (
774  io,
775  const_cast<GeometricField<Type, GeoMesh, PrimitiveField>&>(tgf()),
776  tgf.isTmp(),
777  false
778  ),
780  fieldPrevIterPtr_(nullptr),
781  boundaryField_
782  (
783  this->mesh().boundary(),
784  *this,
785  patchFieldTypes,
786  actualPatchTypes
787  ),
788  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
789 {
790  if (debug)
791  {
793  << "Constructing field from tmp resetting IO params and patch types"
794  << endl << this->info() << endl;
795  }
796 
797  boundaryField_ == tgf().boundaryField_;
798 
799  tgf.clear();
800 
801  readIfPresent();
802 }
803 
804 
805 template<class Type, class GeoMesh, template<class> class PrimitiveField>
806 template<template<class> class PrimitiveField2>
808 (
809  const IOobject& io,
811  const wordList& patchFieldTypes,
812  const wordList& actualPatchTypes,
813  const HashTable<word>& fieldSourceTypes,
814  const IOerrorLocation& fieldSourceErrorLocation
815 )
816 :
817  Internal(io, df, false),
819  fieldPrevIterPtr_(nullptr),
820  boundaryField_
821  (
822  this->mesh().boundary(),
823  *this,
824  patchFieldTypes,
825  actualPatchTypes
826  ),
827  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
828 {
829  if (debug)
830  {
832  << "Constructing field from internal field and patch types"
833  << endl << this->info() << endl;
834  }
835 
836  readIfPresent();
837 }
838 
839 
840 template<class Type, class GeoMesh, template<class> class PrimitiveField>
842 (
843  const IOobject& io,
844  const tmp<Internal>& tdf,
845  const wordList& patchFieldTypes,
846  const wordList& actualPatchTypes,
847  const HashTable<word>& fieldSourceTypes,
848  const IOerrorLocation& fieldSourceErrorLocation
849 )
850 :
851  Internal(io, const_cast<Internal&>(tdf()), tdf.isTmp(), false),
853  fieldPrevIterPtr_(nullptr),
854  boundaryField_
855  (
856  this->mesh().boundary(),
857  *this,
858  patchFieldTypes,
859  actualPatchTypes
860  ),
861  sources_(*this, fieldSourceTypes, fieldSourceErrorLocation)
862 {
863  if (debug)
864  {
866  << "Constructing field from tmp internal field and patch types"
867  << endl << this->info() << endl;
868  }
869 
870  tdf.clear();
871 
872  readIfPresent();
873 }
874 
875 
876 template<class Type, class GeoMesh, template<class> class PrimitiveField>
879 {
881  (
883  );
884 }
885 
886 
887 template<class Type, class GeoMesh, template<class> class PrimitiveField>
890 {
892  (
894  (
895  IOobject
896  (
897  this->name(),
898  this->mesh().db().time().name(),
899  this->mesh().db(),
902  false
903  ),
904  *this,
905  Patch::calculatedType()
906  )
907  );
908 }
909 
910 
911 template<class Type, class GeoMesh, template<class> class PrimitiveField>
914 (
915  const word& name,
916  const Internal& diField,
917  const PtrList<Patch>& ptfl,
918  const HashPtrTable<Source>& stft
919 )
920 {
921  const bool cacheTmp = diField.mesh().db().temporaryObjectCached(name);
922 
924  (
926  (
927  IOobject
928  (
929  name,
930  diField.mesh().db().time().name(),
931  diField.mesh().db(),
934  cacheTmp
935  ),
936  diField,
937  ptfl,
938  stft
939  ),
940  cacheTmp
941  );
942 }
943 
944 
945 template<class Type, class GeoMesh, template<class> class PrimitiveField>
948 (
949  const word& name,
950  const GeoMesh& mesh,
951  const dimensionSet& ds,
952  const word& patchFieldType
953 )
954 {
955  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
956 
958  (
960  (
961  IOobject
962  (
963  name,
964  mesh.db().time().name(),
965  mesh.db(),
968  cacheTmp
969  ),
970  mesh,
971  ds,
973  ),
974  cacheTmp
975  );
976 }
977 
978 
979 template<class Type, class GeoMesh, template<class> class PrimitiveField>
982 (
983  const word& name,
984  const GeoMesh& mesh,
985  const dimensioned<Type>& dt,
986  const word& patchFieldType
987 )
988 {
989  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
990 
992  (
994  (
995  IOobject
996  (
997  name,
998  mesh.db().time().name(),
999  mesh.db(),
1002  cacheTmp
1003  ),
1004  mesh,
1005  dt,
1007  ),
1008  cacheTmp
1009  );
1010 }
1011 
1012 
1013 
1014 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1017 (
1018  const word& name,
1019  const GeoMesh& mesh,
1020  const dimensioned<Type>& dt,
1021  const wordList& patchFieldTypes,
1022  const wordList& actualPatchTypes,
1023  const HashTable<word>& fieldSourceTypes,
1024  const IOerrorLocation& fieldSourceErrorLocation
1025 )
1026 {
1027  const bool cacheTmp = mesh.db().temporaryObjectCached(name);
1028 
1030  (
1032  (
1033  IOobject
1034  (
1035  name,
1036  mesh.db().time().name(),
1037  mesh.db(),
1040  cacheTmp
1041  ),
1042  mesh,
1043  dt,
1044  patchFieldTypes,
1045  actualPatchTypes,
1046  fieldSourceTypes,
1047  fieldSourceErrorLocation
1048  ),
1049  cacheTmp
1050  );
1051 }
1052 
1053 
1054 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1057 (
1058  const word& newName,
1060 )
1061 {
1062  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1063 
1065  (
1067  (
1068  IOobject
1069  (
1070  newName,
1071  tgf().instance(),
1072  tgf().local(),
1073  tgf().db(),
1076  cacheTmp
1077  ),
1078  tgf
1079  ),
1080  cacheTmp
1081  );
1082 }
1083 
1084 
1085 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1086 template<template<class> class PrimitiveField2>
1089 (
1090  const word& newName,
1092  const word& patchFieldType
1093 )
1094 {
1095  const bool cacheTmp = gf.db().temporaryObjectCached(newName);
1096 
1098  (
1100  (
1101  IOobject
1102  (
1103  newName,
1104  gf.instance(),
1105  gf.local(),
1106  gf.db(),
1109  cacheTmp
1110  ),
1111  gf,
1113  ),
1114  cacheTmp
1115  );
1116 }
1117 
1118 
1119 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1122 (
1123  const word& newName,
1125  const word& patchFieldType
1126 )
1127 {
1128  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1129 
1131  (
1133  (
1134  IOobject
1135  (
1136  newName,
1137  tgf().instance(),
1138  tgf().local(),
1139  tgf().db(),
1142  cacheTmp
1143  ),
1144  tgf,
1146  ),
1147  cacheTmp
1148  );
1149 }
1150 
1151 
1152 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1153 template<template<class> class PrimitiveField2>
1156 (
1157  const word& newName,
1159  const word& patchFieldType
1160 )
1161 {
1162  const bool cacheTmp = df.db().temporaryObjectCached(newName);
1163 
1165  (
1167  (
1168  IOobject
1169  (
1170  newName,
1171  df.instance(),
1172  df.local(),
1173  df.db(),
1176  cacheTmp
1177  ),
1178  df,
1180  ),
1181  cacheTmp
1182  );
1183 }
1184 
1185 
1186 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1189 (
1190  const word& newName,
1191  const tmp<Internal>& tdf,
1192  const word& patchFieldType
1193 )
1194 {
1195  const bool cacheTmp = tdf().db().temporaryObjectCached(newName);
1196 
1198  (
1200  (
1201  IOobject
1202  (
1203  newName,
1204  tdf().instance(),
1205  tdf().local(),
1206  tdf().db(),
1209  cacheTmp
1210  ),
1211  tdf,
1213  ),
1214  cacheTmp
1215  );
1216 }
1217 
1218 
1219 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1220 template<template<class> class PrimitiveField2>
1223 (
1224  const word& newName,
1226  const wordList& patchFieldTypes,
1227  const wordList& actualPatchTypes,
1228  const HashTable<word>& fieldSourceTypes,
1229  const IOerrorLocation& fieldSourceErrorLocation
1230 )
1231 {
1232  const bool cacheTmp = gf.db().temporaryObjectCached(newName);
1233 
1235  (
1237  (
1238  IOobject
1239  (
1240  newName,
1241  gf.instance(),
1242  gf.local(),
1243  gf.db(),
1246  cacheTmp
1247  ),
1248  gf,
1249  patchFieldTypes,
1250  actualPatchTypes,
1251  fieldSourceTypes,
1252  fieldSourceErrorLocation
1253  ),
1254  cacheTmp
1255  );
1256 }
1257 
1258 
1259 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1262 (
1263  const word& newName,
1265  const wordList& patchFieldTypes,
1266  const wordList& actualPatchTypes,
1267  const HashTable<word>& fieldSourceTypes,
1268  const IOerrorLocation& fieldSourceErrorLocation
1269 )
1270 {
1271  const bool cacheTmp = tgf().db().temporaryObjectCached(newName);
1272 
1274  (
1276  (
1277  IOobject
1278  (
1279  newName,
1280  tgf().instance(),
1281  tgf().local(),
1282  tgf().db(),
1285  cacheTmp
1286  ),
1287  tgf,
1288  patchFieldTypes,
1289  actualPatchTypes,
1290  fieldSourceTypes,
1291  fieldSourceErrorLocation
1292  ),
1293  cacheTmp
1294  );
1295 }
1296 
1297 
1298 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1299 template<template<class> class PrimitiveField2>
1302 (
1303  const word& newName,
1305  const wordList& patchFieldTypes,
1306  const wordList& actualPatchTypes,
1307  const HashTable<word>& fieldSourceTypes,
1308  const IOerrorLocation& fieldSourceErrorLocation
1309 )
1310 {
1311  const bool cacheTmp = df.db().temporaryObjectCached(newName);
1312 
1314  (
1316  (
1317  IOobject
1318  (
1319  newName,
1320  df.instance(),
1321  df.local(),
1322  df.db(),
1325  cacheTmp
1326  ),
1327  df,
1328  patchFieldTypes,
1329  actualPatchTypes,
1330  fieldSourceTypes,
1331  fieldSourceErrorLocation
1332  ),
1333  cacheTmp
1334  );
1335 }
1336 
1337 
1338 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1341 (
1342  const word& newName,
1343  const tmp<Internal>& tdf,
1344  const wordList& patchFieldTypes,
1345  const wordList& actualPatchTypes,
1346  const HashTable<word>& fieldSourceTypes,
1347  const IOerrorLocation& fieldSourceErrorLocation
1348 )
1349 {
1350  const bool cacheTmp = tdf().db().temporaryObjectCached(newName);
1351 
1353  (
1355  (
1356  IOobject
1357  (
1358  newName,
1359  tdf().instance(),
1360  tdf().local(),
1361  tdf().db(),
1364  cacheTmp
1365  ),
1366  tdf,
1367  patchFieldTypes,
1368  actualPatchTypes,
1369  fieldSourceTypes,
1370  fieldSourceErrorLocation
1371  ),
1372  cacheTmp
1373  );
1374 }
1375 
1376 
1377 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
1378 
1379 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1381 {
1382  this->db().cacheTemporaryObject(*this);
1383 
1384  clearPrevIter();
1385 }
1386 
1387 
1388 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1389 
1390 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1393 {
1394  this->setUpToDate();
1395  storeOldTimes();
1396  return *this;
1397 }
1398 
1399 
1400 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1401 typename
1404 {
1405  this->setUpToDate();
1406  storeOldTimes();
1407  return *this;
1408 }
1409 
1410 
1411 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1412 typename
1415 {
1416  this->setUpToDate();
1417  storeOldTimes();
1418  return boundaryField_;
1419 }
1420 
1421 
1422 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1423 typename
1427 {
1428  this->setUpToDate();
1429  return boundaryField_;
1430 }
1431 
1432 
1433 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1434 typename
1437 {
1438  this->setUpToDate();
1439  storeOldTimes();
1440  return sources_;
1441 }
1442 
1443 
1444 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1446 {
1447  if (!fieldPrevIterPtr_)
1448  {
1449  if (debug)
1450  {
1452  << "Allocating previous iteration field" << endl
1453  << this->info() << endl;
1454  }
1455 
1456  fieldPrevIterPtr_ =
1458  (
1459  this->name() + "PrevIter",
1460  *this
1461  );
1462  }
1463  else
1464  {
1465  *fieldPrevIterPtr_ == *this;
1466  }
1467 }
1468 
1469 
1470 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1472 {
1473  deleteDemandDrivenData(fieldPrevIterPtr_);
1474 }
1475 
1476 
1477 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1480 {
1481  if (!fieldPrevIterPtr_)
1482  {
1484  << "previous iteration field" << endl << this->info() << endl
1485  << " not stored."
1486  << " Use field.storePrevIter() at start of iteration."
1487  << abort(FatalError);
1488  }
1489 
1490  return *fieldPrevIterPtr_;
1491 }
1492 
1493 
1494 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1497 {
1498  this->setUpToDate();
1499  storeOldTimes();
1500  boundaryField_.evaluate();
1501 }
1502 
1503 
1504 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1505 template<template<class> class PrimitiveField2>
1507 (
1509 )
1510 {
1511  Internal::reset(gf);
1512 
1513  boundaryField_.reset(gf.boundaryField());
1514  sources_.reset(*this, gf.sources());
1515 }
1516 
1517 
1518 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1520 (
1522 )
1523 {
1525 
1526  checkFieldAssignment(*this, gf);
1527 
1528  this->dimensions() = gf.dimensions();
1529 
1530  if (tgf.isTmp())
1531  {
1532  PrimitiveField<Type>::transfer(tgf.ref());
1533  }
1534  else
1535  {
1536  PrimitiveField<Type>::operator=(gf.primitiveField());
1537  }
1538 
1539  boundaryField_.reset(gf.boundaryField());
1540  sources_.reset(*this, gf.sources());
1541 
1542  tgf.clear();
1543 }
1544 
1545 
1546 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1547 template<template<class> class PrimitiveField2>
1549 (
1551 )
1552 {
1553  reset(tgf());
1554 
1555  tgf.clear();
1556 }
1557 
1558 
1559 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1561 {
1562  // Search all boundary conditions, if any are
1563  // fixed-value or mixed (Robin) do not set reference level for solution.
1564 
1565  bool needRef = true;
1566 
1567  forAll(boundaryField_, patchi)
1568  {
1569  if (boundaryField_[patchi].fixesValue())
1570  {
1571  needRef = false;
1572  break;
1573  }
1574  }
1575 
1576  reduce(needRef, andOp<bool>());
1577 
1578  return needRef;
1579 }
1580 
1581 
1582 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1584 (
1585  const scalar alpha
1586 )
1587 {
1588  if (alpha < 1)
1589  {
1590  if (debug)
1591  {
1593  << "Relaxing" << endl << this->info()
1594  << " by " << alpha << endl;
1595  }
1596 
1597  operator==(prevIter() + alpha*(*this - prevIter()));
1598  }
1599 }
1600 
1601 
1602 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1603 Foam::scalar
1605 {
1606  if
1607  (
1609  && this->mesh().solution().relaxField(this->name() + "Final")
1610  )
1611  {
1612  return this->mesh().solution().fieldRelaxationFactor
1613  (
1614  this->name() + "Final"
1615  );
1616  }
1617  else if (this->mesh().solution().relaxField(this->name()))
1618  {
1619  return this->mesh().solution().fieldRelaxationFactor(this->name());
1620  }
1621  else
1622  {
1623  return 1;
1624  }
1625 }
1626 
1627 
1628 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1630 {
1631  relax(relaxationFactor());
1632 }
1633 
1634 
1635 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1636 template<template<class> class PrimitiveField2>
1638 (
1640  const scalar alpha
1641 )
1642 {
1643  if (alpha < 1)
1644  {
1645  if (debug)
1646  {
1648  << "Relaxing" << endl << this->info()
1649  << " by " << alpha << endl;
1650  }
1651 
1652  operator==(*this + alpha*(tgf - *this));
1653  }
1654  else
1655  {
1656  operator==(tgf);
1657  }
1658 }
1659 
1660 
1661 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1662 template<template<class> class PrimitiveField2>
1664 (
1666 )
1667 {
1668  relax(tgf, relaxationFactor());
1669 }
1670 
1671 
1672 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1674 (
1675  bool final
1676 ) const
1677 {
1678  if (final)
1679  {
1680  return this->name() + "Final";
1681  }
1682  else
1683  {
1684  return this->name();
1685  }
1686 }
1687 
1688 
1689 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1691 (
1692  Ostream& os
1693 ) const
1694 {
1695  os << "min/max(" << this->name() << ") = "
1696  << Foam::min(*this).value() << ", "
1697  << Foam::max(*this).value()
1698  << endl;
1699 }
1700 
1701 
1702 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1704 (
1705  Ostream& os
1706 ) const
1707 {
1708  os << *this;
1709  return os.good();
1710 }
1711 
1712 
1713 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1714 
1715 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1718 {
1720  (
1722  (
1723  this->name() + ".T()",
1724  this->mesh(),
1725  this->dimensions()
1726  )
1727  );
1728 
1729  Foam::T(result.ref().primitiveFieldRef(), primitiveField());
1730  Foam::T(result.ref().boundaryFieldRef(), boundaryField());
1731 
1732  return result;
1733 }
1734 
1735 
1736 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1737 Foam::tmp
1738 <
1740  <
1742  GeoMesh,
1743  Foam::Field
1744  >
1745 >
1747 (
1748  const direction d
1749 ) const
1750 {
1752  (
1754  (
1755  this->name() + ".component(" + Foam::name(d) + ')',
1756  this->mesh(),
1757  this->dimensions()
1758  )
1759  );
1760 
1761  Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
1762  Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
1763 
1764  return Component;
1765 }
1766 
1767 
1768 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1769 template<template<class> class PrimitiveField2>
1771 (
1772  const direction d,
1773  const GeometricField
1774  <
1776  GeoMesh,
1777  PrimitiveField2
1778  >& gcf
1779 )
1780 {
1781  primitiveFieldRef().replace(d, gcf.primitiveField());
1782  boundaryFieldRef().replace(d, gcf.boundaryField());
1783 }
1784 
1785 
1786 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1787 template<template<class> class PrimitiveField2>
1789 (
1790  const direction d,
1791  const tmp
1792  <
1794  <
1796  GeoMesh,
1797  PrimitiveField2
1798  >
1799  >& gcf
1800 )
1801 {
1802  replace(d, gcf());
1803  gcf.clear();
1804 }
1805 
1806 
1807 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1809 (
1810  const direction d,
1811  const dimensioned<cmptType>& ds
1812 )
1813 {
1814  primitiveFieldRef().replace(d, ds.value());
1815  boundaryFieldRef().replace(d, ds.value());
1816 }
1817 
1818 
1819 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1821 (
1822  const dimensioned<Type>& dt
1823 )
1824 {
1825  Foam::max(primitiveFieldRef(), primitiveField(), dt.value());
1826  Foam::max(boundaryFieldRef(), boundaryField(), dt.value());
1827 }
1828 
1829 
1830 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1832 (
1833  const dimensioned<Type>& dt
1834 )
1835 {
1836  Foam::min(primitiveFieldRef(), primitiveField(), dt.value());
1837  Foam::min(boundaryFieldRef(), boundaryField(), dt.value());
1838 }
1839 
1840 
1841 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1843 (
1844  const dimensioned<Type>& minDt,
1845  const dimensioned<Type>& maxDt
1846 )
1847 {
1848  Foam::max(primitiveFieldRef(), primitiveField(), minDt.value());
1849  Foam::max(boundaryFieldRef(), boundaryField(), minDt.value());
1850  Foam::min(primitiveFieldRef(), primitiveField(), maxDt.value());
1851  Foam::min(boundaryFieldRef(), boundaryField(), maxDt.value());
1852 }
1853 
1854 
1855 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1857 {
1858  primitiveFieldRef().negate();
1859  boundaryFieldRef().negate();
1860 }
1861 
1862 
1863 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1864 
1865 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1867 (
1869 )
1870 {
1871  checkFieldAssignment(*this, gf);
1872  checkFieldOperation(*this, gf, "=");
1873 
1874  internalFieldRef() = gf.internalField();
1875  boundaryFieldRef() = gf.boundaryField();
1876 }
1877 
1878 
1879 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1881 (
1883 )
1884 {
1885  checkFieldAssignment(*this, gf);
1886  checkFieldOperation(*this, gf, "=");
1887 
1888  internalFieldRef() = move(gf.internalField());
1889  boundaryFieldRef() = move(gf.boundaryField());
1890 }
1891 
1892 
1893 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1894 template<template<class> class PrimitiveField2>
1896 (
1898 )
1899 {
1900  checkFieldOperation(*this, gf, "=");
1901 
1902  internalFieldRef() = gf.internalField();
1903  boundaryFieldRef() = gf.boundaryField();
1904 }
1905 
1906 
1907 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1909 (
1911 )
1912 {
1914 
1915  checkFieldAssignment(*this, gf);
1916  checkFieldOperation(*this, gf, "=");
1917 
1918  this->dimensions() = gf.dimensions();
1919 
1920  if (tgf.isTmp())
1921  {
1922  primitiveFieldRef().transfer(tgf.ref());
1923  }
1924  else
1925  {
1927  }
1928 
1929  boundaryFieldRef() = gf.boundaryField();
1930 
1931  tgf.clear();
1932 }
1933 
1934 
1935 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1936 template<template<class> class PrimitiveField2>
1938 (
1940 )
1941 {
1943 
1944  checkFieldOperation(*this, gf, "=");
1945 
1946  internalFieldRef() = gf.internalField();
1947  boundaryFieldRef() = gf.boundaryField();
1948 
1949  tgf.clear();
1950 }
1951 
1952 
1953 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1955 (
1956  const dimensioned<Type>& dt
1957 )
1958 {
1959  internalFieldRef() = dt;
1960  boundaryFieldRef() = dt.value();
1961 }
1962 
1963 
1964 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1966 (
1967  const zero&
1968 )
1969 {
1970  internalFieldRef() = Zero;
1971  boundaryFieldRef() = Zero;
1972 }
1973 
1974 
1975 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1976 template<template<class> class PrimitiveField2>
1978 (
1980 )
1981 {
1982  checkFieldOperation(*this, gf, "==");
1983 
1984  internalFieldRef() = gf.internalField();
1985  boundaryFieldRef() == gf.boundaryField();
1986 }
1987 
1988 
1989 template<class Type, class GeoMesh, template<class> class PrimitiveField>
1991 (
1993 )
1994 {
1996 
1997  checkFieldOperation(*this, gf, "==");
1998 
1999  this->dimensions() = gf.dimensions();
2000 
2001  if (tgf.isTmp())
2002  {
2003  primitiveFieldRef().transfer(tgf.ref());
2004  }
2005  else
2006  {
2008  }
2009 
2010  boundaryFieldRef() == gf.boundaryField();
2011 
2012  tgf.clear();
2013 }
2014 
2015 
2016 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2017 template<template<class> class PrimitiveField2>
2019 (
2021 )
2022 {
2024 
2025  checkFieldOperation(*this, gf, "=");
2026 
2027  internalFieldRef() = gf.internalField();
2028  boundaryFieldRef() == gf.boundaryField();
2029 
2030  tgf.clear();
2031 }
2032 
2033 
2034 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2036 (
2037  const dimensioned<Type>& dt
2038 )
2039 {
2040  internalFieldRef() = dt;
2041  boundaryFieldRef() == dt.value();
2042 }
2043 
2044 
2045 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2047 (
2048  const zero&
2049 )
2050 {
2051  internalFieldRef() = Zero;
2052  boundaryFieldRef() == Zero;
2053 }
2054 
2055 
2056 #define COMPUTED_ASSIGNMENT(TYPE, op) \
2057  \
2058 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2059 template<template<class> class PrimitiveField2> \
2060 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2061 ( \
2062  const GeometricField<TYPE, GeoMesh, PrimitiveField2>& gf \
2063 ) \
2064 { \
2065  checkFieldOperation(*this, gf, #op); \
2066  \
2067  internalFieldRef() op gf.internalField(); \
2068  boundaryFieldRef() op gf.boundaryField(); \
2069 } \
2070  \
2071 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2072 template<template<class> class PrimitiveField2> \
2073 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2074 ( \
2075  const tmp<GeometricField<TYPE, GeoMesh, PrimitiveField2>>& tgf \
2076 ) \
2077 { \
2078  operator op(tgf()); \
2079  tgf.clear(); \
2080 } \
2081  \
2082 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
2083 void Foam::GeometricField<Type, GeoMesh, PrimitiveField>::operator op \
2084 ( \
2085  const dimensioned<TYPE>& dt \
2086 ) \
2087 { \
2088  internalFieldRef() op dt; \
2089  boundaryFieldRef() op dt.value(); \
2090 }
2091 
2096 
2097 #undef COMPUTED_ASSIGNMENT
2098 
2099 
2100 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
2101 
2102 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2103 Foam::Ostream& Foam::operator<<
2104 (
2105  Ostream& os,
2107 )
2108 {
2109  gf().writeData(os, "internalField");
2110  os << nl;
2111  gf.boundaryField().writeEntry("boundaryField", os);
2112 
2113  if (!gf.sources_.empty())
2114  {
2115  os << nl;
2116  gf.sources().writeEntry("sources", os);
2117  }
2118 
2119  // Check state of IOstream
2120  os.check
2121  (
2122  "Ostream& operator<<(Ostream&, "
2123  "const GeometricField<Type, GeoMesh, PrimitiveField>&)"
2124  );
2125 
2126  return (os);
2127 }
2128 
2129 
2130 template<class Type, class GeoMesh, template<class> class PrimitiveField>
2131 Foam::Ostream& Foam::operator<<
2132 (
2133  Ostream& os,
2135 )
2136 {
2137  os << tgf();
2138  tgf.clear();
2139  return os;
2140 }
2141 
2142 
2143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2144 
2145 #undef checkFieldAssignment
2146 #undef checkFieldOperation
2147 
2148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2149 
2150 #include "GeometricFieldFunctions.C"
2151 
2152 // ************************************************************************* //
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
writeOption & writeOpt() const
Definition: IOobject.H:367
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:1803
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 dimless
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()+