Loading...
Searching...
No Matches
GeometricField.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2015-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "GeometricField.H"
30#include "Time.H"
31#include "dictionary.H"
33#include "meshState.H"
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37// Check that both fields use the same mesh
38#undef checkField
39#define checkField(fld1, fld2, op) \
40if (&(fld1).mesh() != &(fld2).mesh()) \
41{ \
42 FatalErrorInFunction \
43 << "Different mesh for fields " \
44 << (fld1).name() << " and " << (fld2).name() \
45 << " during operation " << op \
46 << abort(FatalError); \
47}
48
49
50// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
51
52template<class Type, template<class> class PatchField, class GeoMesh>
53void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields
54(
55 const dictionary& dict
56)
57{
58 Internal::readField(dict, "internalField"); // Includes size check
59
60 boundaryField_.readField(*this, dict.subDict("boundaryField"));
61
62 Type refLevel;
63
64 if (dict.readIfPresent("referenceLevel", refLevel))
65 {
66 // Add to internal (primitive) field
67 this->field() += refLevel;
68
69 // Add to boundary fields
70 forAll(boundaryField_, patchi)
71 {
72 boundaryField_[patchi] == boundaryField_[patchi] + refLevel;
73 }
74 }
75}
76
77
78template<class Type, template<class> class PatchField, class GeoMesh>
79void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields()
80{
82 (
83 localIOdictionary::readContents
84 (
85 IOobject
86 (
87 this->name(),
88 this->instance(),
89 this->local(),
90 this->db(),
91 IOobjectOption::MUST_READ,
92 IOobjectOption::NO_WRITE,
93 IOobjectOption::NO_REGISTER
94 ),
95 typeName
96 )
97 );
98
99 this->close();
100
102}
103
104
105template<class Type, template<class> class PatchField, class GeoMesh>
106bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
107{
108 if (this->isReadRequired())
109 {
111 << "The readOption MUST_READ or READ_MODIFIED"
112 << " suggests that a read constructor for field " << this->name()
113 << " would be more appropriate." << endl;
114 }
115 else if
116 (
117 this->isReadOptional()
118 && this->template typeHeaderOk<this_type>(true) // checkType = true
119 )
120 {
121 readFields();
122 readOldTimeIfPresent();
123
124 return true;
125 }
126
127 return false;
128}
129
130
131template<class Type, template<class> class PatchField, class GeoMesh>
132bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
133{
134 // Read the old time field if present
135 IOobject field0
136 (
137 this->name() + "_0",
138 this->time().timeName(),
139 this->db(),
140 IOobjectOption::LAZY_READ,
141 IOobjectOption::AUTO_WRITE,
142 this->registerObject()
143 );
144
145 if
146 (
147 field0.template typeHeaderOk<this_type>(true) // checkType = true
148 )
149 {
151 << "Reading old time level for field" << nl << this->info() << endl;
152
153 field0Ptr_ = std::make_unique<this_type>(field0, this->mesh());
154
155 // Ensure the old time field oriented flag is set to the parent's state
156 // Note: required for backwards compatibility in case of restarting from
157 // an old run where the oriented state may not have been set
158 field0Ptr_->oriented() = this->oriented();
159
160 field0Ptr_->timeIndex_ = timeIndex_ - 1;
161
162 if (!field0Ptr_->readOldTimeIfPresent())
163 {
164 field0Ptr_->oldTime();
165 }
166
167 return true;
168 }
169
170 return false;
171}
172
173
174// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
175
176template<class Type, template<class> class PatchField, class GeoMesh>
178(
179 const IOobject& io,
180 const Mesh& mesh,
181 const dimensionSet& dims,
182 const word& patchFieldType
183)
184:
185 Internal(io, mesh, dims, false, FieldBase::unifiedGeometricField),
186 timeIndex_(this->time().timeIndex()),
187 boundaryField_(mesh.boundary(), *this, patchFieldType)
188{
190 << "Creating" << nl << this->info() << endl;
191
192 readIfPresent();
193}
194
195
196template<class Type, template<class> class PatchField, class GeoMesh>
198(
199 const IOobject& io,
200 const Mesh& mesh,
201 const dimensionSet& dims,
202 const wordList& patchFieldTypes,
203 const wordList& actualPatchTypes
204)
205:
206 Internal(io, mesh, dims, false, FieldBase::unifiedGeometricField),
207 timeIndex_(this->time().timeIndex()),
208 boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
209{
211 << "Creating" << nl << this->info() << endl;
212
214}
215
216
217template<class Type, template<class> class PatchField, class GeoMesh>
219(
220 const IOobject& io,
221 const Mesh& mesh,
222 const Type& value,
223 const dimensionSet& dims,
224 const word& patchFieldType
225)
226:
227 Internal(io, mesh, value, dims, false, FieldBase::unifiedGeometricField),
228 timeIndex_(this->time().timeIndex()),
229 boundaryField_(mesh.boundary(), *this, patchFieldType)
230{
232 << "Creating" << nl << this->info() << endl;
233
234 boundaryField_ == value;
235
236 readIfPresent();
237}
238
239
240template<class Type, template<class> class PatchField, class GeoMesh>
242(
243 const IOobject& io,
244 const Mesh& mesh,
245 const Type& value,
246 const dimensionSet& dims,
247 const wordList& patchFieldTypes,
248 const wordList& actualPatchTypes
249)
250:
251 Internal(io, mesh, value, dims, false, FieldBase::unifiedGeometricField),
252 timeIndex_(this->time().timeIndex()),
253 boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
254{
256 << "Creating" << nl << this->info() << endl;
257
258 boundaryField_ == value;
259
260 readIfPresent();
261}
262
263
264template<class Type, template<class> class PatchField, class GeoMesh>
266(
267 const IOobject& io,
268 const Mesh& mesh,
269 const dimensioned<Type>& dt,
270 const word& patchFieldType
271)
272:
273 GeometricField<Type, PatchField, GeoMesh>
274 (
275 io,
276 mesh,
277 dt.value(),
279 patchFieldType
280 )
281{}
282
283
284template<class Type, template<class> class PatchField, class GeoMesh>
286(
287 const IOobject& io,
288 const Mesh& mesh,
289 const dimensioned<Type>& dt,
290 const wordList& patchFieldTypes,
291 const wordList& actualPatchTypes
292)
293:
294 GeometricField<Type, PatchField, GeoMesh>
295 (
296 io,
297 mesh,
298 dt.value(),
299 dt.dimensions(),
300 patchFieldTypes,
301 actualPatchTypes
302 )
303{}
304
305
306template<class Type, template<class> class PatchField, class GeoMesh>
308(
309 const IOobject& io,
310 const Internal& diField,
311 const PtrList<PatchField<Type>>& ptfl
312)
313:
314 Internal(io, diField),
315 timeIndex_(this->time().timeIndex()),
316 boundaryField_(this->mesh().boundary(), *this, ptfl)
317{
319 << "Copy construct from components" << nl << this->info() << endl;
320
321 readIfPresent();
322}
323
324
325template<class Type, template<class> class PatchField, class GeoMesh>
327(
328 const IOobject& io,
329 Internal&& diField,
330 const PtrList<PatchField<Type>>& ptfl
331)
332:
333 Internal(io, std::move(diField)),
334 timeIndex_(this->time().timeIndex()),
335 boundaryField_(this->mesh().boundary(), *this, ptfl)
336{
338 << "Move construct from components" << nl << this->info() << endl;
339
340 readIfPresent();
341}
342
343
344template<class Type, template<class> class PatchField, class GeoMesh>
346(
347 const IOobject& io,
348 const tmp<Internal>& tfield,
349 const PtrList<PatchField<Type>>& ptfl
350)
351:
352 Internal(io, tfield),
353 timeIndex_(this->time().timeIndex()),
354 boundaryField_(this->mesh().boundary(), *this, ptfl)
355{
357 << "Construct from tmp internalField" << nl << this->info() << endl;
358
359 readIfPresent();
360}
361
362
363template<class Type, template<class> class PatchField, class GeoMesh>
365(
366 const Internal& diField,
367 const PtrList<PatchField<Type>>& ptfl
368)
369:
370 Internal(diField),
371 timeIndex_(this->time().timeIndex()),
372 boundaryField_(this->mesh().boundary(), *this, ptfl)
373{
375 << "Copy construct from components" << nl << this->info() << endl;
376
377 readIfPresent();
378}
379
380
381template<class Type, template<class> class PatchField, class GeoMesh>
383(
384 Internal&& diField,
385 const PtrList<PatchField<Type>>& ptfl
386)
387:
388 Internal(std::move(diField)),
389 timeIndex_(this->time().timeIndex()),
390 boundaryField_(this->mesh().boundary(), *this, ptfl)
391{
393 << "Move construct from components" << nl << this->info() << endl;
394
395 readIfPresent();
396}
397
398
399template<class Type, template<class> class PatchField, class GeoMesh>
401(
402 const IOobject& io,
403 const Mesh& mesh,
404 const dimensionSet& dims,
405 const Field<Type>& iField,
406 const word& patchFieldType
407)
408:
409 Internal(io, mesh, dims, iField),
410 timeIndex_(this->time().timeIndex()),
411 boundaryField_(mesh.boundary(), *this, patchFieldType)
412{
414 << "Copy construct from primitive field" << nl << this->info() << endl;
415
416 readIfPresent();
417}
418
419
420template<class Type, template<class> class PatchField, class GeoMesh>
422(
423 const IOobject& io,
424 const Mesh& mesh,
425 const dimensionSet& dims,
426 Field<Type>&& iField,
427 const word& patchFieldType
428)
429:
430 Internal(io, mesh, dims, std::move(iField)),
431 timeIndex_(this->time().timeIndex()),
432 boundaryField_(mesh.boundary(), *this, patchFieldType)
433{
435 << "Move construct from primitive field" << nl << this->info() << endl;
436
437 readIfPresent();
438}
439
440
441template<class Type, template<class> class PatchField, class GeoMesh>
443(
444 const IOobject& io,
445 const Mesh& mesh,
446 const dimensionSet& dims,
447 const tmp<Field<Type>>& tfield,
448 const word& patchFieldType
449)
450:
451 Internal(io, mesh, dims, tfield),
452 timeIndex_(this->time().timeIndex()),
453 boundaryField_(mesh.boundary(), *this, patchFieldType)
454{
456 << "Construct from tmp primitive field" << nl << this->info() << endl;
457
458 readIfPresent();
459}
460
461
462template<class Type, template<class> class PatchField, class GeoMesh>
464(
465 const IOobject& io,
466 const Mesh& mesh,
467 const dimensionSet& dims,
468 const Field<Type>& iField,
469 const PtrList<PatchField<Type>>& ptfl
470)
471:
472 Internal(io, mesh, dims, iField),
473 timeIndex_(this->time().timeIndex()),
474 boundaryField_(mesh.boundary(), *this, ptfl)
475{
477 << "Copy construct from components" << nl << this->info() << endl;
478
479 readIfPresent();
480}
481
482
483template<class Type, template<class> class PatchField, class GeoMesh>
485(
486 const IOobject& io,
487 const Mesh& mesh,
488 const dimensionSet& dims,
489 Field<Type>&& iField,
490 const PtrList<PatchField<Type>>& ptfl
491)
492:
493 Internal(io, mesh, dims, std::move(iField)),
494 timeIndex_(this->time().timeIndex()),
495 boundaryField_(mesh.boundary(), *this, ptfl)
496{
498 << "Move construct from components" << nl << this->info() << endl;
499
500 readIfPresent();
501}
502
503
504template<class Type, template<class> class PatchField, class GeoMesh>
506(
507 const IOobject& io,
508 const Mesh& mesh,
509 const dimensionSet& dims,
510 const tmp<Field<Type>>& tfield,
511 const PtrList<PatchField<Type>>& ptfl
512)
513:
514 Internal(io, mesh, dims, tfield),
515 timeIndex_(this->time().timeIndex()),
516 boundaryField_(mesh.boundary(), *this, ptfl)
517{
519 << "Construct from tmp internalField" << nl << this->info() << endl;
520
521 readIfPresent();
522}
523
524
525template<class Type, template<class> class PatchField, class GeoMesh>
527(
528 const IOobject& io,
529 const Mesh& mesh,
530 const bool readOldTime
531)
532:
534 timeIndex_(this->time().timeIndex()),
535 boundaryField_(mesh.boundary())
536{
538 << "Read construct" << nl << this->info() << endl;
539
540 if (!this->isAnyRead())
541 {
542 // Do not warn about LAZY_READ since we may have already checked
543 // the IOobject before calling.
545 << "Had readOption NO_READ for field "
546 << this->name() << ", but constructor always reads field!"
547 << endl;
548 }
549
550 readFields();
551
552 if (readOldTime)
553 {
554 readOldTimeIfPresent();
555 }
558 << "Finishing read-construction" << nl << this->info() << endl;
559}
560
561
562template<class Type, template<class> class PatchField, class GeoMesh>
564(
565 const IOobject& io,
566 const Mesh& mesh,
567 const dictionary& dict
568)
569:
570 Internal(io, mesh, dimless, false, FieldBase::unifiedGeometricField),
571 timeIndex_(this->time().timeIndex()),
572 boundaryField_(mesh.boundary())
573{
577 << "Finishing dictionary-construct" << nl << this->info() << endl;
578}
579
580
581template<class Type, template<class> class PatchField, class GeoMesh>
583(
585)
586:
587 Internal(gf),
588 timeIndex_(gf.timeIndex()),
589 boundaryField_(*this, gf.boundaryField_)
590{
592 << "Copy construct" << nl << this->info() << endl;
593
594 if (gf.field0Ptr_)
595 {
596 field0Ptr_ = std::make_unique<this_type>(*gf.field0Ptr_);
598
600}
601
602
603template<class Type, template<class> class PatchField, class GeoMesh>
605(
606 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
607)
608:
609 Internal(tgf.constCast(), tgf.movable()),
610 timeIndex_(tgf().timeIndex()),
611 boundaryField_(*this, tgf().boundaryField_)
612{
614 << "Constructing from tmp" << nl << this->info() << endl;
615
617
618 tgf.clear();
619}
620
621
622template<class Type, template<class> class PatchField, class GeoMesh>
624(
625 const IOobject& io,
627)
628:
629 Internal(io, gf),
630 timeIndex_(gf.timeIndex()),
631 boundaryField_(*this, gf.boundaryField_)
632{
634 << "Copy construct, resetting IO params" << nl
635 << this->info() << endl;
636
637 if (!readIfPresent() && gf.field0Ptr_)
638 {
639 field0Ptr_ = std::make_unique<this_type>
640 (
641 io.name() + "_0",
642 *gf.field0Ptr_
643 );
644 }
645}
646
647
648template<class Type, template<class> class PatchField, class GeoMesh>
650(
651 const IOobject& io,
652 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
653)
654:
655 Internal(io, tgf.constCast(), tgf.movable()),
656 timeIndex_(tgf().timeIndex()),
657 boundaryField_(*this, tgf().boundaryField_)
658{
660 << "Constructing from tmp resetting IO params" << nl
661 << this->info() << endl;
662
663 tgf.clear();
664
665 readIfPresent();
666}
667
668
669template<class Type, template<class> class PatchField, class GeoMesh>
671(
672 const word& newName,
674)
675:
676 Internal(newName, gf),
677 timeIndex_(gf.timeIndex()),
678 boundaryField_(*this, gf.boundaryField_)
679{
681 << "Copy construct, resetting name" << nl
682 << this->info() << endl;
683
684 if (!readIfPresent() && gf.field0Ptr_)
685 {
686 field0Ptr_ = std::make_unique<this_type>
687 (
688 newName + "_0",
689 *gf.field0Ptr_
690 );
691 }
692}
693
694
695template<class Type, template<class> class PatchField, class GeoMesh>
697(
698 const word& newName,
699 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
700)
701:
702 Internal(newName, tgf.constCast(), tgf.movable()),
703 timeIndex_(tgf().timeIndex()),
704 boundaryField_(*this, tgf().boundaryField_)
705{
707 << "Constructing from tmp resetting name" << nl
708 << this->info() << endl;
709
710 tgf.clear();
711}
712
713
714template<class Type, template<class> class PatchField, class GeoMesh>
716(
717 const IOobject& io,
719 const word& patchFieldType
720)
721:
722 Internal(io, gf),
723 timeIndex_(gf.timeIndex()),
724 boundaryField_(this->mesh().boundary(), *this, patchFieldType)
725{
727 << "Copy construct, resetting IO params" << nl
728 << this->info() << endl;
729
730 boundaryField_ == gf.boundaryField_;
731
732 if (!readIfPresent() && gf.field0Ptr_)
733 {
734 field0Ptr_ = std::make_unique<this_type>
735 (
736 io.name() + "_0",
737 *gf.field0Ptr_
738 );
739 }
740}
741
742
743template<class Type, template<class> class PatchField, class GeoMesh>
745(
746 const IOobject& io,
747 const GeometricField<Type, PatchField, GeoMesh>& gf,
748 const wordList& patchFieldTypes,
749 const wordList& actualPatchTypes
750)
751:
752 Internal(io, gf),
753 timeIndex_(gf.timeIndex()),
754 boundaryField_
755 (
756 this->mesh().boundary(),
757 *this,
758 patchFieldTypes,
759 actualPatchTypes
760 )
761{
763 << "Copy construct, resetting IO params and patch types" << nl
764 << this->info() << endl;
765
766 boundaryField_ == gf.boundaryField_;
767
768 if (!readIfPresent() && gf.field0Ptr_)
769 {
770 field0Ptr_ = std::make_unique<this_type>
771 (
772 io.name() + "_0",
773 *gf.field0Ptr_
774 );
775 }
776}
777
778
779template<class Type, template<class> class PatchField, class GeoMesh>
781(
782 const IOobject& io,
783 const GeometricField<Type, PatchField, GeoMesh>& gf,
784 const labelList& patchIDs,
785 const word& patchFieldType
786)
787:
788 Internal(io, gf),
789 timeIndex_(gf.timeIndex()),
790 boundaryField_(*this, gf.boundaryField_, patchIDs, patchFieldType)
791{
793 << "Copy construct, resetting IO params and setting patchFieldType "
794 << "for patchIDs" << nl
795 << this->info() << endl;
796
797 if (!readIfPresent() && gf.field0Ptr_)
798 {
799 field0Ptr_ = std::make_unique<this_type>
800 (
801 io.name() + "_0",
802 *gf.field0Ptr_
803 );
804 }
805}
806
807
808template<class Type, template<class> class PatchField, class GeoMesh>
810(
811 const IOobject& io,
812 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
813 const wordList& patchFieldTypes,
814 const wordList& actualPatchTypes
815)
816:
817 Internal(io, tgf.constCast(), tgf.movable()),
818 timeIndex_(tgf().timeIndex()),
819 boundaryField_
820 (
821 this->mesh().boundary(),
822 *this,
823 patchFieldTypes,
824 actualPatchTypes
825 )
826{
828 << "Constructing from tmp resetting IO params and patch types" << nl
829 << this->info() << endl;
830
831 boundaryField_ == tgf().boundaryField_;
833 tgf.clear();
834}
835
836
837template<class Type, template<class> class PatchField, class GeoMesh>
840{
842}
843
844
845// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
846
847template<class Type, template<class> class PatchField, class GeoMesh>
849{
850 /*
851 if (debug)
852 {
853 // Problem: temporary fields might have their internal field
854 // already stolen so boundary fields will not be able to access the
855 // internal field anymore
856 boundaryField_.check();
857 }
858 */
859
860 // FUTURE: register cache field info
861 // // this->db().cacheTemporaryObject(*this);
862}
864
865// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
866
867template<class Type, template<class> class PatchField, class GeoMesh>
868typename
871(
872 const bool updateAccessTime
873)
874{
875 if (updateAccessTime)
876 {
877 this->setUpToDate();
879 }
880 return *this;
881}
882
883
884template<class Type, template<class> class PatchField, class GeoMesh>
885typename
888(
889 const bool updateAccessTime
890)
891{
892 if (updateAccessTime)
893 {
894 this->setUpToDate();
895 storeOldTimes();
896 }
897 return *this;
898}
899
900
901template<class Type, template<class> class PatchField, class GeoMesh>
902typename
905(
906 const bool updateAccessTime
907)
908{
909 if (updateAccessTime)
910 {
911 this->setUpToDate();
912 storeOldTimes();
914 return boundaryField_;
915}
916
917
918template<class Type, template<class> class PatchField, class GeoMesh>
919Foam::label
921{
922 return (field0Ptr_ ? (field0Ptr_->nOldTimes() + 1) : 0);
923}
924
925
926template<class Type, template<class> class PatchField, class GeoMesh>
928{
929 if
930 (
931 field0Ptr_
932 && timeIndex_ != this->time().timeIndex()
933 && !this->name().ends_with("_0")
934 )
935 {
936 storeOldTime();
937 timeIndex_ = this->time().timeIndex();
938 }
940 // Correct time index
941 //timeIndex_ = this->time().timeIndex();
942}
943
944
945template<class Type, template<class> class PatchField, class GeoMesh>
947{
948 if (field0Ptr_)
949 {
950 field0Ptr_->storeOldTime();
951
953 << "Storing old time field for field" << nl << this->info() << endl;
954
955 *field0Ptr_ == *this;
956 field0Ptr_->timeIndex_ = timeIndex_;
957
958 if (field0Ptr_->field0Ptr_)
959 {
960 field0Ptr_->writeOpt(this->writeOpt());
962 }
963}
964
965
966template<class Type, template<class> class PatchField, class GeoMesh>
967const Foam::GeometricField<Type, PatchField, GeoMesh>&
969{
970 if (!field0Ptr_)
971 {
972 field0Ptr_ = std::make_unique<this_type>
973 (
975 (
976 this->name() + "_0",
977 this->time().timeName(),
978 this->db(),
981 this->registerObject()
982 ),
983 *this
984 );
985
986 if (debug)
987 {
989 << "created old time field " << field0Ptr_->info() << endl;
990
991 if (debug&2)
992 {
994 }
995 }
996 }
997 else
998 {
999 storeOldTimes();
1000 }
1002 return *field0Ptr_;
1003}
1004
1005
1006template<class Type, template<class> class PatchField, class GeoMesh>
1009{
1010 static_cast<const GeometricField<Type, PatchField, GeoMesh>&>(*this)
1012
1013 return *field0Ptr_;
1014}
1015
1017template<class Type, template<class> class PatchField, class GeoMesh>
1019{
1020 if (!fieldPrevIterPtr_)
1021 {
1023 << "Allocating previous iteration field" << nl
1024 << this->info() << endl;
1025
1026 fieldPrevIterPtr_ = std::make_unique<this_type>
1027 (
1028 this->name() + "PrevIter",
1029 *this
1030 );
1031 }
1032 else
1033 {
1034 *fieldPrevIterPtr_ == *this;
1035 }
1036}
1037
1038
1039template<class Type, template<class> class PatchField, class GeoMesh>
1043 if (!fieldPrevIterPtr_)
1044 {
1046 << "previous iteration field" << endl << this->info() << endl
1047 << " not stored."
1048 << " Use field.storePrevIter() at start of iteration."
1049 << abort(FatalError);
1051
1052 return *fieldPrevIterPtr_;
1053}
1054
1055
1056template<class Type, template<class> class PatchField, class GeoMesh>
1059 field0Ptr_.reset(nullptr);
1060 fieldPrevIterPtr_.reset(nullptr);
1061}
1062
1063
1064template<class Type, template<class> class PatchField, class GeoMesh>
1067{
1068 // updateAccessTime
1069 {
1070 this->setUpToDate();
1072 }
1073 boundaryField_.evaluate();
1074}
1075
1077template<class Type, template<class> class PatchField, class GeoMesh>
1080{
1081 // updateAccessTime
1082 {
1083 this->setUpToDate();
1084 storeOldTimes();
1086 boundaryField_.evaluateLocal();
1087}
1088
1089
1090template<class Type, template<class> class PatchField, class GeoMesh>
1091template<class Cop>
1093boundaryEvaluate(const Cop& cop)
1095 const label meshSize = GeoMesh::size(this->mesh());
1096 const label totalSize = GeoMesh::boundary_size(this->mesh()) + meshSize;
1097
1098 if (FOAM_UNLIKELY(meshSize != this->size() && totalSize != this->size()))
1099 {
1101 << "Problem : field:" << this->name()
1102 << " size:" << this->size()
1103 << " capacity:" << this->capacity()
1104 << " is not mesh size:" << meshSize
1105 << " or total size:" << totalSize
1106 << exit(FatalError);
1107 }
1108
1109 auto& fld = static_cast<DynamicField<Type>&>(*this);
1110
1111 // Resize primitive field to allow for internal+boundary fields
1112 // - avoid size doubling
1113 // - only copying the internal field without boundaries
1115 fld.reserve_exact(totalSize);
1116 fld.resize_copy(meshSize, totalSize);
1117
1118 // Populate the extra space with the flattened boundary values:
1119 for (const auto& pfld : this->boundaryField())
1120 {
1121 const label start = (meshSize + pfld.patch().offset());
1122 SubList<Type> slice(fld, pfld.size(), start);
1123 cop(pfld, slice);
1125
1126 return meshSize;
1127}
1128
1129
1130template<class Type, template<class> class PatchField, class GeoMesh>
1132{
1133 // Search all boundary conditions, if any are
1134 // fixed-value or mixed (Robin) do not set reference level for solution.
1135
1136 bool needRef = true;
1137
1138 for (const auto& pf : boundaryField_)
1139 {
1140 if (pf.fixesValue())
1142 needRef = false;
1143 break;
1144 }
1147 return returnReduceAnd(needRef);
1148}
1149
1150
1151template<class Type, template<class> class PatchField, class GeoMesh>
1153{
1155 << "Relaxing" << nl << this->info() << " by " << alpha << endl;
1156
1157 operator==(prevIter() + alpha*(*this - prevIter()));
1159
1160
1161template<class Type, template<class> class PatchField, class GeoMesh>
1163{
1164 word name = this->name();
1165
1166 if (this->mesh().data().isFinalIteration())
1167 {
1168 name += "Final";
1169 }
1170
1171 scalar relaxCoeff = 1;
1172
1173 if (this->mesh().relaxField(name, relaxCoeff))
1175 relax(relaxCoeff);
1176 }
1177}
1178
1179
1180template<class Type, template<class> class PatchField, class GeoMesh>
1182(
1183 bool final
1184) const
1185{
1186 if (final)
1188 return this->name() + "Final";
1190
1191 return this->name();
1192}
1193
1194
1195template<class Type, template<class> class PatchField, class GeoMesh>
1197(
1198 Ostream& os,
1199 label comm
1200) const
1201{
1202 MinMax<Type> range = Foam::minMax(*this, comm).value();
1204 os << "min/max(" << this->name() << ") = "
1205 << range.min() << ", " << range.max() << endl;
1206}
1207
1208
1209template<class Type, template<class> class PatchField, class GeoMesh>
1211writeData(Ostream& os) const
1212{
1213 this->internalField().writeData(os, "internalField");
1214 os << nl;
1215 this->boundaryField().writeEntry("boundaryField", os);
1216
1218 return os.good();
1220
1221
1222// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1223
1224template<class Type, template<class> class PatchField, class GeoMesh>
1227{
1229 (
1230 this->name() + ".T()",
1231 this->mesh(),
1232 this->dimensions()
1233 );
1234
1235 Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
1236 Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
1237
1238 return tresult;
1239}
1240
1241
1242template<class Type, template<class> class PatchField, class GeoMesh>
1244<
1246 <
1248 PatchField,
1249 GeoMesh
1250 >
1251>
1254 const direction d
1255) const
1256{
1258 (
1259 this->name() + ".component(" + Foam::name(d) + ')',
1260 this->mesh(),
1261 this->dimensions()
1262 );
1263
1264 Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
1265 Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
1266
1267 return tresult;
1268}
1269
1270
1271template<class Type, template<class> class PatchField, class GeoMesh>
1273(
1274 const direction d,
1275 const GeometricField
1276 <
1278 PatchField,
1279 GeoMesh
1280 >& gcf
1281)
1283 primitiveFieldRef().replace(d, gcf.primitiveField());
1284 boundaryFieldRef().replace(d, gcf.boundaryField());
1285}
1286
1287
1288template<class Type, template<class> class PatchField, class GeoMesh>
1290(
1291 const direction d,
1292 const dimensioned<cmptType>& ds
1295 primitiveFieldRef().replace(d, ds.value());
1296 boundaryFieldRef().replace(d, ds.value());
1297}
1298
1299
1300template<class Type, template<class> class PatchField, class GeoMesh>
1302(
1303 const Type& lower
1304)
1306 primitiveFieldRef().clamp_min(lower);
1307 boundaryFieldRef().clamp_min(lower);
1308}
1309
1310
1311template<class Type, template<class> class PatchField, class GeoMesh>
1313(
1314 const Type& upper
1315)
1317 primitiveFieldRef().clamp_max(upper);
1318 boundaryFieldRef().clamp_max(upper);
1319}
1320
1321
1322template<class Type, template<class> class PatchField, class GeoMesh>
1324(
1325 const dimensioned<Type>& lower
1327{
1328 this->clamp_min(lower.value());
1329}
1331
1332template<class Type, template<class> class PatchField, class GeoMesh>
1334(
1335 const dimensioned<Type>& upper
1337{
1338 this->clamp_max(upper.value());
1339}
1340
1341
1342template<class Type, template<class> class PatchField, class GeoMesh>
1344(
1346)
1347{
1348 primitiveFieldRef().clamp_min(lower.primitiveField());
1349 boundaryFieldRef().clamp_min(lower.boundaryField());
1353 boundaryField().check();
1354 }
1356
1357
1358template<class Type, template<class> class PatchField, class GeoMesh>
1360(
1362)
1363{
1364 primitiveFieldRef().clamp_max(upper.primitiveField());
1365 boundaryFieldRef().clamp_max(upper.boundaryField());
1369 boundaryField().check();
1370 }
1371}
1372
1373
1374template<class Type, template<class> class PatchField, class GeoMesh>
1376(
1377 const Type& lower,
1378 const Type& upper
1379)
1381 primitiveFieldRef().clamp_range(lower, upper);
1382 boundaryFieldRef().clamp_range(lower, upper);
1383}
1384
1385
1386template<class Type, template<class> class PatchField, class GeoMesh>
1388(
1389 const MinMax<Type>& range
1390)
1392 primitiveFieldRef().clamp_range(range.min(), range.max());
1393 boundaryFieldRef().clamp_range(range.min(), range.max());
1394}
1395
1396
1397template<class Type, template<class> class PatchField, class GeoMesh>
1399(
1400 const dimensioned<Type>& lower,
1401 const dimensioned<Type>& upper
1403{
1404 this->clamp_range(lower.value(), upper.value());
1405}
1406
1407
1408template<class Type, template<class> class PatchField, class GeoMesh>
1410(
1413{
1414 this->clamp_range(range.value());
1415}
1416
1417
1418template<class Type, template<class> class PatchField, class GeoMesh>
1421 primitiveFieldRef().negate();
1422 boundaryFieldRef().negate();
1423}
1424
1425
1426template<class Type, template<class> class PatchField, class GeoMesh>
1428{
1429 primitiveFieldRef().normalise();
1430 boundaryFieldRef().normalise();
1431}
1432
1433
1434// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1435
1436template<class Type, template<class> class PatchField, class GeoMesh>
1438(
1440)
1441{
1442 if (this == &gf)
1443 {
1444 return; // Self-assignment is a no-op
1445 }
1446
1447 checkField(*this, gf, "=");
1448
1449 // Only assign field contents not ID
1450
1451 internalFieldRef() = gf.internalField();
1452 boundaryFieldRef() = gf.boundaryField();
1453
1454 // Make sure any e.g. jump-cyclic are updated.
1455 boundaryFieldRef().evaluate_if
1457 [](const auto& pfld) { return pfld.constraintOverride(); }
1458 );
1459}
1460
1461
1462template<class Type, template<class> class PatchField, class GeoMesh>
1464(
1465 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
1466)
1467{
1468 const auto& gf = tgf();
1469
1470 if (this == &gf)
1471 {
1472 return; // Self-assignment is a no-op
1473 }
1474
1475 checkField(*this, gf, "=");
1476
1477 // Only assign field contents not ID
1478
1479 this->dimensions() = gf.dimensions();
1480 this->oriented() = gf.oriented();
1481
1482 if (tgf.movable())
1483 {
1484 // Transfer storage from the tmp
1485 primitiveFieldRef().transfer(tgf.constCast().primitiveFieldRef());
1486 }
1487 else
1488 {
1489 primitiveFieldRef() = gf.primitiveField();
1490 }
1491
1492 boundaryFieldRef() = gf.boundaryField();
1493
1494 tgf.clear();
1495
1496 // Make sure any e.g. jump-cyclic are updated.
1497 boundaryFieldRef().evaluate_if
1499 [](const auto& pfld) { return pfld.constraintOverride(); }
1500 );
1501}
1502
1503
1504template<class Type, template<class> class PatchField, class GeoMesh>
1506(
1507 const dimensioned<Type>& dt
1508)
1509{
1510 internalFieldRef() = dt;
1511 boundaryFieldRef() = dt.value();
1512
1513 // Make sure any e.g. jump-cyclic are updated.
1514 boundaryFieldRef().evaluate_if
1516 [](const auto& pfld) { return pfld.constraintOverride(); }
1517 );
1518}
1519
1521template<class Type, template<class> class PatchField, class GeoMesh>
1523{
1524 // No dimension checking
1527
1528 // Make sure any e.g. jump-cyclic are updated.
1529 boundaryFieldRef().evaluate_if
1531 [](const auto& pfld) { return pfld.constraintOverride(); }
1532 );
1533}
1534
1535
1536template<class Type, template<class> class PatchField, class GeoMesh>
1538(
1539 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
1540)
1541{
1542 const auto& gf = tgf();
1543
1544 checkField(*this, gf, "==");
1545
1546 // Only assign field contents not ID
1547
1548 internalFieldRef() = gf.internalField();
1549 boundaryFieldRef() == gf.boundaryField();
1550
1551 tgf.clear();
1552
1553 // Make sure any e.g. jump-cyclic are updated.
1554 boundaryFieldRef().evaluate_if
1556 [](const auto& pfld) { return pfld.constraintOverride(); }
1557 );
1558}
1559
1560
1561template<class Type, template<class> class PatchField, class GeoMesh>
1563(
1564 const dimensioned<Type>& dt
1565)
1566{
1567 internalFieldRef() = dt;
1568 boundaryFieldRef() == dt.value();
1569
1570 // Make sure any e.g. jump-cyclic are updated.
1571 boundaryFieldRef().evaluate_if
1573 [](const auto& pfld) { return pfld.constraintOverride(); }
1574 );
1575}
1576
1577
1578template<class Type, template<class> class PatchField, class GeoMesh>
1580{
1581 // No dimension checking
1583 boundaryFieldRef() == Foam::zero{};
1584
1585 // Make sure any e.g. jump-cyclic are updated.
1586 boundaryFieldRef().evaluate_if
1587 (
1588 [](const auto& pfld) { return pfld.constraintOverride(); }
1589 );
1590}
1591
1592
1593#define COMPUTED_ASSIGNMENT(TYPE, op) \
1594 \
1595template<class Type, template<class> class PatchField, class GeoMesh> \
1596void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1597( \
1598 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1599) \
1600{ \
1601 checkField(*this, gf, #op); \
1602 \
1603 internalFieldRef() op gf.internalField(); \
1604 boundaryFieldRef() op gf.boundaryField(); \
1605 \
1606 boundaryFieldRef().evaluate_if \
1607 ( \
1608 [](const auto& pfld) { return pfld.constraintOverride(); } \
1609 ); \
1610} \
1611 \
1612template<class Type, template<class> class PatchField, class GeoMesh> \
1613void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1614( \
1615 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1616) \
1617{ \
1618 operator op(tgf()); \
1619 tgf.clear(); \
1620 \
1621 boundaryFieldRef().evaluate_if \
1622 ( \
1623 [](const auto& pfld) { return pfld.constraintOverride(); } \
1624 ); \
1625} \
1626 \
1627template<class Type, template<class> class PatchField, class GeoMesh> \
1628void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1629( \
1630 const dimensioned<TYPE>& dt \
1631) \
1632{ \
1633 internalFieldRef() op dt; \
1634 boundaryFieldRef() op dt.value(); \
1636 boundaryFieldRef().evaluate_if \
1637 ( \
1638 [](const auto& pfld) { return pfld.constraintOverride(); } \
1639 ); \
1640}
1641
1642COMPUTED_ASSIGNMENT(Type, +=)
1643COMPUTED_ASSIGNMENT(Type, -=)
1644COMPUTED_ASSIGNMENT(scalar, *=)
1645COMPUTED_ASSIGNMENT(scalar, /=)
1646
1647#undef COMPUTED_ASSIGNMENT
1648
1649
1650// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
1651
1652template<class Type, template<class> class PatchField, class GeoMesh>
1653Foam::Ostream& Foam::operator<<
1654(
1655 Ostream& os,
1657)
1658{
1659 fld.writeData(os);
1660 return os;
1661}
1662
1663
1664template<class Type, template<class> class PatchField, class GeoMesh>
1665Foam::Ostream& Foam::operator<<
1666(
1667 Ostream& os,
1669)
1670{
1671 tfld().writeData(os);
1672 tfld.clear();
1673
1674 return os;
1676
1677
1678// * * * * * * * * * * * * * Expression Templates * * * * * * * * * * * * * //
1679
1680template<class Type, template<class> class PatchField, class GeoMesh>
1681template<typename E>
1683(
1684 const IOobject& io,
1685 const Mesh& mesh,
1687 <
1688 E,
1689 typename E::IntExpr,
1690 typename E::UncoupledPatchExpr,
1691 typename E::CoupledPatchExpr,
1692 typename E::value_type
1693 >& expr
1694)
1695:
1696 Internal(io, mesh, expr.dimensions(), false),
1697 timeIndex_(this->time().timeIndex()),
1698 boundaryField_(mesh.boundary(), *this, PatchField<Type>::calculatedType())
1699{
1701 << "Creating from expression " << nl << this->info() << endl;
1702
1703 bool hasRead = readIfPresent();
1704 if (!hasRead)
1705 {
1706 expr.evaluate(*this);
1707 }
1708}
1709
1710
1711template<class Type, template<class> class PatchField, class GeoMesh>
1712template<typename E>
1714(
1715 const word& name,
1716 const Mesh& mesh,
1717 const Expression::GeometricFieldExpression
1718 <
1719 E,
1720 typename E::IntExpr,
1721 typename E::UncoupledPatchExpr,
1722 typename E::CoupledPatchExpr,
1723 typename E::value_type
1724 >& expr
1725)
1726:
1727 Internal
1728 (
1729 IOobject
1730 (
1731 name,
1732 mesh.time().timeName(),
1733 mesh.thisDb()
1734 ),
1735 mesh,
1736 expr.dimensions(),
1737 false
1738 ),
1739 timeIndex_(this->time().timeIndex()),
1740 boundaryField_(mesh.boundary(), *this, PatchField<Type>::calculatedType())
1741{
1743 << "Creating from expression " << nl << this->info() << endl;
1744
1745 expr.evaluate(*this);
1746}
1748
1749template<class Type, template<class> class PatchField, class GeoMesh>
1751<
1753>
1757}
1758
1759
1760template<class Type, template<class> class PatchField, class GeoMesh>
1761template<typename E>
1763(
1765 <
1766 E,
1767 typename E::IntExpr,
1768 typename E::UncoupledPatchExpr,
1769 typename E::CoupledPatchExpr,
1770 typename E::value_type
1771 >& expr
1772)
1775}
1776
1777
1778template<class Type, template<class> class PatchField, class GeoMesh>
1779template<typename E>
1781(
1783 <
1784 E,
1785 typename E::IntExpr,
1786 typename E::UncoupledPatchExpr,
1787 typename E::CoupledPatchExpr,
1788 typename E::value_type
1789 >& expr
1790)
1791{
1792 expr.evaluate(*this, true);
1793}
1794
1795
1796// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1797
1798#undef checkField
1799
1800// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1801
1802#include "GeometricFieldNew.C"
1804
1805// ************************************************************************* //
#define checkField(fld1, fld2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
scalar range
Y[inertIndex] clamp_min(0)
propsDict readIfPresent("fields", acceptFields)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
labelList patchIDs
DynamicField< Type > FieldType
Type of the field from which this DimensionedField is derived.
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
orientedType oriented() const noexcept
Return oriented type.
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
label capacity() const noexcept
Expression wrap of const reference to GeometricField.
Expression wrap of non-const reference to GeometricField.
Container & evaluate(Container &lst) const
Helper: assign to passed in list.
Template invariant parts for Field and SubField.
Definition Field.H:85
static bool unifiedGeometricField
GeometricField with extra capacity for flattened boundary fields. Uses opt-switch "unifiedGeometricFi...
Definition Field.H:106
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
SubField< scalar > slice(const label pos, label len=-1)
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition GeoMesh.H:46
Generic GeometricField class.
Expression::GeometricFieldConstRefWrap< this_type > expr() const
Wrap value as expression.
void storeOldTime() const
Store the old-time field.
friend Ostream & operator(Ostream &, const GeometricField< Type, PatchField, GeoMesh > &)
Calls GeometricField::writeData().
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=PatchField< Type >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
DimensionedField< Type, GeoMesh > Internal
The internal field type from which this GeometricField is derived.
void clamp_range(const dimensioned< MinMax< Type > > &range)
Clamp field values (in-place) to the specified range.
label timeIndex() const noexcept
The time index of the field.
void relax()
Relax field (for steady-state solution).
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field).
GeoMesh::Mesh Mesh
The mesh type for the GeometricField.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
bool writeData(Ostream &os) const
The writeData function (required by regIOobject).
this_type & constCast() const noexcept
Return non-const reference to this field.
GeometricField(const IOobject &io, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=PatchField< Type >::calculatedType())
Construct given IOobject, mesh, dimensions and patch type.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
void operator==(const tmp< GeometricField< Type, PatchField, GeoMesh > > &)
void clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place).
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
Type of boundary fields.
label nOldTimes() const noexcept
The number of old time fields stored.
const Internal::FieldType & primitiveField() const noexcept
void correctLocalBoundaryConditions()
Correct boundary conditions after a purely local operation.
Field< Type >::cmptType cmptType
Component type of the field elements.
Internal & internalFieldRef(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
bool needReference() const
Does the field need a reference level for solution.
label boundaryEvaluate(const Cop &cop)
Evaluate boundary functions using the field storage:
virtual ~GeometricField()
Destructor.
void negate()
Negate the field inplace. See notes in Field.
void clamp_max(const Type &upper)
Impose upper (ceiling) clamp on the field values (in-place).
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 by returning the field name + "Final" otherwis...
void storeOldTimes() const
Store the old-time fields.
void correctBoundaryConditions()
Correct boundary field.
void normalise()
Normalise the field inplace. See notes in Field.
void operator=(const GeometricField< Type, PatchField, GeoMesh > &)
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
void writeMinMax(Ostream &os, label comm=UPstream::worldComm) const
Helper function to write the min and max to an Ostream.
void clearOldTimes()
Remove old-time and prev-iter fields.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
bool isAnyRead() const noexcept
True if any reading may be required (ie, != NO_READ).
writeOption writeOpt() const noexcept
Get the write option.
bool registerObject() const noexcept
Should objects created with this IOobject be registered?
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
static bool isAnyRead(readOption opt) noexcept
True if any reading may be required (ie, != NO_READ).
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition IOobject.C:450
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
Definition IOobject.H:1041
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition MinMax.H:106
const T & min() const noexcept
The min value.
Definition MinMax.H:207
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition PtrListI.H:98
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
scalar * data() noexcept
void size(const label n)
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Generic dimensioned Type class.
const Type & value() const noexcept
Return const reference to value.
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
void setUpToDate()
Set as up-to-date.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
UEqn relax()
rDeltaTY field()
bool local
Definition EEqn.H:20
faceListList boundary
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
const auto & io
auto & name
rho clamp_range(rhoMin[i], rhoMax[i])
word timeName
Definition getTimeIndex.H:3
#define WarningInFunction
Report a warning using Foam::Warning.
#define FUNCTION_NAME
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
Definition debug.C:45
List< word > wordList
List of word.
Definition fileName.H:60
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
const dimensionSet dimless
Dimensionless.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
List< label > labelList
A List of labels.
Definition List.H:62
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
messageStream Info
Information stream (stdout output on master, null elsewhere).
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition hashSets.C:54
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
errorManip< error > abort(error &err)
Definition errorManip.H:139
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
label timeIndex
volScalarField & alpha
dictionary dict
Us boundaryFieldRef().evaluateCoupled< coupledFaPatch >()
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
#define FOAM_UNLIKELY(cond)
Definition stdFoam.H:64
conserve primitiveFieldRef()+