From 3baebcb1011b42b5f08a6ad2912a77512084c5be Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 15 Jul 2020 10:47:53 +0200 Subject: [PATCH 1/8] STYLE: replace uses of autoPtr::empty() with bool check (#1775) - less clutter using plain tests with the bool operator: (!ptr) vs (ptr.empty()) (ptr) vs (!ptr.empty()) --- .../DelaunayMesh/DistributedDelaunayMesh.C | 5 +- .../mapDistribute/mapDistributeBase.C | 2 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 8 +-- .../thermalBaffle1DFvPatchScalarField.C | 2 +- .../pointHistory/pointHistory.C | 12 ++--- .../turbulentDFSEMInletFvPatchVectorField.C | 2 +- ...lentDigitalFilterInletFvPatchVectorField.C | 2 +- .../field/streamLine/streamLineBase.C | 4 +- ...surfaceDisplacementPointPatchVectorField.C | 2 +- ...aceSlipDisplacementPointPatchVectorField.C | 2 +- ...irectionalPressureGradientExplicitSource.C | 2 +- .../meanVelocityForce/meanVelocityForce.C | 2 +- .../Templates/KinematicCloud/KinematicCloud.C | 4 +- .../KinematicCloud/KinematicCloudI.H | 4 +- .../mappedPolyPatch/mappedPatchBaseI.H | 5 +- .../triSurfaceMesh/triSurfaceMesh.C | 2 +- .../triSurfaceSearch/triSurfaceSearch.C | 2 +- .../adjointBoundaryCondition.C | 4 +- .../objectiveForceTarget.C | 2 +- .../objectiveIncompressible.C | 40 +++++++-------- .../objectivePartialVolume.C | 2 +- .../objectivePtLosses/objectivePtLosses.C | 2 +- .../adjoint/objectives/objective/objective.C | 50 +++++++++---------- .../FIBase/FIBaseIncompressible.C | 2 +- .../sensitivitySurfaceIncompressible.C | 4 +- .../sensitivitySurfacePointsIncompressible.C | 4 +- .../optMeshMovement/optMeshMovement.C | 2 +- .../optimisation/updateMethod/SQP/SQP.C | 2 +- .../NURBS/NURBS3DSurface/NURBS3DSurface.C | 6 +-- .../NURBS3DVolume/NURBS3DVolume.C | 10 ++-- .../optimisation/SIMPLEControlOpt.C | 2 +- .../adjointRASModel/adjointRASModel.C | 4 +- .../dynamicOversetFvMesh.C | 6 +-- .../thermalBaffleFvPatchScalarField.C | 10 +--- .../sampledSets/sampledSetsTemplates.C | 4 +- .../isoSurface/sampledIsoSurface.C | 8 +-- .../sampledCuttingPlane/sampledCuttingPlane.C | 6 +-- .../sampledSurfacesTemplates.C | 4 +- .../linearSpringDamper/linearSpringDamper.C | 2 +- .../sixDoFRigidBodyMotionIO.C | 2 +- .../radiationModel/radiationModel.C | 2 +- .../radiationModels/solarLoad/solarLoad.C | 6 +-- .../greyMeanAbsorptionEmission.C | 3 +- .../wideBandAbsorptionEmission.C | 3 +- .../boundaryRadiationProperties.C | 22 ++++---- 45 files changed, 135 insertions(+), 141 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C index bbd54cf475..e02810916d 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -625,7 +626,7 @@ void Foam::DistributedDelaunayMesh::sync return; } - if (allBackgroundMeshBounds_.empty()) + if (!allBackgroundMeshBounds_) { distributeBoundBoxes(bb); } @@ -810,7 +811,7 @@ void Foam::DistributedDelaunayMesh::sync(const boundBox& bb) return; } - if (allBackgroundMeshBounds_.empty()) + if (!allBackgroundMeshBounds_) { distributeBoundBoxes(bb); } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 5eb53d4214..1f9cb43585 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -176,7 +176,7 @@ Foam::List Foam::mapDistributeBase::schedule const Foam::List& Foam::mapDistributeBase::schedule() const { - if (schedulePtr_.empty()) + if (!schedulePtr_) { schedulePtr_.reset ( diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 4e1d725c89..b81813c293 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -860,7 +860,7 @@ Foam::label Foam::polyMesh::nSolutionD() const const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const { - if (tetBasePtIsPtr_.empty()) + if (!tetBasePtIsPtr_) { if (debug) { @@ -894,7 +894,7 @@ const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const const Foam::indexedOctree& Foam::polyMesh::cellTree() const { - if (cellTreePtr_.empty()) + if (!cellTreePtr_) { treeBoundBox overallBb(points()); @@ -1087,7 +1087,7 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const const Foam::pointField& Foam::polyMesh::oldPoints() const { - if (oldPointsPtr_.empty()) + if (!oldPointsPtr_) { if (debug) { @@ -1233,7 +1233,7 @@ void Foam::polyMesh::resetMotion() const const Foam::globalMeshData& Foam::polyMesh::globalData() const { - if (globalMeshDataPtr_.empty()) + if (!globalMeshDataPtr_) { if (debug) { diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index f982ed44ed..aea435936e 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -206,7 +206,7 @@ const solidType& thermalBaffle1DFvPatchScalarField::solid() const { if (this->owner()) { - if (solidPtr_.empty()) + if (!solidPtr_) { solidPtr_.reset(new solidType(solidDict_)); } diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C index 96470ec5fe..fe61625241 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C @@ -91,7 +91,7 @@ Foam::pointHistory::pointHistory refHistoryPoint_(dict.lookup("refHistoryPoint")), processor_(-1), fileName_(dict.get("fileName")), - historyFilePtr_() + historyFilePtr_(nullptr) { Info<< "Creating " << this->name() << " function object." << endl; @@ -144,7 +144,7 @@ Foam::pointHistory::pointHistory } // Create history file if not already created - if (historyFilePtr_.empty()) + if (!historyFilePtr_) { // File update if (Pstream::master()) @@ -180,13 +180,11 @@ Foam::pointHistory::pointHistory ); // Add headers to output data - if (historyFilePtr_.valid()) + if (historyFilePtr_) { historyFilePtr_() - << "# Time" << tab << "X" << tab - << "Y" << tab << "Z"; - - historyFilePtr_() << endl; + << "# Time" << tab << "X" << tab << "Y" << tab << "Z" + << endl; } } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index b5f75212eb..238b84c502 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -190,7 +190,7 @@ const Foam::pointToPointPlanarInterpolation& Foam::turbulentDFSEMInletFvPatchVectorField::patchMapper() const { // Initialise interpolation (2D planar interpolation by triangulation) - if (mapperPtr_.empty()) + if (!mapperPtr_) { const fileName samplePointsFile ( diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C index ac8709c6dd..6ad03839f7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C @@ -36,7 +36,7 @@ const Foam::pointToPointPlanarInterpolation& Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const { // Initialise interpolation (2D planar interpolation by triangulation) - if (mapperPtr_.empty()) + if (!mapperPtr_) { // Reread values and interpolate const fileName samplePointsFile diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 4fb9e9e3c7..93b9ff90ac 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -65,7 +65,7 @@ Foam::functionObjects::streamLineBase::trackDirTypeNames const Foam::word& Foam::functionObjects::streamLineBase::sampledSetAxis() const { - if (sampledSetPtr_.empty()) + if (!sampledSetPtr_) { sampledSetPoints(); } @@ -77,7 +77,7 @@ Foam::functionObjects::streamLineBase::sampledSetAxis() const const Foam::sampledSet& Foam::functionObjects::streamLineBase::sampledSetPoints() const { - if (sampledSetPtr_.empty()) + if (!sampledSetPtr_) { sampledSetPtr_ = sampledSet::New ( diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C index 549499a162..236616ccee 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C @@ -394,7 +394,7 @@ surfaceDisplacementPointPatchVectorField const Foam::searchableSurfaces& Foam::surfaceDisplacementPointPatchVectorField::surfaces() const { - if (surfacesPtr_.empty()) + if (!surfacesPtr_) { surfacesPtr_.reset ( diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 06ae45244a..b64a78cca4 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -380,7 +380,7 @@ surfaceSlipDisplacementPointPatchVectorField const Foam::searchableSurfaces& Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const { - if (surfacesPtr_.empty()) + if (!surfacesPtr_) { surfacesPtr_.reset ( diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index 1b01f2f995..322a6c0636 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -501,7 +501,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain const label ) { - if (invAPtr_.empty()) + if (!invAPtr_) { invAPtr_.reset ( diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 41ad35a514..63d0af689e 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -237,7 +237,7 @@ void Foam::fv::meanVelocityForce::constrain const label ) { - if (rAPtr_.empty()) + if (!rAPtr_) { rAPtr_.reset ( diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index b7d6d49e4a..f35a0cd11f 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -139,7 +139,7 @@ void Foam::KinematicCloud::solve template void Foam::KinematicCloud::buildCellOccupancy() { - if (cellOccupancyPtr_.empty()) + if (!cellOccupancyPtr_) { cellOccupancyPtr_.reset ( @@ -174,7 +174,7 @@ void Foam::KinematicCloud::updateCellOccupancy() // Only build the cellOccupancy if the pointer is set, i.e. it has // been requested before. - if (cellOccupancyPtr_.valid()) + if (cellOccupancyPtr_) { buildCellOccupancy(); } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 9b2ec4d669..65b35bde96 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -370,7 +370,7 @@ template inline Foam::List>& Foam::KinematicCloud::cellOccupancy() { - if (cellOccupancyPtr_.empty()) + if (!cellOccupancyPtr_) { buildCellOccupancy(); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H index dc507b64e6..f8bc08307c 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -150,10 +151,10 @@ inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const if (topoChange) { - mapPtr_.clear(); + mapPtr_.reset(nullptr); } - if (mapPtr_.empty()) + if (!mapPtr_) { calcMapping(); } diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index f80643164b..8173fec3bb 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -644,7 +644,7 @@ void Foam::triSurfaceMesh::movePoints(const pointField& newPoints) const Foam::indexedOctree& Foam::triSurfaceMesh::edgeTree() const { - if (edgeTree_.empty()) + if (!edgeTree_) { if (debug) { diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index f58dc0691f..c281014c8b 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -205,7 +205,7 @@ void Foam::triSurfaceSearch::clearOut() const Foam::indexedOctree& Foam::triSurfaceSearch::tree() const { - if (treePtr_.empty()) + if (!treePtr_) { // Calculate bb without constructing local point numbering. treeBoundBox bb(Zero, Zero); diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C index 2febf7f912..cfcbdb63f2 100644 --- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -143,7 +143,7 @@ adjointBoundaryCondition::computePatchGrad(word name) template bool adjointBoundaryCondition::addATCUaGradUTerm() { - if (addATCUaGradUTerm_.empty()) + if (!addATCUaGradUTerm_) { addATCUaGradUTerm_.reset(new bool(isA(getATC()))); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C index b6895320e3..6f8ccd0b2d 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C @@ -83,7 +83,7 @@ bool objectiveForceTarget::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 5; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C index dbc0789d24..5564671e54 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C @@ -130,7 +130,7 @@ autoPtr objectiveIncompressible::New void objectiveIncompressible::doNormalization() { - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { const scalar oneOverNorm(1./normFactor_()); @@ -191,7 +191,7 @@ void objectiveIncompressible::doNormalization() const volVectorField& objectiveIncompressible::dJdv() { - if (dJdvPtr_.empty()) + if (!dJdvPtr_) { // If pointer is not set, set it to a zero field dJdvPtr_.reset @@ -210,7 +210,7 @@ const volVectorField& objectiveIncompressible::dJdv() const volScalarField& objectiveIncompressible::dJdp() { - if (dJdpPtr_.empty()) + if (!dJdpPtr_) { // If pointer is not set, set it to a zero field dJdpPtr_.reset @@ -229,7 +229,7 @@ const volScalarField& objectiveIncompressible::dJdp() const volScalarField& objectiveIncompressible::dJdT() { - if (dJdTPtr_.empty()) + if (!dJdTPtr_) { // If pointer is not set, set it to a zero field dJdTPtr_.reset @@ -248,7 +248,7 @@ const volScalarField& objectiveIncompressible::dJdT() const volScalarField& objectiveIncompressible::dJdTMvar1() { - if (dJdTMvar1Ptr_.empty()) + if (!dJdTMvar1Ptr_) { // If pointer is not set, set it to a zero field dJdTMvar1Ptr_.reset @@ -267,7 +267,7 @@ const volScalarField& objectiveIncompressible::dJdTMvar1() const volScalarField& objectiveIncompressible::dJdTMvar2() { - if (dJdTMvar2Ptr_.empty()) + if (!dJdTMvar2Ptr_) { // If pointer is not set, set it to a zero field dJdTMvar2Ptr_.reset @@ -289,7 +289,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdv const label patchI ) { - if (bdJdvPtr_.empty()) + if (!bdJdvPtr_) { bdJdvPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -302,7 +302,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdvn const label patchI ) { - if (bdJdvnPtr_.empty()) + if (!bdJdvnPtr_) { bdJdvnPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -315,7 +315,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdvt const label patchI ) { - if (bdJdvtPtr_.empty()) + if (!bdJdvtPtr_) { bdJdvtPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -328,7 +328,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdp const label patchI ) { - if (bdJdpPtr_.empty()) + if (!bdJdpPtr_) { bdJdpPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -341,7 +341,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdT const label patchI ) { - if (bdJdTPtr_.empty()) + if (!bdJdTPtr_) { bdJdTPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -354,7 +354,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar1 const label patchI ) { - if (bdJdTMvar1Ptr_.empty()) + if (!bdJdTMvar1Ptr_) { bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -367,7 +367,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2 const label patchI ) { - if (bdJdTMvar2Ptr_.empty()) + if (!bdJdTMvar2Ptr_) { bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -377,7 +377,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2 const boundaryVectorField& objectiveIncompressible::boundarydJdv() { - if (bdJdvPtr_.empty()) + if (!bdJdvPtr_) { bdJdvPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -387,7 +387,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdv() const boundaryScalarField& objectiveIncompressible::boundarydJdvn() { - if (bdJdvnPtr_.empty()) + if (!bdJdvnPtr_) { bdJdvnPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -397,7 +397,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdvn() const boundaryVectorField& objectiveIncompressible::boundarydJdvt() { - if (bdJdvtPtr_.empty()) + if (!bdJdvtPtr_) { bdJdvtPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -407,7 +407,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdvt() const boundaryVectorField& objectiveIncompressible::boundarydJdp() { - if (bdJdpPtr_.empty()) + if (!bdJdpPtr_) { bdJdpPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -417,7 +417,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdp() const boundaryScalarField& objectiveIncompressible::boundarydJdT() { - if (bdJdTPtr_.empty()) + if (!bdJdTPtr_) { bdJdTPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -427,7 +427,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdT() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1() { - if (bdJdTMvar1Ptr_.empty()) + if (!bdJdTMvar1Ptr_) { bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -437,7 +437,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar2() { - if (bdJdTMvar2Ptr_.empty()) + if (!bdJdTMvar2Ptr_) { bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr(mesh_)); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C index 3bd600a9e8..6cb85fea56 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C @@ -137,7 +137,7 @@ bool objectivePartialVolume::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 6; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() << setw(4) << "#" << " "; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C index 5379282445..3bbfb18177 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C @@ -242,7 +242,7 @@ bool objectivePtLosses::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 5; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() << setw(4) << "#" << " "; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C index 5a0bf4dea6..b4e3e2d8a3 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C @@ -256,7 +256,7 @@ scalar objective::JCycle() const J -= target_; // Normalize here, in order to get the correct value for line search - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { J /= normFactor_(); } @@ -267,7 +267,7 @@ scalar objective::JCycle() const void objective::updateNormalizationFactor() { - if (normalize_ && normFactor_.empty()) + if (normalize_ && !normFactor_) { normFactor_.reset(new scalar(JCycle())); } @@ -327,7 +327,7 @@ bool objective::normalize() const void objective::doNormalization() { - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { const scalar oneOverNorm(1./normFactor_()); @@ -414,7 +414,7 @@ void objective::incrementIntegrationTimes(const scalar timeSpan) const volScalarField& objective::dJdb() { - if (dJdbPtr_.empty()) + if (!dJdbPtr_) { // If pointer is not set, set it to a zero field dJdbPtr_.reset @@ -434,7 +434,7 @@ const volScalarField& objective::dJdb() const fvPatchVectorField& objective::boundarydJdb(const label patchI) { - if (bdJdbPtr_.empty()) + if (!bdJdbPtr_) { bdJdbPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -444,7 +444,7 @@ const fvPatchVectorField& objective::boundarydJdb(const label patchI) const fvPatchVectorField& objective::dSdbMultiplier(const label patchI) { - if (bdSdbMultPtr_.empty()) + if (!bdSdbMultPtr_) { bdSdbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -454,7 +454,7 @@ const fvPatchVectorField& objective::dSdbMultiplier(const label patchI) const fvPatchVectorField& objective::dndbMultiplier(const label patchI) { - if (bdndbMultPtr_.empty()) + if (!bdndbMultPtr_) { bdndbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -464,7 +464,7 @@ const fvPatchVectorField& objective::dndbMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbMultiplier(const label patchI) { - if (bdxdbMultPtr_.empty()) + if (!bdxdbMultPtr_) { bdxdbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -474,7 +474,7 @@ const fvPatchVectorField& objective::dxdbMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbDirectMultiplier(const label patchI) { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -488,7 +488,7 @@ const vectorField& objective::boundaryEdgeMultiplier const label edgeI ) { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { FatalErrorInFunction << "Unallocated boundaryEdgeMultiplier field" @@ -500,7 +500,7 @@ const vectorField& objective::boundaryEdgeMultiplier const fvPatchTensorField& objective::boundarydJdStress(const label patchI) { - if (bdJdStressPtr_.empty()) + if (!bdJdStressPtr_) { bdJdStressPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -510,7 +510,7 @@ const fvPatchTensorField& objective::boundarydJdStress(const label patchI) const boundaryVectorField& objective::boundarydJdb() { - if (bdJdbPtr_.empty()) + if (!bdJdbPtr_) { bdJdbPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -520,7 +520,7 @@ const boundaryVectorField& objective::boundarydJdb() const boundaryVectorField& objective::dSdbMultiplier() { - if (bdSdbMultPtr_.empty()) + if (!bdSdbMultPtr_) { bdSdbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -530,7 +530,7 @@ const boundaryVectorField& objective::dSdbMultiplier() const boundaryVectorField& objective::dndbMultiplier() { - if (bdndbMultPtr_.empty()) + if (!bdndbMultPtr_) { bdndbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -540,7 +540,7 @@ const boundaryVectorField& objective::dndbMultiplier() const boundaryVectorField& objective::dxdbMultiplier() { - if (bdxdbMultPtr_.empty()) + if (!bdxdbMultPtr_) { bdxdbMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -550,7 +550,7 @@ const boundaryVectorField& objective::dxdbMultiplier() const boundaryVectorField& objective::dxdbDirectMultiplier() { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -560,7 +560,7 @@ const boundaryVectorField& objective::dxdbDirectMultiplier() const vectorField3& objective::boundaryEdgeMultiplier() { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { FatalErrorInFunction << "Unallocated boundaryEdgeMultiplier field" @@ -573,7 +573,7 @@ const vectorField3& objective::boundaryEdgeMultiplier() const boundaryTensorField& objective::boundarydJdStress() { - if (bdJdStressPtr_.empty()) + if (!bdJdStressPtr_) { bdJdStressPtr_.reset(createZeroBoundaryPtr(mesh_)); } @@ -583,7 +583,7 @@ const boundaryTensorField& objective::boundarydJdStress() const volScalarField& objective::divDxDbMultiplier() { - if (divDxDbMultPtr_.empty()) + if (!divDxDbMultPtr_) { // If pointer is not set, set it to a zero field divDxDbMultPtr_.reset @@ -604,7 +604,7 @@ const volScalarField& objective::divDxDbMultiplier() const volTensorField& objective::gradDxDbMultiplier() { - if (gradDxDbMultPtr_.empty()) + if (!gradDxDbMultPtr_) { // If pointer is not set, set it to a zero field gradDxDbMultPtr_.reset @@ -684,7 +684,7 @@ bool objective::write(const bool valid) const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); } @@ -703,7 +703,7 @@ void objective::writeInstantaneousValue() const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (instantValueFilePtr_.empty()) + if (!instantValueFilePtr_) { setInstantValueFilePtr(); } @@ -717,7 +717,7 @@ void objective::writeInstantaneousSeparator() const { if (Pstream::master()) { - if (instantValueFilePtr_.valid()) + if (instantValueFilePtr_) { instantValueFilePtr_() << endl; } @@ -740,7 +740,7 @@ void objective::writeMeanValue() const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (meanValueFilePtr_.empty()) + if (!meanValueFilePtr_) { setMeanValueFilePtr(); } @@ -755,7 +755,7 @@ void objective::writeMeanValue() const bool objective::writeData(Ostream& os) const { os.writeEntry("JMean", JMean_); - if (normFactor_.valid()) + if (normFactor_) { os.writeEntry("normFactor", normFactor_()); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C index 4cc2993e2a..beb01e35e0 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C @@ -55,7 +55,7 @@ void FIBase::read() ); // Allocate distance solver if needed - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C index 50786bf00f..e35e990054 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C @@ -347,7 +347,7 @@ void sensitivitySurface::read() dict().getOrDefault("writeGeometricInfo", false); // Allocate new solvers if necessary - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( @@ -361,7 +361,7 @@ void sensitivitySurface::read() ) ); } - if (includeMeshMovement_ && meshMovementSolver_.empty()) + if (includeMeshMovement_ && !meshMovementSolver_) { meshMovementSolver_.reset ( diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C index 264839e515..fbe520c895 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C @@ -75,7 +75,7 @@ void sensitivitySurfacePoints::read() dict().getOrDefault("includeObjectiveContribution", true); // Allocate new solvers if necessary - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( @@ -90,7 +90,7 @@ void sensitivitySurfacePoints::read() ); } - if (includeMeshMovement_ && meshMovementSolver_.empty()) + if (includeMeshMovement_ && !meshMovementSolver_) { meshMovementSolver_.reset ( diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C index 1cce17ff3b..566165c67f 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C @@ -44,7 +44,7 @@ namespace Foam Foam::scalar Foam::optMeshMovement::getMaxAllowedDisplacement() const { - if (maxAllowedDisplacement_.empty()) + if (!maxAllowedDisplacement_) { FatalErrorInFunction << "maxAllowedDisplacement requested but not set" << nl diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C index 0563693e97..7626776fed 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C @@ -427,7 +427,7 @@ void Foam::SQP::write() constraintsSize = constraintsSize*(width + 1) + 2; // Open file and write header - if (meritFunctionFile_.empty()) + if (!meritFunctionFile_) { meritFunctionFile_.reset ( diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C index 30120c035e..25758e30bf 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -2038,7 +2038,7 @@ scalar NURBS3DSurface::lengthDerivativeV const labelList& NURBS3DSurface::getBoundaryCPIDs() { - if(boundaryCPIDs_.empty()) + if (!boundaryCPIDs_) { const label uNCPs(uBasis_.nCPs()); const label vNCPs(vBasis_.nCPs()); @@ -2082,7 +2082,7 @@ const labelList& NURBS3DSurface::getBoundaryCPIs() const label& NURBS3DSurface::whichBoundaryCPI(const label& globalCPI) { - if(whichBoundaryCPID_.empty()) + if (!whichBoundaryCPID_) { getBoundaryCPIDs(); } diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C index 908ed1ced2..eeb15d9554 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C @@ -1657,7 +1657,7 @@ Foam::scalar Foam::NURBS3DVolume::computeMaxBoundaryDisplacement Foam::tmp Foam::NURBS3DVolume::getPointsInBox() { - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1672,7 +1672,7 @@ Foam::tmp Foam::NURBS3DVolume::getPointsInBox() const Foam::labelList& Foam::NURBS3DVolume::getMap() { - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1683,7 +1683,7 @@ const Foam::labelList& Foam::NURBS3DVolume::getMap() const Foam::labelList& Foam::NURBS3DVolume::getReverseMap() { - if (reverseMapPtr_.empty()) + if (!reverseMapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1695,11 +1695,11 @@ const Foam::labelList& Foam::NURBS3DVolume::getReverseMap() const Foam::pointVectorField& Foam::NURBS3DVolume::getParametricCoordinates() { // If not computed yet, compute parametric coordinates - if (parametricCoordinatesPtr_.empty()) + if (!parametricCoordinatesPtr_) { // Find mesh points inside control points box // if they have been identified yet - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } diff --git a/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C b/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C index 3fe260bb6e..81336289bc 100644 --- a/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C +++ b/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C @@ -126,7 +126,7 @@ bool Foam::SIMPLEControlOpt::loop() Time& runTime = const_cast(mesh_.time()); // Sub-cycle time if this is the first iter - if (subCycledTimePtr_.empty()) + if (!subCycledTimePtr_) { subCycledTimePtr_.reset(new subCycleTime(runTime, nIters())); Info<< "Solving equations for solver " diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C index 6e81abaa01..3abbac727c 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C @@ -260,7 +260,7 @@ bool adjointRASModel::read() volScalarField& adjointRASModel::getAdjointTMVariable1Inst() { - if (adjointTMVariable1Ptr_.empty()) + if (!adjointTMVariable1Ptr_) { // if pointer is not set, set it to a zero field adjointTMVariable1Ptr_.reset @@ -287,7 +287,7 @@ volScalarField& adjointRASModel::getAdjointTMVariable1Inst() volScalarField& adjointRASModel::getAdjointTMVariable2Inst() { - if (adjointTMVariable2Ptr_.empty()) + if (!adjointTMVariable2Ptr_) { // if pointer is not set, set it to a zero field adjointTMVariable2Ptr_.reset diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C index 30479a1f07..89013e02d8 100644 --- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C +++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C @@ -551,7 +551,7 @@ const Foam::lduAddressing& Foam::dynamicOversetFvMesh::lduAddr() const //return dynamicMotionSolverFvMesh::lduAddr(); return dynamicFvMesh::lduAddr(); } - if (lduPtr_.empty()) + if (!lduPtr_) { // Build extended addressing updateAddressing(); @@ -567,7 +567,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const //return dynamicMotionSolverFvMesh::interfaces(); return dynamicFvMesh::interfaces(); } - if (lduPtr_.empty()) + if (!lduPtr_) { // Build extended addressing updateAddressing(); @@ -579,7 +579,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const const Foam::fvMeshPrimitiveLduAddressing& Foam::dynamicOversetFvMesh::primitiveLduAddr() const { - if (lduPtr_.empty()) + if (!lduPtr_) { FatalErrorInFunction << "Extended addressing not allocated" << abort(FatalError); diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index b22753658d..b9656debb4 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -110,7 +110,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField && regionName != "none" ) { - if (extrudeMeshPtr_.empty()) + if (!extrudeMeshPtr_) { createPatchMesh(); } @@ -249,14 +249,6 @@ void thermalBaffleFvPatchScalarField::createPatchMesh() regionPatches ) ); - - if (extrudeMeshPtr_.empty()) - { - WarningInFunction - << "Specified IOobject::MUST_READ_IF_MODIFIED but class" - << " patchMeshPtr not set." - << endl; - } } diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 8a50c1c29f..6ffb818ed4 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -220,7 +220,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup& fields) const bool interpolate = interpolationScheme_ != "cell"; // Create or use existing writer - if (fields.formatter.empty()) + if (!fields.formatter) { fields = writeFormat_; } diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index a857c882db..314153913d 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -74,7 +74,7 @@ void Foam::sampledIsoSurface::getIsoFields() const if ( - storedVolFieldPtr_.empty() + !storedVolFieldPtr_ || (fvm.time().timeName() != storedVolFieldPtr_().instance()) ) { @@ -126,7 +126,7 @@ void Foam::sampledIsoSurface::getIsoFields() const // (volPointInterpolation::interpolate with cache=false deletes any // registered one or if mesh.changing()) - if (subMeshPtr_.empty()) + if (!subMeshPtr_) { const word pointFldName = "volPointInterpolate_" @@ -316,8 +316,8 @@ bool Foam::sampledIsoSurface::updateGeometry() const // Get sub-mesh if any if ( - (-1 != mesh().cellZones().findIndex(zoneNames_)) - && subMeshPtr_.empty() + !subMeshPtr_ + && (-1 != mesh().cellZones().findIndex(zoneNames_)) ) { const polyBoundaryMesh& patches = mesh().boundaryMesh(); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 6718ef56e7..0a9de84b92 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,8 +118,8 @@ void Foam::sampledCuttingPlane::createGeometry() // Get sub-mesh if any if ( - (-1 != mesh().cellZones().findIndex(zoneNames_)) - && subMeshPtr_.empty() + !subMeshPtr_ + && (-1 != mesh().cellZones().findIndex(zoneNames_)) ) { const polyBoundaryMesh& patches = mesh().boundaryMesh(); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 8033f18991..93e5e6f43c 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -110,7 +110,7 @@ void Foam::sampledSurfaces::performAction if (s.interpolate()) { - if (interpPtr.empty()) + if (!interpPtr) { interpPtr = interpolation::New ( @@ -123,7 +123,7 @@ void Foam::sampledSurfaces::performAction } else { - if (samplePtr.empty()) + if (!samplePtr) { samplePtr = interpolation::New ( diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C index 0e33400d02..556b0c4ef7 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C @@ -79,7 +79,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::restrain vector& restraintMoment ) const { - if (anchor_.empty()) + if (!anchor_) { anchor_.reset ( diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C index e60b01a0cf..e6cbb4d598 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C @@ -104,7 +104,7 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const os.endBlock(); } - if (!solver_.empty()) + if (solver_) { os << indent << "solver"; solver_->write(os); diff --git a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C index d526f35f21..f6ffb6c39a 100644 --- a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C +++ b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C @@ -237,7 +237,7 @@ void Foam::radiation::radiationModel::correct() firstIter_ = false; } - if (!soot_.empty()) + if (soot_) { soot_->correct(); } diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 944fdb14ba..315bd43c06 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,7 +58,7 @@ void Foam::radiation::solarLoad::updateReflectedRays const labelHashSet& includePatches ) { - if (reflectedFaces_.empty() && !hitFaces_.empty()) + if (!reflectedFaces_ && hitFaces_) { reflectedFaces_.reset ( @@ -117,7 +117,7 @@ void Foam::radiation::solarLoad::updateReflectedRays bool Foam::radiation::solarLoad::updateHitFaces() { - if (hitFaces_.empty()) + if (!hitFaces_) { hitFaces_.reset(new faceShading(mesh_, solarCalc_.direction())); return true; diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C index 5b0319f810..3e929ae677 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,7 +130,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission volScalarField* fldPtr = mesh.getObjectPtr(specieName); - if (!lookUpTablePtr_.empty()) + if (lookUpTablePtr_) { if (lookUpTablePtr_().found(specieName)) { diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C index d359849c58..9444a1e9a1 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -140,7 +141,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission volScalarField* fldPtr = mesh.getObjectPtr(specieName); - if (!lookUpTablePtr_.empty()) + if (lookUpTablePtr_) { if (lookUpTablePtr_().found(specieName)) { diff --git a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C index be0fe78bf2..3e25ef3d8f 100644 --- a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C +++ b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2018 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -115,7 +115,7 @@ Foam::radiation::boundaryRadiationProperties::emissivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->e ( @@ -144,7 +144,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceEmissivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->e ( @@ -174,7 +174,7 @@ Foam::radiation::boundaryRadiationProperties::absorptivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->a ( @@ -203,7 +203,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceAbsorptivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->a ( @@ -233,7 +233,7 @@ Foam::radiation::boundaryRadiationProperties::transmissivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->t ( @@ -262,7 +262,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceTransmissivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->t ( @@ -292,7 +292,7 @@ Foam::radiation::boundaryRadiationProperties::diffReflectivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rDiff ( @@ -321,7 +321,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceDiffReflectivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rDiff ( @@ -351,7 +351,7 @@ Foam::radiation::boundaryRadiationProperties::specReflectivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rSpec ( @@ -380,7 +380,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceSpecReflectivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rSpec ( -- GitLab From 9af3f85cf98b26daa4239bd89a6cdacabef2156a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 15 Jul 2020 08:50:57 +0200 Subject: [PATCH 2/8] STYLE: simplify short-circuit involving autoPtr (#1775) - with '&&' conditions, often better to check for non-null autoPtr first (it is cheap) - check as bool instead of valid() method for cleaner code, especially when the wrapped item itself has a valid/empty or good. Also when handling multiple checks. Now if (ptr && ptr->valid()) if (ptr1 || ptr2) instead if (ptr.valid() && ptr->valid()) if (ptr1.valid() || ptr2.valid()) --- .../BlendedInterfacialModel.C | 65 ++++++++++--------- .../test/dictionaryTokens/dictionaryTokens.C | 18 ++--- .../extrude/extrudeMesh/extrudeMesh.C | 6 +- .../manipulation/checkMesh/checkGeometry.C | 2 +- .../redistributePar/redistributePar.C | 4 +- .../foamToVTK/convertAreaFields.H | 4 +- .../dataConversion/foamToVTK/writeDimFields.H | 4 +- .../dataConversion/foamToVTK/writeVolFields.H | 4 +- .../setExprFields/setExprFields.C | 2 +- .../surface/surfaceCheck/surfaceCheck.C | 2 +- .../surfaceFeatureExtract.C | 4 +- src/OpenFOAM/db/regIOobject/regIOobjectRead.C | 4 +- .../polyMesh/globalMeshData/globalMeshData.C | 10 +-- .../expressions/base/fvExprDriver.C | 4 +- .../expressions/base/fvExprDriverIO.C | 8 +-- .../surfaceFieldValue/surfaceFieldValueI.H | 4 +- .../surfaceFieldValueTemplates.C | 2 +- .../reactionsSensitivityAnalysis.C | 2 +- .../regionSizeDistribution.C | 4 +- .../forces/forceCoeffs/forceCoeffs.C | 4 +- src/functionObjects/forces/forces/forces.C | 2 +- .../utilities/vtkWrite/vtkWriteTemplates.C | 4 +- .../snappySnapDriverFeature.C | 26 +++----- .../mappedPolyPatch/mappedPatchBase.C | 2 +- .../NURBS3DVolume/NURBS3DVolume.C | 2 +- .../RAS/RASModelVariables/RASModelVariables.C | 4 +- ...allBoilingWallFunctionFvPatchScalarField.C | 12 ++-- .../BlendedInterfacialModel.C | 11 ++-- .../sampledSet/shortestPath/shortestPathSet.C | 2 +- .../isoSurface/sampledIsoSurfaceCell.C | 2 +- .../isoSurface/sampledIsoSurfaceTopo.C | 4 +- .../sampledCuttingPlane/sampledCuttingPlane.C | 4 +- .../sampledSurfaces/sampledSurfaces.C | 4 +- .../sampledThresholdCellFaces.C | 3 +- .../radiationModels/solarLoad/solarLoad.C | 2 +- 35 files changed, 118 insertions(+), 123 deletions(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C index cd7570bf26..89033668c5 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,12 +130,12 @@ Foam::BlendedInterfacialModel::K() const { tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } @@ -157,17 +158,17 @@ Foam::BlendedInterfacialModel::K() const ) ); - if (model_.valid()) + if (model_) { x.ref() += model_->K()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->K()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->K()*f2; } @@ -175,7 +176,7 @@ Foam::BlendedInterfacialModel::K() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -191,7 +192,7 @@ Foam::BlendedInterfacialModel::Kf() const { tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = fvc::interpolate ( @@ -199,7 +200,7 @@ Foam::BlendedInterfacialModel::Kf() const ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = fvc::interpolate ( @@ -225,17 +226,17 @@ Foam::BlendedInterfacialModel::Kf() const ) ); - if (model_.valid()) + if (model_) { x.ref() += model_->Kf()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->Kf()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->Kf()*f2; } @@ -243,7 +244,7 @@ Foam::BlendedInterfacialModel::Kf() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -260,12 +261,12 @@ Foam::BlendedInterfacialModel::F() const { tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } @@ -285,17 +286,17 @@ Foam::BlendedInterfacialModel::F() const dimensioned(modelType::dimF, Zero) ); - if (model_.valid()) + if (model_) { x.ref() += model_->F()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->F()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() -= model2In1_->F()*f2; // note : subtraction } @@ -303,7 +304,7 @@ Foam::BlendedInterfacialModel::F() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -319,7 +320,7 @@ Foam::BlendedInterfacialModel::Ff() const { tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = fvc::interpolate ( @@ -327,7 +328,7 @@ Foam::BlendedInterfacialModel::Ff() const ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = fvc::interpolate ( @@ -352,17 +353,17 @@ Foam::BlendedInterfacialModel::Ff() const x.ref().setOriented(); - if (model_.valid()) + if (model_) { x.ref() += model_->Ff()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->Ff()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() -= model2In1_->Ff()*f2; // note : subtraction } @@ -370,7 +371,7 @@ Foam::BlendedInterfacialModel::Ff() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -386,12 +387,12 @@ Foam::BlendedInterfacialModel::D() const { tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } @@ -414,17 +415,17 @@ Foam::BlendedInterfacialModel::D() const ) ); - if (model_.valid()) + if (model_) { x.ref() += model_->D()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->D()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->D()*f2; } @@ -432,7 +433,7 @@ Foam::BlendedInterfacialModel::D() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -451,8 +452,8 @@ bool Foam::BlendedInterfacialModel::hasModel return ( &phase == &(pair_.phase1()) - ? model1In2_.valid() - : model2In1_.valid() + ? bool(model1In2_) + : bool(model2In1_) ); } diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C index d958b5d945..f61f6ea34c 100644 --- a/applications/test/dictionaryTokens/dictionaryTokens.C +++ b/applications/test/dictionaryTokens/dictionaryTokens.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,8 +53,8 @@ Foam::token Foam::dictionaryTokens::keywordToken(const entry& e) bool Foam::dictionaryTokens::setIterator() const { - primIter_.clear(); - dictIter_.clear(); + primIter_.reset(nullptr); + dictIter_.reset(nullptr); if (entryIter_ != dict_.cend()) { @@ -166,8 +166,8 @@ bool Foam::dictionaryTokens::good() const entryIter_ != dict_.cend() && ( - (primIter_.valid() && primIter_().good()) - || (dictIter_.valid() && dictIter_().good()) + (primIter_ && primIter_->good()) + || (dictIter_ && dictIter_->good()) ) ); } @@ -189,8 +189,8 @@ const Foam::token& Foam::dictionaryTokens::operator*() const { if (good()) { - if (primIter_.valid()) return *(primIter_()); - if (dictIter_.valid()) return *(dictIter_()); + if (primIter_) return *(*primIter_); + if (dictIter_) return *(*dictIter_); } return token::undefinedToken; @@ -251,8 +251,8 @@ bool Foam::dictionaryTokens::operator++() if (ok) { - if (primIter_.valid()) ok = ++(primIter_()); - if (dictIter_.valid()) ok = ++(dictIter_()); + if (primIter_) ok = ++(*primIter_); + if (dictIter_) ok = ++(*dictIter_); if (!ok) { diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 971c546c29..6a08caed38 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -815,9 +815,9 @@ int main(int argc, char *argv[]) polyMesh& mesh = ( - meshFromMesh.valid() - ? meshFromMesh() - : meshFromSurface() + meshFromMesh + ? *meshFromMesh + : *meshFromSurface ); diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 4f1f821681..f1a6b5ff3f 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -954,7 +954,7 @@ Foam::label Foam::checkGeometry patchWriter.reset(new surfaceWriters::vtkWriter()); } - surfaceWriter& wr = (surfWriter.valid() ? *surfWriter : *patchWriter); + surfaceWriter& wr = (surfWriter ? *surfWriter : *patchWriter); // Currently only do AMI checks diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 9043525a32..d624982254 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -1415,9 +1415,9 @@ autoPtr createReconstructMap autoPtr mapPtr; - if (baseMeshPtr.valid() && baseMeshPtr().nCells()) + if (baseMeshPtr && baseMeshPtr->nCells()) { - const fvMesh& baseMesh = baseMeshPtr(); + const fvMesh& baseMesh = *baseMeshPtr; labelListList cellSubMap(Pstream::nProcs()); cellSubMap[Pstream::masterNo()] = identity(mesh.nCells()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H index 923cf7fabf..2466cda860 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,7 @@ if (doFiniteArea) FatalError.throwExceptions(throwing); } - if (faMeshPtr.valid() && nAreaFields) + if (faMeshPtr && nAreaFields) { reportFields::area(Info, objects); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H index bcaf81a9d8..6bdfa0096e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,7 +85,7 @@ bool writeDimField const auto& field = tfield(); - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { internalWriter->write(field, *pInterp); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H index 03bb2bbfe9..e92186fe47 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ bool writeVolField const auto& field = tfield(); // Internal - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { internalWriter->write(field, *pInterp); } diff --git a/applications/utilities/preProcessing/setExprFields/setExprFields.C b/applications/utilities/preProcessing/setExprFields/setExprFields.C index 2b995e0c31..218c1ecfbf 100644 --- a/applications/utilities/preProcessing/setExprFields/setExprFields.C +++ b/applications/utilities/preProcessing/setExprFields/setExprFields.C @@ -723,7 +723,7 @@ int main(int argc, char *argv[]) mesh.readUpdate(); - if (args.found("dummy-phi") && !dummyPhi.valid()) + if (args.found("dummy-phi") && !dummyPhi) { Info<< "Adding a dummy phi" << endl; dummyPhi.reset diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index d7492379ba..05f6f7c09c 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -1043,7 +1043,7 @@ int main(int argc, char *argv[]) // ) // ); // - // if (hitInfo.hit() && intStreamPtr.valid()) + // if (hitInfo.hit() && intStreamPtr) // { // intStreamPtr().write(hitInfo.hitPoint()); // diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 010cec6bd6..5523ab8417 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -346,14 +346,14 @@ int main(int argc, char *argv[]) // Load a single file, or load and combine multiple selected files autoPtr surfPtr = loader.load(loadingOption, scaleFactor); - if (!surfPtr.valid() || surfPtr().empty()) + if (!surfPtr || surfPtr->empty()) { FatalErrorInFunction << "Problem loading surface(s) for entry: " << dictName << exit(FatalError); } - triSurface surf = surfPtr(); + triSurface surf = *surfPtr; Info<< nl << "Statistics:" << nl; diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index e7fce79fdf..a779c4217f 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -185,7 +185,7 @@ void Foam::regIOobject::close() { Pout<< "regIOobject::close() : " << "finished reading " - << (isPtr_.valid() ? isPtr_().name() : "dummy") + << (isPtr_ ? isPtr_->name() : "dummy") << endl; } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 4062471af1..45a6afaacc 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -128,8 +128,8 @@ void Foam::globalMeshData::calcSharedPoints() const if ( nGlobalPoints_ != -1 - || sharedPointLabelsPtr_.valid() - || sharedPointAddrPtr_.valid() + || sharedPointLabelsPtr_ + || sharedPointAddrPtr_ ) { FatalErrorInFunction @@ -295,8 +295,8 @@ void Foam::globalMeshData::calcSharedEdges() const if ( nGlobalEdges_ != -1 - || sharedEdgeLabelsPtr_.valid() - || sharedEdgeAddrPtr_.valid() + || sharedEdgeLabelsPtr_ + || sharedEdgeAddrPtr_ ) { FatalErrorInFunction diff --git a/src/finiteVolume/expressions/base/fvExprDriver.C b/src/finiteVolume/expressions/base/fvExprDriver.C index b363296dc4..a73c38986b 100644 --- a/src/finiteVolume/expressions/base/fvExprDriver.C +++ b/src/finiteVolume/expressions/base/fvExprDriver.C @@ -190,7 +190,7 @@ bool Foam::expressions::fvExprDriver::readDict { ITstream& is = eptr->stream(); - if (writer_.valid() && storedVariables_.size()) + if (writer_ && !storedVariables_.empty()) { WarningInFunction // << "Context: " << driverContext_ << nl @@ -216,7 +216,7 @@ bool Foam::expressions::fvExprDriver::readDict { ITstream& is = eptr->stream(); - if (writer_.valid() && delayedVariables_.size()) + if (writer_ && !delayedVariables_.empty()) { WarningInFunction // << "Context: " << driverContext_ << nl diff --git a/src/finiteVolume/expressions/base/fvExprDriverIO.C b/src/finiteVolume/expressions/base/fvExprDriverIO.C index 3a25df5bdb..93a64e1a2a 100644 --- a/src/finiteVolume/expressions/base/fvExprDriverIO.C +++ b/src/finiteVolume/expressions/base/fvExprDriverIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2010-2018 Bernhard Gschaider - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -261,16 +261,16 @@ Foam::Ostream& Foam::expressions::fvExprDriver::writeCommon void Foam::expressions::fvExprDriver::createWriterAndRead(const word& name) { - if (hasDataToWrite() && !writer_.valid()) + if (!writer_ && hasDataToWrite()) { - writer_.set(new exprDriverWriter(name + "_" + this->type(), *this)); + writer_.reset(new exprDriverWriter(name + "_" + this->type(), *this)); } } void Foam::expressions::fvExprDriver::tryWrite() const { - if (writer_.valid() && mesh().time().outputTime()) + if (writer_ && mesh().time().outputTime()) { writer_->write(); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H index 331d20cb2d..f1ce22a48a 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,7 +38,7 @@ withSurfaceFields() const ( stFaceZone == regionType_ || stPatch == regionType_ - || (sampledPtr_.valid() && sampledPtr_->withSurfaceFields()) + || (sampledPtr_ && sampledPtr_->withSurfaceFields()) ); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 620fa7d46a..8d136cc7af 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -370,7 +370,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues Field values(getFieldValues(fieldName, true)); // Write raw values on surface if specified - if (surfaceWriterPtr_.valid() && surfaceWriterPtr_->enabled()) + if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled()) { Field allValues(values); combineFields(allValues); diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 878ed42ea4..ef50d4e471 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -34,7 +34,7 @@ template void Foam::functionObjects::reactionsSensitivityAnalysis:: createFileNames() { - if (writeToFile() && !prodFilePtr_.valid()) + if (writeToFile() && !prodFilePtr_) { prodFilePtr_ = createFile("production"); writeHeader(prodFilePtr_(), "production"); diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 6375a4ca73..d5c2ee726f 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -413,8 +413,8 @@ bool Foam::functionObjects::regionSizeDistribution::write() const volScalarField& alpha = ( - alphaPtr.valid() - ? alphaPtr() + alphaPtr + ? *alphaPtr : obr_.lookupObject(alphaName_) ); diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index e55aa3ef07..5b5e2b2d7c 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,7 +54,7 @@ void Foam::functionObjects::forceCoeffs::createFiles() { // Note: Only possible to create bin files after bins have been initialised - if (writeToFile() && !coeffFilePtr_.valid()) + if (writeToFile() && !coeffFilePtr_) { coeffFilePtr_ = createFile("coefficient"); writeIntegratedHeader("Coefficients", coeffFilePtr_()); diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index b2e824f781..e3dbc07f1f 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -58,7 +58,7 @@ void Foam::functionObjects::forces::createFiles() { // Note: Only possible to create bin files after bins have been initialised - if (writeToFile() && !forceFilePtr_.valid()) + if (writeToFile() && !forceFilePtr_) { forceFilePtr_ = createFile("force"); writeIntegratedHeader("Force", forceFilePtr_()); diff --git a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C index 3152b74e89..1528db7951 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -126,7 +126,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields const auto& field = tfield(); // Internal - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { ok = true; internalWriter->write(field, *pInterp); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 9db24f0e39..752f6d5b95 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -1253,11 +1253,11 @@ void Foam::snappySnapDriver::featureAttractionUsingReconstruction const point& pt = pp.localPoints()[pointi]; - if (patchConstraints[pointi].first() == 2 && feStr.valid()) + if (feStr && patchConstraints[pointi].first() == 2) { feStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } - else if (patchConstraints[pointi].first() == 3 && fpStr.valid()) + else if (fpStr && patchConstraints[pointi].first() == 3) { fpStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } @@ -2580,11 +2580,7 @@ void Foam::snappySnapDriver::determineFeatures hasSnapped = true; // Debug: dump missed feature point - if - ( - missedMP0Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP0Str && !nearInfo.second().hit()) { missedMP0Str().write ( @@ -2649,11 +2645,7 @@ void Foam::snappySnapDriver::determineFeatures } // Debug: dump missed feature point - if - ( - missedMP1Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP1Str && !nearInfo.second().hit()) { missedMP1Str().write ( @@ -2693,8 +2685,8 @@ void Foam::snappySnapDriver::determineFeatures { if ( - patchConstraints[pointi].first() == 3 - && featurePointStr.valid() + featurePointStr + && patchConstraints[pointi].first() == 3 ) { featurePointStr().write @@ -2704,8 +2696,8 @@ void Foam::snappySnapDriver::determineFeatures } else if ( - patchConstraints[pointi].first() == 2 - && featureEdgeStr.valid() + featureEdgeStr + && patchConstraints[pointi].first() == 2 ) { featureEdgeStr().write @@ -2812,7 +2804,7 @@ void Foam::snappySnapDriver::determineFeatures } const pointIndexHit& info = nearInfo.second(); - if (info.hit() && featurePointStr.valid()) + if (featurePointStr && info.hit()) { featurePointStr().write ( diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index cef6859a6f..81babc9c45 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -763,7 +763,7 @@ const { const word surfType(surfDict_.getOrDefault("type", "none")); - if (!surfPtr_.valid() && surfType != "none") + if (!surfPtr_ && surfType != "none") { word surfName(surfDict_.getOrDefault("name", patch_.name())); diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C index eeb15d9554..46ed2da21d 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C @@ -63,7 +63,7 @@ Foam::label Foam::NURBS3DVolume::getCPID void Foam::NURBS3DVolume::findPointsInBox(const vectorField& meshPoints) { // It is considered an error to recompute points in the control boxes - if (mapPtr_.valid() || reverseMapPtr_.valid()) + if (mapPtr_ || reverseMapPtr_) { FatalErrorInFunction << "Attempting to recompute points residing within control boxes" diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C index b6e57519d6..4394e4884b 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -153,7 +153,7 @@ RASModelVariables::autoTmp RASModelVariables::cloneAutoTmp(const autoTmp& source) const { autoTmp returnField(nullptr); - if (source.valid() && source().valid()) + if (source && source->valid()) { const volScalarField& sf = source()(); DebugInfo diff --git a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C index 2d673c7d23..92f9c06aaf 100644 --- a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C +++ b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C @@ -646,12 +646,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs() if ( - CHFModel_.valid() - && CHFSoobModel_.valid() - && TDNBModel_.valid() - && MHFModel_.valid() - && LeidenfrostModel_.valid() - && filmBoilingModel_.valid() + CHFModel_ + && CHFSoobModel_ + && TDNBModel_ + && MHFModel_ + && LeidenfrostModel_ + && filmBoilingModel_ ) { diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C index b2b7ba7031..8aa6ad3e5d 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +107,7 @@ Foam::BlendedInterfacialModel::evaluate tmp f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blendedInterfacialModel::interpolate @@ -115,7 +116,7 @@ Foam::BlendedInterfacialModel::evaluate ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blendedInterfacialModel::interpolate @@ -177,7 +178,7 @@ Foam::BlendedInterfacialModel::evaluate if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -300,8 +301,8 @@ bool Foam::BlendedInterfacialModel::hasModel { return &phase == &(phase1_) - ? model1In2_.valid() - : model2In1_.valid(); + ? bool(model1In2_) + : bool(model2In1_); } diff --git a/src/sampling/sampledSet/shortestPath/shortestPathSet.C b/src/sampling/sampledSet/shortestPath/shortestPathSet.C index 2fcbdd0ed4..8b4ba57e65 100644 --- a/src/sampling/sampledSet/shortestPath/shortestPathSet.C +++ b/src/sampling/sampledSet/shortestPath/shortestPathSet.C @@ -969,7 +969,7 @@ void Foam::shortestPathSet::genSamples markLeakPath, iter, mesh, - (isBlockedFace.valid() ? isBlockedFace() : isBoundaryFace), + (isBlockedFace ? *isBlockedFace : isBoundaryFace), insidePoint, insideCelli, outsidePoint, diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C index c6d8380b05..a5fe5b56f0 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C index 058cf05fcf..a9ce4fba01 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceTopo::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 0a9de84b92..4d846848eb 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -164,8 +164,8 @@ void Foam::sampledCuttingPlane::createGeometry() // Select either the submesh or the underlying mesh const fvMesh& mesh = ( - subMeshPtr_.valid() - ? subMeshPtr_().subMesh() + subMeshPtr_ + ? subMeshPtr_->subMesh() : fvm ); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 6211ad7d6e..3779ff20d3 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -326,7 +326,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) surfDict ); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } @@ -392,7 +392,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) autoPtr surf = input.release(inputi); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C index 719286664f..bdf7861580 100644 --- a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -102,8 +102,9 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const fvm ); } + const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); thresholdCellFaces surf diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 315bd43c06..3d2eeb2d2d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -439,7 +439,7 @@ void Foam::radiation::solarLoad::calculateQdiff ); - if (finalAgglom_.size() > 0 && coarseMesh_.empty()) + if (!coarseMesh_ && !finalAgglom_.empty()) { coarseMesh_.reset ( -- GitLab From 12c91b9472eee094b36150f5d74ade19e485271f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 15 Jul 2020 08:50:57 +0200 Subject: [PATCH 3/8] STYLE: check autoPtr as plain bool instead of valid() - cleaner code, more similarity with unique_ptr Now if (ptr) if (!ptr) instead if (ptr.valid()) if (!ptr.valid()) --- .../orderedPhasePair/orderedPhasePair.C | 3 +- applications/test/autoPtr/Test-autoPtr.C | 14 ++--- .../combinePatchFaces/combinePatchFaces.C | 6 +- .../extrude/extrudeMesh/extrudeMesh.C | 16 ++--- .../manipulation/checkMesh/checkGeometry.C | 38 ++++++------ .../manipulation/checkMesh/checkMeshQuality.C | 2 +- .../manipulation/checkMesh/checkTopology.C | 22 +++---- .../manipulation/polyDualMesh/meshDualiser.C | 13 +++-- .../mesh/manipulation/setSet/setSet.C | 10 ++-- .../mesh/manipulation/topoSet/topoSet.C | 4 +- .../foamFormatConvert/foamFormatConvert.C | 4 +- .../decomposePar/domainDecomposition.C | 6 +- .../redistributePar/redistributePar.C | 10 ++-- .../foamToVTK/convertProcessorPatches.H | 4 +- .../foamToVTK/convertVolumeFields.H | 6 +- .../dataConversion/foamToVTK/writeDimFields.H | 2 +- .../foamToVTK/writePointFields.H | 4 +- .../dataConversion/foamToVTK/writeVolFields.H | 2 +- .../lumpedPointZones/lumpedPointZones.C | 4 +- .../setExprFields/setExprFields.C | 6 +- .../surface/surfaceCheck/surfaceCheck.C | 14 ++--- .../surfaceFeatureExtract.C | 6 +- .../surfaceMeshExport/surfaceMeshExport.C | 4 +- src/OpenFOAM/db/IOobjectList/IOobjectList.C | 6 +- .../functionObjectList/functionObjectList.C | 12 ++-- .../db/functionObjects/writeFile/writeFile.C | 2 +- src/OpenFOAM/db/regIOobject/regIOobjectRead.C | 6 +- .../expressions/exprResult/exprResult.C | 4 +- .../expressions/exprResult/exprResultI.H | 4 +- .../codedFixedValuePointPatchField.C | 4 +- src/OpenFOAM/global/argList/argList.C | 2 +- .../interpolationTable/interpolationTable.C | 2 +- .../GAMGAgglomeration/GAMGAgglomeration.H | 4 +- .../procFacesGAMGProcAgglomeration.C | 6 +- .../polyMesh/globalMeshData/globalMeshData.C | 58 +++++++++---------- .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.H | 3 +- .../polyBoundaryMesh/polyBoundaryMesh.C | 6 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 30 +++++----- src/OpenFOAM/meshes/polyMesh/polyMeshClear.C | 4 +- src/OpenFOAM/meshes/polyMesh/polyMeshIO.C | 2 +- src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C | 8 +-- .../constraint/processor/processorPolyPatch.C | 6 +- .../RAS/mixtureKEpsilon/mixtureKEpsilon.C | 2 +- .../codedFixedValueFvPatchField.C | 4 +- .../codedMixed/codedMixedFvPatchField.C | 4 +- .../fixedProfile/fixedProfileFvPatchField.C | 3 +- .../freestream/freestreamFvPatchField.C | 14 ++--- .../uniformFixedGradientFvPatchField.C | 2 +- .../surfaceFieldValue/surfaceFieldValue.C | 16 ++--- .../surfaceFieldValueTemplates.C | 8 +-- .../regionSizeDistribution.C | 2 +- .../codedFunctionObject/codedFunctionObject.C | 4 +- .../utilities/ensightWrite/ensightWrite.C | 2 +- .../ensightWrite/ensightWriteUpdate.C | 10 ++-- .../utilities/vtkWrite/vtkWrite.C | 6 +- .../utilities/vtkWrite/vtkWriteTemplates.C | 2 +- ...lacementComponentLaplacianFvMotionSolver.C | 2 +- .../displacementLaplacianFvMotionSolver.C | 6 +- ...dBodyDisplacementLaplacianFvMotionSolver.C | 6 +- ...meVaryingMappedFixedValuePointPatchField.C | 4 +- ...polatedDisplacementPointPatchVectorField.C | 4 +- .../interRegionOption/interRegionOptionI.H | 3 +- .../jouleHeatingSourceTemplates.C | 4 +- .../rotorDiskSourceTemplates.C | 4 +- .../sources/general/codedSource/CodedSource.C | 4 +- .../interRegionHeatTransferModelI.H | 3 +- .../tabulatedHeatTransfer.C | 4 +- .../tabulatedNTUHeatTransfer.C | 2 +- src/lagrangian/basic/Cloud/Cloud.C | 3 +- .../Templates/ReactingCloud/ReactingCloud.C | 4 +- .../ReactingMultiphaseCloud.C | 3 +- .../ThermoParcel/ThermoParcelTrackingDataI.H | 3 +- .../ParticleCollector/ParticleCollector.C | 2 +- .../ParticleErosion/ParticleErosion.C | 4 +- .../ParticleTracks/ParticleTracks.C | 8 +-- .../ParticleTrap/ParticleTrap.C | 4 +- .../VoidFraction/VoidFraction.C | 4 +- .../Lift/LiftForce/LiftForceI.H | 3 +- .../PressureGradient/PressureGradientForceI.H | 3 +- .../LocalInteraction/LocalInteraction.C | 4 +- .../projectCurveEdge/projectCurveEdge.C | 5 +- .../blockEdges/projectEdge/projectEdge.C | 5 +- .../blockFaces/projectFace/projectFace.C | 8 +-- .../displacementMeshMoverMotionSolver.C | 5 +- .../medialAxisMeshMover.C | 4 +- .../meshRefinement/meshRefinement.C | 2 +- .../meshRefinement/meshRefinementBaffles.C | 2 +- .../refinementFeatures/refinementFeatures.C | 2 +- .../snappyHexMeshDriver/snappyLayerDriver.C | 14 ++--- .../snappyHexMeshDriver/snappySnapDriver.C | 6 +- .../snappySnapDriverFeature.C | 14 ++--- .../AMIInterpolation/AMIInterpolation.C | 2 +- .../cyclicACMIPointPatchField.H | 7 ++- .../cyclicAMIPointPatchField.H | 7 ++- .../cyclicPeriodicAMIPolyPatch.C | 27 ++++----- .../mappedPolyPatch/mappedPatchBase.C | 2 +- src/meshTools/meshSearch/meshSearch.C | 8 +-- .../searchableSurfaces/searchableSurfaces.C | 2 +- .../objectiveIncompressible.C | 10 ++-- .../objectiveIncompressibleI.H | 26 ++++----- .../adjoint/objectives/objective/objective.C | 20 +++---- .../adjoint/objectives/objective/objectiveI.H | 26 ++++----- .../FIBase/FIBaseIncompressible.C | 2 +- .../adjointMeshMovementSolverIncompressible.C | 2 +- .../adjointSensitivityIncompressible.C | 2 +- .../sensitivitySurfaceIncompressible.C | 4 +- .../sensitivitySurfacePointsIncompressible.C | 4 +- .../sensitivity/sensitivity.C | 6 +- .../shapeSensitivitiesBase.C | 30 +++++----- .../steadyOptimisation/steadyOptimisation.C | 4 +- .../optimisationTypeIncompressible.C | 4 +- .../shapeOptimisationIncompressible.C | 2 +- .../NURBS3DVolume/NURBS3DVolume.C | 2 +- .../adjointRASModel/adjointRASModel.C | 12 ++-- .../cellVolumeWeightCellCellStencil.C | 10 ++-- .../cellVolumeWeightCellCellStencil.H | 2 +- .../inverseDistanceCellCellStencil.H | 4 +- .../decompose/decompose/decompositionModel.H | 4 +- .../distributedTriSurfaceMesh.C | 8 +-- .../exact/exactPatchDistMethod.C | 4 +- .../BlendedInterfacialModel.C | 6 +- ...terfaceCompositionPhaseChangePhaseSystem.C | 2 +- .../TwoResistanceHeatTransferPhaseSystem.C | 4 +- .../phaseSystem/phaseSystemTemplates.C | 4 +- .../regionModel/regionModel/regionModel.C | 2 +- .../regionModel/regionModel/regionModelI.H | 5 +- .../regionModel1D/regionModel1DI.H | 3 +- .../singleLayerRegion/singleLayerRegion.C | 5 +- .../sampledSet/patchSeed/patchSeedSet.C | 4 +- .../sampledSet/shortestPath/shortestPathSet.C | 7 +-- .../isoSurface/sampledIsoSurface.C | 8 +-- .../isoSurface/sampledIsoSurfaceTemplates.C | 6 +- .../readers/ensight/ensightSurfaceReader.C | 2 +- .../sampledCuttingPlaneTemplates.C | 6 +- .../sampledSurfacesTemplates.C | 2 +- .../SLGThermo/SLGThermo/SLGThermo.C | 9 +-- .../radiativeIntensityRay.C | 4 +- .../radiationModel/radiationModel.C | 6 +- .../dynamicMotionSolverTopoFvMesh.C | 4 +- .../linearValveFvMesh/linearValveFvMesh.C | 4 +- .../linearValveLayersFvMesh.C | 4 +- .../mixerFvMesh/mixerFvMesh.C | 2 +- .../movingConeTopoFvMesh.C | 2 +- .../rawTopoChangerFvMesh.C | 3 +- 144 files changed, 483 insertions(+), 470 deletions(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C index 65a87f642b..21b6214b4c 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,7 +86,7 @@ Foam::word Foam::orderedPhasePair::name() const Foam::tmp Foam::orderedPhasePair::E() const { - if (!aspectRatio_.valid()) + if (!aspectRatio_) { FatalErrorInFunction << "Aspect ratio model not specified for " << *this << "." diff --git a/applications/test/autoPtr/Test-autoPtr.C b/applications/test/autoPtr/Test-autoPtr.C index d0b18a0dad..ed621ea0f2 100644 --- a/applications/test/autoPtr/Test-autoPtr.C +++ b/applications/test/autoPtr/Test-autoPtr.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,7 @@ void testTransfer1(autoPtr ap) // Passed in copy, so automatically removes content // Transfer would be nice, but not actually needed - Info<< "recv " << Switch::name(ap.valid()) << nl; + Info<< "recv " << Switch::name(bool(ap)) << nl; } @@ -53,7 +53,7 @@ void testTransfer1(autoPtr ap) void testTransfer2(autoPtr&& ap) { // As rvalue, so this time we actually get to manage content - Info<< "recv " << Switch::name(ap.valid()) << nl; + Info<< "recv " << Switch::name(bool(ap)) << nl; } @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) testTransfer2(std::move(list)); - Info<<"now have valid=" << Switch::name(list.valid()); + Info<<"now have valid=" << Switch::name(bool(list)); if (list) { @@ -209,9 +209,9 @@ int main(int argc, char *argv[]) testTransfer2(std::move(list)); - Info<<"now have valid=" << Switch::name(list.valid()); + Info<<"now have valid=" << Switch::name(bool(list)); - if (list.valid()) + if (list) { Info<< nl << flatOutput(*list) << " @ " << name(list->cdata()) @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) auto ptr1 = autoPtr::New(); auto ptr2 = autoPtr::New(); - Info<<"ptr valid: " << ptr1.valid() << nl; + Info<<"ptr valid: " << bool(ptr1) << nl; // Refuses to compile (good!): ptr1 = new labelList(10); diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index a37ac14a39..b4591c7721 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -137,9 +137,9 @@ label mergePatchFaces // Faces in error. labelHashSet errorFaces; - if (qualDictPtr.valid()) + if (qualDictPtr) { - motionSmoother::checkMesh(false, mesh, qualDictPtr(), errorFaces); + motionSmoother::checkMesh(false, mesh, *qualDictPtr, errorFaces); } else { @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) ); // Merge points on straight edges and remove unused points - if (qualDict.valid()) + if (qualDict) { Info<< "Merging all 'loose' points on surface edges, " << "regardless of the angle they make." << endl; diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 6a08caed38..7d0909ba5b 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -731,9 +731,9 @@ int main(int argc, char *argv[]) ); // Update - if (refDataPtr.valid()) + if (refDataPtr) { - refDataPtr().updateMesh(map()); + refDataPtr->updateMesh(map()); } // Store added cells @@ -896,9 +896,9 @@ int main(int argc, char *argv[]) updateFaceLabels(map(), backPatchFaces); updateCellSet(map(), addedCellsSet); - if (refDataPtr.valid()) + if (refDataPtr) { - refDataPtr().updateMesh(map()); + refDataPtr->updateMesh(map()); } // Move mesh (if inflation used) @@ -1029,9 +1029,9 @@ int main(int argc, char *argv[]) // Update local data updateCellSet(map(), addedCellsSet); - if (refDataPtr.valid()) + if (refDataPtr) { - refDataPtr().updateMesh(map()); + refDataPtr->updateMesh(map()); } // Move mesh (if inflation used) @@ -1067,9 +1067,9 @@ int main(int argc, char *argv[]) } } - if (refDataPtr.valid()) + if (refDataPtr) { - refDataPtr().write(); + refDataPtr->write(); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index f1a6b5ff3f..90268fdf4b 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -539,7 +539,7 @@ Foam::label Foam::checkGeometry << nonAlignedPoints.name() << endl; nonAlignedPoints.instance() = mesh.pointsInstance(); nonAlignedPoints.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, nonAlignedPoints); } @@ -573,7 +573,7 @@ Foam::label Foam::checkGeometry << " non closed cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -589,7 +589,7 @@ Foam::label Foam::checkGeometry << aspectCells.name() << endl; aspectCells.instance() = mesh.pointsInstance(); aspectCells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, aspectCells); } @@ -610,7 +610,7 @@ Foam::label Foam::checkGeometry << " zero area faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -632,7 +632,7 @@ Foam::label Foam::checkGeometry << " zero volume cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -655,7 +655,7 @@ Foam::label Foam::checkGeometry << " non-orthogonal faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -677,7 +677,7 @@ Foam::label Foam::checkGeometry << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -699,7 +699,7 @@ Foam::label Foam::checkGeometry << " skew faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -723,7 +723,7 @@ Foam::label Foam::checkGeometry << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -756,7 +756,7 @@ Foam::label Foam::checkGeometry << "decomposition tets to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -781,7 +781,7 @@ Foam::label Foam::checkGeometry << endl; points.instance() = mesh.pointsInstance(); points.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, points); } @@ -804,7 +804,7 @@ Foam::label Foam::checkGeometry << " apart) points to set " << nearPoints.name() << endl; nearPoints.instance() = mesh.pointsInstance(); nearPoints.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, nearPoints); } @@ -828,7 +828,7 @@ Foam::label Foam::checkGeometry << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -851,7 +851,7 @@ Foam::label Foam::checkGeometry << " warped faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -872,7 +872,7 @@ Foam::label Foam::checkGeometry << " under-determined cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -892,7 +892,7 @@ Foam::label Foam::checkGeometry << " concave cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -913,7 +913,7 @@ Foam::label Foam::checkGeometry << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -934,7 +934,7 @@ Foam::label Foam::checkGeometry << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -949,7 +949,7 @@ Foam::label Foam::checkGeometry const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName); autoPtr patchWriter; - if (!surfWriter.valid()) + if (!surfWriter) { patchWriter.reset(new surfaceWriters::vtkWriter()); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index 26dfbb6d20..d97308d6ec 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -30,7 +30,7 @@ Foam::label Foam::checkMeshQuality faces.instance() = mesh.pointsInstance(); faces.write(); - if (writer.valid()) + if (writer) { mergeAndWrite(*writer, faces); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index ebb2a62255..cfd0a579fa 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -202,7 +202,7 @@ Foam::label Foam::checkTopology << " illegal cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -226,7 +226,7 @@ Foam::label Foam::checkTopology << " unused points to set " << points.name() << endl; points.instance() = mesh.pointsInstance(); points.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, points); } @@ -248,7 +248,7 @@ Foam::label Foam::checkTopology << " unordered faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -268,7 +268,7 @@ Foam::label Foam::checkTopology << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -289,7 +289,7 @@ Foam::label Foam::checkTopology << endl; cells.instance() = mesh.pointsInstance(); cells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, cells); } @@ -313,7 +313,7 @@ Foam::label Foam::checkTopology << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, faces); } @@ -368,7 +368,7 @@ Foam::label Foam::checkTopology << endl; oneCells.instance() = mesh.pointsInstance(); oneCells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, oneCells); } @@ -384,7 +384,7 @@ Foam::label Foam::checkTopology << endl; twoCells.instance() = mesh.pointsInstance(); twoCells.write(); - if (surfWriter.valid()) + if (surfWriter) { mergeAndWrite(*surfWriter, twoCells); } @@ -529,7 +529,7 @@ Foam::label Foam::checkTopology << " points that are in multiple regions to set " << points.name() << endl; points.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, points); } @@ -640,7 +640,7 @@ Foam::label Foam::checkTopology << " conflicting points to set " << points.name() << endl; points.instance() = mesh.pointsInstance(); points.write(); - if (setWriter.valid()) + if (setWriter) { mergeAndWrite(*setWriter, points); } diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 18d47f32ff..0abc91fb28 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1035,9 +1036,9 @@ void Foam::meshDualiser::setRefinement -1, //masterCellID, -1 //zoneID ); - if (dualCcStr.valid()) + if (dualCcStr) { - meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]); + meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]); } } @@ -1079,11 +1080,11 @@ void Foam::meshDualiser::setRefinement -1, //masterCellID mesh_.cellZones().whichZone(pCells[pCelli]) //zoneID ); - if (dualCcStr.valid()) + if (dualCcStr) { meshTools::writeOBJ ( - dualCcStr(), + *dualCcStr, 0.5*(mesh_.points()[pointi]+cellCentres[pCells[pCelli]]) ); } @@ -1104,9 +1105,9 @@ void Foam::meshDualiser::setRefinement -1 //zoneID ); - if (dualCcStr.valid()) + if (dualCcStr) { - meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]); + meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]); } } } diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index e0e60be11c..1473bf293f 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -393,9 +393,9 @@ bool doCommand currentSet.resize(max(currentSet.size(), typSize)); } - if (currentSetPtr.valid()) + if (currentSetPtr) { - topoSet& currentSet = currentSetPtr(); + topoSet& currentSet = *currentSetPtr; Info<< " Set:" << currentSet.name() << " Size:" << returnReduce(currentSet.size(), sumOp