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 |
-------------------------------------------------------------------------------
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<Triangulation>::sync
return;
}
if (allBackgroundMeshBounds_.empty())
if (!allBackgroundMeshBounds_)
{
distributeBoundBoxes(bb);
}
@ -810,7 +811,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync(const boundBox& bb)
return;
}
if (allBackgroundMeshBounds_.empty())
if (!allBackgroundMeshBounds_)
{
distributeBoundBoxes(bb);
}

View File

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

View File

@ -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::treeDataCell>&
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)
{

View File

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

View File

@ -91,7 +91,7 @@ Foam::pointHistory::pointHistory
refHistoryPoint_(dict.lookup("refHistoryPoint")),
processor_(-1),
fileName_(dict.get<word>("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;
}
}
}

View File

@ -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
(

View File

@ -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

View File

@ -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
(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<class CloudType>
inline Foam::List<Foam::DynamicList<typename CloudType::particleType*>>&
Foam::KinematicCloud<CloudType>::cellOccupancy()
{
if (cellOccupancyPtr_.empty())
if (!cellOccupancyPtr_)
{
buildCellOccupancy();
}

View File

@ -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();
}

View File

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

View File

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

View File

@ -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<Type>::computePatchGrad(word name)
template<class Type>
bool adjointBoundaryCondition<Type>::addATCUaGradUTerm()
{
if (addATCUaGradUTerm_.empty())
if (!addATCUaGradUTerm_)
{
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
// opening the same file
unsigned int width = IOstream::defaultPrecision() + 5;
if (objFunctionFilePtr_.empty())
if (!objFunctionFilePtr_)
{
setObjectiveFilePtr();
objFunctionFilePtr_()

View File

@ -130,7 +130,7 @@ autoPtr<objectiveIncompressible> 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<vector>(mesh_));
}
@ -302,7 +302,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdvn
const label patchI
)
{
if (bdJdvnPtr_.empty())
if (!bdJdvnPtr_)
{
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -315,7 +315,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdvt
const label patchI
)
{
if (bdJdvtPtr_.empty())
if (!bdJdvtPtr_)
{
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -328,7 +328,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdp
const label patchI
)
{
if (bdJdpPtr_.empty())
if (!bdJdpPtr_)
{
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -341,7 +341,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdT
const label patchI
)
{
if (bdJdTPtr_.empty())
if (!bdJdTPtr_)
{
bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -354,7 +354,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar1
const label patchI
)
{
if (bdJdTMvar1Ptr_.empty())
if (!bdJdTMvar1Ptr_)
{
bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -367,7 +367,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2
const label patchI
)
{
if (bdJdTMvar2Ptr_.empty())
if (!bdJdTMvar2Ptr_)
{
bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -377,7 +377,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2
const boundaryVectorField& objectiveIncompressible::boundarydJdv()
{
if (bdJdvPtr_.empty())
if (!bdJdvPtr_)
{
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -387,7 +387,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdv()
const boundaryScalarField& objectiveIncompressible::boundarydJdvn()
{
if (bdJdvnPtr_.empty())
if (!bdJdvnPtr_)
{
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -397,7 +397,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdvn()
const boundaryVectorField& objectiveIncompressible::boundarydJdvt()
{
if (bdJdvtPtr_.empty())
if (!bdJdvtPtr_)
{
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -407,7 +407,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdvt()
const boundaryVectorField& objectiveIncompressible::boundarydJdp()
{
if (bdJdpPtr_.empty())
if (!bdJdpPtr_)
{
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -417,7 +417,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdp()
const boundaryScalarField& objectiveIncompressible::boundarydJdT()
{
if (bdJdTPtr_.empty())
if (!bdJdTPtr_)
{
bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -427,7 +427,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdT()
const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1()
{
if (bdJdTMvar1Ptr_.empty())
if (!bdJdTMvar1Ptr_)
{
bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
}
@ -437,7 +437,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1()
const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar2()
{
if (bdJdTMvar2Ptr_.empty())
if (!bdJdTMvar2Ptr_)
{
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
// opening the same file
unsigned int width = IOstream::defaultPrecision() + 6;
if (objFunctionFilePtr_.empty())
if (!objFunctionFilePtr_)
{
setObjectiveFilePtr();
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
// opening the same file
unsigned int width = IOstream::defaultPrecision() + 5;
if (objFunctionFilePtr_.empty())
if (!objFunctionFilePtr_)
{
setObjectiveFilePtr();
objFunctionFilePtr_() << setw(4) << "#" << " ";

View File

@ -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<vector>(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<vector>(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<vector>(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<vector>(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<vector>(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<tensor>(mesh_));
}
@ -510,7 +510,7 @@ const fvPatchTensorField& objective::boundarydJdStress(const label patchI)
const boundaryVectorField& objective::boundarydJdb()
{
if (bdJdbPtr_.empty())
if (!bdJdbPtr_)
{
bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -520,7 +520,7 @@ const boundaryVectorField& objective::boundarydJdb()
const boundaryVectorField& objective::dSdbMultiplier()
{
if (bdSdbMultPtr_.empty())
if (!bdSdbMultPtr_)
{
bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -530,7 +530,7 @@ const boundaryVectorField& objective::dSdbMultiplier()
const boundaryVectorField& objective::dndbMultiplier()
{
if (bdndbMultPtr_.empty())
if (!bdndbMultPtr_)
{
bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -540,7 +540,7 @@ const boundaryVectorField& objective::dndbMultiplier()
const boundaryVectorField& objective::dxdbMultiplier()
{
if (bdxdbMultPtr_.empty())
if (!bdxdbMultPtr_)
{
bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
@ -550,7 +550,7 @@ const boundaryVectorField& objective::dxdbMultiplier()
const boundaryVectorField& objective::dxdbDirectMultiplier()
{
if (bdxdbDirectMultPtr_.empty())
if (!bdxdbDirectMultPtr_)
{
bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(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<tensor>(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_());
}

View File

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

View File

@ -347,7 +347,7 @@ void sensitivitySurface::read()
dict().getOrDefault<bool>("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
(

View File

@ -75,7 +75,7 @@ void sensitivitySurfacePoints::read()
dict().getOrDefault<bool>("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
(

View File

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

View File

@ -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
(

View File

@ -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();
}

View File

@ -1657,7 +1657,7 @@ Foam::scalar Foam::NURBS3DVolume::computeMaxBoundaryDisplacement
Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox()
{
if (mapPtr_.empty())
if (!mapPtr_)
{
findPointsInBox(localSystemCoordinates_);
}
@ -1672,7 +1672,7 @@ Foam::tmp<Foam::vectorField> 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_);
}

View File

@ -126,7 +126,7 @@ bool Foam::SIMPLEControlOpt::loop()
Time& runTime = const_cast<Time&>(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 "

View File

@ -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

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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<Type>& fields)
const bool interpolate = interpolationScheme_ != "cell";
// Create or use existing writer
if (fields.formatter.empty())
if (!fields.formatter)
{
fields = writeFormat_;
}

View File

@ -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();

View File

@ -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();

View File

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

View File

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

View File

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

View File

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

View File

@ -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;

View File

@ -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<volScalarField>(specieName);
if (!lookUpTablePtr_.empty())
if (lookUpTablePtr_)
{
if (lookUpTablePtr_().found(specieName))
{

View File

@ -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<volScalarField>(specieName);
if (!lookUpTablePtr_.empty())
if (lookUpTablePtr_)
{
if (lookUpTablePtr_().found(specieName))
{

View File

@ -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
(