From 40cadfd2f23854a1cc419ef0270d0a529fd68b6d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 3 Jun 2022 10:04:38 +0200 Subject: [PATCH] COMP: references to temporaries COMP: include --- .../dataConversion/foamToVTK/foamToVTK.C | 2 +- .../preProcessing/setFields/setFields.C | 4 +-- .../primitives/functions/Math/erfInv.C | 2 ++ .../primitives/functions/Math/incGamma.C | 1 + .../primitives/functions/Math/invIncGamma.C | 2 ++ ...lentDigitalFilterInletFvPatchVectorField.C | 34 ++++++++++++------- .../field/nearWallFields/nearWallFields.C | 2 +- .../meshRefinement/weightedPosition.H | 2 +- .../solarLoad/faceReflecting/faceReflecting.C | 2 +- .../solarLoad/faceShading/faceShading.C | 2 +- 10 files changed, 33 insertions(+), 20 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index f2e447b5bb..5e769fa830 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -591,7 +591,7 @@ int main(int argc, char *argv[]) { for ( - const word& opt + const char * const opt : { "cellSet", "cellZone", "faceSet", "pointSet" } ) { diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index 14f3a5acf7..a57514f9d6 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.C @@ -92,7 +92,7 @@ bool setCellFieldType fieldType field(fieldHeader, mesh, false); - const Type& value = pTraits(fieldValueStream); + const Type value = pTraits(fieldValueStream); if (selectedCells.size() == field.size()) { @@ -244,7 +244,7 @@ bool setFaceFieldType fieldType field(fieldHeader, mesh); - const Type& value = pTraits(fieldValueStream); + const Type value = pTraits(fieldValueStream); // Create flat list of selected faces and their value. Field allBoundaryValues(mesh.nBoundaryFaces()); diff --git a/src/OpenFOAM/primitives/functions/Math/erfInv.C b/src/OpenFOAM/primitives/functions/Math/erfInv.C index 1c5b01497c..8d7fb042e3 100644 --- a/src/OpenFOAM/primitives/functions/Math/erfInv.C +++ b/src/OpenFOAM/primitives/functions/Math/erfInv.C @@ -28,6 +28,8 @@ License #include "MathFunctions.H" #include "mathematicalConstants.H" #include "error.H" +#include +#include // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/functions/Math/incGamma.C b/src/OpenFOAM/primitives/functions/Math/incGamma.C index 22f97c4b6b..5b78d62981 100644 --- a/src/OpenFOAM/primitives/functions/Math/incGamma.C +++ b/src/OpenFOAM/primitives/functions/Math/incGamma.C @@ -36,6 +36,7 @@ Description #include "mathematicalConstants.H" #include "error.H" #include +#include // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/functions/Math/invIncGamma.C b/src/OpenFOAM/primitives/functions/Math/invIncGamma.C index 58897f62d2..26e262be4a 100644 --- a/src/OpenFOAM/primitives/functions/Math/invIncGamma.C +++ b/src/OpenFOAM/primitives/functions/Math/invIncGamma.C @@ -35,6 +35,8 @@ Description #include "MathFunctions.H" #include "mathematicalConstants.H" #include "error.H" +#include +#include using namespace Foam::constant::mathematical; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C index 6ad03839f7..180451f164 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C @@ -161,38 +161,38 @@ Foam::turbulentDigitalFilterInletFvPatchVectorField::indexPairs() void Foam::turbulentDigitalFilterInletFvPatchVectorField::checkR() const { - const vectorField& faceCentres = this->patch().patch().faceCentres(); + label badFacei = -1; forAll(R_, facei) { if (R_[facei].xx() <= 0) { + badFacei = facei; FatalErrorInFunction << "Reynolds stress tensor component Rxx cannot be negative" - << " or zero, where Rxx = " << R_[facei].xx() - << " at the face centre = " << faceCentres[facei] - << exit(FatalError); + << " or zero, where Rxx = " << R_[facei].xx(); + break; } if (R_[facei].yy() < 0 || R_[facei].zz() < 0) { + badFacei = facei; FatalErrorInFunction << "Reynolds stress tensor components Ryy or Rzz cannot be" << " negative where Ryy = " << R_[facei].yy() - << ", and Rzz = " << R_[facei].zz() - << " at the face centre = " << faceCentres[facei] - << exit(FatalError); + << ", and Rzz = " << R_[facei].zz(); + break; } const scalar x0 = R_[facei].xx()*R_[facei].yy() - sqr(R_[facei].xy()); if (x0 <= 0) { + badFacei = facei; FatalErrorInFunction << "Reynolds stress tensor component group, Rxx*Ryy - Rxy^2" - << " cannot be negative or zero" - << " at the face centre = " << faceCentres[facei] - << exit(FatalError); + << " cannot be negative or zero"; + break; } const scalar x1 = R_[facei].zz() - sqr(R_[facei].xz())/R_[facei].xx(); @@ -202,15 +202,23 @@ void Foam::turbulentDigitalFilterInletFvPatchVectorField::checkR() const if (x3 < 0) { + badFacei = facei; FatalErrorInFunction << "Reynolds stress tensor component group, " << "Rzz - Rxz^2/Rxx - (Ryz - Rxy*Rxz/(Rxx*(Rxx*Ryy - Rxy^2)))^2" - << " cannot be negative at the face centre = " - << faceCentres[facei] - << exit(FatalError); + << " cannot be negative"; + break; } } + if (badFacei >= 0) + { + FatalError + << " at the face centre = " + << this->patch().patch().faceCentres()[badFacei] + << exit(FatalError); + } + Info<< " # Reynolds stress tensor on patch is consistent #" << endl; } diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 27a8e0da6a..302fcc9204 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -79,7 +79,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing() const vectorField nf(patch.nf()); const vectorField faceCellCentres(patch.patch().faceCellCentres()); const labelUList& faceCells = patch.patch().faceCells(); - const vectorField::subField& faceCentres = patch.patch().faceCentres(); + const vectorField::subField faceCentres = patch.patch().faceCentres(); forAll(patch, patchFacei) { diff --git a/src/mesh/snappyHexMesh/meshRefinement/weightedPosition.H b/src/mesh/snappyHexMesh/meshRefinement/weightedPosition.H index 0594b1f9a3..a56fe80d25 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/weightedPosition.H +++ b/src/mesh/snappyHexMesh/meshRefinement/weightedPosition.H @@ -37,7 +37,7 @@ Description Typical use might be to e.g. average face centres to points on a patch const labelListList& pointFaces = pp.pointFaces(); - const pointField& faceCentres = pp.faceCentres(); + const vectorField::subField faceCentres = pp.faceCentres(); Field avgBoundary(pointFaces.size()); diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C index b301f66041..28d1ed4da8 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C @@ -136,7 +136,7 @@ void Foam::faceReflecting::initialise(const dictionary& coeffs) forAll(patches, patchI) { const polyPatch& pp = patches[patchI]; - const pointField& cf = pp.faceCentres(); + const vectorField::subField cf = pp.faceCentres(); if (!pp.coupled() && !isA(pp)) { diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C index 2ce4008006..675a1b6de9 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C @@ -155,7 +155,7 @@ void Foam::faceShading::calculate() forAll(patches, patchI) { const polyPatch& pp = patches[patchI]; - const pointField& cf = pp.faceCentres(); + const vectorField::subField cf = pp.faceCentres(); if (!pp.coupled() && !isA(pp)) {