diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 1925bbbe12..453e9b4785 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -991,6 +991,17 @@ Foam::GeometricField::boundaryFieldRef() } +template class PatchField, class GeoMesh> +typename +Foam::GeometricField::Boundary& +Foam::GeometricField:: +boundaryFieldRefNoStoreOldTimes() +{ + this->setUpToDate(); + return boundaryField_; +} + + template class PatchField, class GeoMesh> void Foam::GeometricField::storePrevIter() const { diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 23934ea75f..6f458d805d 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -404,6 +404,10 @@ public: // old-time fields; avoid in loops. Boundary& boundaryFieldRef(); + //- Return a reference to the boundary field without storing old times + // Note: this increments the event counter; avoid in loops. + Boundary& boundaryFieldRefNoStoreOldTimes(); + //- Return const-reference to the boundary field inline const Boundary& boundaryField() const; diff --git a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C index 426fc6f141..5c17fac148 100644 --- a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C +++ b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C @@ -1977,7 +1977,7 @@ void Foam::fvMeshStitcher::postUnconformVolFields() const label origPatchi = origPatchIndices[i]; typename volVectorField::Patch& origUp = - boundaryFieldRefNoUpdate(U)[origPatchi]; + U.boundaryFieldRefNoStoreOldTimes()[origPatchi]; if ( @@ -1985,7 +1985,7 @@ void Foam::fvMeshStitcher::postUnconformVolFields() || isA(origUp) ) { - boundaryFieldRefNoUpdate(U).set + U.boundaryFieldRefNoStoreOldTimes().set ( errorPatchi, new movingWallSlipVelocityFvPatchVectorField @@ -2020,7 +2020,7 @@ void Foam::fvMeshStitcher::postUnconformVolFields() { if (isA(mesh_.boundary()[patchi])) { - boundaryFieldRefNoUpdate(Uf)[patchi] == + Uf.boundaryFieldRefNoStoreOldTimes()[patchi] == UfInterpolated.boundaryField()[patchi]; } } diff --git a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.H b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.H index 5e89958ca4..51b891f299 100644 --- a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.H +++ b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.H @@ -369,15 +369,6 @@ protected: // Protected Member Functions - //- Access the boundary field reference of a field, without updating - // the time index, storing old time fields, etc... - template - static typename GeoField::Boundary& boundaryFieldRefNoUpdate - ( - GeoField& fld - ); - - // Checking //- Determine which patches are coupled; i.e., for which diff --git a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherTemplates.C b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherTemplates.C index c1a920de05..72de01fe91 100644 --- a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherTemplates.C +++ b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherTemplates.C @@ -46,7 +46,7 @@ void Foam::fvMeshStitcher::resizePatchFields() forAll(mesh_.boundary(), patchi) { typename GeoField::Patch& pf = - boundaryFieldRefNoUpdate(fields[i])[patchi]; + fields[i].boundaryFieldRefNoStoreOldTimes()[patchi]; if (isA(pf.patch())) { @@ -80,7 +80,7 @@ void Foam::fvMeshStitcher::preConformSurfaceFields() { conformedFvsPatchField::conform ( - boundaryFieldRefNoUpdate(field.oldTime(ti)) + field.oldTimeRef(ti).boundaryFieldRefNoStoreOldTimes() ); } } @@ -100,7 +100,7 @@ void Foam::fvMeshStitcher::preConformVolFields() { conformedFvPatchField::conform ( - boundaryFieldRefNoUpdate(field.oldTime(ti)) + field.oldTimeRef(ti).boundaryFieldRefNoStoreOldTimes() ); } } @@ -120,7 +120,7 @@ void Foam::fvMeshStitcher::postUnconformSurfaceFields() { conformedFvsPatchField::unconform ( - boundaryFieldRefNoUpdate(field.oldTime(ti)) + field.oldTimeRef(ti).boundaryFieldRefNoStoreOldTimes() ); } } @@ -140,7 +140,7 @@ void Foam::fvMeshStitcher::postUnconformVolFields() { conformedFvPatchField::unconform ( - boundaryFieldRefNoUpdate(field.oldTime(ti)) + field.oldTimeRef(ti).boundaryFieldRefNoStoreOldTimes() ); } } @@ -170,7 +170,7 @@ void Foam::fvMeshStitcher::postUnconformEvaluateVolFields() forAll(mesh_.boundary(), patchi) { typename VolField::Patch& pf = - boundaryFieldRefNoUpdate(fields[i])[patchi]; + fields[i].boundaryFieldRefNoStoreOldTimes()[patchi]; if (evaluate(pf)) { @@ -190,7 +190,7 @@ void Foam::fvMeshStitcher::postUnconformEvaluateVolFields() forAll(mesh_.boundary(), patchi) { typename VolField::Patch& pf = - boundaryFieldRefNoUpdate(fields[i])[patchi]; + fields[i].boundaryFieldRefNoStoreOldTimes()[patchi]; if (evaluate(pf)) { @@ -201,16 +201,4 @@ void Foam::fvMeshStitcher::postUnconformEvaluateVolFields() } -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -template -typename GeoField::Boundary& Foam::fvMeshStitcher::boundaryFieldRefNoUpdate -( - GeoField& fld -) -{ - return const_cast(fld.boundaryField()); -} - - // ************************************************************************* // diff --git a/src/fvMeshStitchers/moving/fvMeshStitchersMoving.C b/src/fvMeshStitchers/moving/fvMeshStitchersMoving.C index 2453ff85ef..c0d26846d9 100644 --- a/src/fvMeshStitchers/moving/fvMeshStitchersMoving.C +++ b/src/fvMeshStitchers/moving/fvMeshStitchersMoving.C @@ -1030,7 +1030,7 @@ void Foam::fvMeshStitchers::moving::unconformCorrectMeshPhi for (label i = 0; i <= phi.nOldTimes(false); ++ i) { surfaceScalarField::Boundary& phi0Bf = - boundaryFieldRefNoUpdate(phi.oldTime(i)); + phi.oldTimeRef(i).boundaryFieldRefNoStoreOldTimes(); forAll(polyFacesBf, ncPatchi) {