mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: check autoPtr as plain bool instead of valid()
- cleaner code, more similarity with unique_ptr
Now
if (ptr)
if (!ptr)
instead
if (ptr.valid())
if (!ptr.valid())
This commit is contained in:
@ -399,9 +399,9 @@ combineSurfaceGeometry
|
||||
points = s.points();
|
||||
}
|
||||
}
|
||||
else if (sampledPtr_.valid())
|
||||
else if (sampledPtr_)
|
||||
{
|
||||
const sampledSurface& s = sampledPtr_();
|
||||
const sampledSurface& s = *sampledPtr_;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
@ -443,9 +443,9 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
|
||||
|
||||
totalArea = gSum(s.magSf());
|
||||
}
|
||||
else if (sampledPtr_.valid())
|
||||
else if (sampledPtr_)
|
||||
{
|
||||
totalArea = gSum(sampledPtr_().magSf());
|
||||
totalArea = gSum(sampledPtr_->magSf());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -482,7 +482,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::usesSf() const
|
||||
|
||||
bool Foam::functionObjects::fieldValues::surfaceFieldValue::update()
|
||||
{
|
||||
if (sampledPtr_.valid())
|
||||
if (sampledPtr_)
|
||||
{
|
||||
sampledPtr_->update();
|
||||
}
|
||||
@ -1022,9 +1022,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
const polySurface& s = dynamicCast<const polySurface>(obr());
|
||||
Sf = s.Sf();
|
||||
}
|
||||
else if (sampledPtr_.valid())
|
||||
else if (sampledPtr_)
|
||||
{
|
||||
Sf = sampledPtr_().Sf();
|
||||
Sf = sampledPtr_->Sf();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1036,7 +1036,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
faceList faces;
|
||||
pointField points;
|
||||
|
||||
if (surfaceWriterPtr_.valid())
|
||||
if (surfaceWriterPtr_)
|
||||
{
|
||||
if (withTopologicalMerge())
|
||||
{
|
||||
|
||||
@ -94,19 +94,19 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
{
|
||||
const vf& fld = lookupObject<vf>(fieldName);
|
||||
|
||||
if (sampledPtr_.valid())
|
||||
if (sampledPtr_)
|
||||
{
|
||||
if (sampledPtr_().interpolate())
|
||||
if (sampledPtr_->interpolate())
|
||||
{
|
||||
const interpolationCellPoint<Type> interp(fld);
|
||||
|
||||
return sampledPtr_().interpolate(interp);
|
||||
return sampledPtr_->interpolate(interp);
|
||||
}
|
||||
else
|
||||
{
|
||||
const interpolationCell<Type> interp(fld);
|
||||
|
||||
return sampledPtr_().sample(interp);
|
||||
return sampledPtr_->sample(interp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -903,7 +903,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
|
||||
volVectorField
|
||||
>(fldName).primitiveField();
|
||||
|
||||
if (csysPtr_.valid())
|
||||
if (csysPtr_)
|
||||
{
|
||||
Log << "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
|
||||
@ -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.
|
||||
@ -144,7 +144,7 @@ Foam::functionObjects::codedFunctionObject::codedFunctionObject
|
||||
Foam::functionObject&
|
||||
Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const
|
||||
{
|
||||
if (!redirectFunctionObjectPtr_.valid())
|
||||
if (!redirectFunctionObjectPtr_)
|
||||
{
|
||||
dictionary constructDict(dict_);
|
||||
constructDict.set("type", name_);
|
||||
|
||||
@ -189,7 +189,7 @@ bool Foam::functionObjects::ensightWrite::execute()
|
||||
|
||||
bool Foam::functionObjects::ensightWrite::write()
|
||||
{
|
||||
if (!ensCase_.valid())
|
||||
if (!ensCase_)
|
||||
{
|
||||
ensCase_.reset
|
||||
(
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -146,7 +146,7 @@ bool Foam::functionObjects::ensightWrite::update()
|
||||
// ensMesh_.clear();
|
||||
// meshSubset_.clear();
|
||||
// }
|
||||
// else if (ensMesh_.valid())
|
||||
// else if (ensMesh_)
|
||||
// {
|
||||
// ensMesh_->expire();
|
||||
// }
|
||||
@ -157,13 +157,13 @@ bool Foam::functionObjects::ensightWrite::update()
|
||||
|
||||
meshState_ = polyMesh::UNCHANGED;
|
||||
|
||||
if (!ensMesh_.valid())
|
||||
if (!ensMesh_)
|
||||
{
|
||||
ensMesh_.reset(new ensightMesh(meshSubset_.mesh(), writeOpts_));
|
||||
}
|
||||
else if (ensMesh_().needsUpdate())
|
||||
else if (ensMesh_->needsUpdate())
|
||||
{
|
||||
ensMesh_().correct();
|
||||
ensMesh_->correct();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -521,7 +521,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
||||
|
||||
// CellData
|
||||
{
|
||||
if (internalWriter.valid())
|
||||
if (internalWriter)
|
||||
{
|
||||
// Optionally with cellID and procID fields
|
||||
internalWriter->beginCellData
|
||||
@ -580,7 +580,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
||||
if (interpolate_)
|
||||
{
|
||||
// Begin PointData
|
||||
if (internalWriter.valid())
|
||||
if (internalWriter)
|
||||
{
|
||||
internalWriter->beginPointData
|
||||
(
|
||||
@ -631,7 +631,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
||||
|
||||
|
||||
// Finish writers
|
||||
if (internalWriter.valid())
|
||||
if (internalWriter)
|
||||
{
|
||||
internalWriter->close();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields
|
||||
const auto& field = tfield();
|
||||
|
||||
// Internal
|
||||
if (internalWriter.valid())
|
||||
if (internalWriter)
|
||||
{
|
||||
ok = true;
|
||||
internalWriter->write(field);
|
||||
|
||||
Reference in New Issue
Block a user