STYLE: avoid deprecation warnings for autoPtr set() method

- set() was silently deprecated in favour of reset() FEB-2018
  since the original additional check for overwriting an existing
  pointer was never used. The reset(...) name is more consistent
  with unique_ptr, tmp etc.

  Now emit deprecations for set().

- use direct test for autoPtr, tmp instead of valid() method.
  More consistent with unique_ptr etc.

STYLE: eliminate redundant ptr() use on cloned quantities
This commit is contained in:
Mark Olesen 2022-01-20 17:09:28 +01:00
parent 3b1f6e867c
commit d2961eec09
36 changed files with 128 additions and 150 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -716,7 +716,7 @@ void writeProcAddressing
}
autoPtr<fileOperation> defaultHandler;
if (writeHandler.valid())
if (writeHandler)
{
defaultHandler = fileHandler(std::move(writeHandler));
}
@ -726,7 +726,7 @@ void writeProcAddressing
const bool pointOk = pointMap.write();
const bool patchOk = patchMap.write();
if (defaultHandler.valid())
if (defaultHandler)
{
writeHandler = fileHandler(std::move(defaultHandler));
}
@ -1412,14 +1412,14 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
else
{
autoPtr<fileOperation> defaultHandler;
if (writeHandler.valid())
if (writeHandler)
{
defaultHandler = fileHandler(std::move(writeHandler));
}
mesh.write();
if (defaultHandler.valid())
if (defaultHandler)
{
writeHandler = fileHandler(std::move(defaultHandler));
}
@ -2543,7 +2543,7 @@ int main(int argc, char *argv[])
// File handler to be used for writing
const fileOperation& fh
(
writeHandler.valid()
writeHandler
? writeHandler()
: fileHandler()
);
@ -2989,7 +2989,7 @@ int main(int argc, char *argv[])
);
fvMesh& mesh = meshPtr();
if (writeHandler.valid() && Pstream::master())
if (writeHandler && Pstream::master())
{
// Remove any left-over empty processor directories created
// by loadOrCreateMesh to get around e.g. collated start-up
@ -3290,7 +3290,7 @@ int main(int argc, char *argv[])
);
fvMesh& mesh = meshPtr();
if (writeHandler.valid())
if (writeHandler)
{
// Remove any left-over empty processor directories created
// by loadOrCreateMesh to get around the collated start-up

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,7 +90,7 @@ makeZeroGradientField
>& tdf
)
{
if (tdf.valid())
if (tdf)
{
auto& df = tdf.ref();
@ -125,7 +125,7 @@ makeZeroGradientField
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tdf
)
{
if (tdf.valid())
if (tdf)
{
auto& df = tdf.ref();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -37,7 +37,7 @@ bool writeAreaField
const tmp<GeometricField<Type, faPatchField, areaMesh>>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -36,7 +36,7 @@ bool writeDimField
const tmp<DimensionedField<Type, volMesh>>& tdf
)
{
if (!tdf.valid())
if (!tdf)
{
return false;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -38,7 +38,7 @@ bool writePointField
const tmp<GeometricField<Type, pointPatchField, pointMesh>>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -38,7 +38,7 @@ bool writeVolField
const bool nearCellValue = false
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -118,7 +118,7 @@ Foam::PtrList<const GeoField> Foam::readFields
auto tfield =
getField<GeoField>(mesh, objects, fieldName, syncPar);
if (tfield.valid())
if (tfield)
{
fields.set(nFields++, tfield.ptr());
}
@ -157,7 +157,7 @@ Foam::PtrList<const GeoField> Foam::readFields
auto tfield =
getField<GeoField>(proxy, objects, fieldName, syncPar);
if (tfield.valid())
if (tfield)
{
fields.set(nFields++, tfield.ptr());
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,7 +56,7 @@ bool writeAreaField
const tmp<GeoField>& tfield
)
{
if (tfield.valid())
if (tfield)
{
writer.write(tfield());
tfield.clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,7 +53,7 @@ bool writeDimField
const tmp<GeoField>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}
@ -78,7 +78,7 @@ bool writeDimField
const tmp<GeoField>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +57,7 @@ bool writePointField
const fvMeshSubsetProxy& proxy
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}
@ -73,7 +73,7 @@ bool writePointField
tproxied = tfield;
}
if (!tproxied.valid())
if (!tproxied)
{
// Or Error?
return false;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,7 +55,7 @@ bool writeVolField
const tmp<GeoField>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}
@ -91,7 +91,7 @@ bool writeVolField
const tmp<GeoField>& tfield
)
{
if (!tfield.valid())
if (!tfield)
{
return false;
}

View File

@ -45,7 +45,7 @@ Foam::expressions::fieldExpr::parseDriver::getField
}
if (tvar.valid())
if (tvar)
{
const auto& var = tvar.cref();
const Field<Type>& vals = var.cref<Type>();

View File

@ -36,8 +36,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef PrecisionAdaptor_H
#define PrecisionAdaptor_H
#ifndef Foam_PrecisionAdaptor_H
#define Foam_PrecisionAdaptor_H
#include <algorithm> // For std::copy
#include <type_traits> // For std::is_same

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,13 +43,13 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef autoPtr_H
#define autoPtr_H
#ifndef Foam_autoPtr_H
#define Foam_autoPtr_H
// Transitional features/misfeatures
#define Foam_autoPtr_copyConstruct
#define Foam_autoPtr_castOperator
// #define Foam_autoPtr_deprecate_setMethod
// #define Foam_autoPtr_nodeprecate_setMethod
#include "stdFoam.H"
@ -283,8 +283,8 @@ public:
// enforced a run-time check (Fatal if pointer was already set)
// but this was rarely used.
// \deprecated(2018-02) Identical to reset().
#ifdef Foam_autoPtr_deprecate_setMethod
FOAM_DEPRECATED_FOR(2018-02, "reset() - same behaviour")
#ifndef Foam_autoPtr_nodeprecate_setMethod
FOAM_DEPRECATED_FOR(2022-01, "reset() - same behaviour")
#endif
void set(T* p) noexcept { reset(p); }
};

View File

@ -36,8 +36,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef refCount_H
#define refCount_H
#ifndef Foam_refCount_H
#define Foam_refCount_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -39,8 +39,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef refPtr_H
#define refPtr_H
#ifndef Foam_refPtr_H
#define Foam_refPtr_H
#include "autoPtr.H"
#include "tmp.H"

View File

@ -31,6 +31,13 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
inline Foam::word Foam::refPtr<T>::typeName()
{
return "refPtr<" + word(typeid(T).name()) + '>';
}
template<class T>
template<class... Args>
inline Foam::refPtr<T> Foam::refPtr<T>::New(Args&&... args)
@ -47,13 +54,6 @@ inline Foam::refPtr<T> Foam::refPtr<T>::NewFrom(Args&&... args)
}
template<class T>
inline Foam::word Foam::refPtr<T>::typeName()
{
return "refPtr<" + word(typeid(T).name()) + '>';
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>

View File

@ -45,8 +45,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef tmp_H
#define tmp_H
#ifndef Foam_tmp_H
#define Foam_tmp_H
#include "refCount.H"
#include "word.H"
@ -81,7 +81,7 @@ class tmp
mutable refType type_;
// Private Member Operators
// Private Member Functions
//- Increment the ref-count for a managed pointer
//- and check that it is not oversubscribed

View File

@ -29,7 +29,7 @@ License
#include "error.H"
#include <typeinfo>
// * * * * * * * * * * * * * Private Member Operators * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
inline void Foam::tmp<T>::incrCount()
@ -49,6 +49,13 @@ inline void Foam::tmp<T>::incrCount()
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
inline Foam::word Foam::tmp<T>::typeName()
{
return "tmp<" + word(typeid(T).name()) + '>';
}
template<class T>
template<class... Args>
inline Foam::tmp<T> Foam::tmp<T>::New(Args&&... args)
@ -65,13 +72,6 @@ inline Foam::tmp<T> Foam::tmp<T>::NewFrom(Args&&... args)
}
template<class T>
inline Foam::word Foam::tmp<T>::typeName()
{
return "tmp<" + word(typeid(T).name()) + '>';
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>

View File

@ -18,8 +18,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef tmpNrc_H
#define tmpNrc_H
#ifndef Foam_tmpNrc_H
#define Foam_tmpNrc_H
#include "refPtr.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -198,7 +198,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size());
patches.resize(patchEntries.size());
forAll(patches, patchi)
{
@ -225,7 +225,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
patches.setSize(ppl.size());
forAll(patches, patchi)
{
patches.set(patchi, ppl[patchi].clone(*this).ptr());
patches.set(patchi, ppl[patchi].clone(*this));
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -254,7 +254,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
forAll(zones, zonei)
{
zones.set(zonei, pzm[zonei].clone(*this).ptr());
zones.set(zonei, pzm[zonei].clone(*this));
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -148,14 +148,14 @@ void Foam::fvMeshDistribute::saveBoundaryFields
mesh_.objectRegistry::lookupClass<const fldType>()
);
bflds.setSize(flds.size());
bflds.resize(flds.size());
label i = 0;
forAllConstIters(flds, iter)
{
const fldType& fld = *iter();
bflds.set(i, fld.boundaryField().clone().ptr());
bflds.set(i, fld.boundaryField().clone());
++i;
}
@ -236,7 +236,7 @@ void Foam::fvMeshDistribute::saveInternalFields
mesh_.objectRegistry::lookupClass<const fldType>()
);
iflds.setSize(flds.size());
iflds.resize(flds.size());
label i = 0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -407,7 +407,7 @@ void Foam::cyclicAMIFvPatchField<Type>::collectStencilData
)
{
expandedData.setSize(stencil.size());
if (mapPtr.valid())
if (mapPtr)
{
Type2 work(data);
mapPtr().distribute(work);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -686,7 +686,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
autoPtr<surfaceWriter> writerPtr;
if (debug)
{
osPtr.set
osPtr.reset
(
new OBJstream
(

View File

@ -79,7 +79,7 @@ bool Foam::patchDistMethods::Poisson::correct
volVectorField& n
)
{
if (!tyPsi_.valid())
if (!tyPsi_)
{
tyPsi_ = tmp<volScalarField>
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,6 +60,7 @@ void Foam::surfaceInterpolation::clearOut()
Foam::surfaceInterpolation::surfaceInterpolation(const fvMesh& fvm)
:
mesh_(fvm),
geometryPtr_(nullptr),
weights_(nullptr),
deltaCoeffs_(nullptr),
nonOrthDeltaCoeffs_(nullptr),
@ -79,7 +80,7 @@ Foam::surfaceInterpolation::~surfaceInterpolation()
const Foam::fvGeometryScheme& Foam::surfaceInterpolation::geometry() const
{
if (!geometryPtr_.valid())
if (!geometryPtr_)
{
geometryPtr_ = fvGeometryScheme::New
(
@ -101,9 +102,9 @@ void Foam::surfaceInterpolation::geometry(tmp<fvGeometryScheme>& schemePtr)
const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const
{
if (!weights_.valid())
if (!weights_)
{
weights_.set(geometry().weights().ptr());
weights_.reset(geometry().weights().ptr());
}
return weights_();
@ -112,9 +113,9 @@ const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const
const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const
{
if (!deltaCoeffs_.valid())
if (!deltaCoeffs_)
{
deltaCoeffs_.set(geometry().deltaCoeffs().ptr());
deltaCoeffs_.reset(geometry().deltaCoeffs().ptr());
}
return deltaCoeffs_();
@ -124,9 +125,9 @@ const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const
const Foam::surfaceScalarField&
Foam::surfaceInterpolation::nonOrthDeltaCoeffs() const
{
if (!nonOrthDeltaCoeffs_.valid())
if (!nonOrthDeltaCoeffs_)
{
nonOrthDeltaCoeffs_.set(geometry().nonOrthDeltaCoeffs().ptr());
nonOrthDeltaCoeffs_.reset(geometry().nonOrthDeltaCoeffs().ptr());
}
return nonOrthDeltaCoeffs_();
@ -136,9 +137,9 @@ Foam::surfaceInterpolation::nonOrthDeltaCoeffs() const
const Foam::surfaceVectorField&
Foam::surfaceInterpolation::nonOrthCorrectionVectors() const
{
if (!nonOrthCorrectionVectors_.valid())
if (!nonOrthCorrectionVectors_)
{
nonOrthCorrectionVectors_.set
nonOrthCorrectionVectors_.reset
(
geometry().nonOrthCorrectionVectors().ptr()
);

View File

@ -160,9 +160,9 @@ bool Foam::functionObjects::histogram::write()
const volScalarField& field =
(
fieldPtr.valid()
? fieldPtr()
: obr_.lookupObject<volScalarField>(fieldName_)
fieldPtr
? fieldPtr()
: obr_.lookupObject<volScalarField>(fieldName_)
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,7 @@ License
inline const Foam::primitivePatch& Foam::AMIInterpolation::srcPatch0() const
{
if (!tsrcPatch0_.valid())
if (!tsrcPatch0_)
{
FatalErrorInFunction
<< "tsrcPatch0Ptr_ not set"
@ -42,7 +42,7 @@ inline const Foam::primitivePatch& Foam::AMIInterpolation::srcPatch0() const
inline const Foam::primitivePatch& Foam::AMIInterpolation::tgtPatch0() const
{
if (!ttgtPatch0_.valid())
if (!ttgtPatch0_)
{
FatalErrorInFunction
<< "ttgtPatch0Ptr_ not set"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,7 +27,7 @@ License
inline const Foam::primitivePatch& Foam::advancingFrontAMI::srcPatch() const
{
if (!tsrcPatch0_.valid())
if (!tsrcPatch0_)
{
FatalErrorInFunction
<< "tsrcPatch0_ not allocated"
@ -45,7 +45,7 @@ inline const Foam::primitivePatch& Foam::advancingFrontAMI::tgtPatch() const
return extendedTgtPatchPtr_();
}
if (!ttgtPatch0_.valid())
if (!ttgtPatch0_)
{
FatalErrorInFunction
<< "srcPatch0Ptr not allocated"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,7 +69,7 @@ bool Foam::cyclicACMIPolyPatch::updateAreas() const
// Check if scaling enabled (and necessary)
if
(
srcScalePtr_.valid()
srcScalePtr_
&& (updated || prevTimeIndex_ != mesh.time().timeIndex())
)
{
@ -103,7 +103,7 @@ bool Foam::cyclicACMIPolyPatch::updateAreas() const
);
if (!tgtScalePtr_.valid())
if (!tgtScalePtr_)
{
tgtScalePtr_= srcScalePtr_.clone(neighbPatch());
}
@ -361,7 +361,7 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas()
const cyclicACMIPolyPatch& nbrPatch = this->neighbPatch();
const polyPatch& nbrNonOverlapPatch = nbrPatch.nonOverlapPatch();
if (srcScalePtr_.valid())
if (srcScalePtr_)
{
// Save overlap geometry for later scaling
thisSf_ = this->faceAreas();
@ -476,7 +476,7 @@ void Foam::cyclicACMIPolyPatch::clearGeom()
const Foam::scalarField& Foam::cyclicACMIPolyPatch::srcMask() const
{
if (srcScalePtr_.valid())
if (srcScalePtr_)
{
// Make sure areas are up-to-date
updateAreas();
@ -492,7 +492,7 @@ const Foam::scalarField& Foam::cyclicACMIPolyPatch::srcMask() const
const Foam::scalarField& Foam::cyclicACMIPolyPatch::tgtMask() const
{
if (tgtScalePtr_.valid())
if (tgtScalePtr_)
{
// Make sure areas are up-to-date
updateAreas();
@ -619,12 +619,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
nonOverlapPatchID_(-1),
srcMask_(),
tgtMask_(),
srcScalePtr_
(
pp.srcScalePtr_.valid()
? pp.srcScalePtr_.clone(*this)
: nullptr
),
srcScalePtr_(pp.srcScalePtr_.clone(*this)),
AMITime_
(
IOobject
@ -663,12 +658,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
nonOverlapPatchID_(-1),
srcMask_(),
tgtMask_(),
srcScalePtr_
(
pp.srcScalePtr_.valid()
? pp.srcScalePtr_.clone(*this)
: nullptr
),
srcScalePtr_(pp.srcScalePtr_.clone(*this)),
AMITime_
(
IOobject
@ -713,12 +703,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
nonOverlapPatchID_(-1),
srcMask_(),
tgtMask_(),
srcScalePtr_
(
pp.srcScalePtr_.valid()
? pp.srcScalePtr_.clone(*this)
: nullptr
),
srcScalePtr_(pp.srcScalePtr_.clone(*this)),
AMITime_
(
IOobject
@ -804,7 +789,7 @@ const Foam::cyclicACMIPolyPatch& Foam::cyclicACMIPolyPatch::neighbPatch() const
const polyPatch& pp = this->boundaryMesh()[neighbPatchID()];
// Bit of checking now we know neighbour patch
if (!owner() && srcScalePtr_.valid())
if (!owner() && srcScalePtr_)
{
WarningInFunction
<< "Ignoring \"scale\" setting in slave patch " << name()
@ -911,7 +896,7 @@ void Foam::cyclicACMIPolyPatch::write(Ostream& os) const
os.writeEntry("nonOverlapPatch", nonOverlapPatchName_);
if (owner() && srcScalePtr_.valid())
if (owner() && srcScalePtr_)
{
srcScalePtr_->writeData(os);
}

View File

@ -290,8 +290,6 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
Foam::autoPtr<Foam::coordSystem::cylindrical>
Foam::cyclicAMIPolyPatch::cylindricalCS() const
{
autoPtr<coordSystem::cylindrical> csPtr;
const label periodicID = periodicPatchID();
if (periodicID != -1)
{
@ -328,10 +326,10 @@ Foam::cyclicAMIPolyPatch::cylindricalCS() const
<< exit(FatalError);
}
csPtr.set(new coordSystem::cylindrical(axisPoint, axis));
return autoPtr<coordSystem::cylindrical>::New(axisPoint, axis);
}
}
return csPtr;
return nullptr;
}

View File

@ -60,7 +60,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
else
{
autoPtr<coordSystem::cylindrical> cs(cylindricalCS());
if (!cs.valid())
if (!cs)
{
return interpolateUntransformed(fld, defaultValues);
}
@ -173,7 +173,7 @@ void Foam::cyclicAMIPolyPatch::interpolate
/*
autoPtr<coordSystem::cylindrical> cs(cylindricalCS());
if (cs.valid() && pTraits<Type>::rank > 0)
if (cs && pTraits<Type>::rank > 0)
{
const cyclicAMIPolyPatch& nbrPp = this->neighbPatch();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,32 +91,26 @@ Foam::autoPtr<Foam::fileName> Foam::mappedPatchBase::readDatabase
const dictionary& dict
)
{
autoPtr<fileName> dbNamePtr_;
if (dict.found("sampleDatabase"))
{
const bool useDb = dict.get<bool>("sampleDatabase");
if (useDb)
if (dict.get<bool>("sampleDatabase"))
{
dbNamePtr_.set
return autoPtr<fileName>::New
(
new fileName
dict.lookupOrDefault<fileName>
(
dict.lookupOrDefault<fileName>
(
"sampleDatabasePath",
fileName::null
)
"sampleDatabasePath",
fileName::null
)
);
}
}
else if (dict.found("sampleDatabasePath"))
{
dbNamePtr_.set(new fileName(dict.get<fileName>("sampleDatabasePath")));
return autoPtr<fileName>::New(dict.get<fileName>("sampleDatabasePath"));
}
return dbNamePtr_;
return nullptr;
}

View File

@ -55,14 +55,14 @@ MultiComponentPhaseModel
species_(),
inertIndex_(-1)
{
thermoPtr_.set
thermoPtr_.reset
(
phaseThermo::New
(
fluid.mesh(),
phaseName,
basicThermo::phasePropertyName(basicThermo::dictName, phaseName)
).ptr()
)
);
if (thermoPtr_->composition().species().empty())

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,7 +68,7 @@ inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const
{
return *regionPtr;
}
else if (!regionMeshPtr_.valid())
else if (!regionMeshPtr_)
{
FatalErrorInFunction
<< "Region mesh not available" << abort(FatalError);
@ -86,7 +86,7 @@ inline Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh()
{
return *regionPtr;
}
else if (!regionMeshPtr_.valid())
else if (!regionMeshPtr_)
{
FatalErrorInFunction
<< "Region mesh not available" << abort(FatalError);