STYLE: prefer autoPtr::reset() to autoPtr::set()

- in most cases already checked valid() so don't need additional check
  for setting an existing pointer
This commit is contained in:
Mark Olesen 2017-11-22 19:11:11 +01:00
parent e96cbd9050
commit 416a3790ea
34 changed files with 141 additions and 124 deletions

View File

@ -29,8 +29,10 @@ volVectorField U
#include "createPhi.H" #include "createPhi.H"
// Creating e based thermo // Creating e based thermo
autoPtr<twoPhaseMixtureEThermo> thermo; autoPtr<twoPhaseMixtureEThermo> thermo
thermo.set(new twoPhaseMixtureEThermo(U, phi)); (
new twoPhaseMixtureEThermo(U, phi)
);
// Create mixture and // Create mixture and
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n" << endl; Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n" << endl;

View File

@ -49,7 +49,7 @@ Foam::ThermoPhaseModel<BasePhaseModel, ThermoType>::ThermoPhaseModel
{ {
if (createThermo) if (createThermo)
{ {
thermoPtr_.set thermoPtr_.reset
( (
ThermoType::New(fluid.mesh(), this->name()).ptr() ThermoType::New(fluid.mesh(), this->name()).ptr()
); );

View File

@ -76,7 +76,7 @@ Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
{ {
if (modelTable.found(pair_)) if (modelTable.found(pair_))
{ {
model_.set model_.reset
( (
modelType::New modelType::New
( (
@ -88,7 +88,7 @@ Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
if (modelTable.found(pair1In2_)) if (modelTable.found(pair1In2_))
{ {
model1In2_.set model1In2_.reset
( (
modelType::New modelType::New
( (
@ -100,7 +100,7 @@ Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
if (modelTable.found(pair2In1_)) if (modelTable.found(pair2In1_))
{ {
model2In1_.set model2In1_.reset
( (
modelType::New modelType::New
( (

View File

@ -41,7 +41,7 @@ Foam::orderedPhasePair::orderedPhasePair
{ {
if (aspectRatioTable.found(*this)) if (aspectRatioTable.found(*this))
{ {
aspectRatio_.set aspectRatio_.reset
( (
aspectRatioModel::New aspectRatioModel::New
( (

View File

@ -132,7 +132,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
phasePair::scalarTable sigmaTable(lookup("sigma")); phasePair::scalarTable sigmaTable(lookup("sigma"));
phasePair::dictTable aspectRatioTable(lookup("aspectRatio")); phasePair::dictTable aspectRatioTable(lookup("aspectRatio"));
pair_.set pair_.reset
( (
new phasePair new phasePair
( (
@ -143,7 +143,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
pair1In2_.set pair1In2_.reset
( (
new orderedPhasePair new orderedPhasePair
( (
@ -155,7 +155,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
pair2In1_.set pair2In1_.reset
( (
new orderedPhasePair new orderedPhasePair
( (
@ -170,7 +170,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
// Models // Models
drag_.set drag_.reset
( (
new BlendedInterfacialModel<dragModel> new BlendedInterfacialModel<dragModel>
( (
@ -187,7 +187,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
virtualMass_.set virtualMass_.reset
( (
new BlendedInterfacialModel<virtualMassModel> new BlendedInterfacialModel<virtualMassModel>
( (
@ -203,7 +203,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
heatTransfer_.set heatTransfer_.reset
( (
new BlendedInterfacialModel<heatTransferModel> new BlendedInterfacialModel<heatTransferModel>
( (
@ -219,7 +219,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
lift_.set lift_.reset
( (
new BlendedInterfacialModel<liftModel> new BlendedInterfacialModel<liftModel>
( (
@ -235,7 +235,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
wallLubrication_.set wallLubrication_.reset
( (
new BlendedInterfacialModel<wallLubricationModel> new BlendedInterfacialModel<wallLubricationModel>
( (
@ -251,7 +251,7 @@ Foam::twoPhaseSystem::twoPhaseSystem
) )
); );
turbulentDispersion_.set turbulentDispersion_.reset
( (
new BlendedInterfacialModel<turbulentDispersionModel> new BlendedInterfacialModel<turbulentDispersionModel>
( (

View File

@ -166,7 +166,7 @@ int main(int argc, char *argv[])
{ {
meshFilterPtr.set meshFilterPtr.reset
( (
new polyMeshFilter(mesh, pointPriority, collapseDict) new polyMeshFilter(mesh, pointPriority, collapseDict)
); );

View File

@ -159,7 +159,7 @@ int main(int argc, char *argv[])
if (surfaceFormat == MESHEDSURFACE) if (surfaceFormat == MESHEDSURFACE)
{ {
fMesh.set(new MeshedSurface<face>("MeshedSurface.obj")); fMesh.reset(new MeshedSurface<face>("MeshedSurface.obj"));
EdgeMap<label> edgeRegionMap; EdgeMap<label> edgeRegionMap;
wordList patchNames(1, "default"); wordList patchNames(1, "default");
@ -184,7 +184,7 @@ int main(int argc, char *argv[])
poly2DMesh.createMesh(); poly2DMesh.createMesh();
mesh.set mesh.reset
( (
new polyMesh new polyMesh
( (
@ -224,7 +224,7 @@ int main(int argc, char *argv[])
} }
else if (surfaceFormat == POLYMESH2D) else if (surfaceFormat == POLYMESH2D)
{ {
mesh.set mesh.reset
( (
new polyMesh new polyMesh
( (
@ -244,7 +244,7 @@ int main(int argc, char *argv[])
extruder.addFrontBackPatches(); extruder.addFrontBackPatches();
meshMod.set(new polyTopoChange(mesh().boundaryMesh().size())); meshMod.reset(new polyTopoChange(mesh().boundaryMesh().size()));
extruder.setRefinement(meshMod()); extruder.setRefinement(meshMod());

View File

@ -379,7 +379,7 @@ void Foam::searchableSurfaceControl::initialVertices
vectorField norms = features.featurePointNormals(info.index()); vectorField norms = features.featurePointNormals(info.index());
// Create a triad from these norms. // Create a triad from these norms.
pointAlignment.set(new triad()); pointAlignment.reset(new triad());
forAll(norms, nI) forAll(norms, nI)
{ {
pointAlignment() += norms[nI]; pointAlignment() += norms[nI];
@ -406,7 +406,7 @@ void Foam::searchableSurfaceControl::initialVertices
vectorField norms = features.edgeNormals(info.index()); vectorField norms = features.edgeNormals(info.index());
// Create a triad from these norms. // Create a triad from these norms.
pointAlignment.set(new triad()); pointAlignment.reset(new triad());
forAll(norms, nI) forAll(norms, nI)
{ {
pointAlignment() += norms[nI]; pointAlignment() += norms[nI];
@ -431,7 +431,7 @@ void Foam::searchableSurfaceControl::initialVertices
normals[0] = vector(1, 1, 1); normals[0] = vector(1, 1, 1);
} }
pointAlignment.set(new triad(normals[0])); pointAlignment.reset(new triad(normals[0]));
if (infoList[0].hit()) if (infoList[0].hit())
{ {

View File

@ -420,7 +420,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation()
} }
} }
receivedVertices.set receivedVertices.reset
( (
new labelPairHashSet(number_of_vertices()/Pstream::nProcs()) new labelPairHashSet(number_of_vertices()/Pstream::nProcs())
); );

View File

@ -167,7 +167,7 @@ Foam::searchableBoxFeatures::features() const
labelList regionEdges; labelList regionEdges;
features.set features.reset
( (
new extendedFeatureEdgeMesh new extendedFeatureEdgeMesh
( (

View File

@ -183,7 +183,7 @@ Foam::searchablePlateFeatures::features() const
labelList regionEdges; labelList regionEdges;
features.set features.reset
( (
new extendedFeatureEdgeMesh new extendedFeatureEdgeMesh
( (

View File

@ -44,10 +44,6 @@ addToRunTimeSelectionTable
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::triSurfaceMeshFeatures::triSurfaceMeshFeatures Foam::triSurfaceMeshFeatures::triSurfaceMeshFeatures
@ -98,7 +94,7 @@ Foam::triSurfaceMeshFeatures::features() const
(mode_ == extendedFeatureEdgeMesh::BOTH ? true : false) (mode_ == extendedFeatureEdgeMesh::BOTH ? true : false)
); );
features.set features.reset
( (
new extendedFeatureEdgeMesh new extendedFeatureEdgeMesh
( (

View File

@ -314,7 +314,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
} }
} }
surfacePtr.set surfacePtr.reset
( (
new refinementSurfaces new refinementSurfaces
( (
@ -731,7 +731,7 @@ int main(int argc, char *argv[])
<< runTime.timeName() << nl << endl; << runTime.timeName() << nl << endl;
} }
meshPtr.set meshPtr.reset
( (
new fvMesh new fvMesh
( (
@ -982,7 +982,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
surfacesPtr.set surfacesPtr.reset
( (
new refinementSurfaces new refinementSurfaces
( (

View File

@ -165,7 +165,7 @@ int main(int argc, char *argv[])
if (dictPath.size()) if (dictPath.size())
{ {
csDictIoPtr.set csDictIoPtr.reset
( (
new IOobject new IOobject
( (
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
csDictIoPtr.set csDictIoPtr.reset
( (
new IOobject new IOobject
( (

View File

@ -145,7 +145,7 @@ int main(int argc, char *argv[])
{ {
const fileName dictPath = args["dict"]; const fileName dictPath = args["dict"];
ioPtr.set ioPtr.reset
( (
new IOobject new IOobject
( (
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
ioPtr.set ioPtr.reset
( (
new IOobject new IOobject
( (

View File

@ -158,7 +158,7 @@ int main(int argc, char *argv[])
{ {
const fileName dictPath = args["dict"]; const fileName dictPath = args["dict"];
ioPtr.set ioPtr.reset
( (
new IOobject new IOobject
( (
@ -176,7 +176,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
ioPtr.set ioPtr.reset
( (
new IOobject new IOobject
( (

View File

@ -1019,7 +1019,7 @@ void Foam::Time::setDeltaT(const scalar deltaT, const bool adjust)
Foam::TimeState Foam::Time::subCycle(const label nSubCycles) Foam::TimeState Foam::Time::subCycle(const label nSubCycles)
{ {
subCycling_ = true; subCycling_ = true;
prevTimeState_.set(new TimeState(*this)); prevTimeState_.reset(new TimeState(*this));
setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles); setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles);
deltaT_ /= nSubCycles; deltaT_ /= nSubCycles;

View File

@ -770,7 +770,7 @@ bool Foam::functionObjectList::read()
); );
if (functionObjects::timeControl::entriesPresent(dict)) if (functionObjects::timeControl::entriesPresent(dict))
{ {
foPtr.set foPtr.reset
( (
new functionObjects::timeControl(key, time_, dict) new functionObjects::timeControl(key, time_, dict)
); );

View File

@ -112,7 +112,7 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
fName = fName + "_" + startTimeName; fName = fName + "_" + startTimeName;
} }
osPtr.set(new OFstream(outputDir/(fName + ".dat"))); osPtr.reset(new OFstream(outputDir/(fName + ".dat")));
initStream(osPtr()); initStream(osPtr());
} }

View File

@ -275,7 +275,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
IStringStream is(os.str()); IStringStream is(os.str());
dictionary dict(is); dictionary dict(is);
redirectPatchFieldPtr_.set redirectPatchFieldPtr_.reset
( (
pointPatchField<Type>::New pointPatchField<Type>::New
( (

View File

@ -253,7 +253,7 @@ Foam::GAMGSolver::GAMGSolver
if (matrixLevels_.set(coarsestLevel)) if (matrixLevels_.set(coarsestLevel))
{ {
coarsestLUMatrixPtr_.set coarsestLUMatrixPtr_.reset
( (
new LUscalarMatrix new LUscalarMatrix
( (

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef autoPtr_H #ifndef autoPtr_H
#define autoPtr_H #define autoPtr_H
#include <cstddef>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -63,11 +61,14 @@ public:
// Constructors // Constructors
//- Construct null with nullptr
inline explicit autoPtr();
//- Store object pointer //- Store object pointer
inline explicit autoPtr(T* p = nullptr); inline explicit autoPtr(T* p);
//- Construct as copy by transferring pointer to this autoPtr and //- Construct as copy by transferring pointer to this autoPtr and
// setting the arguments pointer to nullptr //- setting the arguments pointer to nullptr
inline autoPtr(const autoPtr<T>& ap); inline autoPtr(const autoPtr<T>& ap);
//- Construct either by transferring pointer or cloning. //- Construct either by transferring pointer or cloning.
@ -92,7 +93,7 @@ public:
// Edit // Edit
//- Return object pointer for reuse //- Release ownership of the object pointer and return the pointer
inline T* ptr(); inline T* ptr();
//- Set pointer to that given. //- Set pointer to that given.
@ -100,11 +101,11 @@ public:
inline void set(T* p); inline void set(T* p);
//- If object pointer already set, delete object and set to given //- If object pointer already set, delete object and set to given
// pointer //- pointer
inline void reset(T* p = nullptr); inline void reset(T* p = nullptr);
//- Delete object (if the pointer is valid) and set pointer to //- Delete object (if the pointer is valid)
// nullptr //- and set pointer to nullptr
inline void clear(); inline void clear();
@ -127,19 +128,24 @@ public:
// Member operators // Member operators
//- Return reference to the object data //- Return reference to the object data.
// Fatal if no pointer is allocated.
inline T& operator()(); inline T& operator()();
//- Return const reference to the object data //- Return const reference to the object data
// Fatal if no pointer is allocated.
inline const T& operator()() const; inline const T& operator()() const;
//- Const cast to the underlying type reference //- Const cast to the underlying type reference
// Fatal if no pointer is allocated.
inline operator const T&() const; inline operator const T&() const;
//- Return object pointer //- Dereferences (non-const) pointer to the managed object
// Fatal if no pointer is allocated.
inline T* operator->(); inline T* operator->();
//- Return const object pointer //- Dereferences (const) pointer to the managed object
// Fatal if no pointer is allocated.
inline const T* operator->() const; inline const T* operator->() const;
//- Take over the object pointer from parameter //- Take over the object pointer from parameter

View File

@ -28,6 +28,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
inline Foam::autoPtr<T>::autoPtr()
:
ptr_(nullptr)
{}
template<class T> template<class T>
inline Foam::autoPtr<T>::autoPtr(T* p) inline Foam::autoPtr<T>::autoPtr(T* p)
: :
@ -89,9 +96,9 @@ inline bool Foam::autoPtr<T>::valid() const
template<class T> template<class T>
inline T* Foam::autoPtr<T>::ptr() inline T* Foam::autoPtr<T>::ptr()
{ {
T* ptr = ptr_; T* p = ptr_;
ptr_ = nullptr; ptr_ = nullptr;
return ptr; return p;
} }

View File

@ -83,11 +83,14 @@ public:
// Constructors // Constructors
//- Null pointer construct
inline tmp();
//- Store object pointer //- Store object pointer
inline explicit tmp(T* tPtr = nullptr); inline explicit tmp(T* p);
//- Store object const reference //- Store object const reference
inline tmp(const T& tRef); inline tmp(const T& t);
//- Construct copy and increment reference count //- Construct copy and increment reference count
inline tmp(const tmp<T>& t); inline tmp(const tmp<T>& t);
@ -125,16 +128,15 @@ public:
// Edit // Edit
//- Return non-const reference or generate a fatal error
// if the object is const.
inline T& ref() const;
//- Return tmp pointer for reuse. //- Return tmp pointer for reuse.
// Returns a clone if the object is not a temporary // Returns a clone if the object is not a temporary
inline T* ptr() const; inline T* ptr() const;
//- Return non-const reference. Fatal if the object is const.
inline T& ref() const;
//- If object pointer points to valid object: //- If object pointer points to valid object:
// delete object and set pointer to nullptr //- delete object and set pointer to nullptr
inline void clear() const; inline void clear() const;
@ -153,7 +155,7 @@ public:
inline const T* operator->() const; inline const T* operator->() const;
//- Assignment to pointer changing this tmp to a temporary T //- Assignment to pointer changing this tmp to a temporary T
inline void operator=(T* tPtr); inline void operator=(T* p);
//- Assignment transferring the temporary T to this tmp //- Assignment transferring the temporary T to this tmp
inline void operator=(const tmp<T>& t); inline void operator=(const tmp<T>& t);

View File

@ -46,12 +46,20 @@ inline void Foam::tmp<T>::operator++()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T> template<class T>
inline Foam::tmp<T>::tmp(T* tPtr) inline Foam::tmp<T>::tmp()
: :
type_(TMP), type_(TMP),
ptr_(tPtr) ptr_(nullptr)
{}
template<class T>
inline Foam::tmp<T>::tmp(T* p)
:
type_(TMP),
ptr_(p)
{ {
if (tPtr && !tPtr->unique()) if (p && !p->unique())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempted construction of a " << typeName() << "Attempted construction of a " << typeName()
@ -62,10 +70,10 @@ inline Foam::tmp<T>::tmp(T* tPtr)
template<class T> template<class T>
inline Foam::tmp<T>::tmp(const T& tRef) inline Foam::tmp<T>::tmp(const T& t)
: :
type_(CONST_REF), type_(CONST_REF),
ptr_(const_cast<T*>(&tRef)) ptr_(const_cast<T*>(&t))
{} {}
@ -170,30 +178,6 @@ inline Foam::word Foam::tmp<T>::typeName() const
} }
template<class T>
inline T& Foam::tmp<T>::ref() const
{
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
}
else
{
FatalErrorInFunction
<< "Attempt to acquire non-const reference to const object"
<< " from a " << typeName()
<< abort(FatalError);
}
return *ptr_;
}
template<class T> template<class T>
inline T* Foam::tmp<T>::ptr() const inline T* Foam::tmp<T>::ptr() const
{ {
@ -219,10 +203,32 @@ inline T* Foam::tmp<T>::ptr() const
return ptr; return ptr;
} }
return ptr_->clone().ptr();
}
template<class T>
inline T& Foam::tmp<T>::ref() const
{
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
}
else else
{ {
return ptr_->clone().ptr(); FatalErrorInFunction
<< "Attempt to acquire non-const reference to const object"
<< " from a " << typeName()
<< abort(FatalError);
} }
return *ptr_;
} }
@ -310,18 +316,18 @@ inline const T* Foam::tmp<T>::operator->() const
template<class T> template<class T>
inline void Foam::tmp<T>::operator=(T* tPtr) inline void Foam::tmp<T>::operator=(T* p)
{ {
clear(); clear();
if (!tPtr) if (!p)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName() << "Attempted copy of a deallocated " << typeName()
<< abort(FatalError); << abort(FatalError);
} }
if (tPtr && !tPtr->unique()) if (p && !p->unique())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempted assignment of a " << typeName() << "Attempted assignment of a " << typeName()
@ -330,7 +336,7 @@ inline void Foam::tmp<T>::operator=(T* tPtr)
} }
type_ = TMP; type_ = TMP;
ptr_ = tPtr; ptr_ = p;
} }

View File

@ -236,7 +236,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
this->runTime_.timeName(this->runTime_.startTime().value()) this->runTime_.timeName(this->runTime_.startTime().value())
); );
Ct2_.set Ct2_.reset
( (
new volScalarField new volScalarField
( (
@ -252,7 +252,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
) )
); );
rhom_.set rhom_.reset
( (
new volScalarField new volScalarField
( (
@ -268,7 +268,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
) )
); );
km_.set km_.reset
( (
new volScalarField new volScalarField
( (
@ -286,7 +286,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
); );
correctInletOutlet(km_(), kl); correctInletOutlet(km_(), kl);
epsilonm_.set epsilonm_.reset
( (
new volScalarField new volScalarField
( (
@ -323,10 +323,8 @@ bool mixtureKEpsilon<BasicTurbulenceModel>::read()
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -92,7 +92,7 @@ Foam::velocityDisplacementMotionSolver::velocityDisplacementMotionSolver
pointDisplacement.primitiveFieldRef() = mesh.points() - points0; pointDisplacement.primitiveFieldRef() = mesh.points() - points0;
displacementMotionSolverPtr_.set displacementMotionSolverPtr_.reset
( (
dynamic_cast<displacementMotionSolver*> dynamic_cast<displacementMotionSolver*>
( (

View File

@ -73,27 +73,27 @@ Foam::vtk::newFormatter
switch (fmtType) switch (fmtType)
{ {
case formatType::INLINE_ASCII: case formatType::INLINE_ASCII:
fmt.set(new vtk::asciiFormatter(os, prec)); fmt.reset(new vtk::asciiFormatter(os, prec));
break; break;
case formatType::INLINE_BASE64: case formatType::INLINE_BASE64:
fmt.set(new vtk::base64Formatter(os)); fmt.reset(new vtk::base64Formatter(os));
break; break;
case formatType::APPEND_BASE64: case formatType::APPEND_BASE64:
fmt.set(new vtk::appendBase64Formatter(os)); fmt.reset(new vtk::appendBase64Formatter(os));
break; break;
case formatType::APPEND_BINARY: case formatType::APPEND_BINARY:
fmt.set(new vtk::appendRawFormatter(os)); fmt.reset(new vtk::appendRawFormatter(os));
break; break;
case formatType::LEGACY_ASCII: case formatType::LEGACY_ASCII:
fmt.set(new vtk::legacyAsciiFormatter(os, prec)); fmt.reset(new vtk::legacyAsciiFormatter(os, prec));
break; break;
case formatType::LEGACY_BINARY: case formatType::LEGACY_BINARY:
fmt.set(new vtk::legacyRawFormatter(os)); fmt.reset(new vtk::legacyRawFormatter(os));
break; break;
} }

View File

@ -273,7 +273,7 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
IStringStream is(os.str()); IStringStream is(os.str());
dictionary dict(is); dictionary dict(is);
redirectPatchFieldPtr_.set redirectPatchFieldPtr_.reset
( (
fvPatchField<Type>::New fvPatchField<Type>::New
( (

View File

@ -278,7 +278,7 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
// to choose our type // to choose our type
dict.set("type", name_); dict.set("type", name_);
redirectPatchFieldPtr_.set redirectPatchFieldPtr_.reset
( (
dynamic_cast<mixedFvPatchField<Type>*> dynamic_cast<mixedFvPatchField<Type>*>
( (

View File

@ -231,7 +231,7 @@ Foam::autoPtr<Foam::triSurface> Foam::triSurfaceLoader::load
else if (selected_.size() == 1) else if (selected_.size() == 1)
{ {
// Use scaling (if any) // Use scaling (if any)
output.set(new triSurface(directory_/selected_[0], scaleFactor)); output.reset(new triSurface(directory_/selected_[0], scaleFactor));
triSurface& surf = output(); triSurface& surf = output();
@ -400,7 +400,7 @@ Foam::autoPtr<Foam::triSurface> Foam::triSurfaceLoader::load
points *= scaleFactor; points *= scaleFactor;
} }
output.set(new triSurface(faces, patches, points, true)); output.reset(new triSurface(faces, patches, points, true));
return output; return output;
} }

View File

@ -327,7 +327,7 @@ Foam::label Foam::RBD::rigidBodyModel::merge
makeComposite(sBody.masterID()); makeComposite(sBody.masterID());
sBodyPtr.set sBodyPtr.reset
( (
new subBody new subBody
( (
@ -342,7 +342,7 @@ Foam::label Foam::RBD::rigidBodyModel::merge
{ {
makeComposite(parentID); makeComposite(parentID);
sBodyPtr.set sBodyPtr.reset
( (
new subBody new subBody
( (

View File

@ -94,7 +94,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
const word name = coeffsDict_.lookup("lookUpTableFileName"); const word name = coeffsDict_.lookup("lookUpTableFileName");
if (name != "none") if (name != "none")
{ {
lookUpTablePtr_.set lookUpTablePtr_.reset
( (
new interpolationLookUpTable<scalar> new interpolationLookUpTable<scalar>
( (

View File

@ -73,7 +73,7 @@ Foam::radiation::boundaryRadiationProperties::boundaryRadiationProperties
{ {
const dictionary& dict = radiationDict.subDict(pp.name()); const dictionary& dict = radiationDict.subDict(pp.name());
radBoundaryPropertiesPtrList_[patchi].set radBoundaryPropertiesPtrList_[patchi].reset
( (
new boundaryRadiationPropertiesPatch(pp, dict) new boundaryRadiationPropertiesPatch(pp, dict)
); );