diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index df75d2ac64f332e64e68c1c2acc8da9a7ed67a2e..f6ec16baf73f7bf6f6203ad65c6214cdb98704c2 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -719,10 +719,16 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::~GeometricField() template<class Type, template<class> class PatchField, class GeoMesh> typename Foam::GeometricField<Type, PatchField, GeoMesh>::Internal& -Foam::GeometricField<Type, PatchField, GeoMesh>::ref() +Foam::GeometricField<Type, PatchField, GeoMesh>::ref +( + const bool updateAccessTime +) { - this->setUpToDate(); - storeOldTimes(); + if (updateAccessTime) + { + this->setUpToDate(); + storeOldTimes(); + } return *this; } @@ -730,10 +736,16 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::ref() template<class Type, template<class> class PatchField, class GeoMesh> typename Foam::GeometricField<Type, PatchField, GeoMesh>::Internal::FieldType& -Foam::GeometricField<Type, PatchField, GeoMesh>::primitiveFieldRef() +Foam::GeometricField<Type, PatchField, GeoMesh>::primitiveFieldRef +( + const bool updateAccessTime +) { - this->setUpToDate(); - storeOldTimes(); + if (updateAccessTime) + { + this->setUpToDate(); + storeOldTimes(); + } return *this; } @@ -741,10 +753,16 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::primitiveFieldRef() template<class Type, template<class> class PatchField, class GeoMesh> typename Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary& -Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryFieldRef() +Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryFieldRef +( + const bool updateAccessTime +) { - this->setUpToDate(); - storeOldTimes(); + if (updateAccessTime) + { + this->setUpToDate(); + storeOldTimes(); + } return boundaryField_; } @@ -796,10 +814,8 @@ Foam::label Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const { return field0Ptr_->nOldTimes() + 1; } - else - { - return 0; - } + + return 0; } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index d9ac7efa0ed5055ae836cf886f9344f2bbaf4ed9..8174985f757ad00e7e37eec841df457d2a63f237 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -266,7 +266,7 @@ private: // Private Member Functions //- Read the field from the dictionary - void readFields(const dictionary&); + void readFields(const dictionary& dict); //- Read the field - create the field dictionary on-the-fly void readFields(); @@ -475,30 +475,39 @@ public: // Member Functions //- Return a reference to the dimensioned internal field - // Note: this increments the event counter and checks the - // old-time fields; avoid in loops. - Internal& ref(); + // \param updateAccessTime update event counter and check + // old-time fields + // + // \note Should avoid using updateAccessTime = true within loops. + Internal& ref(const bool updateAccessTime = true); //- Return a const-reference to the dimensioned internal field inline const Internal& internalField() const; //- Return a const-reference to the dimensioned internal field - // of a "vol" field. Useful in the formulation of source-terms - // for FV equations + //- of a "vol" field. + // Useful in the formulation of source-terms for FV equations inline const Internal& v() const; //- Return a reference to the internal field - // Note: this increments the event counter and checks the - // old-time fields; avoid in loops. - typename Internal::FieldType& primitiveFieldRef(); + // \param updateAccessTime update event counter and check + // old-time fields + // + // \note Should avoid using updateAccessTime = true within loops. + typename Internal::FieldType& primitiveFieldRef + ( + const bool updateAccessTime = true + ); //- Return a const-reference to the internal field inline const typename Internal::FieldType& primitiveField() const; //- Return a reference to the boundary field - // Note: this increments the event counter and checks the - // old-time fields; avoid in loops. - Boundary& boundaryFieldRef(); + // \param updateAccessTime update event counter and check + // old-time fields + // + // \note Should avoid using updateAccessTime = true within loops. + Boundary& boundaryFieldRef(const bool updateAccessTime = true); //- Return const-reference to the boundary field inline const Boundary& boundaryField() const;