From 45f73bf64f3cfa5d7de9900d2d709fc42255a2ca Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 23 Apr 2016 23:07:28 +0100 Subject: [PATCH] GeometricField: New non-const access function boundaryFieldRef() There is a need to specify const or non-const access to a non-const object which is not currently possible with the "boundaryField()" access function the const-ness of the return of which is defined by the const-ness of the object for which it is called. For consistency with the latest "tmp" storage class in which non-const access is obtained with the "ref()" function it is proposed to replace the non-const form of "boundaryField()" with "boundaryFieldRef()". Thanks to Mattijs Janssens for starting the process of migration to "boundaryFieldRef()" and providing a patch for the OpenFOAM and finiteVolume libraries. --- .../GeometricField/GeometricField.C | 30 ++++----- .../GeometricField/GeometricField.H | 10 ++- .../GeometricField/GeometricFieldFunctions.C | 25 +++++--- .../GeometricField/GeometricFieldFunctionsM.C | 23 ++++--- .../GeometricField/MapGeometricFields.H | 2 +- .../GeometricScalarField.C | 16 ++--- .../transformGeometricField.C | 4 +- .../general/CorrectPhi/correctUphiBCs.C | 42 ++++++------ .../cfdTools/general/MRF/MRFZone.C | 19 ++++-- .../cfdTools/general/MRF/MRFZoneList.C | 9 ++- .../cfdTools/general/MRF/MRFZoneTemplates.C | 9 ++- .../general/SRF/SRFModel/SRFModel/SRFModel.C | 9 ++- .../cfdTools/general/adjustPhi/adjustPhi.C | 3 +- .../cfdTools/general/bound/bound.C | 4 +- .../general/constrainHbyA/constrainHbyA.C | 3 +- .../externalCoupledMixedFvPatchField.C | 42 ++++++------ ...mappedVelocityFluxFixedValueFvPatchField.C | 11 ++-- .../waveSurfacePressureFvPatchScalarField.C | 12 ++-- .../CoEulerDdtScheme/CoEulerDdtScheme.C | 12 ++-- .../CrankNicolsonDdtScheme.C | 64 +++++++++++++------ .../ddtSchemes/ddtScheme/ddtScheme.C | 5 +- .../finiteVolume/fvc/fvcAverage.C | 2 +- .../gradSchemes/fourthGrad/fourthGrad.C | 2 +- .../gradSchemes/gaussGrad/gaussGrad.C | 9 ++- .../leastSquaresGrad/leastSquaresGrad.C | 2 +- .../leastSquaresGrad/leastSquaresVectors.C | 10 +-- .../faceCorrectedSnGrad/faceCorrectedSnGrad.C | 2 +- .../snGradSchemes/snGradScheme/snGradScheme.C | 8 ++- .../fvMatrices/fvMatrix/fvMatrix.C | 10 +-- .../fvMatrices/fvMatrix/fvMatrixSolve.C | 2 +- .../fvScalarMatrix/fvScalarMatrix.C | 2 +- .../solvers/MULES/CMULESTemplates.C | 4 +- .../fvMatrices/solvers/MULES/MULESTemplates.C | 4 +- .../extendedCellToFaceStencilTemplates.C | 2 +- ...extendedUpwindCellToFaceStencilTemplates.C | 2 +- src/finiteVolume/fvMesh/fvMesh.C | 6 +- src/finiteVolume/fvMesh/fvMeshGeometry.C | 7 +- .../fvMeshSubset/fvMeshSubsetInterpolate.C | 6 +- .../Poisson/PoissonPatchDistMethod.C | 2 +- .../advectionDiffusionPatchDistMethod.C | 3 +- .../meshWave/meshWavePatchDistMethod.C | 24 ++++--- .../fvMesh/wallDist/wallDist/wallDist.C | 4 +- .../LimitedScheme/LimitedScheme.C | 2 +- .../limitedSchemes/PhiScheme/PhiScheme.C | 2 +- .../limitedSurfaceInterpolationScheme.C | 2 +- .../schemes/clippedLinear/clippedLinear.H | 10 +-- .../schemes/cubic/cubic.H | 9 ++- .../schemes/linearUpwind/linearUpwind.C | 2 +- .../schemes/linearUpwind/linearUpwindV.C | 2 +- .../schemes/localMax/localMax.H | 7 +- .../schemes/localMin/localMin.H | 7 +- .../schemes/midPoint/midPoint.H | 10 +-- .../schemes/pointLinear/pointLinear.C | 2 +- .../schemes/reverseLinear/reverseLinear.H | 12 ++-- .../skewCorrected/skewCorrectionVectors.C | 11 ++-- .../surfaceInterpolation.C | 36 +++++++---- .../surfaceInterpolationScheme.C | 11 +++- .../pointConstraintsTemplates.C | 7 +- .../volPointInterpolate.C | 15 +++-- 59 files changed, 369 insertions(+), 245 deletions(-) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 959a1182b1..b30ca6e5a7 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -712,7 +712,7 @@ Foam::GeometricField::internalField() template class PatchField, class GeoMesh> typename Foam::GeometricField::GeometricBoundaryField& -Foam::GeometricField::boundaryField() +Foam::GeometricField::boundaryFieldRef() { this->setUpToDate(); storeOldTimes(); @@ -993,7 +993,7 @@ Foam::GeometricField::T() const ); Foam::T(result.ref().internalField(), internalField()); - Foam::T(result.ref().boundaryField(), boundaryField()); + Foam::T(result.ref().boundaryFieldRef(), boundaryField()); return result; } @@ -1030,7 +1030,7 @@ Foam::GeometricField::component ); Foam::component(Component.ref().internalField(), internalField(), d); - Foam::component(Component.ref().boundaryField(), boundaryField(), d); + Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d); return Component; } @@ -1049,7 +1049,7 @@ void Foam::GeometricField::replace ) { internalField().replace(d, gcf.internalField()); - boundaryField().replace(d, gcf.boundaryField()); + boundaryFieldRef().replace(d, gcf.boundaryField()); } @@ -1061,7 +1061,7 @@ void Foam::GeometricField::replace ) { internalField().replace(d, ds.value()); - boundaryField().replace(d, ds.value()); + boundaryFieldRef().replace(d, ds.value()); } @@ -1072,7 +1072,7 @@ void Foam::GeometricField::max ) { Foam::max(internalField(), internalField(), dt.value()); - Foam::max(boundaryField(), boundaryField(), dt.value()); + Foam::max(boundaryFieldRef(), boundaryField(), dt.value()); } @@ -1083,7 +1083,7 @@ void Foam::GeometricField::min ) { Foam::min(internalField(), internalField(), dt.value()); - Foam::min(boundaryField(), boundaryField(), dt.value()); + Foam::min(boundaryFieldRef(), boundaryField(), dt.value()); } @@ -1091,7 +1091,7 @@ template class PatchField, class GeoMesh> void Foam::GeometricField::negate() { internalField().negate(); - boundaryField().negate(); + boundaryFieldRef().negate(); } @@ -1115,7 +1115,7 @@ void Foam::GeometricField::operator= // only equate field contents not ID dimensionedInternalField() = gf.dimensionedInternalField(); - boundaryField() = gf.boundaryField(); + boundaryFieldRef() = gf.boundaryField(); } @@ -1146,7 +1146,7 @@ void Foam::GeometricField::operator= const_cast&>(gf.internalField()) ); - boundaryField() = gf.boundaryField(); + boundaryFieldRef() = gf.boundaryField(); tgf.clear(); } @@ -1159,7 +1159,7 @@ void Foam::GeometricField::operator= ) { dimensionedInternalField() = dt; - boundaryField() = dt.value(); + boundaryFieldRef() = dt.value(); } @@ -1176,7 +1176,7 @@ void Foam::GeometricField::operator== // only equate field contents not ID dimensionedInternalField() = gf.dimensionedInternalField(); - boundaryField() == gf.boundaryField(); + boundaryFieldRef() == gf.boundaryField(); tgf.clear(); } @@ -1189,7 +1189,7 @@ void Foam::GeometricField::operator== ) { dimensionedInternalField() = dt; - boundaryField() == dt.value(); + boundaryFieldRef() == dt.value(); } @@ -1204,7 +1204,7 @@ void Foam::GeometricField::operator op \ checkField(*this, gf, #op); \ \ dimensionedInternalField() op gf.dimensionedInternalField(); \ - boundaryField() op gf.boundaryField(); \ + boundaryFieldRef() op gf.boundaryField(); \ } \ \ template class PatchField, class GeoMesh> \ @@ -1224,7 +1224,7 @@ void Foam::GeometricField::operator op \ ) \ { \ dimensionedInternalField() op dt; \ - boundaryField() op dt.value(); \ + boundaryFieldRef() op dt.value(); \ } COMPUTED_ASSIGNMENT(Type, +=) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 4efc05d309..2f1b71f7f1 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -442,7 +442,15 @@ public: inline const InternalField& internalField() const; //- Return reference to GeometricBoundaryField - GeometricBoundaryField& boundaryField(); + GeometricBoundaryField& boundaryFieldRef(); + + //- Return reference to GeometricBoundaryField + #ifndef BOUNDARY_FIELD_REF + GeometricBoundaryField& boundaryField() + { + return boundaryFieldRef(); + } + #endif //- Return reference to GeometricBoundaryField for const field inline const GeometricBoundaryField& boundaryField() const; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C index e04a1588b5..dda0738161 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C @@ -50,7 +50,7 @@ void component ) { component(gcf.internalField(), gf.internalField(), d); - component(gcf.boundaryField(), gf.boundaryField(), d); + component(gcf.boundaryFieldRef(), gf.boundaryField(), d); } @@ -62,7 +62,7 @@ void T ) { T(gf.internalField(), gf1.internalField()); - T(gf.boundaryField(), gf1.boundaryField()); + T(gf.boundaryFieldRef(), gf1.boundaryField()); } @@ -80,7 +80,7 @@ void pow ) { pow(gf.internalField(), gf1.internalField(), r); - pow(gf.boundaryField(), gf1.boundaryField(), r); + pow(gf.boundaryFieldRef(), gf1.boundaryField(), r); } template @@ -174,7 +174,7 @@ void sqr ) { sqr(gf.internalField(), gf1.internalField()); - sqr(gf.boundaryField(), gf1.boundaryField()); + sqr(gf.boundaryFieldRef(), gf1.boundaryField()); } template class PatchField, class GeoMesh> @@ -262,7 +262,7 @@ void magSqr ) { magSqr(gsf.internalField(), gf.internalField()); - magSqr(gsf.boundaryField(), gf.boundaryField()); + magSqr(gsf.boundaryFieldRef(), gf.boundaryField()); } template class PatchField, class GeoMesh> @@ -334,7 +334,7 @@ void mag ) { mag(gsf.internalField(), gf.internalField()); - mag(gsf.boundaryField(), gf.boundaryField()); + mag(gsf.boundaryFieldRef(), gf.boundaryField()); } template class PatchField, class GeoMesh> @@ -411,7 +411,7 @@ void cmptAv ) { cmptAv(gcf.internalField(), gf.internalField()); - cmptAv(gcf.boundaryField(), gf.boundaryField()); + cmptAv(gcf.boundaryFieldRef(), gf.boundaryField()); } template class PatchField, class GeoMesh> @@ -600,7 +600,12 @@ void opFunc \ ) \ { \ Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\ - Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\ + Foam::opFunc \ + ( \ + gf.boundaryFieldRef(), \ + gf1.boundaryField(), \ + gf2.boundaryField() \ + );\ } \ \ template \ @@ -746,7 +751,7 @@ void opFunc \ ) \ { \ Foam::opFunc(gf.internalField(), gf1.internalField(), dvs.value()); \ - Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), dvs.value()); \ + Foam::opFunc(gf.boundaryFieldRef(), gf1.boundaryField(), dvs.value()); \ } \ \ template \ @@ -859,7 +864,7 @@ void opFunc \ ) \ { \ Foam::opFunc(gf.internalField(), dvs.value(), gf1.internalField()); \ - Foam::opFunc(gf.boundaryField(), dvs.value(), gf1.boundaryField()); \ + Foam::opFunc(gf.boundaryFieldRef(), dvs.value(), gf1.boundaryField()); \ } \ \ template \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C index 2d0b007c27..d044d677aa 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C @@ -42,7 +42,7 @@ void Func \ ) \ { \ Foam::Func(res.internalField(), gf1.internalField()); \ - Foam::Func(res.boundaryField(), gf1.boundaryField()); \ + Foam::Func(res.boundaryFieldRef(), gf1.boundaryField()); \ } \ \ TEMPLATE \ @@ -111,7 +111,7 @@ void OpFunc \ ) \ { \ Foam::OpFunc(res.internalField(), gf1.internalField()); \ - Foam::OpFunc(res.boundaryField(), gf1.boundaryField()); \ + Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField()); \ } \ \ TEMPLATE \ @@ -180,8 +180,13 @@ void Func \ const GeometricField& gf2 \ ) \ { \ - Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField());\ - Foam::Func(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\ + Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField()); \ + Foam::Func \ + ( \ + res.boundaryFieldRef(), \ + gf1.boundaryField(), \ + gf2.boundaryField() \ + );\ } \ \ TEMPLATE \ @@ -309,7 +314,7 @@ void Func \ ) \ { \ Foam::Func(res.internalField(), dt1.value(), gf2.internalField()); \ - Foam::Func(res.boundaryField(), dt1.value(), gf2.boundaryField()); \ + Foam::Func(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ } \ \ TEMPLATE \ @@ -400,7 +405,7 @@ void Func \ ) \ { \ Foam::Func(res.internalField(), gf1.internalField(), dt2.value()); \ - Foam::Func(res.boundaryField(), gf1.boundaryField(), dt2.value()); \ + Foam::Func(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ } \ \ TEMPLATE \ @@ -500,7 +505,7 @@ void OpFunc \ Foam::OpFunc \ (res.internalField(), gf1.internalField(), gf2.internalField()); \ Foam::OpFunc \ - (res.boundaryField(), gf1.boundaryField(), gf2.boundaryField()); \ + (res.boundaryFieldRef(), gf1.boundaryField(), gf2.boundaryField()); \ } \ \ TEMPLATE \ @@ -628,7 +633,7 @@ void OpFunc \ ) \ { \ Foam::OpFunc(res.internalField(), dt1.value(), gf2.internalField()); \ - Foam::OpFunc(res.boundaryField(), dt1.value(), gf2.boundaryField()); \ + Foam::OpFunc(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ } \ \ TEMPLATE \ @@ -719,7 +724,7 @@ void OpFunc \ ) \ { \ Foam::OpFunc(res.internalField(), gf1.internalField(), dt2.value()); \ - Foam::OpFunc(res.boundaryField(), gf1.boundaryField(), dt2.value()); \ + Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ } \ \ TEMPLATE \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H index 637e4314f3..ca437acec4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H @@ -132,7 +132,7 @@ void MapGeometricFields // Map the patch fields typename GeometricField - ::GeometricBoundaryField& bfield = field.boundaryField(); + ::GeometricBoundaryField& bfield = field.boundaryFieldRef(); forAll(bfield, patchi) { // Cannot check sizes for patch fields because of diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C b/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C index 41bbe8178f..6b58138dc7 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C @@ -44,7 +44,7 @@ void stabilise ) { stabilise(result.internalField(), gsf.internalField(), ds.value()); - stabilise(result.boundaryField(), gsf.boundaryField(), ds.value()); + stabilise(result.boundaryFieldRef(), gsf.boundaryField(), ds.value()); } @@ -127,7 +127,7 @@ void pow ) { pow(Pow.internalField(), gsf1.internalField(), gsf2.internalField()); - pow(Pow.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField()); + pow(Pow.boundaryFieldRef(), gsf1.boundaryField(), gsf2.boundaryField()); } @@ -270,7 +270,7 @@ void pow ) { pow(tPow.internalField(), gsf.internalField(), ds.value()); - pow(tPow.boundaryField(), gsf.boundaryField(), ds.value()); + pow(tPow.boundaryFieldRef(), gsf.boundaryField(), ds.value()); } @@ -359,7 +359,7 @@ void pow ) { pow(tPow.internalField(), ds.value(), gsf.internalField()); - pow(tPow.boundaryField(), ds.value(), gsf.boundaryField()); + pow(tPow.boundaryFieldRef(), ds.value(), gsf.boundaryField()); } @@ -451,7 +451,7 @@ void atan2 ) { atan2(Atan2.internalField(), gsf1.internalField(), gsf2.internalField()); - atan2(Atan2.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField()); + atan2(Atan2.boundaryFieldRef(), gsf1.boundaryField(), gsf2.boundaryField()); } @@ -578,7 +578,7 @@ void atan2 ) { atan2(tAtan2.internalField(), gsf.internalField(), ds.value()); - atan2(tAtan2.boundaryField(), gsf.boundaryField(), ds.value()); + atan2(tAtan2.boundaryFieldRef(), gsf.boundaryField(), ds.value()); } @@ -667,7 +667,7 @@ void atan2 ) { atan2(tAtan2.internalField(), ds.value(), gsf.internalField()); - atan2(tAtan2.boundaryField(), ds.value(), gsf.boundaryField()); + atan2(tAtan2.boundaryFieldRef(), ds.value(), gsf.boundaryField()); } @@ -800,7 +800,7 @@ void func \ ) \ { \ func(gsf.internalField(), n, gsf1.internalField()); \ - func(gsf.boundaryField(), n, gsf1.boundaryField()); \ + func(gsf.boundaryFieldRef(), n, gsf1.boundaryField()); \ } \ \ template class PatchField, class GeoMesh> \ diff --git a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C index e3b75000b4..baa2f7041b 100644 --- a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C @@ -46,7 +46,7 @@ void transform ) { transform(rtf.internalField(), trf.internalField(), tf.internalField()); - transform(rtf.boundaryField(), trf.boundaryField(), tf.boundaryField()); + transform(rtf.boundaryFieldRef(), trf.boundaryField(), tf.boundaryField()); } @@ -132,7 +132,7 @@ void transform ) { transform(rtf.internalField(), t.value(), tf.internalField()); - transform(rtf.boundaryField(), t.value(), tf.boundaryField()); + transform(rtf.boundaryFieldRef(), t.value(), tf.boundaryField()); } diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C b/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C index d9ab448b46..beff14e462 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C +++ b/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,23 +37,25 @@ void Foam::correctUphiBCs if (mesh.changing()) { - forAll(U.boundaryField(), patchi) + volVectorField::GeometricBoundaryField& Ubf = U.boundaryFieldRef(); + surfaceScalarField::GeometricBoundaryField& phibf = + phi.boundaryFieldRef(); + + forAll(Ubf, patchi) { - if (U.boundaryField()[patchi].fixesValue()) + if (Ubf[patchi].fixesValue()) { - U.boundaryField()[patchi].initEvaluate(); + Ubf[patchi].initEvaluate(); } } - forAll(U.boundaryField(), patchi) + forAll(Ubf, patchi) { - if (U.boundaryField()[patchi].fixesValue()) + if (Ubf[patchi].fixesValue()) { - U.boundaryField()[patchi].evaluate(); + Ubf[patchi].evaluate(); - phi.boundaryField()[patchi] = - U.boundaryField()[patchi] - & mesh.Sf().boundaryField()[patchi]; + phibf[patchi] = Ubf[patchi] & mesh.Sf().boundaryField()[patchi]; } } } @@ -71,24 +73,28 @@ void Foam::correctUphiBCs if (mesh.changing()) { - forAll(U.boundaryField(), patchi) + volVectorField::GeometricBoundaryField& Ubf = U.boundaryFieldRef(); + surfaceScalarField::GeometricBoundaryField& phibf = + phi.boundaryFieldRef(); + + forAll(Ubf, patchi) { - if (U.boundaryField()[patchi].fixesValue()) + if (Ubf[patchi].fixesValue()) { - U.boundaryField()[patchi].initEvaluate(); + Ubf[patchi].initEvaluate(); } } - forAll(U.boundaryField(), patchi) + forAll(Ubf, patchi) { - if (U.boundaryField()[patchi].fixesValue()) + if (Ubf[patchi].fixesValue()) { - U.boundaryField()[patchi].evaluate(); + Ubf[patchi].evaluate(); - phi.boundaryField()[patchi] = + phibf[patchi] = rho.boundaryField()[patchi] *( - U.boundaryField()[patchi] + Ubf[patchi] & mesh.Sf().boundaryField()[patchi] ); } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index 90239b4984..00fb6ffe09 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -418,12 +418,15 @@ void Foam::MRFZone::makeRelative(volVectorField& U) const } // Included patches + + volVectorField::GeometricBoundaryField& Ubf = U.boundaryFieldRef(); + forAll(includedFaces_, patchi) { forAll(includedFaces_[patchi], i) { label patchFacei = includedFaces_[patchi][i]; - U.boundaryField()[patchi][patchFacei] = Zero; + Ubf[patchi][patchFacei] = Zero; } } @@ -433,7 +436,7 @@ void Foam::MRFZone::makeRelative(volVectorField& U) const forAll(excludedFaces_[patchi], i) { label patchFacei = excludedFaces_[patchi][i]; - U.boundaryField()[patchi][patchFacei] -= + Ubf[patchi][patchFacei] -= (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin_)); } @@ -484,12 +487,14 @@ void Foam::MRFZone::makeAbsolute(volVectorField& U) const } // Included patches + volVectorField::GeometricBoundaryField& Ubf = U.boundaryFieldRef(); + forAll(includedFaces_, patchi) { forAll(includedFaces_[patchi], i) { label patchFacei = includedFaces_[patchi][i]; - U.boundaryField()[patchi][patchFacei] = + Ubf[patchi][patchFacei] = (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin_)); } } @@ -500,7 +505,7 @@ void Foam::MRFZone::makeAbsolute(volVectorField& U) const forAll(excludedFaces_[patchi], i) { label patchFacei = excludedFaces_[patchi][i]; - U.boundaryField()[patchi][patchFacei] += + Ubf[patchi][patchFacei] += (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin_)); } } @@ -528,11 +533,13 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const const vector Omega = this->Omega(); // Included patches + volVectorField::GeometricBoundaryField& Ubf = U.boundaryFieldRef(); + forAll(includedFaces_, patchi) { const vectorField& patchC = mesh_.Cf().boundaryField()[patchi]; - vectorField pfld(U.boundaryField()[patchi]); + vectorField pfld(Ubf[patchi]); forAll(includedFaces_[patchi], i) { @@ -541,7 +548,7 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_)); } - U.boundaryField()[patchi] == pfld; + Ubf[patchi] == pfld; } } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index 271157b9a6..761e7b7428 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -393,19 +393,22 @@ void Foam::MRFZoneList::correctBoundaryFlux surfaceScalarField& phi ) const { - FieldField phibf + FieldField Uf ( relative(mesh_.Sf().boundaryField() & U.boundaryField()) ); + + surfaceScalarField::GeometricBoundaryField& phibf = phi.boundaryFieldRef(); + forAll(mesh_.boundary(), patchi) { if ( - isA(phi.boundaryField()[patchi]) + isA(phibf[patchi]) ) { - phi.boundaryField()[patchi] == phibf[patchi]; + phibf[patchi] == Uf[patchi]; } } } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C index b4a59329df..effeed232c 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C @@ -54,7 +54,7 @@ void Foam::MRFZone::makeRelativeRhoFlux phii[facei] -= rho[facei]*(Omega ^ (Cfi[facei] - origin_)) & Sfi[facei]; } - makeRelativeRhoFlux(rho.boundaryField(), phi.boundaryField()); + makeRelativeRhoFlux(rho.boundaryField(), phi.boundaryFieldRef()); } @@ -154,6 +154,9 @@ void Foam::MRFZone::makeAbsoluteRhoFlux phii[facei] += rho[facei]*(Omega ^ (Cfi[facei] - origin_)) & Sfi[facei]; } + surfaceScalarField::GeometricBoundaryField& phibf = phi.boundaryFieldRef(); + + // Included patches forAll(includedFaces_, patchi) { @@ -161,7 +164,7 @@ void Foam::MRFZone::makeAbsoluteRhoFlux { label patchFacei = includedFaces_[patchi][i]; - phi.boundaryField()[patchi][patchFacei] += + phibf[patchi][patchFacei] += rho.boundaryField()[patchi][patchFacei] * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin_)) & Sf.boundaryField()[patchi][patchFacei]; @@ -175,7 +178,7 @@ void Foam::MRFZone::makeAbsoluteRhoFlux { label patchFacei = excludedFaces_[patchi][i]; - phi.boundaryField()[patchi][patchFacei] += + phibf[patchi][patchFacei] += rho.boundaryField()[patchi][patchFacei] * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin_)) & Sf.boundaryField()[patchi][patchFacei]; diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C index 7077bc2f6b..a48b028b5e 100644 --- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C +++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C @@ -225,10 +225,13 @@ Foam::tmp Foam::SRF::SRFModel::Uabs() const ) ); + volVectorField& Uabs = tUabs.ref(); + // Add SRF contribution to internal field - tUabs.ref().internalField() += Urel_.internalField(); + Uabs.internalField() += Urel_.internalField(); // Add Urel boundary contributions + volVectorField::GeometricBoundaryField& Uabsbf = Uabs.boundaryFieldRef(); const volVectorField::GeometricBoundaryField& bvf = Urel_.boundaryField(); forAll(bvf, i) @@ -241,12 +244,12 @@ Foam::tmp Foam::SRF::SRFModel::Uabs() const refCast(bvf[i]); if (UrelPatch.relative()) { - tUabs.ref().boundaryField()[i] += Urel_.boundaryField()[i]; + Uabsbf[i] += Urel_.boundaryField()[i]; } } else { - tUabs.ref().boundaryField()[i] += Urel_.boundaryField()[i]; + Uabsbf[i] += Urel_.boundaryField()[i]; } } diff --git a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C index 6f0742b26e..c34239a4c3 100644 --- a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C +++ b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C @@ -43,7 +43,8 @@ bool Foam::adjustPhi scalar fixedMassOut = 0.0; scalar adjustableMassOut = 0.0; - surfaceScalarField::GeometricBoundaryField& bphi = phi.boundaryField(); + surfaceScalarField::GeometricBoundaryField& bphi = + phi.boundaryFieldRef(); forAll(bphi, patchi) { diff --git a/src/finiteVolume/cfdTools/general/bound/bound.C b/src/finiteVolume/cfdTools/general/bound/bound.C index f47cfd33ff..009a14388d 100644 --- a/src/finiteVolume/cfdTools/general/bound/bound.C +++ b/src/finiteVolume/cfdTools/general/bound/bound.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,7 +53,7 @@ Foam::bound(volScalarField& vsf, const dimensionedScalar& lowerBound) lowerBound.value() ); - vsf.boundaryField() = max(vsf.boundaryField(), lowerBound.value()); + vsf.boundaryFieldRef() = max(vsf.boundaryField(), lowerBound.value()); } return vsf; diff --git a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C index 38f84f96a7..bd51322e6e 100644 --- a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C +++ b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C @@ -49,6 +49,7 @@ Foam::tmp Foam::constrainHbyA } volVectorField& HbyA = tHbyANew.ref(); + volVectorField::GeometricBoundaryField& HbyAbf = HbyA.boundaryFieldRef(); forAll(U.boundaryField(), patchi) { @@ -61,7 +62,7 @@ Foam::tmp Foam::constrainHbyA ) ) { - HbyA.boundaryField()[patchi] = U.boundaryField()[patchi]; + HbyAbf[patchi] = U.boundaryField()[patchi]; } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C index b3629e877f..568bc9a6f7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C @@ -68,7 +68,7 @@ void Foam::externalCoupledMixedFvPatchField::setMaster volFieldType& vf = const_cast(cvf); - typename volFieldType::GeometricBoundaryField& bf = vf.boundaryField(); + typename volFieldType::GeometricBoundaryField& bf = vf.boundaryFieldRef(); // number of patches can be different in parallel... label nPatch = bf.size(); @@ -84,11 +84,11 @@ void Foam::externalCoupledMixedFvPatchField::setMaster // set the master patch forAll(patchIDs, i) { - label patchI = patchIDs[i]; + label patchi = patchIDs[i]; - patchType& pf = refCast(bf[patchI]); + patchType& pf = refCast(bf[patchi]); - offsets_[patchI][Pstream::myProcNo()] = pf.size(); + offsets_[patchi][Pstream::myProcNo()] = pf.size(); if (i == 0) { @@ -109,10 +109,10 @@ void Foam::externalCoupledMixedFvPatchField::setMaster } label patchOffset = 0; - forAll(offsets_, patchI) + forAll(offsets_, patchi) { label sumOffset = 0; - List