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())
This commit is contained in:
Mark Olesen
2020-07-15 10:47:53 +02:00
parent 53eda1c4f1
commit 3baebcb101
45 changed files with 135 additions and 141 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -625,7 +626,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync
return; return;
} }
if (allBackgroundMeshBounds_.empty()) if (!allBackgroundMeshBounds_)
{ {
distributeBoundBoxes(bb); distributeBoundBoxes(bb);
} }
@ -810,7 +811,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync(const boundBox& bb)
return; return;
} }
if (allBackgroundMeshBounds_.empty()) if (!allBackgroundMeshBounds_)
{ {
distributeBoundBoxes(bb); distributeBoundBoxes(bb);
} }

View File

@ -176,7 +176,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
const Foam::List<Foam::labelPair>& Foam::mapDistributeBase::schedule() const const Foam::List<Foam::labelPair>& Foam::mapDistributeBase::schedule() const
{ {
if (schedulePtr_.empty()) if (!schedulePtr_)
{ {
schedulePtr_.reset schedulePtr_.reset
( (

View File

@ -860,7 +860,7 @@ Foam::label Foam::polyMesh::nSolutionD() const
const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const
{ {
if (tetBasePtIsPtr_.empty()) if (!tetBasePtIsPtr_)
{ {
if (debug) if (debug)
{ {
@ -894,7 +894,7 @@ const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const
const Foam::indexedOctree<Foam::treeDataCell>& const Foam::indexedOctree<Foam::treeDataCell>&
Foam::polyMesh::cellTree() const Foam::polyMesh::cellTree() const
{ {
if (cellTreePtr_.empty()) if (!cellTreePtr_)
{ {
treeBoundBox overallBb(points()); treeBoundBox overallBb(points());
@ -1087,7 +1087,7 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const
const Foam::pointField& Foam::polyMesh::oldPoints() const const Foam::pointField& Foam::polyMesh::oldPoints() const
{ {
if (oldPointsPtr_.empty()) if (!oldPointsPtr_)
{ {
if (debug) if (debug)
{ {
@ -1233,7 +1233,7 @@ void Foam::polyMesh::resetMotion() const
const Foam::globalMeshData& Foam::polyMesh::globalData() const const Foam::globalMeshData& Foam::polyMesh::globalData() const
{ {
if (globalMeshDataPtr_.empty()) if (!globalMeshDataPtr_)
{ {
if (debug) if (debug)
{ {

View File

@ -206,7 +206,7 @@ const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solid() const
{ {
if (this->owner()) if (this->owner())
{ {
if (solidPtr_.empty()) if (!solidPtr_)
{ {
solidPtr_.reset(new solidType(solidDict_)); solidPtr_.reset(new solidType(solidDict_));
} }

View File

@ -91,7 +91,7 @@ Foam::pointHistory::pointHistory
refHistoryPoint_(dict.lookup("refHistoryPoint")), refHistoryPoint_(dict.lookup("refHistoryPoint")),
processor_(-1), processor_(-1),
fileName_(dict.get<word>("fileName")), fileName_(dict.get<word>("fileName")),
historyFilePtr_() historyFilePtr_(nullptr)
{ {
Info<< "Creating " << this->name() << " function object." << endl; Info<< "Creating " << this->name() << " function object." << endl;
@ -144,7 +144,7 @@ Foam::pointHistory::pointHistory
} }
// Create history file if not already created // Create history file if not already created
if (historyFilePtr_.empty()) if (!historyFilePtr_)
{ {
// File update // File update
if (Pstream::master()) if (Pstream::master())
@ -180,13 +180,11 @@ Foam::pointHistory::pointHistory
); );
// Add headers to output data // Add headers to output data
if (historyFilePtr_.valid()) if (historyFilePtr_)
{ {
historyFilePtr_() historyFilePtr_()
<< "# Time" << tab << "X" << tab << "# Time" << tab << "X" << tab << "Y" << tab << "Z"
<< "Y" << tab << "Z"; << endl;
historyFilePtr_() << endl;
} }
} }
} }

View File

@ -190,7 +190,7 @@ const Foam::pointToPointPlanarInterpolation&
Foam::turbulentDFSEMInletFvPatchVectorField::patchMapper() const Foam::turbulentDFSEMInletFvPatchVectorField::patchMapper() const
{ {
// Initialise interpolation (2D planar interpolation by triangulation) // Initialise interpolation (2D planar interpolation by triangulation)
if (mapperPtr_.empty()) if (!mapperPtr_)
{ {
const fileName samplePointsFile const fileName samplePointsFile
( (

View File

@ -36,7 +36,7 @@ const Foam::pointToPointPlanarInterpolation&
Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const
{ {
// Initialise interpolation (2D planar interpolation by triangulation) // Initialise interpolation (2D planar interpolation by triangulation)
if (mapperPtr_.empty()) if (!mapperPtr_)
{ {
// Reread values and interpolate // Reread values and interpolate
const fileName samplePointsFile const fileName samplePointsFile

View File

@ -65,7 +65,7 @@ Foam::functionObjects::streamLineBase::trackDirTypeNames
const Foam::word& const Foam::word&
Foam::functionObjects::streamLineBase::sampledSetAxis() const Foam::functionObjects::streamLineBase::sampledSetAxis() const
{ {
if (sampledSetPtr_.empty()) if (!sampledSetPtr_)
{ {
sampledSetPoints(); sampledSetPoints();
} }
@ -77,7 +77,7 @@ Foam::functionObjects::streamLineBase::sampledSetAxis() const
const Foam::sampledSet& const Foam::sampledSet&
Foam::functionObjects::streamLineBase::sampledSetPoints() const Foam::functionObjects::streamLineBase::sampledSetPoints() const
{ {
if (sampledSetPtr_.empty()) if (!sampledSetPtr_)
{ {
sampledSetPtr_ = sampledSet::New sampledSetPtr_ = sampledSet::New
( (

View File

@ -394,7 +394,7 @@ surfaceDisplacementPointPatchVectorField
const Foam::searchableSurfaces& const Foam::searchableSurfaces&
Foam::surfaceDisplacementPointPatchVectorField::surfaces() const Foam::surfaceDisplacementPointPatchVectorField::surfaces() const
{ {
if (surfacesPtr_.empty()) if (!surfacesPtr_)
{ {
surfacesPtr_.reset surfacesPtr_.reset
( (

View File

@ -380,7 +380,7 @@ surfaceSlipDisplacementPointPatchVectorField
const Foam::searchableSurfaces& const Foam::searchableSurfaces&
Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const
{ {
if (surfacesPtr_.empty()) if (!surfacesPtr_)
{ {
surfacesPtr_.reset surfacesPtr_.reset
( (

View File

@ -501,7 +501,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain
const label const label
) )
{ {
if (invAPtr_.empty()) if (!invAPtr_)
{ {
invAPtr_.reset invAPtr_.reset
( (

View File

@ -237,7 +237,7 @@ void Foam::fv::meanVelocityForce::constrain
const label const label
) )
{ {
if (rAPtr_.empty()) if (!rAPtr_)
{ {
rAPtr_.reset rAPtr_.reset
( (

View File

@ -139,7 +139,7 @@ void Foam::KinematicCloud<CloudType>::solve
template<class CloudType> template<class CloudType>
void Foam::KinematicCloud<CloudType>::buildCellOccupancy() void Foam::KinematicCloud<CloudType>::buildCellOccupancy()
{ {
if (cellOccupancyPtr_.empty()) if (!cellOccupancyPtr_)
{ {
cellOccupancyPtr_.reset cellOccupancyPtr_.reset
( (
@ -174,7 +174,7 @@ void Foam::KinematicCloud<CloudType>::updateCellOccupancy()
// Only build the cellOccupancy if the pointer is set, i.e. it has // Only build the cellOccupancy if the pointer is set, i.e. it has
// been requested before. // been requested before.
if (cellOccupancyPtr_.valid()) if (cellOccupancyPtr_)
{ {
buildCellOccupancy(); buildCellOccupancy();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -370,7 +370,7 @@ template<class CloudType>
inline Foam::List<Foam::DynamicList<typename CloudType::particleType*>>& inline Foam::List<Foam::DynamicList<typename CloudType::particleType*>>&
Foam::KinematicCloud<CloudType>::cellOccupancy() Foam::KinematicCloud<CloudType>::cellOccupancy()
{ {
if (cellOccupancyPtr_.empty()) if (!cellOccupancyPtr_)
{ {
buildCellOccupancy(); buildCellOccupancy();
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -150,10 +151,10 @@ inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const
if (topoChange) if (topoChange)
{ {
mapPtr_.clear(); mapPtr_.reset(nullptr);
} }
if (mapPtr_.empty()) if (!mapPtr_)
{ {
calcMapping(); calcMapping();
} }

View File

@ -644,7 +644,7 @@ void Foam::triSurfaceMesh::movePoints(const pointField& newPoints)
const Foam::indexedOctree<Foam::treeDataEdge>& const Foam::indexedOctree<Foam::treeDataEdge>&
Foam::triSurfaceMesh::edgeTree() const Foam::triSurfaceMesh::edgeTree() const
{ {
if (edgeTree_.empty()) if (!edgeTree_)
{ {
if (debug) if (debug)
{ {

View File

@ -205,7 +205,7 @@ void Foam::triSurfaceSearch::clearOut()
const Foam::indexedOctree<Foam::treeDataTriSurface>& const Foam::indexedOctree<Foam::treeDataTriSurface>&
Foam::triSurfaceSearch::tree() const Foam::triSurfaceSearch::tree() const
{ {
if (treePtr_.empty()) if (!treePtr_)
{ {
// Calculate bb without constructing local point numbering. // Calculate bb without constructing local point numbering.
treeBoundBox bb(Zero, Zero); treeBoundBox bb(Zero, Zero);

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2020 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -143,7 +143,7 @@ adjointBoundaryCondition<Type>::computePatchGrad(word name)
template<class Type> template<class Type>
bool adjointBoundaryCondition<Type>::addATCUaGradUTerm() bool adjointBoundaryCondition<Type>::addATCUaGradUTerm()
{ {
if (addATCUaGradUTerm_.empty()) if (!addATCUaGradUTerm_)
{ {
addATCUaGradUTerm_.reset(new bool(isA<ATCUaGradU>(getATC()))); addATCUaGradUTerm_.reset(new bool(isA<ATCUaGradU>(getATC())));
} }

View File

@ -83,7 +83,7 @@ bool objectiveForceTarget::write(const bool valid) const
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
unsigned int width = IOstream::defaultPrecision() + 5; unsigned int width = IOstream::defaultPrecision() + 5;
if (objFunctionFilePtr_.empty()) if (!objFunctionFilePtr_)
{ {
setObjectiveFilePtr(); setObjectiveFilePtr();
objFunctionFilePtr_() objFunctionFilePtr_()

View File

@ -130,7 +130,7 @@ autoPtr<objectiveIncompressible> objectiveIncompressible::New
void objectiveIncompressible::doNormalization() void objectiveIncompressible::doNormalization()
{ {
if (normalize_ && normFactor_.valid()) if (normalize_ && normFactor_)
{ {
const scalar oneOverNorm(1./normFactor_()); const scalar oneOverNorm(1./normFactor_());
@ -191,7 +191,7 @@ void objectiveIncompressible::doNormalization()
const volVectorField& objectiveIncompressible::dJdv() const volVectorField& objectiveIncompressible::dJdv()
{ {
if (dJdvPtr_.empty()) if (!dJdvPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdvPtr_.reset dJdvPtr_.reset
@ -210,7 +210,7 @@ const volVectorField& objectiveIncompressible::dJdv()
const volScalarField& objectiveIncompressible::dJdp() const volScalarField& objectiveIncompressible::dJdp()
{ {
if (dJdpPtr_.empty()) if (!dJdpPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdpPtr_.reset dJdpPtr_.reset
@ -229,7 +229,7 @@ const volScalarField& objectiveIncompressible::dJdp()
const volScalarField& objectiveIncompressible::dJdT() const volScalarField& objectiveIncompressible::dJdT()
{ {
if (dJdTPtr_.empty()) if (!dJdTPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdTPtr_.reset dJdTPtr_.reset
@ -248,7 +248,7 @@ const volScalarField& objectiveIncompressible::dJdT()
const volScalarField& objectiveIncompressible::dJdTMvar1() const volScalarField& objectiveIncompressible::dJdTMvar1()
{ {
if (dJdTMvar1Ptr_.empty()) if (!dJdTMvar1Ptr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdTMvar1Ptr_.reset dJdTMvar1Ptr_.reset
@ -267,7 +267,7 @@ const volScalarField& objectiveIncompressible::dJdTMvar1()
const volScalarField& objectiveIncompressible::dJdTMvar2() const volScalarField& objectiveIncompressible::dJdTMvar2()
{ {
if (dJdTMvar2Ptr_.empty()) if (!dJdTMvar2Ptr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdTMvar2Ptr_.reset dJdTMvar2Ptr_.reset
@ -289,7 +289,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdv
const label patchI const label patchI
) )
{ {
if (bdJdvPtr_.empty()) if (!bdJdvPtr_)
{ {
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -302,7 +302,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdvn
const label patchI const label patchI
) )
{ {
if (bdJdvnPtr_.empty()) if (!bdJdvnPtr_)
{ {
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -315,7 +315,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdvt
const label patchI const label patchI
) )
{ {
if (bdJdvtPtr_.empty()) if (!bdJdvtPtr_)
{ {
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -328,7 +328,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdp
const label patchI const label patchI
) )
{ {
if (bdJdpPtr_.empty()) if (!bdJdpPtr_)
{ {
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -341,7 +341,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdT
const label patchI const label patchI
) )
{ {
if (bdJdTPtr_.empty()) if (!bdJdTPtr_)
{ {
bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -354,7 +354,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar1
const label patchI const label patchI
) )
{ {
if (bdJdTMvar1Ptr_.empty()) if (!bdJdTMvar1Ptr_)
{ {
bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -367,7 +367,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2
const label patchI const label patchI
) )
{ {
if (bdJdTMvar2Ptr_.empty()) if (!bdJdTMvar2Ptr_)
{ {
bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -377,7 +377,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2
const boundaryVectorField& objectiveIncompressible::boundarydJdv() const boundaryVectorField& objectiveIncompressible::boundarydJdv()
{ {
if (bdJdvPtr_.empty()) if (!bdJdvPtr_)
{ {
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -387,7 +387,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdv()
const boundaryScalarField& objectiveIncompressible::boundarydJdvn() const boundaryScalarField& objectiveIncompressible::boundarydJdvn()
{ {
if (bdJdvnPtr_.empty()) if (!bdJdvnPtr_)
{ {
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -397,7 +397,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdvn()
const boundaryVectorField& objectiveIncompressible::boundarydJdvt() const boundaryVectorField& objectiveIncompressible::boundarydJdvt()
{ {
if (bdJdvtPtr_.empty()) if (!bdJdvtPtr_)
{ {
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -407,7 +407,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdvt()
const boundaryVectorField& objectiveIncompressible::boundarydJdp() const boundaryVectorField& objectiveIncompressible::boundarydJdp()
{ {
if (bdJdpPtr_.empty()) if (!bdJdpPtr_)
{ {
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -417,7 +417,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdp()
const boundaryScalarField& objectiveIncompressible::boundarydJdT() const boundaryScalarField& objectiveIncompressible::boundarydJdT()
{ {
if (bdJdTPtr_.empty()) if (!bdJdTPtr_)
{ {
bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -427,7 +427,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdT()
const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1()
{ {
if (bdJdTMvar1Ptr_.empty()) if (!bdJdTMvar1Ptr_)
{ {
bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }
@ -437,7 +437,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1()
const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar2() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar2()
{ {
if (bdJdTMvar2Ptr_.empty()) if (!bdJdTMvar2Ptr_)
{ {
bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
} }

View File

@ -137,7 +137,7 @@ bool objectivePartialVolume::write(const bool valid) const
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
unsigned int width = IOstream::defaultPrecision() + 6; unsigned int width = IOstream::defaultPrecision() + 6;
if (objFunctionFilePtr_.empty()) if (!objFunctionFilePtr_)
{ {
setObjectiveFilePtr(); setObjectiveFilePtr();
objFunctionFilePtr_() << setw(4) << "#" << " "; objFunctionFilePtr_() << setw(4) << "#" << " ";

View File

@ -242,7 +242,7 @@ bool objectivePtLosses::write(const bool valid) const
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
unsigned int width = IOstream::defaultPrecision() + 5; unsigned int width = IOstream::defaultPrecision() + 5;
if (objFunctionFilePtr_.empty()) if (!objFunctionFilePtr_)
{ {
setObjectiveFilePtr(); setObjectiveFilePtr();
objFunctionFilePtr_() << setw(4) << "#" << " "; objFunctionFilePtr_() << setw(4) << "#" << " ";

View File

@ -256,7 +256,7 @@ scalar objective::JCycle() const
J -= target_; J -= target_;
// Normalize here, in order to get the correct value for line search // Normalize here, in order to get the correct value for line search
if (normalize_ && normFactor_.valid()) if (normalize_ && normFactor_)
{ {
J /= normFactor_(); J /= normFactor_();
} }
@ -267,7 +267,7 @@ scalar objective::JCycle() const
void objective::updateNormalizationFactor() void objective::updateNormalizationFactor()
{ {
if (normalize_ && normFactor_.empty()) if (normalize_ && !normFactor_)
{ {
normFactor_.reset(new scalar(JCycle())); normFactor_.reset(new scalar(JCycle()));
} }
@ -327,7 +327,7 @@ bool objective::normalize() const
void objective::doNormalization() void objective::doNormalization()
{ {
if (normalize_ && normFactor_.valid()) if (normalize_ && normFactor_)
{ {
const scalar oneOverNorm(1./normFactor_()); const scalar oneOverNorm(1./normFactor_());
@ -414,7 +414,7 @@ void objective::incrementIntegrationTimes(const scalar timeSpan)
const volScalarField& objective::dJdb() const volScalarField& objective::dJdb()
{ {
if (dJdbPtr_.empty()) if (!dJdbPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
dJdbPtr_.reset dJdbPtr_.reset
@ -434,7 +434,7 @@ const volScalarField& objective::dJdb()
const fvPatchVectorField& objective::boundarydJdb(const label patchI) const fvPatchVectorField& objective::boundarydJdb(const label patchI)
{ {
if (bdJdbPtr_.empty()) if (!bdJdbPtr_)
{ {
bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -444,7 +444,7 @@ const fvPatchVectorField& objective::boundarydJdb(const label patchI)
const fvPatchVectorField& objective::dSdbMultiplier(const label patchI) const fvPatchVectorField& objective::dSdbMultiplier(const label patchI)
{ {
if (bdSdbMultPtr_.empty()) if (!bdSdbMultPtr_)
{ {
bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -454,7 +454,7 @@ const fvPatchVectorField& objective::dSdbMultiplier(const label patchI)
const fvPatchVectorField& objective::dndbMultiplier(const label patchI) const fvPatchVectorField& objective::dndbMultiplier(const label patchI)
{ {
if (bdndbMultPtr_.empty()) if (!bdndbMultPtr_)
{ {
bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -464,7 +464,7 @@ const fvPatchVectorField& objective::dndbMultiplier(const label patchI)
const fvPatchVectorField& objective::dxdbMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbMultiplier(const label patchI)
{ {
if (bdxdbMultPtr_.empty()) if (!bdxdbMultPtr_)
{ {
bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -474,7 +474,7 @@ const fvPatchVectorField& objective::dxdbMultiplier(const label patchI)
const fvPatchVectorField& objective::dxdbDirectMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbDirectMultiplier(const label patchI)
{ {
if (bdxdbDirectMultPtr_.empty()) if (!bdxdbDirectMultPtr_)
{ {
bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -488,7 +488,7 @@ const vectorField& objective::boundaryEdgeMultiplier
const label edgeI const label edgeI
) )
{ {
if (bdxdbDirectMultPtr_.empty()) if (!bdxdbDirectMultPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unallocated boundaryEdgeMultiplier field" << "Unallocated boundaryEdgeMultiplier field"
@ -500,7 +500,7 @@ const vectorField& objective::boundaryEdgeMultiplier
const fvPatchTensorField& objective::boundarydJdStress(const label patchI) const fvPatchTensorField& objective::boundarydJdStress(const label patchI)
{ {
if (bdJdStressPtr_.empty()) if (!bdJdStressPtr_)
{ {
bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_)); bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_));
} }
@ -510,7 +510,7 @@ const fvPatchTensorField& objective::boundarydJdStress(const label patchI)
const boundaryVectorField& objective::boundarydJdb() const boundaryVectorField& objective::boundarydJdb()
{ {
if (bdJdbPtr_.empty()) if (!bdJdbPtr_)
{ {
bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -520,7 +520,7 @@ const boundaryVectorField& objective::boundarydJdb()
const boundaryVectorField& objective::dSdbMultiplier() const boundaryVectorField& objective::dSdbMultiplier()
{ {
if (bdSdbMultPtr_.empty()) if (!bdSdbMultPtr_)
{ {
bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -530,7 +530,7 @@ const boundaryVectorField& objective::dSdbMultiplier()
const boundaryVectorField& objective::dndbMultiplier() const boundaryVectorField& objective::dndbMultiplier()
{ {
if (bdndbMultPtr_.empty()) if (!bdndbMultPtr_)
{ {
bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -540,7 +540,7 @@ const boundaryVectorField& objective::dndbMultiplier()
const boundaryVectorField& objective::dxdbMultiplier() const boundaryVectorField& objective::dxdbMultiplier()
{ {
if (bdxdbMultPtr_.empty()) if (!bdxdbMultPtr_)
{ {
bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -550,7 +550,7 @@ const boundaryVectorField& objective::dxdbMultiplier()
const boundaryVectorField& objective::dxdbDirectMultiplier() const boundaryVectorField& objective::dxdbDirectMultiplier()
{ {
if (bdxdbDirectMultPtr_.empty()) if (!bdxdbDirectMultPtr_)
{ {
bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
} }
@ -560,7 +560,7 @@ const boundaryVectorField& objective::dxdbDirectMultiplier()
const vectorField3& objective::boundaryEdgeMultiplier() const vectorField3& objective::boundaryEdgeMultiplier()
{ {
if (bdxdbDirectMultPtr_.empty()) if (!bdxdbDirectMultPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unallocated boundaryEdgeMultiplier field" << "Unallocated boundaryEdgeMultiplier field"
@ -573,7 +573,7 @@ const vectorField3& objective::boundaryEdgeMultiplier()
const boundaryTensorField& objective::boundarydJdStress() const boundaryTensorField& objective::boundarydJdStress()
{ {
if (bdJdStressPtr_.empty()) if (!bdJdStressPtr_)
{ {
bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_)); bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_));
} }
@ -583,7 +583,7 @@ const boundaryTensorField& objective::boundarydJdStress()
const volScalarField& objective::divDxDbMultiplier() const volScalarField& objective::divDxDbMultiplier()
{ {
if (divDxDbMultPtr_.empty()) if (!divDxDbMultPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
divDxDbMultPtr_.reset divDxDbMultPtr_.reset
@ -604,7 +604,7 @@ const volScalarField& objective::divDxDbMultiplier()
const volTensorField& objective::gradDxDbMultiplier() const volTensorField& objective::gradDxDbMultiplier()
{ {
if (gradDxDbMultPtr_.empty()) if (!gradDxDbMultPtr_)
{ {
// If pointer is not set, set it to a zero field // If pointer is not set, set it to a zero field
gradDxDbMultPtr_.reset gradDxDbMultPtr_.reset
@ -684,7 +684,7 @@ bool objective::write(const bool valid) const
// File is opened only upon invocation of the write function // File is opened only upon invocation of the write function
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
if (objFunctionFilePtr_.empty()) if (!objFunctionFilePtr_)
{ {
setObjectiveFilePtr(); setObjectiveFilePtr();
} }
@ -703,7 +703,7 @@ void objective::writeInstantaneousValue() const
// File is opened only upon invocation of the write function // File is opened only upon invocation of the write function
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
if (instantValueFilePtr_.empty()) if (!instantValueFilePtr_)
{ {
setInstantValueFilePtr(); setInstantValueFilePtr();
} }
@ -717,7 +717,7 @@ void objective::writeInstantaneousSeparator() const
{ {
if (Pstream::master()) if (Pstream::master())
{ {
if (instantValueFilePtr_.valid()) if (instantValueFilePtr_)
{ {
instantValueFilePtr_() << endl; instantValueFilePtr_() << endl;
} }
@ -740,7 +740,7 @@ void objective::writeMeanValue() const
// File is opened only upon invocation of the write function // File is opened only upon invocation of the write function
// in order to avoid various instantiations of the same objective // in order to avoid various instantiations of the same objective
// opening the same file // opening the same file
if (meanValueFilePtr_.empty()) if (!meanValueFilePtr_)
{ {
setMeanValueFilePtr(); setMeanValueFilePtr();
} }
@ -755,7 +755,7 @@ void objective::writeMeanValue() const
bool objective::writeData(Ostream& os) const bool objective::writeData(Ostream& os) const
{ {
os.writeEntry("JMean", JMean_); os.writeEntry("JMean", JMean_);
if (normFactor_.valid()) if (normFactor_)
{ {
os.writeEntry("normFactor", normFactor_()); os.writeEntry("normFactor", normFactor_());
} }

View File

@ -55,7 +55,7 @@ void FIBase::read()
); );
// Allocate distance solver if needed // Allocate distance solver if needed
if (includeDistance_ && eikonalSolver_.empty()) if (includeDistance_ && !eikonalSolver_)
{ {
eikonalSolver_.reset eikonalSolver_.reset
( (

View File

@ -347,7 +347,7 @@ void sensitivitySurface::read()
dict().getOrDefault<bool>("writeGeometricInfo", false); dict().getOrDefault<bool>("writeGeometricInfo", false);
// Allocate new solvers if necessary // Allocate new solvers if necessary
if (includeDistance_ && eikonalSolver_.empty()) if (includeDistance_ && !eikonalSolver_)
{ {
eikonalSolver_.reset eikonalSolver_.reset
( (
@ -361,7 +361,7 @@ void sensitivitySurface::read()
) )
); );
} }
if (includeMeshMovement_ && meshMovementSolver_.empty()) if (includeMeshMovement_ && !meshMovementSolver_)
{ {
meshMovementSolver_.reset meshMovementSolver_.reset
( (

View File

@ -75,7 +75,7 @@ void sensitivitySurfacePoints::read()
dict().getOrDefault<bool>("includeObjectiveContribution", true); dict().getOrDefault<bool>("includeObjectiveContribution", true);
// Allocate new solvers if necessary // Allocate new solvers if necessary
if (includeDistance_ && eikonalSolver_.empty()) if (includeDistance_ && !eikonalSolver_)
{ {
eikonalSolver_.reset eikonalSolver_.reset
( (
@ -90,7 +90,7 @@ void sensitivitySurfacePoints::read()
); );
} }
if (includeMeshMovement_ && meshMovementSolver_.empty()) if (includeMeshMovement_ && !meshMovementSolver_)
{ {
meshMovementSolver_.reset meshMovementSolver_.reset
( (

View File

@ -44,7 +44,7 @@ namespace Foam
Foam::scalar Foam::optMeshMovement::getMaxAllowedDisplacement() const Foam::scalar Foam::optMeshMovement::getMaxAllowedDisplacement() const
{ {
if (maxAllowedDisplacement_.empty()) if (!maxAllowedDisplacement_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "maxAllowedDisplacement requested but not set" << nl << "maxAllowedDisplacement requested but not set" << nl

View File

@ -427,7 +427,7 @@ void Foam::SQP::write()
constraintsSize = constraintsSize*(width + 1) + 2; constraintsSize = constraintsSize*(width + 1) + 2;
// Open file and write header // Open file and write header
if (meritFunctionFile_.empty()) if (!meritFunctionFile_)
{ {
meritFunctionFile_.reset meritFunctionFile_.reset
( (

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -2038,7 +2038,7 @@ scalar NURBS3DSurface::lengthDerivativeV
const labelList& NURBS3DSurface::getBoundaryCPIDs() const labelList& NURBS3DSurface::getBoundaryCPIDs()
{ {
if(boundaryCPIDs_.empty()) if (!boundaryCPIDs_)
{ {
const label uNCPs(uBasis_.nCPs()); const label uNCPs(uBasis_.nCPs());
const label vNCPs(vBasis_.nCPs()); const label vNCPs(vBasis_.nCPs());
@ -2082,7 +2082,7 @@ const labelList& NURBS3DSurface::getBoundaryCPIs()
const label& NURBS3DSurface::whichBoundaryCPI(const label& globalCPI) const label& NURBS3DSurface::whichBoundaryCPI(const label& globalCPI)
{ {
if(whichBoundaryCPID_.empty()) if (!whichBoundaryCPID_)
{ {
getBoundaryCPIDs(); getBoundaryCPIDs();
} }

View File

@ -1657,7 +1657,7 @@ Foam::scalar Foam::NURBS3DVolume::computeMaxBoundaryDisplacement
Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox() Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox()
{ {
if (mapPtr_.empty()) if (!mapPtr_)
{ {
findPointsInBox(localSystemCoordinates_); findPointsInBox(localSystemCoordinates_);
} }
@ -1672,7 +1672,7 @@ Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox()
const Foam::labelList& Foam::NURBS3DVolume::getMap() const Foam::labelList& Foam::NURBS3DVolume::getMap()
{ {
if (mapPtr_.empty()) if (!mapPtr_)
{ {
findPointsInBox(localSystemCoordinates_); findPointsInBox(localSystemCoordinates_);
} }
@ -1683,7 +1683,7 @@ const Foam::labelList& Foam::NURBS3DVolume::getMap()
const Foam::labelList& Foam::NURBS3DVolume::getReverseMap() const Foam::labelList& Foam::NURBS3DVolume::getReverseMap()
{ {
if (reverseMapPtr_.empty()) if (!reverseMapPtr_)
{ {
findPointsInBox(localSystemCoordinates_); findPointsInBox(localSystemCoordinates_);
} }
@ -1695,11 +1695,11 @@ const Foam::labelList& Foam::NURBS3DVolume::getReverseMap()
const Foam::pointVectorField& Foam::NURBS3DVolume::getParametricCoordinates() const Foam::pointVectorField& Foam::NURBS3DVolume::getParametricCoordinates()
{ {
// If not computed yet, compute parametric coordinates // If not computed yet, compute parametric coordinates
if (parametricCoordinatesPtr_.empty()) if (!parametricCoordinatesPtr_)
{ {
// Find mesh points inside control points box // Find mesh points inside control points box
// if they have been identified yet // if they have been identified yet
if (mapPtr_.empty()) if (!mapPtr_)
{ {
findPointsInBox(localSystemCoordinates_); findPointsInBox(localSystemCoordinates_);
} }

View File

@ -126,7 +126,7 @@ bool Foam::SIMPLEControlOpt::loop()
Time& runTime = const_cast<Time&>(mesh_.time()); Time& runTime = const_cast<Time&>(mesh_.time());
// Sub-cycle time if this is the first iter // Sub-cycle time if this is the first iter
if (subCycledTimePtr_.empty()) if (!subCycledTimePtr_)
{ {
subCycledTimePtr_.reset(new subCycleTime(runTime, nIters())); subCycledTimePtr_.reset(new subCycleTime(runTime, nIters()));
Info<< "Solving equations for solver " Info<< "Solving equations for solver "

View File

@ -260,7 +260,7 @@ bool adjointRASModel::read()
volScalarField& adjointRASModel::getAdjointTMVariable1Inst() volScalarField& adjointRASModel::getAdjointTMVariable1Inst()
{ {
if (adjointTMVariable1Ptr_.empty()) if (!adjointTMVariable1Ptr_)
{ {
// if pointer is not set, set it to a zero field // if pointer is not set, set it to a zero field
adjointTMVariable1Ptr_.reset adjointTMVariable1Ptr_.reset
@ -287,7 +287,7 @@ volScalarField& adjointRASModel::getAdjointTMVariable1Inst()
volScalarField& adjointRASModel::getAdjointTMVariable2Inst() volScalarField& adjointRASModel::getAdjointTMVariable2Inst()
{ {
if (adjointTMVariable2Ptr_.empty()) if (!adjointTMVariable2Ptr_)
{ {
// if pointer is not set, set it to a zero field // if pointer is not set, set it to a zero field
adjointTMVariable2Ptr_.reset adjointTMVariable2Ptr_.reset

View File

@ -551,7 +551,7 @@ const Foam::lduAddressing& Foam::dynamicOversetFvMesh::lduAddr() const
//return dynamicMotionSolverFvMesh::lduAddr(); //return dynamicMotionSolverFvMesh::lduAddr();
return dynamicFvMesh::lduAddr(); return dynamicFvMesh::lduAddr();
} }
if (lduPtr_.empty()) if (!lduPtr_)
{ {
// Build extended addressing // Build extended addressing
updateAddressing(); updateAddressing();
@ -567,7 +567,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const
//return dynamicMotionSolverFvMesh::interfaces(); //return dynamicMotionSolverFvMesh::interfaces();
return dynamicFvMesh::interfaces(); return dynamicFvMesh::interfaces();
} }
if (lduPtr_.empty()) if (!lduPtr_)
{ {
// Build extended addressing // Build extended addressing
updateAddressing(); updateAddressing();
@ -579,7 +579,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const
const Foam::fvMeshPrimitiveLduAddressing& const Foam::fvMeshPrimitiveLduAddressing&
Foam::dynamicOversetFvMesh::primitiveLduAddr() const Foam::dynamicOversetFvMesh::primitiveLduAddr() const
{ {
if (lduPtr_.empty()) if (!lduPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Extended addressing not allocated" << abort(FatalError); << "Extended addressing not allocated" << abort(FatalError);

View File

@ -110,7 +110,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
&& regionName != "none" && regionName != "none"
) )
{ {
if (extrudeMeshPtr_.empty()) if (!extrudeMeshPtr_)
{ {
createPatchMesh(); createPatchMesh();
} }
@ -249,14 +249,6 @@ void thermalBaffleFvPatchScalarField::createPatchMesh()
regionPatches regionPatches
) )
); );
if (extrudeMeshPtr_.empty())
{
WarningInFunction
<< "Specified IOobject::MUST_READ_IF_MODIFIED but class"
<< " patchMeshPtr not set."
<< endl;
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -220,7 +220,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
const bool interpolate = interpolationScheme_ != "cell"; const bool interpolate = interpolationScheme_ != "cell";
// Create or use existing writer // Create or use existing writer
if (fields.formatter.empty()) if (!fields.formatter)
{ {
fields = writeFormat_; fields = writeFormat_;
} }

View File

@ -74,7 +74,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
if if
( (
storedVolFieldPtr_.empty() !storedVolFieldPtr_
|| (fvm.time().timeName() != storedVolFieldPtr_().instance()) || (fvm.time().timeName() != storedVolFieldPtr_().instance())
) )
{ {
@ -126,7 +126,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
// (volPointInterpolation::interpolate with cache=false deletes any // (volPointInterpolation::interpolate with cache=false deletes any
// registered one or if mesh.changing()) // registered one or if mesh.changing())
if (subMeshPtr_.empty()) if (!subMeshPtr_)
{ {
const word pointFldName = const word pointFldName =
"volPointInterpolate_" "volPointInterpolate_"
@ -316,8 +316,8 @@ bool Foam::sampledIsoSurface::updateGeometry() const
// Get sub-mesh if any // Get sub-mesh if any
if if
( (
(-1 != mesh().cellZones().findIndex(zoneNames_)) !subMeshPtr_
&& subMeshPtr_.empty() && (-1 != mesh().cellZones().findIndex(zoneNames_))
) )
{ {
const polyBoundaryMesh& patches = mesh().boundaryMesh(); const polyBoundaryMesh& patches = mesh().boundaryMesh();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -118,8 +118,8 @@ void Foam::sampledCuttingPlane::createGeometry()
// Get sub-mesh if any // Get sub-mesh if any
if if
( (
(-1 != mesh().cellZones().findIndex(zoneNames_)) !subMeshPtr_
&& subMeshPtr_.empty() && (-1 != mesh().cellZones().findIndex(zoneNames_))
) )
{ {
const polyBoundaryMesh& patches = mesh().boundaryMesh(); const polyBoundaryMesh& patches = mesh().boundaryMesh();

View File

@ -110,7 +110,7 @@ void Foam::sampledSurfaces::performAction
if (s.interpolate()) if (s.interpolate())
{ {
if (interpPtr.empty()) if (!interpPtr)
{ {
interpPtr = interpolation<Type>::New interpPtr = interpolation<Type>::New
( (
@ -123,7 +123,7 @@ void Foam::sampledSurfaces::performAction
} }
else else
{ {
if (samplePtr.empty()) if (!samplePtr)
{ {
samplePtr = interpolation<Type>::New samplePtr = interpolation<Type>::New
( (

View File

@ -79,7 +79,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::restrain
vector& restraintMoment vector& restraintMoment
) const ) const
{ {
if (anchor_.empty()) if (!anchor_)
{ {
anchor_.reset anchor_.reset
( (

View File

@ -104,7 +104,7 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
os.endBlock(); os.endBlock();
} }
if (!solver_.empty()) if (solver_)
{ {
os << indent << "solver"; os << indent << "solver";
solver_->write(os); solver_->write(os);

View File

@ -237,7 +237,7 @@ void Foam::radiation::radiationModel::correct()
firstIter_ = false; firstIter_ = false;
} }
if (!soot_.empty()) if (soot_)
{ {
soot_->correct(); soot_->correct();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,7 +58,7 @@ void Foam::radiation::solarLoad::updateReflectedRays
const labelHashSet& includePatches const labelHashSet& includePatches
) )
{ {
if (reflectedFaces_.empty() && !hitFaces_.empty()) if (!reflectedFaces_ && hitFaces_)
{ {
reflectedFaces_.reset reflectedFaces_.reset
( (
@ -117,7 +117,7 @@ void Foam::radiation::solarLoad::updateReflectedRays
bool Foam::radiation::solarLoad::updateHitFaces() bool Foam::radiation::solarLoad::updateHitFaces()
{ {
if (hitFaces_.empty()) if (!hitFaces_)
{ {
hitFaces_.reset(new faceShading(mesh_, solarCalc_.direction())); hitFaces_.reset(new faceShading(mesh_, solarCalc_.direction()));
return true; return true;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -129,7 +130,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName); volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName);
if (!lookUpTablePtr_.empty()) if (lookUpTablePtr_)
{ {
if (lookUpTablePtr_().found(specieName)) if (lookUpTablePtr_().found(specieName))
{ {

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -140,7 +141,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName); volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName);
if (!lookUpTablePtr_.empty()) if (lookUpTablePtr_)
{ {
if (lookUpTablePtr_().found(specieName)) if (lookUpTablePtr_().found(specieName))
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -115,7 +115,7 @@ Foam::radiation::boundaryRadiationProperties::emissivity
scalarField* T scalarField* T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->e return radBoundaryPropertiesPtrList_[patchi]->e
( (
@ -144,7 +144,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceEmissivity
scalar T scalar T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->e return radBoundaryPropertiesPtrList_[patchi]->e
( (
@ -174,7 +174,7 @@ Foam::radiation::boundaryRadiationProperties::absorptivity
scalarField* T scalarField* T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->a return radBoundaryPropertiesPtrList_[patchi]->a
( (
@ -203,7 +203,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceAbsorptivity
scalar T scalar T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->a return radBoundaryPropertiesPtrList_[patchi]->a
( (
@ -233,7 +233,7 @@ Foam::radiation::boundaryRadiationProperties::transmissivity
scalarField* T scalarField* T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->t return radBoundaryPropertiesPtrList_[patchi]->t
( (
@ -262,7 +262,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceTransmissivity
scalar T scalar T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->t return radBoundaryPropertiesPtrList_[patchi]->t
( (
@ -292,7 +292,7 @@ Foam::radiation::boundaryRadiationProperties::diffReflectivity
scalarField* T scalarField* T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->rDiff return radBoundaryPropertiesPtrList_[patchi]->rDiff
( (
@ -321,7 +321,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceDiffReflectivity
scalar T scalar T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->rDiff return radBoundaryPropertiesPtrList_[patchi]->rDiff
( (
@ -351,7 +351,7 @@ Foam::radiation::boundaryRadiationProperties::specReflectivity
scalarField* T scalarField* T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->rSpec return radBoundaryPropertiesPtrList_[patchi]->rSpec
( (
@ -380,7 +380,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceSpecReflectivity
scalar T scalar T
) const ) const
{ {
if (!radBoundaryPropertiesPtrList_[patchi].empty()) if (radBoundaryPropertiesPtrList_[patchi])
{ {
return radBoundaryPropertiesPtrList_[patchi]->rSpec return radBoundaryPropertiesPtrList_[patchi]->rSpec
( (