Merge branch 'enh-memory-cleanup' into 'develop'

autoPtr/tmp cleanup

See merge request Development/openfoam!378
This commit is contained in:
Andrew Heather
2020-07-17 16:29:16 +01:00
199 changed files with 874 additions and 973 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -129,12 +130,12 @@ Foam::BlendedInterfacialModel<modelType>::K() const
{
tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
}
@ -157,17 +158,17 @@ Foam::BlendedInterfacialModel<modelType>::K() const
)
);
if (model_.valid())
if (model_)
{
x.ref() += model_->K()*(f1() - f2());
}
if (model1In2_.valid())
if (model1In2_)
{
x.ref() += model1In2_->K()*(1 - f1);
}
if (model2In1_.valid())
if (model2In1_)
{
x.ref() += model2In1_->K()*f2;
}
@ -175,7 +176,7 @@ Foam::BlendedInterfacialModel<modelType>::K() const
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -191,7 +192,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
{
tmp<surfaceScalarField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 = fvc::interpolate
(
@ -199,7 +200,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
);
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 = fvc::interpolate
(
@ -225,17 +226,17 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
)
);
if (model_.valid())
if (model_)
{
x.ref() += model_->Kf()*(f1() - f2());
}
if (model1In2_.valid())
if (model1In2_)
{
x.ref() += model1In2_->Kf()*(1 - f1);
}
if (model2In1_.valid())
if (model2In1_)
{
x.ref() += model2In1_->Kf()*f2;
}
@ -243,7 +244,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -260,12 +261,12 @@ Foam::BlendedInterfacialModel<modelType>::F() const
{
tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
}
@ -285,17 +286,17 @@ Foam::BlendedInterfacialModel<modelType>::F() const
dimensioned<Type>(modelType::dimF, Zero)
);
if (model_.valid())
if (model_)
{
x.ref() += model_->F()*(f1() - f2());
}
if (model1In2_.valid())
if (model1In2_)
{
x.ref() += model1In2_->F()*(1 - f1);
}
if (model2In1_.valid())
if (model2In1_)
{
x.ref() -= model2In1_->F()*f2; // note : subtraction
}
@ -303,7 +304,7 @@ Foam::BlendedInterfacialModel<modelType>::F() const
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -319,7 +320,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
{
tmp<surfaceScalarField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 = fvc::interpolate
(
@ -327,7 +328,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
);
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 = fvc::interpolate
(
@ -352,17 +353,17 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
x.ref().setOriented();
if (model_.valid())
if (model_)
{
x.ref() += model_->Ff()*(f1() - f2());
}
if (model1In2_.valid())
if (model1In2_)
{
x.ref() += model1In2_->Ff()*(1 - f1);
}
if (model2In1_.valid())
if (model2In1_)
{
x.ref() -= model2In1_->Ff()*f2; // note : subtraction
}
@ -370,7 +371,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -386,12 +387,12 @@ Foam::BlendedInterfacialModel<modelType>::D() const
{
tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
}
@ -414,17 +415,17 @@ Foam::BlendedInterfacialModel<modelType>::D() const
)
);
if (model_.valid())
if (model_)
{
x.ref() += model_->D()*(f1() - f2());
}
if (model1In2_.valid())
if (model1In2_)
{
x.ref() += model1In2_->D()*(1 - f1);
}
if (model2In1_.valid())
if (model2In1_)
{
x.ref() += model2In1_->D()*f2;
}
@ -432,7 +433,7 @@ Foam::BlendedInterfacialModel<modelType>::D() const
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -451,8 +452,8 @@ bool Foam::BlendedInterfacialModel<modelType>::hasModel
return
(
&phase == &(pair_.phase1())
? model1In2_.valid()
: model2In1_.valid()
? bool(model1In2_)
: bool(model2In1_)
);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +86,7 @@ Foam::word Foam::orderedPhasePair::name() const
Foam::tmp<Foam::volScalarField> Foam::orderedPhasePair::E() const
{
if (!aspectRatio_.valid())
if (!aspectRatio_)
{
FatalErrorInFunction
<< "Aspect ratio model not specified for " << *this << "."

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,7 +44,7 @@ void testTransfer1(autoPtr<labelList> ap)
// Passed in copy, so automatically removes content
// Transfer would be nice, but not actually needed
Info<< "recv " << Switch::name(ap.valid()) << nl;
Info<< "recv " << Switch::name(bool(ap)) << nl;
}
@ -53,7 +53,7 @@ void testTransfer1(autoPtr<labelList> ap)
void testTransfer2(autoPtr<labelList>&& ap)
{
// As rvalue, so this time we actually get to manage content
Info<< "recv " << Switch::name(ap.valid()) << nl;
Info<< "recv " << Switch::name(bool(ap)) << nl;
}
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
testTransfer2(std::move(list));
Info<<"now have valid=" << Switch::name(list.valid());
Info<<"now have valid=" << Switch::name(bool(list));
if (list)
{
@ -209,9 +209,9 @@ int main(int argc, char *argv[])
testTransfer2(std::move(list));
Info<<"now have valid=" << Switch::name(list.valid());
Info<<"now have valid=" << Switch::name(bool(list));
if (list.valid())
if (list)
{
Info<< nl
<< flatOutput(*list) << " @ " << name(list->cdata())
@ -229,7 +229,7 @@ int main(int argc, char *argv[])
auto ptr1 = autoPtr<labelList>::New();
auto ptr2 = autoPtr<labelList>::New();
Info<<"ptr valid: " << ptr1.valid() << nl;
Info<<"ptr valid: " << bool(ptr1) << nl;
// Refuses to compile (good!): ptr1 = new labelList(10);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,8 +53,8 @@ Foam::token Foam::dictionaryTokens::keywordToken(const entry& e)
bool Foam::dictionaryTokens::setIterator() const
{
primIter_.clear();
dictIter_.clear();
primIter_.reset(nullptr);
dictIter_.reset(nullptr);
if (entryIter_ != dict_.cend())
{
@ -166,8 +166,8 @@ bool Foam::dictionaryTokens::good() const
entryIter_ != dict_.cend()
&&
(
(primIter_.valid() && primIter_().good())
|| (dictIter_.valid() && dictIter_().good())
(primIter_ && primIter_->good())
|| (dictIter_ && dictIter_->good())
)
);
}
@ -189,8 +189,8 @@ const Foam::token& Foam::dictionaryTokens::operator*() const
{
if (good())
{
if (primIter_.valid()) return *(primIter_());
if (dictIter_.valid()) return *(dictIter_());
if (primIter_) return *(*primIter_);
if (dictIter_) return *(*dictIter_);
}
return token::undefinedToken;
@ -251,8 +251,8 @@ bool Foam::dictionaryTokens::operator++()
if (ok)
{
if (primIter_.valid()) ok = ++(primIter_());
if (dictIter_.valid()) ok = ++(dictIter_());
if (primIter_) ok = ++(*primIter_);
if (dictIter_) ok = ++(*dictIter_);
if (!ok)
{

View File

@ -137,9 +137,9 @@ label mergePatchFaces
// Faces in error.
labelHashSet errorFaces;
if (qualDictPtr.valid())
if (qualDictPtr)
{
motionSmoother::checkMesh(false, mesh, qualDictPtr(), errorFaces);
motionSmoother::checkMesh(false, mesh, *qualDictPtr, errorFaces);
}
else
{
@ -440,7 +440,7 @@ int main(int argc, char *argv[])
);
// Merge points on straight edges and remove unused points
if (qualDict.valid())
if (qualDict)
{
Info<< "Merging all 'loose' points on surface edges, "
<< "regardless of the angle they make." << endl;

View File

@ -731,9 +731,9 @@ int main(int argc, char *argv[])
);
// Update
if (refDataPtr.valid())
if (refDataPtr)
{
refDataPtr().updateMesh(map());
refDataPtr->updateMesh(map());
}
// Store added cells
@ -815,9 +815,9 @@ int main(int argc, char *argv[])
polyMesh& mesh =
(
meshFromMesh.valid()
? meshFromMesh()
: meshFromSurface()
meshFromMesh
? *meshFromMesh
: *meshFromSurface
);
@ -896,9 +896,9 @@ int main(int argc, char *argv[])
updateFaceLabels(map(), backPatchFaces);
updateCellSet(map(), addedCellsSet);
if (refDataPtr.valid())
if (refDataPtr)
{
refDataPtr().updateMesh(map());
refDataPtr->updateMesh(map());
}
// Move mesh (if inflation used)
@ -1029,9 +1029,9 @@ int main(int argc, char *argv[])
// Update local data
updateCellSet(map(), addedCellsSet);
if (refDataPtr.valid())
if (refDataPtr)
{
refDataPtr().updateMesh(map());
refDataPtr->updateMesh(map());
}
// Move mesh (if inflation used)
@ -1067,9 +1067,9 @@ int main(int argc, char *argv[])
}
}
if (refDataPtr.valid())
if (refDataPtr)
{
refDataPtr().write();
refDataPtr->write();
}

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

@ -539,7 +539,7 @@ Foam::label Foam::checkGeometry
<< nonAlignedPoints.name() << endl;
nonAlignedPoints.instance() = mesh.pointsInstance();
nonAlignedPoints.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, nonAlignedPoints);
}
@ -573,7 +573,7 @@ Foam::label Foam::checkGeometry
<< " non closed cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -589,7 +589,7 @@ Foam::label Foam::checkGeometry
<< aspectCells.name() << endl;
aspectCells.instance() = mesh.pointsInstance();
aspectCells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, aspectCells);
}
@ -610,7 +610,7 @@ Foam::label Foam::checkGeometry
<< " zero area faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -632,7 +632,7 @@ Foam::label Foam::checkGeometry
<< " zero volume cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -655,7 +655,7 @@ Foam::label Foam::checkGeometry
<< " non-orthogonal faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -677,7 +677,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -699,7 +699,7 @@ Foam::label Foam::checkGeometry
<< " skew faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -723,7 +723,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -756,7 +756,7 @@ Foam::label Foam::checkGeometry
<< "decomposition tets to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -781,7 +781,7 @@ Foam::label Foam::checkGeometry
<< endl;
points.instance() = mesh.pointsInstance();
points.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, points);
}
@ -804,7 +804,7 @@ Foam::label Foam::checkGeometry
<< " apart) points to set " << nearPoints.name() << endl;
nearPoints.instance() = mesh.pointsInstance();
nearPoints.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, nearPoints);
}
@ -828,7 +828,7 @@ Foam::label Foam::checkGeometry
<< endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -851,7 +851,7 @@ Foam::label Foam::checkGeometry
<< " warped faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -872,7 +872,7 @@ Foam::label Foam::checkGeometry
<< " under-determined cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -892,7 +892,7 @@ Foam::label Foam::checkGeometry
<< " concave cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -913,7 +913,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -934,7 +934,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -949,12 +949,12 @@ Foam::label Foam::checkGeometry
const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName);
autoPtr<surfaceWriter> patchWriter;
if (!surfWriter.valid())
if (!surfWriter)
{
patchWriter.reset(new surfaceWriters::vtkWriter());
}
surfaceWriter& wr = (surfWriter.valid() ? *surfWriter : *patchWriter);
surfaceWriter& wr = (surfWriter ? *surfWriter : *patchWriter);
// Currently only do AMI checks

View File

@ -30,7 +30,7 @@ Foam::label Foam::checkMeshQuality
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (writer)
{
mergeAndWrite(*writer, faces);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -202,7 +202,7 @@ Foam::label Foam::checkTopology
<< " illegal cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -226,7 +226,7 @@ Foam::label Foam::checkTopology
<< " unused points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance();
points.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, points);
}
@ -248,7 +248,7 @@ Foam::label Foam::checkTopology
<< " unordered faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -268,7 +268,7 @@ Foam::label Foam::checkTopology
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -289,7 +289,7 @@ Foam::label Foam::checkTopology
<< endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, cells);
}
@ -313,7 +313,7 @@ Foam::label Foam::checkTopology
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, faces);
}
@ -368,7 +368,7 @@ Foam::label Foam::checkTopology
<< endl;
oneCells.instance() = mesh.pointsInstance();
oneCells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, oneCells);
}
@ -384,7 +384,7 @@ Foam::label Foam::checkTopology
<< endl;
twoCells.instance() = mesh.pointsInstance();
twoCells.write();
if (surfWriter.valid())
if (surfWriter)
{
mergeAndWrite(*surfWriter, twoCells);
}
@ -529,7 +529,7 @@ Foam::label Foam::checkTopology
<< " points that are in multiple regions to set "
<< points.name() << endl;
points.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, points);
}
@ -640,7 +640,7 @@ Foam::label Foam::checkTopology
<< " conflicting points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance();
points.write();
if (setWriter.valid())
if (setWriter)
{
mergeAndWrite(*setWriter, points);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1035,9 +1036,9 @@ void Foam::meshDualiser::setRefinement
-1, //masterCellID,
-1 //zoneID
);
if (dualCcStr.valid())
if (dualCcStr)
{
meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]);
meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]);
}
}
@ -1079,11 +1080,11 @@ void Foam::meshDualiser::setRefinement
-1, //masterCellID
mesh_.cellZones().whichZone(pCells[pCelli]) //zoneID
);
if (dualCcStr.valid())
if (dualCcStr)
{
meshTools::writeOBJ
(
dualCcStr(),
*dualCcStr,
0.5*(mesh_.points()[pointi]+cellCentres[pCells[pCelli]])
);
}
@ -1104,9 +1105,9 @@ void Foam::meshDualiser::setRefinement
-1 //zoneID
);
if (dualCcStr.valid())
if (dualCcStr)
{
meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]);
meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -393,9 +393,9 @@ bool doCommand
currentSet.resize(max(currentSet.size(), typSize));
}
if (currentSetPtr.valid())
if (currentSetPtr)
{
topoSet& currentSet = currentSetPtr();
topoSet& currentSet = *currentSetPtr;
Info<< " Set:" << currentSet.name()
<< " Size:" << returnReduce(currentSet.size(), sumOp<label>())
@ -829,9 +829,9 @@ int main(int argc, char *argv[])
commandStatus stat = INVALID;
if (fileStreamPtr.valid())
if (fileStreamPtr)
{
if (!fileStreamPtr().good())
if (!fileStreamPtr->good())
{
Info<< "End of batch file" << endl;
// No error.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -394,7 +394,7 @@ int main(int argc, char *argv[])
break;
}
if (currentSet.valid())
if (currentSet)
{
Info<< " "
<< currentSet().type() << ' '

View File

@ -426,9 +426,9 @@ int main(int argc, char *argv[])
if (!lagrangianDirs.empty())
{
if (meshPtr.valid())
if (meshPtr)
{
meshPtr().readUpdate();
meshPtr->readUpdate();
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -334,7 +334,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
autoPtr<polyMesh> procMeshPtr;
if (facesInstancePointsPtr_.valid())
if (facesInstancePointsPtr_)
{
// Construct mesh from facesInstance.
pointField facesInstancePoints
@ -738,7 +738,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
procMesh.write();
// Write points if pointsInstance differing from facesInstance
if (facesInstancePointsPtr_.valid())
if (facesInstancePointsPtr_)
{
pointIOField pointsInstancePoints
(

View File

@ -672,9 +672,9 @@ void readFields
// Load field (but not oldTime)
readField(io, mesh, i, fields);
// Create zero sized field and send
if (subsetterPtr.valid())
if (subsetterPtr)
{
tmp<GeoField> tsubfld = subsetterPtr().interpolate(fields[i]);
tmp<GeoField> tsubfld = subsetterPtr->interpolate(fields[i]);
// Send to all processors that don't have a mesh
for (label procI = 1; procI < Pstream::nProcs(); ++procI)
@ -1415,9 +1415,9 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
autoPtr<mapDistributePolyMesh> mapPtr;
if (baseMeshPtr.valid() && baseMeshPtr().nCells())
if (baseMeshPtr && baseMeshPtr->nCells())
{
const fvMesh& baseMesh = baseMeshPtr();
const fvMesh& baseMesh = *baseMeshPtr;
labelListList cellSubMap(Pstream::nProcs());
cellSubMap[Pstream::masterNo()] = identity(mesh.nCells());
@ -1803,7 +1803,7 @@ void reconstructLagrangian
if (cloudNames.size())
{
if (!lagrangianReconstructorPtr.valid())
if (!lagrangianReconstructorPtr)
{
lagrangianReconstructorPtr.reset
(
@ -2116,7 +2116,7 @@ void redistributeLagrangian
{
if (clouds.size())
{
if (!lagrangianReconstructorPtr.valid())
if (!lagrangianReconstructorPtr)
{
lagrangianReconstructorPtr.reset
(
@ -2804,7 +2804,7 @@ int main(int argc, char *argv[])
Info<< " Detected topology change;"
<< " reconstructing addressing" << nl << endl;
if (baseMeshPtr.valid())
if (baseMeshPtr)
{
// Cannot do a baseMesh::readUpdate() since not all
// processors will have mesh files. So instead just

View File

@ -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.
@ -56,7 +56,7 @@ if (doFiniteArea)
FatalError.throwExceptions(throwing);
}
if (faMeshPtr.valid() && nAreaFields)
if (faMeshPtr && nAreaFields)
{
reportFields::area(Info, objects);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -153,7 +153,7 @@ Description
// Finish writers
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->close();
}

View File

@ -262,7 +262,7 @@ Description
// CellData
{
// Begin CellData
if (internalWriter.valid())
if (internalWriter)
{
// Optionally with cellID and procID fields
internalWriter->beginCellData
@ -323,7 +323,7 @@ Description
if (doPointValues)
{
// Begin PointData
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->beginPointData
(
@ -386,7 +386,7 @@ Description
// Finish writers
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->close();
}

View File

@ -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.
@ -60,7 +60,7 @@ bool writeDimField
const auto& field = tfield();
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->write(field);
}
@ -85,7 +85,7 @@ bool writeDimField
const auto& field = tfield();
if (internalWriter.valid() && pInterp.valid())
if (internalWriter && pInterp)
{
internalWriter->write(field, *pInterp);
}

View File

@ -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.
@ -83,7 +83,7 @@ bool writePointField
const auto& field = tproxied();
// Internal
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->write(field);
}

View File

@ -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.
@ -63,7 +63,7 @@ bool writeVolField
const auto& field = tfield();
// Internal
if (internalWriter.valid())
if (internalWriter)
{
internalWriter->write(field);
}
@ -99,7 +99,7 @@ bool writeVolField
const auto& field = tfield();
// Internal
if (internalWriter.valid() && pInterp.valid())
if (internalWriter && pInterp)
{
internalWriter->write(field, *pInterp);
}

View File

@ -99,7 +99,7 @@ int main(int argc, char *argv[])
autoPtr<lumpedPointIOMovement> movement =
lumpedPointIOMovement::New(runTime);
if (!movement.valid())
if (!movement)
{
Info<< "No valid movement found" << endl;
return 1;
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh);
if (!movement.valid())
if (!movement)
{
Info<< "No valid movement found" << endl;
return 1;

View File

@ -723,7 +723,7 @@ int main(int argc, char *argv[])
mesh.readUpdate();
if (args.found("dummy-phi") && !dummyPhi.valid())
if (args.found("dummy-phi") && !dummyPhi)
{
Info<< "Adding a dummy phi" << endl;
dummyPhi.reset
@ -802,9 +802,9 @@ int main(int argc, char *argv[])
ctrl
);
}
else if (exprDictPtr.valid())
else if (exprDictPtr)
{
const dictionary& exprDict = exprDictPtr();
const dictionary& exprDict = *exprDictPtr;
// Read set construct info from dictionary
PtrList<entry> actions(exprDict.lookup("expressions"));
@ -898,7 +898,7 @@ int main(int argc, char *argv[])
);
}
}
else if (exprDictPtr.valid())
else
{
FatalErrorInFunction
<< "No command-line or dictionary??" << nl << endl

View File

@ -469,7 +469,7 @@ int main(int argc, char *argv[])
Info<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl;
if (surfWriter.valid())
if (surfWriter)
{
boolList isIllegalFace(surf.size(), false);
UIndirectList<bool>(isIllegalFace, illegalFaces) = true;
@ -598,7 +598,7 @@ int main(int argc, char *argv[])
}
// Dump for subsetting
if (surfWriter.valid())
if (surfWriter)
{
// Transcribe faces
faceList faces(surf.size());
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
{
Info<< "Splitting surface into parts ..." << endl << endl;
if (!surfWriter.valid())
if (!surfWriter)
{
surfWriter.reset(new surfaceWriters::vtkWriter());
}
@ -933,7 +933,7 @@ int main(int argc, char *argv[])
if (outputThreshold > 0)
{
if (!surfWriter.valid())
if (!surfWriter)
{
surfWriter.reset(new surfaceWriters::vtkWriter());
}
@ -1001,7 +1001,7 @@ int main(int argc, char *argv[])
{
nInt++;
if (intStreamPtr.valid())
if (intStreamPtr)
{
intStreamPtr().write(hitInfo.hitPoint());
}
@ -1013,7 +1013,7 @@ int main(int argc, char *argv[])
{
nInt++;
if (intStreamPtr.valid())
if (intStreamPtr)
{
intStreamPtr().write(hitInfo2.hitPoint());
}
@ -1043,7 +1043,7 @@ int main(int argc, char *argv[])
// )
// );
//
// if (hitInfo.hit() && intStreamPtr.valid())
// if (hitInfo.hit() && intStreamPtr)
// {
// intStreamPtr().write(hitInfo.hitPoint());
//
@ -1070,7 +1070,7 @@ int main(int argc, char *argv[])
Info<< "Surface is self-intersecting at " << nInt
<< " locations." << endl;
if (intStreamPtr.valid())
if (intStreamPtr)
{
Info<< "Writing intersection points to "
<< intStreamPtr().name() << endl;

View File

@ -346,14 +346,14 @@ int main(int argc, char *argv[])
// Load a single file, or load and combine multiple selected files
autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor);
if (!surfPtr.valid() || surfPtr().empty())
if (!surfPtr || surfPtr->empty())
{
FatalErrorInFunction
<< "Problem loading surface(s) for entry: "
<< dictName << exit(FatalError);
}
triSurface surf = surfPtr();
triSurface surf = *surfPtr;
Info<< nl
<< "Statistics:" << nl;
@ -711,7 +711,7 @@ int main(int argc, char *argv[])
10 // externalAngleTolerance
);
if (vtkWriter.valid())
if (vtkWriter)
{
vtkWriter->beginCellData();
vtkWriter->write("internalCloseness", tcloseness[0]());
@ -735,7 +735,7 @@ int main(int argc, char *argv[])
maxProximity
);
if (vtkWriter.valid())
if (vtkWriter)
{
vtkWriter->beginCellData();
vtkWriter->write("featureProximity", tproximity());
@ -753,7 +753,7 @@ int main(int argc, char *argv[])
surf
);
if (vtkWriter.valid())
if (vtkWriter)
{
vtkWriter->beginPointData();
vtkWriter->write("curvature", tcurvature());

View File

@ -277,7 +277,7 @@ int main(int argc, char *argv[])
surf.cleanup(true);
}
if (fromCsys.valid())
if (fromCsys)
{
Info<< "move points from coordinate system: "
<< fromCsys->name() << endl;
@ -285,7 +285,7 @@ int main(int argc, char *argv[])
surf.movePoints(tpf());
}
if (toCsys.valid())
if (toCsys)
{
Info<< "move points to coordinate system: "
<< toCsys->name() << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -163,7 +163,7 @@ Foam::IOobjectList::IOobjectList
bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
{
if (objectPtr.valid())
if (objectPtr)
{
return insert(objectPtr->name(), objectPtr);
}
@ -174,7 +174,7 @@ bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
bool Foam::IOobjectList::add(autoPtr<IOobject>&& objectPtr)
{
if (objectPtr.valid())
if (objectPtr)
{
return insert(objectPtr->name(), objectPtr);
}

View File

@ -495,7 +495,7 @@ void Foam::functionObjectList::resetState()
Foam::IOdictionary& Foam::functionObjectList::stateDict()
{
if (!stateDictPtr_.valid())
if (!stateDictPtr_)
{
createStateDict();
}
@ -506,7 +506,7 @@ Foam::IOdictionary& Foam::functionObjectList::stateDict()
const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
{
if (!stateDictPtr_.valid())
if (!stateDictPtr_)
{
createStateDict();
}
@ -517,7 +517,7 @@ const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
Foam::objectRegistry& Foam::functionObjectList::storedObjects()
{
if (!objectsRegistryPtr_.valid())
if (!objectsRegistryPtr_)
{
createOutputRegistry();
}
@ -528,7 +528,7 @@ Foam::objectRegistry& Foam::functionObjectList::storedObjects()
const Foam::objectRegistry& Foam::functionObjectList::storedObjects() const
{
if (!objectsRegistryPtr_.valid())
if (!objectsRegistryPtr_)
{
createOutputRegistry();
}
@ -727,7 +727,7 @@ bool Foam::functionObjectList::adjustTimeStep()
bool Foam::functionObjectList::read()
{
if (!stateDictPtr_.valid())
if (!stateDictPtr_)
{
createStateDict();
}
@ -903,7 +903,7 @@ bool Foam::functionObjectList::read()
FatalIOError.throwExceptions(throwingIOerr);
// Required functionObject to be valid on all processors
if (returnReduce(foPtr.valid(), andOp<bool>()))
if (returnReduce(bool(foPtr), andOp<bool>()))
{
objPtr.reset(foPtr.release());
}

View File

@ -241,7 +241,7 @@ Foam::OFstream& Foam::functionObjects::writeFile::file()
return Snull;
}
if (!filePtr_.valid())
if (!filePtr_)
{
FatalErrorInFunction
<< "File pointer not allocated\n";

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,7 +106,7 @@ Foam::Istream& Foam::regIOobject::readStream(const bool valid)
}
// Construct object stream and read header if not already constructed
if (!isPtr_.valid())
if (!isPtr_)
{
fileName objPath;
if (watchIndices_.size())
@ -152,7 +152,7 @@ Foam::Istream& Foam::regIOobject::readStream
}
// Construct IFstream if not already constructed
if (!isPtr_.valid())
if (!isPtr_)
{
readStream(valid);
@ -185,11 +185,11 @@ void Foam::regIOobject::close()
{
Pout<< "regIOobject::close() : "
<< "finished reading "
<< (isPtr_.valid() ? isPtr_().name() : "dummy")
<< (isPtr_ ? isPtr_->name() : "dummy")
<< endl;
}
isPtr_.clear();
isPtr_.reset(nullptr);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -518,7 +518,7 @@ void Foam::expressions::exprResult::operator=(const exprResult& rhs)
<< exit(FatalError);
}
}
else if (objectPtr_.valid())
else if (objectPtr_)
{
FatalErrorInFunction
<< "Assignment with general content not possible" << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -283,7 +283,7 @@ inline bool Foam::expressions::exprResult::isBool() const
inline bool Foam::expressions::exprResult::isObject() const
{
return objectPtr_.valid();
return bool(objectPtr_);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -228,7 +228,7 @@ template<class Type>
const Foam::pointPatchField<Type>&
Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
{
if (!redirectPatchFieldPtr_.valid())
if (!redirectPatchFieldPtr_)
{
// Construct a patch
// Make sure to construct the patchfield with up-to-date value

View File

@ -1262,7 +1262,7 @@ void Foam::argList::parse
fileHandler().NewIFstream(source)
);
if (!decompDictStream.valid() || !decompDictStream->good())
if (!decompDictStream || !decompDictStream->good())
{
FatalError
<< "Cannot read decomposeParDict from "

View File

@ -161,7 +161,7 @@ void Foam::interpolationTable<Type>::write(Ostream& os) const
{
os.writeEntry("file", fileName_);
os.writeEntry("outOfBounds", bounds::repeatableBoundingNames[bounding_]);
if (reader_.valid())
if (reader_)
{
reader_->write(os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -447,7 +447,7 @@ public:
//- Whether to agglomerate across processors
bool processorAgglomerate() const
{
return procAgglomeratorPtr_.valid();
return bool(procAgglomeratorPtr_);
}
//- Mapping from processor to agglomerated processor (global, all

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -170,10 +170,10 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
tmp<labelField> tfineToCoarse(new labelField(0));
labelField& fineToCoarse = tfineToCoarse.ref();
if (singleCellMeshPtr.valid())
if (singleCellMeshPtr)
{
// On master call the agglomerator
const lduPrimitiveMesh& singleCellMesh = singleCellMeshPtr();
const lduPrimitiveMesh& singleCellMesh = *singleCellMeshPtr;
label nCoarseProcs;
fineToCoarse = pairGAMGAgglomeration::agglomerate

View File

@ -140,9 +140,12 @@ public:
// Member Functions
// Check
// Query
//- True if the managed pointer is null
//- Deprecated(2020-07) True if the managed pointer is null
//
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; }
//- True if the managed pointer is non-null

View File

@ -50,7 +50,7 @@ namespace Foam
class refCount
{
// Private data
// Private Data
int count_;
@ -62,7 +62,7 @@ public:
// Constructors
//- Construct null initializing count to 0
//- Default construct, initializing count to 0
constexpr refCount() noexcept
:
count_(0)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,7 +49,7 @@ See also
#include "refCount.H"
#include "word.H"
#include <utility>
#include "stdFoam.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,20 +69,21 @@ class tmp
enum refType
{
PTR, //!< Managing a pointer (ref-counted)
CREF //!< Using a const-reference to an object
CREF //!< Using (const) reference to an object
};
//- The managed pointer or the address of const-reference object
//- The managed pointer or address of the object (reference)
mutable T* ptr_;
//- The type (managed pointer | const-reference object)
//- The type (managed pointer | object reference)
mutable refType type_;
// Private Member Operators
//- Increment the ref-count for a managed pointer
inline void operator++();
//- and check that it is not oversubscribed
inline void incrCount();
public:
@ -122,7 +123,7 @@ public:
// Constructors
//- Construct with no managed pointer.
//- Default construct, no managed pointer.
inline constexpr tmp() noexcept;
//- Construct with no managed pointer.
@ -159,15 +160,17 @@ public:
// Query
//- True if this is a managed pointer (not a const reference)
inline bool isTmp() const noexcept;
//- Deprecated(2020-07) True if a null managed pointer
//
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; }
//- True if this is a non-null managed pointer
inline bool empty() const noexcept;
//- True for non-null pointer/reference
bool valid() const noexcept { return ptr_; }
//- True if this is a non-null managed pointer,
//- or is a const object reference
inline bool valid() const noexcept;
//- True if this is a managed pointer (not a reference)
bool isTmp() const noexcept { return type_ == PTR; }
//- True if this is a non-null managed pointer with a unique ref-count
inline bool movable() const noexcept;
@ -179,10 +182,10 @@ public:
// Access
//- Return pointer without nullptr checking.
inline T* get() noexcept;
T* get() noexcept { return ptr_; }
//- Return const pointer without nullptr checking.
inline const T* get() const noexcept;
const T* get() const noexcept { return ptr_; }
//- Return the const object reference or a const reference to the
//- contents of a non-null managed pointer.
@ -211,12 +214,8 @@ public:
//- delete object and set pointer to nullptr
inline void clear() const noexcept;
//- Release ownership of managed temporary object.
// After this call no object is managed.
inline void reset() noexcept;
//- Delete managed temporary object and set to new given pointer
inline void reset(T* p) noexcept;
inline void reset(T* p = nullptr) noexcept;
//- Clear existing and transfer ownership.
inline void reset(tmp<T>&& other) noexcept;
@ -245,12 +244,8 @@ public:
// Fatal for a null managed pointer or if the object is const.
inline T* operator->();
//- Is non-null managed pointer or const object reference : valid()
explicit inline operator bool() const noexcept;
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
//- Non-null pointer/reference : valid()
explicit operator bool() const noexcept { return ptr_; }
//- Transfer ownership of the managed pointer.
// Fatal for a null managed pointer or if the object is const.
@ -259,12 +254,12 @@ public:
//- Clear existing and transfer ownership.
inline void operator=(tmp<T>&& other) noexcept;
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
// Housekeeping
//- No assignment from literal nullptr.
// Consistent with run-time check for nullptr on assignment.
void operator=(std::nullptr_t) = delete;
//- Reset via assignment from literal nullptr
inline void operator=(std::nullptr_t) noexcept;
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,7 @@ License
// * * * * * * * * * * * * * Private Member Operators * * * * * * * * * * * //
template<class T>
inline void Foam::tmp<T>::operator++()
inline void Foam::tmp<T>::incrCount()
{
ptr_->operator++();
@ -138,7 +138,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t)
{
if (ptr_)
{
operator++();
this->incrCount();
}
else
{
@ -166,7 +166,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t, bool reuse)
}
else
{
operator++();
this->incrCount();
}
}
else
@ -188,27 +188,6 @@ inline Foam::tmp<T>::~tmp()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline bool Foam::tmp<T>::isTmp() const noexcept
{
return type_ == PTR;
}
template<class T>
inline bool Foam::tmp<T>::empty() const noexcept
{
return (!ptr_ && isTmp());
}
template<class T>
inline bool Foam::tmp<T>::valid() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline bool Foam::tmp<T>::movable() const noexcept
{
@ -223,20 +202,6 @@ inline Foam::word Foam::tmp<T>::typeName() const
}
template<class T>
inline T* Foam::tmp<T>::get() noexcept
{
return ptr_; // non-const pointer
}
template<class T>
inline const T* Foam::tmp<T>::get() const noexcept
{
return ptr_; // const pointer
}
template<class T>
inline const T& Foam::tmp<T>::cref() const
{
@ -266,7 +231,7 @@ inline T& Foam::tmp<T>::ref() const
<< abort(FatalError);
}
}
else
else // if (type_ == CREF)
{
FatalErrorInFunction
<< "Attempted non-const reference to const object from a "
@ -295,15 +260,16 @@ inline T& Foam::tmp<T>::constCast() const
template<class T>
inline T* Foam::tmp<T>::ptr() const
{
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
else if (!ptr_->unique())
if (isTmp())
{
if (!ptr_->unique())
{
FatalErrorInFunction
<< "Attempt to acquire pointer to object referred to"
@ -311,10 +277,10 @@ inline T* Foam::tmp<T>::ptr() const
<< abort(FatalError);
}
T* ptr = ptr_;
T* p = ptr_;
ptr_ = nullptr;
return ptr;
return p;
}
return ptr_->clone().ptr();
@ -339,15 +305,6 @@ inline void Foam::tmp<T>::clear() const noexcept
}
template<class T>
inline void Foam::tmp<T>::reset() noexcept
{
clear();
ptr_ = nullptr;
type_ = PTR;
}
template<class T>
inline void Foam::tmp<T>::reset(T* p) noexcept
{
@ -455,37 +412,6 @@ inline T* Foam::tmp<T>::operator->()
}
template<class T>
inline Foam::tmp<T>::operator bool() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline void Foam::tmp<T>::operator=(T* p)
{
clear();
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
else if (!p->unique())
{
FatalErrorInFunction
<< "Attempted assignment of a " << typeName()
<< " to non-unique pointer"
<< abort(FatalError);
}
ptr_ = p;
type_ = PTR;
}
template<class T>
inline void Foam::tmp<T>::operator=(const tmp<T>& t)
{
@ -536,4 +462,32 @@ inline void Foam::tmp<T>::operator=(tmp<T>&& other) noexcept
}
template<class T>
inline void Foam::tmp<T>::operator=(T* p)
{
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
else if (!p->unique())
{
FatalErrorInFunction
<< "Attempted assignment of a " << typeName()
<< " to non-unique pointer"
<< abort(FatalError);
}
reset(p);
}
template<class T>
inline void Foam::tmp<T>::operator=(std::nullptr_t) noexcept
{
reset(nullptr);
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,13 +62,13 @@ class tmpNrc
enum refType
{
PTR, //!< Managing a pointer (not ref-counted)
CREF //!< Using a const-reference to an object
CREF //!< Using (const) reference to an object
};
//- The managed pointer or the address of const-reference object
//- The managed pointer or address of the object (reference)
mutable T* ptr_;
//- The type (managed pointer | const-reference object)
//- The type (managed pointer | object reference)
mutable refType type_;
@ -109,7 +109,7 @@ public:
// Constructors
//- Construct with no managed pointer.
//- Default construct, no managed pointer.
inline constexpr tmpNrc() noexcept;
//- Construct with no managed pointer.
@ -139,17 +139,19 @@ public:
// Query
//- True if this is a managed pointer (not a const reference)
inline bool isTmp() const noexcept;
//- Deprecated(2020-07) True if a null managed pointer
//
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; }
//- True for non-null pointer/reference
bool valid() const noexcept { return ptr_; }
//- True if this is a managed pointer (not a reference)
bool isTmp() const noexcept { return type_ == PTR; }
//- True if this is a non-null managed pointer
inline bool empty() const noexcept;
//- True if this is a non-null managed pointer,
//- or is a const object reference
inline bool valid() const noexcept;
//- True if this is a non-null managed pointer with a unique ref-count
inline bool movable() const noexcept;
//- Return type-name of the tmp, constructed from type-name of T
@ -159,10 +161,10 @@ public:
// Access
//- Return pointer without nullptr checking.
inline T* get() noexcept;
T* get() noexcept { return ptr_; }
//- Return const pointer without nullptr checking.
inline const T* get() const noexcept;
const T* get() const noexcept { return ptr_; }
//- Return the const object reference or a const reference to the
//- contents of a non-null managed pointer.
@ -191,12 +193,8 @@ public:
//- delete object and set pointer to nullptr
inline void clear() const noexcept;
//- Release ownership of managed temporary object.
// After this call no object is managed.
inline void reset() noexcept;
//- Delete managed temporary object and set to new given pointer
inline void reset(T* p) noexcept;
inline void reset(T* p = nullptr) noexcept;
//- Clear existing and transfer ownership.
inline void reset(tmpNrc<T>&& other) noexcept;
@ -225,12 +223,8 @@ public:
// Fatal for a null managed pointer or if the object is const.
inline T* operator->();
//- Is non-null managed pointer or const object reference : valid()
explicit inline operator bool() const noexcept;
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
//- Non-null pointer/reference : valid()
explicit operator bool() const noexcept { return ptr_; }
//- Transfer ownership of the managed pointer.
// Fatal for a null managed pointer or if the object is const.
@ -239,15 +233,15 @@ public:
//- Clear existing and transfer ownership.
inline void operator=(tmpNrc<T>&& other) noexcept;
//- Conversion to tmp
//- Take ownership of the pointer.
// Fatal for a null pointer
inline void operator=(T* p);
//- Reset via assignment from literal nullptr
inline void operator=(std::nullptr_t) noexcept;
//- Conversion to tmp - releases pointer or copies reference
inline operator tmp<T>();
// Housekeeping
//- No assignment from literal nullptr.
// Consistent with run-time check for nullptr on assignment.
void operator=(std::nullptr_t) = delete;
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -152,27 +152,6 @@ inline Foam::tmpNrc<T>::~tmpNrc()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline bool Foam::tmpNrc<T>::isTmp() const noexcept
{
return type_ == PTR;
}
template<class T>
inline bool Foam::tmpNrc<T>::empty() const noexcept
{
return (!ptr_ && isTmp());
}
template<class T>
inline bool Foam::tmpNrc<T>::valid() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline bool Foam::tmpNrc<T>::movable() const noexcept
{
@ -187,20 +166,6 @@ inline Foam::word Foam::tmpNrc<T>::typeName() const
}
template<class T>
inline T* Foam::tmpNrc<T>::get() noexcept
{
return ptr_; // non-const pointer
}
template<class T>
inline const T* Foam::tmpNrc<T>::get() const noexcept
{
return ptr_; // const pointer
}
template<class T>
inline const T& Foam::tmpNrc<T>::cref() const
{
@ -230,7 +195,7 @@ inline T& Foam::tmpNrc<T>::ref() const
<< abort(FatalError);
}
}
else
else // if (type_ == CREF)
{
FatalErrorInFunction
<< "Attempted non-const reference to const object from a "
@ -259,8 +224,6 @@ inline T& Foam::tmpNrc<T>::constCast() const
template<class T>
inline T* Foam::tmpNrc<T>::ptr() const
{
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
@ -268,10 +231,12 @@ inline T* Foam::tmpNrc<T>::ptr() const
<< abort(FatalError);
}
T* ptr = ptr_;
if (isTmp())
{
T* p = ptr_;
ptr_ = nullptr;
return ptr;
return p;
}
return ptr_->clone().ptr();
@ -289,15 +254,6 @@ inline void Foam::tmpNrc<T>::clear() const noexcept
}
template<class T>
inline void Foam::tmpNrc<T>::reset() noexcept
{
clear();
ptr_ = nullptr;
type_ = PTR;
}
template<class T>
inline void Foam::tmpNrc<T>::reset(T* p) noexcept
{
@ -405,30 +361,6 @@ inline T* Foam::tmpNrc<T>::operator->()
}
template<class T>
inline Foam::tmpNrc<T>::operator bool() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(T* p)
{
clear();
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
ptr_ = p;
type_ = PTR;
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(const tmpNrc<T>& t)
{
@ -479,6 +411,27 @@ inline void Foam::tmpNrc<T>::operator=(tmpNrc<T>&& other) noexcept
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(T* p)
{
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
reset(p);
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(std::nullptr_t) noexcept
{
reset(nullptr);
}
template<class T>
inline Foam::tmpNrc<T>::operator tmp<T>()
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -128,8 +128,8 @@ void Foam::globalMeshData::calcSharedPoints() const
if
(
nGlobalPoints_ != -1
|| sharedPointLabelsPtr_.valid()
|| sharedPointAddrPtr_.valid()
|| sharedPointLabelsPtr_
|| sharedPointAddrPtr_
)
{
FatalErrorInFunction
@ -295,8 +295,8 @@ void Foam::globalMeshData::calcSharedEdges() const
if
(
nGlobalEdges_ != -1
|| sharedEdgeLabelsPtr_.valid()
|| sharedEdgeAddrPtr_.valid()
|| sharedEdgeLabelsPtr_
|| sharedEdgeAddrPtr_
)
{
FatalErrorInFunction
@ -1837,7 +1837,7 @@ void Foam::globalMeshData::clearOut()
const Foam::labelList& Foam::globalMeshData::sharedPointGlobalLabels() const
{
if (!sharedPointGlobalLabelsPtr_.valid())
if (!sharedPointGlobalLabelsPtr_)
{
sharedPointGlobalLabelsPtr_.reset
(
@ -2015,7 +2015,7 @@ Foam::label Foam::globalMeshData::nGlobalPoints() const
const Foam::labelList& Foam::globalMeshData::sharedPointLabels() const
{
if (!sharedPointLabelsPtr_.valid())
if (!sharedPointLabelsPtr_)
{
calcSharedPoints();
}
@ -2025,7 +2025,7 @@ const Foam::labelList& Foam::globalMeshData::sharedPointLabels() const
const Foam::labelList& Foam::globalMeshData::sharedPointAddr() const
{
if (!sharedPointAddrPtr_.valid())
if (!sharedPointAddrPtr_)
{
calcSharedPoints();
}
@ -2045,7 +2045,7 @@ Foam::label Foam::globalMeshData::nGlobalEdges() const
const Foam::labelList& Foam::globalMeshData::sharedEdgeLabels() const
{
if (!sharedEdgeLabelsPtr_.valid())
if (!sharedEdgeLabelsPtr_)
{
calcSharedEdges();
}
@ -2055,7 +2055,7 @@ const Foam::labelList& Foam::globalMeshData::sharedEdgeLabels() const
const Foam::labelList& Foam::globalMeshData::sharedEdgeAddr() const
{
if (!sharedEdgeAddrPtr_.valid())
if (!sharedEdgeAddrPtr_)
{
calcSharedEdges();
}
@ -2065,7 +2065,7 @@ const Foam::labelList& Foam::globalMeshData::sharedEdgeAddr() const
const Foam::indirectPrimitivePatch& Foam::globalMeshData::coupledPatch() const
{
if (!coupledPatchPtr_.valid())
if (!coupledPatchPtr_)
{
const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
@ -2126,7 +2126,7 @@ const Foam::indirectPrimitivePatch& Foam::globalMeshData::coupledPatch() const
const Foam::labelList& Foam::globalMeshData::coupledPatchMeshEdges() const
{
if (!coupledPatchMeshEdgesPtr_.valid())
if (!coupledPatchMeshEdgesPtr_)
{
coupledPatchMeshEdgesPtr_.reset
(
@ -2147,7 +2147,7 @@ const Foam::labelList& Foam::globalMeshData::coupledPatchMeshEdges() const
const Foam::Map<Foam::label>& Foam::globalMeshData::coupledPatchMeshEdgeMap()
const
{
if (!coupledPatchMeshEdgeMapPtr_.valid())
if (!coupledPatchMeshEdgeMapPtr_)
{
const labelList& me = coupledPatchMeshEdges();
@ -2165,7 +2165,7 @@ const
const Foam::globalIndex& Foam::globalMeshData::globalPointNumbering() const
{
if (!globalPointNumberingPtr_.valid())
if (!globalPointNumberingPtr_)
{
globalPointNumberingPtr_.reset
(
@ -2179,7 +2179,7 @@ const Foam::globalIndex& Foam::globalMeshData::globalPointNumbering() const
const Foam::globalIndexAndTransform&
Foam::globalMeshData::globalTransforms() const
{
if (!globalTransformsPtr_.valid())
if (!globalTransformsPtr_)
{
globalTransformsPtr_.reset(new globalIndexAndTransform(mesh_));
}
@ -2189,7 +2189,7 @@ Foam::globalMeshData::globalTransforms() const
const Foam::labelListList& Foam::globalMeshData::globalPointSlaves() const
{
if (!globalPointSlavesPtr_.valid())
if (!globalPointSlavesPtr_)
{
calcGlobalPointSlaves();
}
@ -2200,7 +2200,7 @@ const Foam::labelListList& Foam::globalMeshData::globalPointSlaves() const
const Foam::labelListList& Foam::globalMeshData::globalPointTransformedSlaves()
const
{
if (!globalPointTransformedSlavesPtr_.valid())
if (!globalPointTransformedSlavesPtr_)
{
calcGlobalPointSlaves();
}
@ -2210,7 +2210,7 @@ const
const Foam::mapDistribute& Foam::globalMeshData::globalPointSlavesMap() const
{
if (!globalPointSlavesMapPtr_.valid())
if (!globalPointSlavesMapPtr_)
{
calcGlobalPointSlaves();
}
@ -2220,7 +2220,7 @@ const Foam::mapDistribute& Foam::globalMeshData::globalPointSlavesMap() const
const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
{
if (!globalEdgeNumberingPtr_.valid())
if (!globalEdgeNumberingPtr_)
{
globalEdgeNumberingPtr_.reset
(
@ -2233,7 +2233,7 @@ const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
const Foam::labelListList& Foam::globalMeshData::globalEdgeSlaves() const
{
if (!globalEdgeSlavesPtr_.valid())
if (!globalEdgeSlavesPtr_)
{
calcGlobalEdgeSlaves();
}
@ -2244,7 +2244,7 @@ const Foam::labelListList& Foam::globalMeshData::globalEdgeSlaves() const
const Foam::labelListList& Foam::globalMeshData::globalEdgeTransformedSlaves()
const
{
if (!globalEdgeTransformedSlavesPtr_.valid())
if (!globalEdgeTransformedSlavesPtr_)
{
calcGlobalEdgeSlaves();
}
@ -2254,7 +2254,7 @@ const
const Foam::bitSet& Foam::globalMeshData::globalEdgeOrientation() const
{
if (!globalEdgeOrientationPtr_.valid())
if (!globalEdgeOrientationPtr_)
{
calcGlobalEdgeOrientation();
}
@ -2264,7 +2264,7 @@ const Foam::bitSet& Foam::globalMeshData::globalEdgeOrientation() const
const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const
{
if (!globalEdgeSlavesMapPtr_.valid())
if (!globalEdgeSlavesMapPtr_)
{
calcGlobalEdgeSlaves();
}
@ -2275,7 +2275,7 @@ const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const
const Foam::globalIndex& Foam::globalMeshData::globalBoundaryFaceNumbering()
const
{
if (!globalBoundaryFaceNumberingPtr_.valid())
if (!globalBoundaryFaceNumberingPtr_)
{
calcGlobalPointBoundaryFaces();
}
@ -2286,7 +2286,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryFaces()
const
{
if (!globalPointBoundaryFacesPtr_.valid())
if (!globalPointBoundaryFacesPtr_)
{
calcGlobalPointBoundaryFaces();
}
@ -2297,7 +2297,7 @@ const
const Foam::labelListList&
Foam::globalMeshData::globalPointTransformedBoundaryFaces() const
{
if (!globalPointTransformedBoundaryFacesPtr_.valid())
if (!globalPointTransformedBoundaryFacesPtr_)
{
calcGlobalPointBoundaryFaces();
}
@ -2308,7 +2308,7 @@ Foam::globalMeshData::globalPointTransformedBoundaryFaces() const
const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryFacesMap()
const
{
if (!globalPointBoundaryFacesMapPtr_.valid())
if (!globalPointBoundaryFacesMapPtr_)
{
calcGlobalPointBoundaryFaces();
}
@ -2318,7 +2318,7 @@ const
const Foam::labelList& Foam::globalMeshData::boundaryCells() const
{
if (!boundaryCellsPtr_.valid())
if (!boundaryCellsPtr_)
{
calcGlobalPointBoundaryCells();
}
@ -2329,7 +2329,7 @@ const Foam::labelList& Foam::globalMeshData::boundaryCells() const
const Foam::globalIndex& Foam::globalMeshData::globalBoundaryCellNumbering()
const
{
if (!globalBoundaryCellNumberingPtr_.valid())
if (!globalBoundaryCellNumberingPtr_)
{
calcGlobalPointBoundaryCells();
}
@ -2340,7 +2340,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryCells()
const
{
if (!globalPointBoundaryCellsPtr_.valid())
if (!globalPointBoundaryCellsPtr_)
{
calcGlobalPointBoundaryCells();
}
@ -2351,7 +2351,7 @@ const
const Foam::labelListList&
Foam::globalMeshData::globalPointTransformedBoundaryCells() const
{
if (!globalPointTransformedBoundaryCellsPtr_.valid())
if (!globalPointTransformedBoundaryCellsPtr_)
{
calcGlobalPointBoundaryCells();
}
@ -2362,7 +2362,7 @@ Foam::globalMeshData::globalPointTransformedBoundaryCells() const
const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryCellsMap()
const
{
if (!globalPointBoundaryCellsMapPtr_.valid())
if (!globalPointBoundaryCellsMapPtr_)
{
calcGlobalPointBoundaryCells();
}
@ -2372,7 +2372,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalCoPointSlaves() const
{
if (!globalCoPointSlavesPtr_.valid())
if (!globalCoPointSlavesPtr_)
{
calcGlobalCoPointSlaves();
}
@ -2382,7 +2382,7 @@ const Foam::labelListList& Foam::globalMeshData::globalCoPointSlaves() const
const Foam::mapDistribute& Foam::globalMeshData::globalCoPointSlavesMap() const
{
if (!globalCoPointSlavesMapPtr_.valid())
if (!globalCoPointSlavesMapPtr_)
{
calcGlobalCoPointSlaves();
}

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

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -645,7 +646,7 @@ public:
bool hasOldCellVolumes() const
{
return oldCellVolumesPtr_.valid();
return bool(oldCellVolumesPtr_);
}
const scalarField& oldCellVolumes() const

View File

@ -329,7 +329,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
<< " boundaries." << endl;
}
if (!neighbourEdgesPtr_.valid())
if (!neighbourEdgesPtr_)
{
neighbourEdgesPtr_.reset(new List<labelPairList>(size()));
List<labelPairList>& neighbourEdges = neighbourEdgesPtr_();
@ -451,7 +451,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
{
if (!patchIDPtr_.valid())
if (!patchIDPtr_)
{
patchIDPtr_.reset(new labelList(mesh_.nBoundaryFaces()));
labelList& list = *patchIDPtr_;
@ -476,7 +476,7 @@ const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
const Foam::HashTable<Foam::labelList>&
Foam::polyBoundaryMesh::groupPatchIDs() const
{
if (!groupPatchIDsPtr_.valid())
if (!groupPatchIDsPtr_)
{
groupPatchIDsPtr_.reset(new HashTable<labelList>(16));
auto& groupPatchIDs = *groupPatchIDsPtr_;

View File

@ -699,25 +699,25 @@ void Foam::polyMesh::resetPrimitives
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (points.valid())
if (points)
{
points_.transfer(points());
points_.transfer(*points);
bounds_ = boundBox(points_, validBoundary);
}
if (faces.valid())
if (faces)
{
faces_.transfer(faces());
faces_.transfer(*faces);
}
if (owner.valid())
if (owner)
{
owner_.transfer(owner());
owner_.transfer(*owner);
}
if (neighbour.valid())
if (neighbour)
{
neighbour_.transfer(neighbour());
neighbour_.transfer(*neighbour);
}
@ -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());
@ -922,7 +922,7 @@ Foam::polyMesh::cellTree() const
);
}
return cellTreePtr_();
return *cellTreePtr_;
}
@ -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)
{
@ -1160,11 +1160,11 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
points_.instance() = time().timeName();
points_.eventNo() = getEvent();
if (tetBasePtIsPtr_.valid())
if (tetBasePtIsPtr_)
{
tetBasePtIsPtr_().writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_().instance() = time().timeName();
tetBasePtIsPtr_().eventNo() = getEvent();
tetBasePtIsPtr_->writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_->instance() = time().timeName();
tetBasePtIsPtr_->eventNo() = getEvent();
}
tmp<scalarField> sweptVols = primitiveMesh::movePoints
@ -1174,9 +1174,9 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
);
// Adjust parallel shared points
if (globalMeshDataPtr_.valid())
if (globalMeshDataPtr_)
{
globalMeshDataPtr_().movePoints(points_);
globalMeshDataPtr_->movePoints(points_);
}
// Force recalculation of all geometric data with new points
@ -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

@ -80,7 +80,7 @@ void Foam::polyMesh::updateGeom
DebugInFunction
<< "Updating geometric data with newPoints:"
<< newPoints.size() << " newTetBasePtIs:"
<< newTetBasePtIsPtr.valid() << endl;
<< bool(newTetBasePtIsPtr) << endl;
if (points_.size() != 0 && points_.size() != newPoints.size())
{
@ -128,7 +128,7 @@ void Foam::polyMesh::updateGeom
points_.transfer(newPoints);
// Optional new tet base points
if (newTetBasePtIsPtr.valid())
if (newTetBasePtIsPtr)
{
tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr);
}

View File

@ -64,7 +64,7 @@ void Foam::polyMesh::setInstance
cellZones_.writeOpt() = wOpt;
cellZones_.instance() = inst;
if (tetBasePtIsPtr_.valid())
if (tetBasePtIsPtr_)
{
tetBasePtIsPtr_->writeOpt() = wOpt;
tetBasePtIsPtr_->instance() = inst;

View File

@ -59,7 +59,7 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
cellTreePtr_.clear();
// Update parallel data
if (globalMeshDataPtr_.valid())
if (globalMeshDataPtr_)
{
globalMeshDataPtr_->updateMesh();
}
@ -67,12 +67,12 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
setInstance(time().timeName());
// Map the old motion points if present
if (oldPointsPtr_.valid())
if (oldPointsPtr_)
{
// Make a copy of the original points
pointField oldMotionPoints = oldPointsPtr_();
pointField oldMotionPoints = *oldPointsPtr_;
pointField& newMotionPoints = oldPointsPtr_();
pointField& newMotionPoints = *oldPointsPtr_;
// Resize the list to new size
newMotionPoints.setSize(points_.size());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -528,7 +528,7 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const
{
if (!neighbPointsPtr_.valid())
if (!neighbPointsPtr_)
{
FatalErrorInFunction
<< "No extended addressing calculated for patch " << name()
@ -540,7 +540,7 @@ const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const
const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const
{
if (!neighbEdgesPtr_.valid())
if (!neighbEdgesPtr_)
{
FatalErrorInFunction
<< "No extended addressing calculated for patch " << name()

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

@ -224,7 +224,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::correctInletOutlet
template<class BasicTurbulenceModel>
void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
{
if (rhom_.valid()) return;
if (rhom_) return;
// Local references to gas-phase properties
const volScalarField& kg = this->k_;

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 @@ bool Foam::expressions::fvExprDriver::readDict
{
ITstream& is = eptr->stream();
if (writer_.valid() && storedVariables_.size())
if (writer_ && !storedVariables_.empty())
{
WarningInFunction
// << "Context: " << driverContext_ << nl
@ -216,7 +216,7 @@ bool Foam::expressions::fvExprDriver::readDict
{
ITstream& is = eptr->stream();
if (writer_.valid() && delayedVariables_.size())
if (writer_ && !delayedVariables_.empty())
{
WarningInFunction
// << "Context: " << driverContext_ << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -261,16 +261,16 @@ Foam::Ostream& Foam::expressions::fvExprDriver::writeCommon
void Foam::expressions::fvExprDriver::createWriterAndRead(const word& name)
{
if (hasDataToWrite() && !writer_.valid())
if (!writer_ && hasDataToWrite())
{
writer_.set(new exprDriverWriter(name + "_" + this->type(), *this));
writer_.reset(new exprDriverWriter(name + "_" + this->type(), *this));
}
}
void Foam::expressions::fvExprDriver::tryWrite() const
{
if (writer_.valid() && mesh().time().outputTime())
if (writer_ && mesh().time().outputTime())
{
writer_->write();
}

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.
@ -227,7 +227,7 @@ template<class Type>
const Foam::fvPatchField<Type>&
Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
{
if (!redirectPatchFieldPtr_.valid())
if (!redirectPatchFieldPtr_)
{
// Construct a patch
// Make sure to construct the patchfield with up-to-date value

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.
@ -226,7 +226,7 @@ template<class Type>
const Foam::mixedFvPatchField<Type>&
Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
{
if (!redirectPatchFieldPtr_.valid())
if (!redirectPatchFieldPtr_)
{
// Construct a patch
// Make sure to construct the patchfield with up-to-date value

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,7 +132,7 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
origin_(ptf.origin_)
{
// Evaluate the profile if defined
if (ptf.profile_.valid())
if (ptf.profile_)
{
this->evaluate();
}

View File

@ -102,7 +102,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
freestreamBCPtr_()
{
if (ptf.freestreamBCPtr_.valid())
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ =
fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper);
@ -119,7 +119,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf),
freestreamBCPtr_()
{
if (ptf.freestreamBCPtr_.valid())
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
}
@ -136,7 +136,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf, iF),
freestreamBCPtr_()
{
if (ptf.freestreamBCPtr_.valid())
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
}
@ -149,7 +149,7 @@ template<class Type>
void Foam::freestreamFvPatchField<Type>::autoMap(const fvPatchFieldMapper& m)
{
inletOutletFvPatchField<Type>::autoMap(m);
if (freestreamBCPtr_.valid())
if (freestreamBCPtr_)
{
freestreamBCPtr_->autoMap(m);
}
@ -167,7 +167,7 @@ void Foam::freestreamFvPatchField<Type>::rmap
const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
if (fsptf.freestreamBCPtr_.valid())
if (fsptf.freestreamBCPtr_)
{
freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
}
@ -182,7 +182,7 @@ void Foam::freestreamFvPatchField<Type>::updateCoeffs()
return;
}
if (freestreamBCPtr_.valid())
if (freestreamBCPtr_)
{
freestreamBCPtr_->evaluate();
freestreamValue() = freestreamBCPtr_();
@ -198,7 +198,7 @@ void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const
fvPatchField<Type>::write(os);
os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
if (freestreamBCPtr_.valid())
if (freestreamBCPtr_)
{
os.beginBlock("freestreamBC");
freestreamBCPtr_->write(os);

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

@ -107,7 +107,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
uniformGradient_(ptf.uniformGradient_.clone())
{
// Evaluate the profile if defined
if (ptf.uniformGradient_.valid())
if (ptf.uniformGradient_)
{
this->evaluate();
}

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,7 +38,7 @@ withSurfaceFields() const
(
stFaceZone == regionType_
|| stPatch == regionType_
|| (sampledPtr_.valid() && sampledPtr_->withSurfaceFields())
|| (sampledPtr_ && sampledPtr_->withSurfaceFields())
);
}

View File

@ -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
@ -370,7 +370,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
Field<Type> values(getFieldValues<Type>(fieldName, true));
// Write raw values on surface if specified
if (surfaceWriterPtr_.valid() && surfaceWriterPtr_->enabled())
if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
{
Field<Type> allValues(values);
combineFields(allValues);

View File

@ -34,7 +34,7 @@ template<class chemistryType>
void Foam::functionObjects::reactionsSensitivityAnalysis<chemistryType>::
createFileNames()
{
if (writeToFile() && !prodFilePtr_.valid())
if (writeToFile() && !prodFilePtr_)
{
prodFilePtr_ = createFile("production");
writeHeader(prodFilePtr_(), "production");

View File

@ -413,8 +413,8 @@ bool Foam::functionObjects::regionSizeDistribution::write()
const volScalarField& alpha =
(
alphaPtr.valid()
? alphaPtr()
alphaPtr
? *alphaPtr
: obr_.lookupObject<volScalarField>(alphaName_)
);
@ -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 "

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

@ -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.
@ -54,7 +54,7 @@ void Foam::functionObjects::forceCoeffs::createFiles()
{
// Note: Only possible to create bin files after bins have been initialised
if (writeToFile() && !coeffFilePtr_.valid())
if (writeToFile() && !coeffFilePtr_)
{
coeffFilePtr_ = createFile("coefficient");
writeIntegratedHeader("Coefficients", coeffFilePtr_());

View File

@ -58,7 +58,7 @@ void Foam::functionObjects::forces::createFiles()
{
// Note: Only possible to create bin files after bins have been initialised
if (writeToFile() && !forceFilePtr_.valid())
if (writeToFile() && !forceFilePtr_)
{
forceFilePtr_ = createFile("force");
writeIntegratedHeader("Force", forceFilePtr_());

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

View File

@ -189,7 +189,7 @@ bool Foam::functionObjects::ensightWrite::execute()
bool Foam::functionObjects::ensightWrite::write()
{
if (!ensCase_.valid())
if (!ensCase_)
{
ensCase_.reset
(

View File

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

View File

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

View File

@ -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.
@ -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);
@ -126,7 +126,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields
const auto& field = tfield();
// Internal
if (internalWriter.valid() && pInterp.valid())
if (internalWriter && pInterp)
{
ok = true;
internalWriter->write(field, *pInterp);

View File

@ -145,7 +145,7 @@ Foam::displacementComponentLaplacianFvMotionSolver::curPoints() const
pointDisplacement_
);
if (pointLocation_.valid())
if (pointLocation_)
{
if (debug)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -245,7 +245,7 @@ Foam::displacementLaplacianFvMotionSolver::
Foam::motionDiffusivity&
Foam::displacementLaplacianFvMotionSolver::diffusivity()
{
if (!diffusivityPtr_.valid())
if (!diffusivityPtr_)
{
diffusivityPtr_ = motionDiffusivity::New
(
@ -267,7 +267,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const
pointDisplacement_
);
if (pointLocation_.valid())
if (pointLocation_)
{
if (debug)
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -249,7 +249,7 @@ Foam::solidBodyDisplacementLaplacianFvMotionSolver::
Foam::motionDiffusivity&
Foam::solidBodyDisplacementLaplacianFvMotionSolver::diffusivity()
{
if (!diffusivityPtr_.valid())
if (!diffusivityPtr_)
{
diffusivityPtr_ = motionDiffusivity::New
(
@ -277,7 +277,7 @@ Foam::solidBodyDisplacementLaplacianFvMotionSolver::curPoints() const
);
const pointField& newPoints = tnewPoints();
if (pointLocation_.valid())
if (pointLocation_)
{
if (debug)
{

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

@ -591,7 +591,7 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
}
// Apply offset to mapped values
if (offset_.valid())
if (offset_)
{
const scalar t = this->db().time().timeOutputValue();
this->operator==(*this + offset_->value(t));
@ -633,7 +633,7 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write
mapMethod_
);
if (offset_.valid())
if (offset_)
{
offset_->writeData(os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -155,7 +155,7 @@ void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs()
return;
}
if (!interpolatorPtr_.valid())
if (!interpolatorPtr_)
{
interpolatorPtr_ = interpolationWeights::New
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +38,7 @@ Foam::fv::interRegionOption::nbrRegionName() const
inline const Foam::meshToMesh&
Foam::fv::interRegionOption::meshInterp() const
{
if (!meshInterpPtr_.valid())
if (!meshInterpPtr_)
{
FatalErrorInFunction
<< "Interpolation object not set"

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +95,7 @@ Foam::fv::jouleHeatingSource::updateSigma
VolFieldType& sigma =
mesh_.lookupObjectRef<VolFieldType>(typeName + ":sigma");
if (!sigmaVsTPtr.valid())
if (!sigmaVsTPtr)
{
// Electrical conductivity field, sigma, was specified by the user
return sigma;

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,7 +54,7 @@ void Foam::fv::rotorDiskSource::calculate
scalar AOAmax = -GREAT;
// Cached position-dependent rotations available?
const bool hasCache = Rcyl_.valid();
const bool hasCache = bool(Rcyl_);
forAll(cells_, i)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -134,7 +134,7 @@ Foam::fv::CodedSource<Type>::CodedSource
template<class Type>
Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const
{
if (!redirectFvOptionPtr_.valid())
if (!redirectFvOptionPtr_)
{
dictionary constructDict(dict_);
constructDict.set("type", name_);

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.
@ -37,7 +38,7 @@ Foam::fv::interRegionHeatTransferModel::nbrRegionName() const
inline const Foam::meshToMesh&
Foam::fv::interRegionHeatTransferModel::meshInterp() const
{
if (!meshInterpPtr_.valid())
if (!meshInterpPtr_)
{
FatalErrorInFunction
<< "Interpolation object not set"

View File

@ -51,7 +51,7 @@ namespace fv
const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedHeatTransfer::hTable()
{
if (!hTable_.valid())
if (!hTable_)
{
hTable_.reset(new interpolation2DTable<scalar>(coeffs_));
}
@ -62,7 +62,7 @@ Foam::fv::tabulatedHeatTransfer::hTable()
const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV()
{
if (!AoV_.valid())
if (!AoV_)
{
AoV_.reset
(

View File

@ -61,7 +61,7 @@ Foam::fv::tabulatedNTUHeatTransfer::geometryModelNames_
const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedNTUHeatTransfer::ntuTable()
{
if (!ntuTable_.valid())
if (!ntuTable_)
{
ntuTable_.reset(new interpolation2DTable<scalar>(coeffs_));
}

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.
@ -343,7 +344,7 @@ void Foam::Cloud<ParticleType>::move
template<class ParticleType>
void Foam::Cloud<ParticleType>::autoMap(const mapPolyMesh& mapper)
{
if (!globalPositionsPtr_.valid())
if (!globalPositionsPtr_)
{
FatalErrorInFunction
<< "Global positions are not available. "

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,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.
@ -343,7 +343,7 @@ void Foam::ReactingCloud<CloudType>::info()
template<class CloudType>
void Foam::ReactingCloud<CloudType>::writeFields() const
{
if (compositionModel_.valid())
if (compositionModel_)
{
CloudType::particleType::writeFields(*this, this->composition());
}

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.
@ -279,7 +280,7 @@ void Foam::ReactingMultiphaseCloud<CloudType>::info()
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::writeFields() const
{
if (this->compositionModel_.valid())
if (this->compositionModel_)
{
CloudType::particleType::writeFields(*this, this->composition());
}

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.
@ -123,7 +124,7 @@ template<class ParcelType>
inline const Foam::interpolation<Foam::scalar>&
Foam::ThermoParcel<ParcelType>::trackingData::GInterp() const
{
if (!GInterp_.valid())
if (!GInterp_)
{
FatalErrorInFunction
<< "Radiation G interpolation object not set"

Some files were not shown because too many files have changed in this diff Show More