1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "GeometricField.H"
29 #include "demandDrivenData.H"
30 #include "dictionary.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // check mesh for two fields
36 #define checkField(gf1, gf2, op) \
37 if ((gf1).mesh() != (gf2).mesh()) \
39 FatalErrorIn("checkField(gf1, gf2, op)") \
40 << "different mesh for fields " \
41 << (gf1).name() << " and " << (gf2).name() \
42 << " during operatrion " << op \
43 << abort(FatalError); \
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
49 template<class Type, template<class> class PatchField, class GeoMesh>
52 typename Foam::GeometricField<Type, PatchField, GeoMesh>::
53 GeometricBoundaryField
55 Foam::GeometricField<Type, PatchField, GeoMesh>::readField
57 const dictionary& fieldDict
60 DimensionedField<Type, GeoMesh>::readField(fieldDict, "internalField");
62 tmp<GeometricBoundaryField> tboundaryField
64 new GeometricBoundaryField
66 this->mesh().boundary(),
68 fieldDict.subDict("boundaryField")
72 if (fieldDict.found("referenceLevel"))
74 Type fieldAverage(pTraits<Type>(fieldDict.lookup("referenceLevel")));
76 Field<Type>::operator+=(fieldAverage);
78 GeometricBoundaryField& boundaryField = tboundaryField();
80 forAll(boundaryField, patchi)
82 boundaryField[patchi] == boundaryField[patchi] + fieldAverage;
86 return tboundaryField;
90 template<class Type, template<class> class PatchField, class GeoMesh>
93 typename Foam::GeometricField<Type, PatchField, GeoMesh>::
94 GeometricBoundaryField
96 Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
98 if (is.version() < 2.0)
102 "GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
104 ) << "IO versions < 2.0 are not supported."
105 << exit(FatalIOError);
108 return readField(dictionary(is));
112 template<class Type, template<class> class PatchField, class GeoMesh>
113 bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
115 if (this->readOpt() == IOobject::MUST_READ)
119 "GeometricField<Type, PatchField, GeoMesh>::readIfPresent()"
120 ) << "read option IOobject::MUST_READ "
121 << "suggests that a read constructor for field " << this->name()
122 << " would be more appropriate." << endl;
124 else if (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
126 boundaryField_.transfer(readField(this->readStream(typeName))());
129 // Check compatibility between field and mesh
130 if (this->size() != GeoMesh::size(this->mesh()))
134 "GeometricField<Type, PatchField, GeoMesh>::"
136 this->readStream(typeName)
137 ) << " number of field elements = " << this->size()
138 << " number of mesh elements = "
139 << GeoMesh::size(this->mesh())
140 << exit(FatalIOError);
143 readOldTimeIfPresent();
152 template<class Type, template<class> class PatchField, class GeoMesh>
153 bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
155 // Read the old time field if present
159 this->time().timeName(),
161 IOobject::READ_IF_PRESENT,
165 if (field0.headerOk())
169 Info<< "Reading old time level for field"
170 << endl << this->info() << endl;
173 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
179 field0Ptr_->timeIndex_ = timeIndex_ - 1;
181 if (!field0Ptr_->readOldTimeIfPresent())
183 field0Ptr_->oldTime();
193 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
195 // Constructor given a GeometricField and dimensionSet
196 // This allocates storage for the field but not values.
197 // Note : This constructor should only be used to
198 // construct TEMPORARY variables
199 template<class Type, template<class> class PatchField, class GeoMesh>
200 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
204 const dimensionSet& ds,
205 const word& patchFieldType
208 DimensionedField<Type, GeoMesh>(io, mesh, ds),
209 timeIndex_(this->time().timeIndex()),
211 fieldPrevIterPtr_(NULL),
212 boundaryField_(mesh.boundary(), *this, patchFieldType)
216 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
218 << endl << this->info() << endl;
225 // Constructor given a GeometricField and dimensionSet
226 // This allocates storage for the field but not values.
227 // Note : This constructor should only be used to
228 // construct TEMPORARY variables
229 template<class Type, template<class> class PatchField, class GeoMesh>
230 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
234 const dimensionSet& ds,
235 const wordList& patchFieldTypes
238 DimensionedField<Type, GeoMesh>(io, mesh, ds),
239 timeIndex_(this->time().timeIndex()),
241 fieldPrevIterPtr_(NULL),
242 boundaryField_(mesh.boundary(), *this, patchFieldTypes)
246 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
248 << endl << this->info() << endl;
255 // Constructor given a GeometricField and dimensioned<Type>
256 template<class Type, template<class> class PatchField, class GeoMesh>
257 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
261 const dimensioned<Type>& dt,
262 const word& patchFieldType
265 DimensionedField<Type, GeoMesh>(io, mesh, dt),
266 timeIndex_(this->time().timeIndex()),
268 fieldPrevIterPtr_(NULL),
269 boundaryField_(mesh.boundary(), *this, patchFieldType)
273 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
275 << endl << this->info() << endl;
278 boundaryField_ == dt.value();
284 // Constructor given a GeometricField and dimensioned<Type>
285 template<class Type, template<class> class PatchField, class GeoMesh>
286 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
290 const dimensioned<Type>& dt,
291 const wordList& patchFieldTypes
294 DimensionedField<Type, GeoMesh>(io, mesh, dt),
295 timeIndex_(this->time().timeIndex()),
297 fieldPrevIterPtr_(NULL),
298 boundaryField_(mesh.boundary(), *this, patchFieldTypes)
302 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
304 << endl << this->info() << endl;
307 boundaryField_ == dt.value();
313 // construct from components
314 template<class Type, template<class> class PatchField, class GeoMesh>
315 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
319 const dimensionSet& ds,
320 const Field<Type>& iField,
321 const PtrList<PatchField<Type> >& ptfl
324 DimensionedField<Type, GeoMesh>(io, mesh, ds, iField),
325 timeIndex_(this->time().timeIndex()),
327 fieldPrevIterPtr_(NULL),
328 boundaryField_(mesh.boundary(), *this, ptfl)
332 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
333 "constructing from components"
334 << endl << this->info() << endl;
341 template<class Type, template<class> class PatchField, class GeoMesh>
342 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
348 DimensionedField<Type, GeoMesh>(io, mesh, dimless),
349 timeIndex_(this->time().timeIndex()),
351 fieldPrevIterPtr_(NULL),
352 boundaryField_(*this, readField(this->readStream(typeName)))
356 // Check compatibility between field and mesh
358 if (this->size() != GeoMesh::size(this->mesh()))
362 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
363 "(const IOobject&, const Mesh&)",
364 this->readStream(typeName)
365 ) << " number of field elements = " << this->size()
366 << " number of mesh elements = " << GeoMesh::size(this->mesh())
367 << exit(FatalIOError);
370 readOldTimeIfPresent();
374 Info<< "Finishing read-construct of "
375 "GeometricField<Type, PatchField, GeoMesh>"
376 << endl << this->info() << endl;
381 template<class Type, template<class> class PatchField, class GeoMesh>
382 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
389 DimensionedField<Type, GeoMesh>(io, mesh, dimless),
390 timeIndex_(this->time().timeIndex()),
392 fieldPrevIterPtr_(NULL),
393 boundaryField_(*this, readField(is))
395 // Check compatibility between field and mesh
397 if (this->size() != GeoMesh::size(this->mesh()))
401 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
402 "(const IOobject&, const Mesh&, Istream&)",
404 ) << " number of field elements = " << this->size()
405 << " number of mesh elements = " << GeoMesh::size(this->mesh())
406 << exit(FatalIOError);
409 readOldTimeIfPresent();
413 Info<< "Finishing read-construct of "
414 "GeometricField<Type, PatchField, GeoMesh>"
415 << endl << this->info() << endl;
420 template<class Type, template<class> class PatchField, class GeoMesh>
421 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
425 const dictionary& dict
428 DimensionedField<Type, GeoMesh>(io, mesh, dimless),
429 timeIndex_(this->time().timeIndex()),
431 fieldPrevIterPtr_(NULL),
432 boundaryField_(*this, readField(dict))
434 // Check compatibility between field and mesh
436 if (this->size() != GeoMesh::size(this->mesh()))
440 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
441 "(const IOobject&, const Mesh&, const dictionary&)"
442 ) << " number of field elements = " << this->size()
443 << " number of mesh elements = " << GeoMesh::size(this->mesh())
444 << exit(FatalIOError);
447 readOldTimeIfPresent();
451 Info<< "Finishing dictionary-construct of "
452 "GeometricField<Type, PatchField, GeoMesh>"
453 << endl << this->info() << endl;
459 template<class Type, template<class> class PatchField, class GeoMesh>
460 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
462 const GeometricField<Type, PatchField, GeoMesh>& gf
465 DimensionedField<Type, GeoMesh>(gf),
466 timeIndex_(gf.timeIndex()),
468 fieldPrevIterPtr_(NULL),
469 boundaryField_(*this, gf.boundaryField_)
473 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
474 "constructing as copy"
475 << endl << this->info() << endl;
480 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
486 this->writeOpt() = IOobject::NO_WRITE;
489 // construct as copy of tmp<GeometricField> deleting argument
490 #ifdef ConstructFromTmp
491 template<class Type, template<class> class PatchField, class GeoMesh>
492 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
494 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
497 DimensionedField<Type, GeoMesh>
499 const_cast<GeometricField<Type, PatchField, GeoMesh>&>(tgf()),
502 timeIndex_(tgf().timeIndex()),
504 fieldPrevIterPtr_(NULL),
505 boundaryField_(*this, tgf().boundaryField_)
509 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
510 "constructing as copy"
511 << endl << this->info() << endl;
514 this->writeOpt() = IOobject::NO_WRITE;
521 // construct as copy resetting IO parameters
522 template<class Type, template<class> class PatchField, class GeoMesh>
523 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
526 const GeometricField<Type, PatchField, GeoMesh>& gf
529 DimensionedField<Type, GeoMesh>(io, gf),
530 timeIndex_(gf.timeIndex()),
532 fieldPrevIterPtr_(NULL),
533 boundaryField_(*this, gf.boundaryField_)
537 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
538 "constructing as copy resetting IO params"
539 << endl << this->info() << endl;
542 if (!readIfPresent() && gf.field0Ptr_)
544 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
553 // construct as copy resetting name
554 template<class Type, template<class> class PatchField, class GeoMesh>
555 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
558 const GeometricField<Type, PatchField, GeoMesh>& gf
561 DimensionedField<Type, GeoMesh>(newName, gf),
562 timeIndex_(gf.timeIndex()),
564 fieldPrevIterPtr_(NULL),
565 boundaryField_(*this, gf.boundaryField_)
569 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
570 "constructing as copy resetting name"
571 << endl << this->info() << endl;
574 if (!readIfPresent() && gf.field0Ptr_)
576 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
585 // construct as copy resetting name
586 #ifdef ConstructFromTmp
587 template<class Type, template<class> class PatchField, class GeoMesh>
588 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
591 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
594 DimensionedField<Type, GeoMesh>
597 const_cast<GeometricField<Type, PatchField, GeoMesh>&>(tgf()),
600 timeIndex_(tgf().timeIndex()),
602 fieldPrevIterPtr_(NULL),
603 boundaryField_(*this, tgf().boundaryField_)
607 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
608 "constructing from tmp resetting name"
609 << endl << this->info() << endl;
616 // construct as copy resetting IO parameters and patch type
617 template<class Type, template<class> class PatchField, class GeoMesh>
618 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
621 const GeometricField<Type, PatchField, GeoMesh>& gf,
622 const word& patchFieldType
625 DimensionedField<Type, GeoMesh>(io, gf),
626 timeIndex_(gf.timeIndex()),
628 fieldPrevIterPtr_(NULL),
629 boundaryField_(this->mesh().boundary(), *this, patchFieldType)
633 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
634 "constructing as copy resetting IO params"
635 << endl << this->info() << endl;
638 boundaryField_ == gf.boundaryField_;
640 if (!readIfPresent() && gf.field0Ptr_)
642 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
651 // construct as copy resetting IO parameters and boundary types
652 template<class Type, template<class> class PatchField, class GeoMesh>
653 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
656 const GeometricField<Type, PatchField, GeoMesh>& gf,
657 const wordList& patchFieldTypes
660 DimensionedField<Type, GeoMesh>(io, gf),
661 timeIndex_(gf.timeIndex()),
663 fieldPrevIterPtr_(NULL),
664 boundaryField_(this->mesh().boundary(), *this, patchFieldTypes)
668 Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
669 "constructing as copy resetting IO params"
670 << endl << this->info() << endl;
673 boundaryField_ == gf.boundaryField_;
675 if (!readIfPresent() && gf.field0Ptr_)
677 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
686 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
688 template<class Type, template<class> class PatchField, class GeoMesh>
689 Foam::GeometricField<Type, PatchField, GeoMesh>::~GeometricField()
691 deleteDemandDrivenData(field0Ptr_);
692 deleteDemandDrivenData(fieldPrevIterPtr_);
696 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
698 template<class Type, template<class> class PatchField, class GeoMesh>
700 Foam::GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField&
701 Foam::GeometricField<Type, PatchField, GeoMesh>::dimensionedInternalField()
709 template<class Type, template<class> class PatchField, class GeoMesh>
711 Foam::GeometricField<Type, PatchField, GeoMesh>::InternalField&
712 Foam::GeometricField<Type, PatchField, GeoMesh>::internalField()
720 // Return reference to GeometricBoundaryField
721 template<class Type, template<class> class PatchField, class GeoMesh>
723 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField&
724 Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField()
728 return boundaryField_;
732 // Store old-time field
733 template<class Type, template<class> class PatchField, class GeoMesh>
734 void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
739 && timeIndex_ != this->time().timeIndex()
741 this->name().size() > 2
742 && this->name()(this->name().size()-2, 2) == "_0"
749 // Correct time index
750 timeIndex_ = this->time().timeIndex();
753 // Store old-time field
754 template<class Type, template<class> class PatchField, class GeoMesh>
755 void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTime() const
759 field0Ptr_->storeOldTime();
763 Info<< "Storing old time field for field" << endl
764 << this->info() << endl;
767 *field0Ptr_ == *this;
768 field0Ptr_->timeIndex_ = timeIndex_;
770 if (field0Ptr_->field0Ptr_)
772 field0Ptr_->writeOpt() = this->writeOpt();
777 // Return the number of old time fields stored
778 template<class Type, template<class> class PatchField, class GeoMesh>
779 Foam::label Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const
783 return field0Ptr_->nOldTimes() + 1;
791 // Return old time internal field
792 template<class Type, template<class> class PatchField, class GeoMesh>
793 const Foam::GeometricField<Type, PatchField, GeoMesh>&
794 Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const
798 field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
803 this->time().timeName(),
817 // Return old time internal field
818 template<class Type, template<class> class PatchField, class GeoMesh>
819 Foam::GeometricField<Type, PatchField, GeoMesh>&
820 Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime()
822 static_cast<const GeometricField<Type, PatchField, GeoMesh>&>(*this)
829 // Store previous iteration field
830 template<class Type, template<class> class PatchField, class GeoMesh>
831 void Foam::GeometricField<Type, PatchField, GeoMesh>::storePrevIter() const
833 if (!fieldPrevIterPtr_)
837 Info<< "Allocating previous iteration field" << endl
838 << this->info() << endl;
841 fieldPrevIterPtr_ = new GeometricField<Type, PatchField, GeoMesh>
843 this->name() + "PrevIter",
849 *fieldPrevIterPtr_ == *this;
854 // Return previous iteration field
855 template<class Type, template<class> class PatchField, class GeoMesh>
856 const Foam::GeometricField<Type, PatchField, GeoMesh>&
857 Foam::GeometricField<Type, PatchField, GeoMesh>::prevIter() const
859 if (!fieldPrevIterPtr_)
863 "GeometricField<Type, PatchField, GeoMesh>::prevIter() const"
864 ) << "previous iteration field" << endl << this->info() << endl
866 << " Use field.storePrevIter() at start of iteration."
867 << abort(FatalError);
870 return *fieldPrevIterPtr_;
874 // Correct the boundary conditions
875 template<class Type, template<class> class PatchField, class GeoMesh>
876 void Foam::GeometricField<Type, PatchField, GeoMesh>::
877 correctBoundaryConditions()
881 boundaryField_.evaluate();
885 // Does the field need a reference level for solution
886 template<class Type, template<class> class PatchField, class GeoMesh>
887 bool Foam::GeometricField<Type, PatchField, GeoMesh>::needReference() const
889 // Search all boundary conditions, if any are
890 // fixed-value or mixed (Robin) do not set reference level for solution.
894 forAll(boundaryField_, patchi)
896 if (boundaryField_[patchi].fixesValue())
903 reduce(needRef, andOp<bool>());
909 template<class Type, template<class> class PatchField, class GeoMesh>
910 void Foam::GeometricField<Type, PatchField, GeoMesh>::relax(const scalar alpha)
912 operator==(prevIter() + alpha*(*this - prevIter()));
916 template<class Type, template<class> class PatchField, class GeoMesh>
917 void Foam::GeometricField<Type, PatchField, GeoMesh>::relax()
921 if (this->mesh().relax(this->name()))
923 alpha = this->mesh().relaxationFactor(this->name());
933 // writeData member function required by regIOobject
934 template<class Type, template<class> class PatchField, class GeoMesh>
935 bool Foam::GeometricField<Type, PatchField, GeoMesh>::
936 writeData(Ostream& os) const
943 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
945 template<class Type, template<class> class PatchField, class GeoMesh>
946 Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >
947 Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
949 tmp<GeometricField<Type, PatchField, GeoMesh> > result
951 new GeometricField<Type, PatchField, GeoMesh>
955 this->name() + ".T()",
964 Foam::T(result().internalField(), internalField());
965 Foam::T(result().boundaryField(), boundaryField());
971 template<class Type, template<class> class PatchField, class GeoMesh>
976 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
981 Foam::GeometricField<Type, PatchField, GeoMesh>::component
986 tmp<GeometricField<cmptType, PatchField, GeoMesh> > Component
988 new GeometricField<cmptType, PatchField, GeoMesh>
992 this->name() + ".component(" + Foam::name(d) + ')',
1001 Foam::component(Component().internalField(), internalField(), d);
1002 Foam::component(Component().boundaryField(), boundaryField(), d);
1008 template<class Type, template<class> class PatchField, class GeoMesh>
1009 void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
1012 const GeometricField
1014 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
1020 internalField().replace(d, gcf.internalField());
1021 boundaryField().replace(d, gcf.boundaryField());
1025 template<class Type, template<class> class PatchField, class GeoMesh>
1026 void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
1029 const dimensioned<cmptType>& ds
1032 internalField().replace(d, ds.value());
1033 boundaryField().replace(d, ds.value());
1037 template<class Type, template<class> class PatchField, class GeoMesh>
1038 void Foam::GeometricField<Type, PatchField, GeoMesh>::max
1040 const dimensioned<Type>& dt
1043 Foam::max(internalField(), internalField(), dt.value());
1044 Foam::max(boundaryField(), boundaryField(), dt.value());
1048 template<class Type, template<class> class PatchField, class GeoMesh>
1049 void Foam::GeometricField<Type, PatchField, GeoMesh>::min
1051 const dimensioned<Type>& dt
1054 Foam::min(internalField(), internalField(), dt.value());
1055 Foam::min(boundaryField(), boundaryField(), dt.value());
1059 template<class Type, template<class> class PatchField, class GeoMesh>
1060 void Foam::GeometricField<Type, PatchField, GeoMesh>::negate()
1062 internalField().negate();
1063 boundaryField().negate();
1067 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1069 template<class Type, template<class> class PatchField, class GeoMesh>
1070 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1072 const GeometricField<Type, PatchField, GeoMesh>& gf
1079 "GeometricField<Type, PatchField, GeoMesh>::operator="
1080 "(const GeometricField<Type, PatchField, GeoMesh>&)"
1081 ) << "attempted assignment to self"
1082 << abort(FatalError);
1085 checkField(*this, gf, "=");
1087 // only equate field contents not ID
1089 dimensionedInternalField() = gf.dimensionedInternalField();
1090 boundaryField() = gf.boundaryField();
1094 template<class Type, template<class> class PatchField, class GeoMesh>
1095 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1097 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
1100 if (this == &(tgf()))
1104 "GeometricField<Type, PatchField, GeoMesh>::operator="
1105 "(const tmp<GeometricField<Type, PatchField, GeoMesh> >&)"
1106 ) << "attempted assignment to self"
1107 << abort(FatalError);
1110 const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
1112 checkField(*this, gf, "=");
1114 // only equate field contents not ID
1116 this->dimensions() = gf.dimensions();
1118 // This is dodgy stuff, don't try it at home.
1119 internalField().transfer
1121 const_cast<Field<Type>&>(gf.internalField())
1124 boundaryField() = gf.boundaryField();
1130 template<class Type, template<class> class PatchField, class GeoMesh>
1131 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1133 const dimensioned<Type>& dt
1136 dimensionedInternalField() = dt;
1137 boundaryField() = dt.value();
1141 template<class Type, template<class> class PatchField, class GeoMesh>
1142 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1144 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
1147 const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
1149 checkField(*this, gf, "==");
1151 // only equate field contents not ID
1153 dimensionedInternalField() = gf.dimensionedInternalField();
1154 boundaryField() == gf.boundaryField();
1160 template<class Type, template<class> class PatchField, class GeoMesh>
1161 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1163 const dimensioned<Type>& dt
1166 dimensionedInternalField() = dt;
1167 boundaryField() == dt.value();
1171 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1173 template<class Type, template<class> class PatchField, class GeoMesh> \
1174 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1176 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1179 checkField(*this, gf, #op); \
1181 dimensionedInternalField() op gf.dimensionedInternalField(); \
1182 boundaryField() op gf.boundaryField(); \
1185 template<class Type, template<class> class PatchField, class GeoMesh> \
1186 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1188 const tmp<GeometricField<TYPE, PatchField, GeoMesh> >& tgf \
1191 operator op(tgf()); \
1195 template<class Type, template<class> class PatchField, class GeoMesh> \
1196 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1198 const dimensioned<TYPE>& dt \
1201 dimensionedInternalField() op dt; \
1202 boundaryField() op dt.value(); \
1205 COMPUTED_ASSIGNMENT(Type, +=)
1206 COMPUTED_ASSIGNMENT(Type, -=)
1207 COMPUTED_ASSIGNMENT(scalar, *=)
1208 COMPUTED_ASSIGNMENT(scalar, /=)
1210 #undef COMPUTED_ASSIGNMENT
1213 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
1215 template<class Type, template<class> class PatchField, class GeoMesh>
1216 Foam::Ostream& Foam::operator<<
1219 const GeometricField<Type, PatchField, GeoMesh>& gf
1222 gf.dimensionedInternalField().writeData(os, "internalField");
1224 gf.boundaryField().writeEntry("boundaryField", os);
1226 // Check state of IOstream
1229 "Ostream& operator<<(Ostream&, "
1230 "const GeometricField<Type, PatchField, GeoMesh>&)"
1237 template<class Type, template<class> class PatchField, class GeoMesh>
1238 Foam::Ostream& Foam::operator<<
1241 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
1250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1256 #include "GeometricBoundaryField.C"
1257 #include "GeometricFieldFunctions.C"
1259 // ************************************************************************* //