diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C index cd7570bf26d7f6ff2537d2050f205c1c4bffb433..89033668c53740abf809a2640bd2de70a311a7f1 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -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_) ); } diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C index 65a87f642bba3e0145b264d43113a7d55e3cd190..21b6214b4ca2f6177cf6e462c625ace0abf47b92 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phasePair/orderedPhasePair/orderedPhasePair.C @@ -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 << "." diff --git a/applications/test/autoPtr/Test-autoPtr.C b/applications/test/autoPtr/Test-autoPtr.C index d0b18a0dad6d921148a2dc313e7dab7c20c90fb1..ed621ea0f261e6143ef703d9b89c5fb133add8bc 100644 --- a/applications/test/autoPtr/Test-autoPtr.C +++ b/applications/test/autoPtr/Test-autoPtr.C @@ -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); diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C index d958b5d9452f409658a4b2e7933b00f63b8f6ca1..f61f6ea34c29845b269f3c9bcfe5f510a78fe126 100644 --- a/applications/test/dictionaryTokens/dictionaryTokens.C +++ b/applications/test/dictionaryTokens/dictionaryTokens.C @@ -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) { diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index a37ac14a39644d44eb6ad285c3286ffaa9215315..b4591c772197f4a107843fc0bae90e91fd3cd648 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -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; diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 971c546c29f3d60c51b1b157de11a2d78fa6decc..7d0909ba5b52ab8c6630462f0673682b484a2f7d 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -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(); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C index bbd54cf475457e12bb5e1aef2119a580bdab770d..e02810916d18065d759981d84edad64179135c68 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C @@ -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); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 4f1f821681022aaafc0cee51a41dde3840976b90..90268fdf4b67624d1c870515933cb66dc641672c 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -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 diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index 26dfbb6d20fd2725788052f3749e1e0cbb72dcb6..d97308d6ec2b335f468bf734c655b6757f9d3fea 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -30,7 +30,7 @@ Foam::label Foam::checkMeshQuality faces.instance() = mesh.pointsInstance(); faces.write(); - if (writer.valid()) + if (writer) { mergeAndWrite(*writer, faces); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index ebb2a62255eff01b3c4bb5ccc5d7c534487254e1..cfd0a579fa0c8c81ac442357f42ca365c81b939f 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -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); } diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 18d47f32ffd8e1428c56064661347e5e4eb57775..0abc91fb2842e2795c35cd730592d8f981e81f93 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -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]); } } } diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index e0e60be11c3c445f7639cdcd4ff656098f08bd8b..1473bf293fa84e1f855f24b6d8adcbbb31b3fffd 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -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. diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index f8eb90fe092145a951d1ca16c6c2402e7e3625ce..162fd3fd1043bf80184cb28a1e723b931bcc5b2f 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -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() << ' ' diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index f9e5ccebf457802267cd4d90b77fe03d4d60ab4e..e3cd0db67149566d1c75bd3b0b936c412ce0833c 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -426,9 +426,9 @@ int main(int argc, char *argv[]) if (!lagrangianDirs.empty()) { - if (meshPtr.valid()) + if (meshPtr) { - meshPtr().readUpdate(); + meshPtr->readUpdate(); } else { diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index 8d3d950cf406a327fc5994d0b6d387a90cdea5fe..49d12e091b07b4bc8c366a8fafd90c5183260080 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -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 ( diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 9043525a3202e8e0fecc3a7f7bcf40401944bcd2..96f7bc50df6c4851760cea4dc13b183b739fd594 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -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 diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H index 923cf7fabf34d2803a5d451ccf1ff6a0c0ded97a..2466cda860edc9b6373d4fc28894756b64cd6145 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H @@ -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); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertProcessorPatches.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertProcessorPatches.H index 8374aa5bacfab9e6ceaf129be8f2f55dd460eaab..cc2aba6bb3f5a8bf36074b6c70aca068e660a64a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertProcessorPatches.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertProcessorPatches.H @@ -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(); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H index 72714c73154ac56e234e022a71f82f32d58ebf36..d91da0a2933cb7d9566a2b8bd4c5dbdf9ed248c1 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H @@ -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(); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H index bcaf81a9d8dbba33e68deb31a019028b81106166..345c467eeb13c30c4a40a82d66c0e72772264c40 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H @@ -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); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H index 3a55fac6d5ef03de9706f5ecd351808051e1141b..6c845d7c0d93684626d1d983a57ce2b739a8e27b 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H @@ -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); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H index 03bb2bbfe9a3802783ba49b895d4f82904e4d573..66ce5331bbf6f1a1515f6a8e9f6eb01285e0496e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H @@ -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); } diff --git a/applications/utilities/postProcessing/lumped/lumpedPointZones/lumpedPointZones.C b/applications/utilities/postProcessing/lumped/lumpedPointZones/lumpedPointZones.C index d0edb92330aee85bb2d12926067f9e087f9c9e7b..aae3d4c86928cf4cce7a35d42e0feb068d3ab986 100644 --- a/applications/utilities/postProcessing/lumped/lumpedPointZones/lumpedPointZones.C +++ b/applications/utilities/postProcessing/lumped/lumpedPointZones/lumpedPointZones.C @@ -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; diff --git a/applications/utilities/preProcessing/setExprFields/setExprFields.C b/applications/utilities/preProcessing/setExprFields/setExprFields.C index 2b995e0c3184874deb9cecd14f67ee5ad702005f..57e05ad4cb3a184b132da2b1176c1885a1ae62ed 100644 --- a/applications/utilities/preProcessing/setExprFields/setExprFields.C +++ b/applications/utilities/preProcessing/setExprFields/setExprFields.C @@ -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 diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index d7492379baa3772818d6ead9e0eda4f72b437290..87a04e1e2166170d4298fb5b96182c3ebdc5b3d4 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -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; diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 010cec6bd6c6ceb953310d0d75eeae9a8102582a..9cf57bc3412c9fab43179c39884404ba4d11b824 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -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()); diff --git a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C index 9430397e410fe9205194d4ed9c57d27aeae4ccb0..d80437d35a3a3e36d3fd088d5c94d5cedcaf1a1a 100644 --- a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C +++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C @@ -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; diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.C b/src/OpenFOAM/db/IOobjectList/IOobjectList.C index dd50e0c930016a2cfd371391b9827e677ba41ab9..85439ec787beba3f28045d8a4d208524fa51f8a8 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.C +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.C @@ -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); } diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 1c3e75609889f39c10fa0357e9109f7701ae0bce..fc54c45ff1e6821d58cdb3f8d3b436484c1f0730 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -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()); } diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 39870e475533112c7825afe98ab24af59ab1796b..36cb7cdd0a53198affd7982c12e45f86a5e616d4 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -241,7 +241,7 @@ Foam::OFstream& Foam::functionObjects::writeFile::file() return Snull; } - if (!filePtr_.valid()) + if (!filePtr_) { FatalErrorInFunction << "File pointer not allocated\n"; diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index e7fce79fdf153c55425b2fdee330e655d3161476..01b67843c4ecb71485d093d0f909219f4aa13de0 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -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); } diff --git a/src/OpenFOAM/expressions/exprResult/exprResult.C b/src/OpenFOAM/expressions/exprResult/exprResult.C index e53bfacbddd554bbadc70efaf21d5fea7878b608..43de67484d24f968779b6afa582c3a6cccf80512 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResult.C +++ b/src/OpenFOAM/expressions/exprResult/exprResult.C @@ -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 diff --git a/src/OpenFOAM/expressions/exprResult/exprResultI.H b/src/OpenFOAM/expressions/exprResult/exprResultI.H index 2b49e7ea6773b0113904926a7f55202bd51ec48f..818fa4758f3634967a06ba0dc4939a31cc3ac16f 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResultI.H +++ b/src/OpenFOAM/expressions/exprResult/exprResultI.H @@ -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_); } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C index d6e38e9f56e02b89b5e5cd591cec06098031ac01..bd94be76eb1a988703cdb37db506d1034593fd42 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -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 diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index eae90020674626c67c1d5fc645168ec3629dcaee..e808f5993d2465c5f37b3c1c2c6a49b0d1a853e4 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -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 " diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C index 18eaf5bc56d6cae9f7397f008dd77d15e9ac7f65..9a4404f5d99c26f9161dbe586a7f36a029418175 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C @@ -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); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H index e3d0f89ce6c4f8b1d7f137796060a1e2e0375f7f..0dd96c71505fe2a9e1b2d5b72b06ec2daafeabce 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H @@ -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 diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/procFacesGAMGProcAgglomeration/procFacesGAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/procFacesGAMGProcAgglomeration/procFacesGAMGProcAgglomeration.C index fcb6addf72eed44150178547f0542523fc929eb7..1678a9a5ed78add6029d5f0776cae482e2119358 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/procFacesGAMGProcAgglomeration/procFacesGAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/procFacesGAMGProcAgglomeration/procFacesGAMGProcAgglomeration.C @@ -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 diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H index 24ea395166d2db87012f9b3730ab2ab01e97fdc9..9fdd8e7f5c64cc02feb226fdb1e06465295578d1 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtr.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H @@ -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 diff --git a/src/OpenFOAM/memory/refCount/refCount.H b/src/OpenFOAM/memory/refCount/refCount.H index 303188bda58edac22429fe5b6f4c2a88ac341286..281d6535909e3e57fad055308b83147d42e2aa17 100644 --- a/src/OpenFOAM/memory/refCount/refCount.H +++ b/src/OpenFOAM/memory/refCount/refCount.H @@ -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) diff --git a/src/OpenFOAM/memory/tmp/tmp.H b/src/OpenFOAM/memory/tmp/tmp.H index dacb813c5ff0386be620a8ca2462733a8b3359f4..c2f9f6b187c39e0e51e17321ccb19144127e1ce5 100644 --- a/src/OpenFOAM/memory/tmp/tmp.H +++ b/src/OpenFOAM/memory/tmp/tmp.H @@ -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; }; diff --git a/src/OpenFOAM/memory/tmp/tmpI.H b/src/OpenFOAM/memory/tmp/tmpI.H index a035432d813c9ffa2f8412f42e8e79a526863f4e..729a13fedbdfe4d58f274ca0a09adfc45783069f 100644 --- a/src/OpenFOAM/memory/tmp/tmpI.H +++ b/src/OpenFOAM/memory/tmp/tmpI.H @@ -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 (!ptr_) + { + FatalErrorInFunction + << typeName() << " deallocated" + << abort(FatalError); + } + if (isTmp()) { - if (!ptr_) - { - FatalErrorInFunction - << typeName() << " deallocated" - << abort(FatalError); - } - else if (!ptr_->unique()) + 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); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/memory/tmp/tmpNrc.H b/src/OpenFOAM/memory/tmp/tmpNrc.H index c997b3c800029740279694adc1c00fef3109d4e2..b12e88124518ead68f767d90dc75e2d37ae99d0b 100644 --- a/src/OpenFOAM/memory/tmp/tmpNrc.H +++ b/src/OpenFOAM/memory/tmp/tmpNrc.H @@ -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 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 + //- True if this is a non-null managed pointer 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 - inline operator tmp<T>(); - + //- Take ownership of the pointer. + // Fatal for a null pointer + inline void operator=(T* p); - // Housekeeping + //- Reset via assignment from literal nullptr + inline void operator=(std::nullptr_t) noexcept; - //- No assignment from literal nullptr. - // Consistent with run-time check for nullptr on assignment. - void operator=(std::nullptr_t) = delete; + //- Conversion to tmp - releases pointer or copies reference + inline operator tmp<T>(); }; diff --git a/src/OpenFOAM/memory/tmp/tmpNrcI.H b/src/OpenFOAM/memory/tmp/tmpNrcI.H index 3ff8924c16be4a64184ed76790e9a3ca2a373edd..36ec5e8b8a167cca93204d8fa870ceaa6b7c3c08 100644 --- a/src/OpenFOAM/memory/tmp/tmpNrcI.H +++ b/src/OpenFOAM/memory/tmp/tmpNrcI.H @@ -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,19 +224,19 @@ inline T& Foam::tmpNrc<T>::constCast() const template<class T> inline T* Foam::tmpNrc<T>::ptr() const { - if (isTmp()) + if (!ptr_) { - if (!ptr_) - { - FatalErrorInFunction - << typeName() << " deallocated" - << abort(FatalError); - } + FatalErrorInFunction + << typeName() << " deallocated" + << 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>() { diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 4062471af1facc27cedffb7859cfc8bb51a6174e..f3782b6aaa2b6a06d61d4f3d736528e5b81114a5 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -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(); } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 5eb53d4214d447e6ecb94692594075e04efc67ac..1f9cb435857355bfeff48737a8b732101ac84fc9 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -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 ( diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H index c18788742799a49da13b75d7081cd4e2102ec2bc..a7b8f955a5e55a2487b7a97379f2b80259b2cfb1 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H @@ -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 diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 71f84b929a23143de98d01230adedad60b5e2b3b..ec523bc956d5e98de5c04e069a6e2f15c2048816 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -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_; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 4e1d725c897b590ef4687328dae698ac038fc56f..81fcd21f7f18b0680a2cf3a5f15317f7437d4bbe 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -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) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C index 123a95741a90d219f891f79fc050304172c853a0..e23cf5edc1dad1200474320c74ace5a63ac684ed 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C @@ -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); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C index 0789ee7accf14828bb219e6b1f6f2de9ab1194b1..0ba633b8f0661fce99de6cf4edbfa7c3fea2454b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C @@ -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; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C index e5818171d53ac6f85da1ceb6399a5e40ab79df99..65e7152c2af523bd212c711916942789005e0f48 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C @@ -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()); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index b8d5ebfa3c0dfca7220032c0719081a8d47603f0..46b2792a76a2a431ff7a9db421654a7a00ab7069 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -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() diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index f982ed44edda0a8e8b532571042c973fc326862a..aea435936ea8b41567f464c8f08c3414713405a5 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -206,7 +206,7 @@ const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solid() const { if (this->owner()) { - if (solidPtr_.empty()) + if (!solidPtr_) { solidPtr_.reset(new solidType(solidDict_)); } diff --git a/src/TurbulenceModels/phaseCompressible/RAS/mixtureKEpsilon/mixtureKEpsilon.C b/src/TurbulenceModels/phaseCompressible/RAS/mixtureKEpsilon/mixtureKEpsilon.C index bbb0e4d0c753eba6dc6d6101d63221d274445b82..ab153b6641d7fa459fb8929e4cb921badae8fdd0 100644 --- a/src/TurbulenceModels/phaseCompressible/RAS/mixtureKEpsilon/mixtureKEpsilon.C +++ b/src/TurbulenceModels/phaseCompressible/RAS/mixtureKEpsilon/mixtureKEpsilon.C @@ -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_; diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C index 96470ec5fe65ce4de89cdc03e116900f59668989..fe616252418db37f9106318dc9d0a0a00c939af1 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C @@ -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; } } } diff --git a/src/finiteVolume/expressions/base/fvExprDriver.C b/src/finiteVolume/expressions/base/fvExprDriver.C index b363296dc49df156fff1891ebac7a9bd6ddadf48..a73c38986bff9a502c2a2bcf77b0e99fac7e5212 100644 --- a/src/finiteVolume/expressions/base/fvExprDriver.C +++ b/src/finiteVolume/expressions/base/fvExprDriver.C @@ -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 diff --git a/src/finiteVolume/expressions/base/fvExprDriverIO.C b/src/finiteVolume/expressions/base/fvExprDriverIO.C index 3a25df5bdb6d4ec33f824fee81699a4141c01f95..93a64e1a2a7ea545ab5c700f8a3ff27cf09a0a6c 100644 --- a/src/finiteVolume/expressions/base/fvExprDriverIO.C +++ b/src/finiteVolume/expressions/base/fvExprDriverIO.C @@ -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(); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index bf827222324a8bdf3a2cdab21b32ae357c6434a4..55e412cf02ef0490a86b84ce2d45b48c6273c9e9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -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 diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C index ad721c0b37ed9c263f22a91493621b60c41c5ec2..96e11f9f4eabd1b20adc47707e48958c2de93cd9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -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 diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C index a0a4e59be72ec64caa3aa0c156f437627e251987..b9bbdedf819d72c8717f477532178116b9679181 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C @@ -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(); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C index 1cfd48f0dfeca423fb09fb62287b4e0f1e4e5650..eed403c590f6df13ee58b205eec75015287b2625 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C @@ -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); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index b5f75212eb0913e86b6e9bf11cdefb1b30b8770e..238b84c5029152b6dd4c512189edf187c314bdd0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -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 ( diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C index ac8709c6dd3e9286f52e0655aa9a3b3c0f7349d6..6ad03839f7aff29cc18ee1180e7bb933ded086a3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C @@ -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 diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C index e82228b7aebf4982dee7b079259379f9c891ed17..a2ee30027a0775af74a1a6c7e5fff5ab12047fe0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C @@ -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(); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index ccc3c313754db8a6d715779ab7e967590ef095c0..bfc8baaddaf21775b6fa5dd4250d93e97813bade 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -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()) { diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H index 331d20cb2dc39e2fdd278d81337893bd9090539c..f1ce22a48a45cd3b88d4b71e339cba0833bfee4d 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H @@ -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()) ); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 620fa7d46a90e04362606d69669b50b758a9c782..51fb11bf9946242876f2e1e6baa86318a5c8f4ac 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -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); diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 878ed42ea43eb9e7fc924f4d4338acff43f58ff6..ef50d4e471b6da9a065695c0b319027bc8103499 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -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"); diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 6375a4ca73a0f539518b3dae01684a69ef3df50a..bb0f702dc5f093ee7ef81ca5c6558679dfdf947b 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -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 " diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 4fb9e9e3c7677ffae3a8c0d546319c19450b766f..93b9ff90acf0dd98d6e41baf84c89aa5395302e3 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -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 ( diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index e55aa3ef0723e2e44ddbc441decda54d2e714d37..5b5e2b2d7cf5994e6f738adeeb523a7b38e00c3d 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -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_()); diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index b2e824f78160b35a006c960d40f39a4ba56c77a1..e3dbc07f1f967eb828828a3555061f1f431a7a5f 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -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_()); diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index d96810f03b90b831562578e7f3e6eb2f17a61f84..0b58ed947a571702d166f3cde6e8819e9ac882bc 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -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_); diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C index ebf3277e36f4812d4ca5b5d388bfe9497e6a01fb..7131e34fc6b475abd2bcf78ef95f0fbfb827aa0a 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -189,7 +189,7 @@ bool Foam::functionObjects::ensightWrite::execute() bool Foam::functionObjects::ensightWrite::write() { - if (!ensCase_.valid()) + if (!ensCase_) { ensCase_.reset ( diff --git a/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C b/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C index 4826d962369e5dbe758464ebd1721a9585d43ecb..7898063c976512cc4c39b8cefaeee00bae8075b0 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C @@ -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; diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index fb18af2daccd08c92a893bc7c04180e3bb709133..7eaeb707fe692468954e49e58c944f6a2fdd93a4 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -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(); } diff --git a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C index 3152b74e893f3caf528428d6950c96a02d7c374f..b46a3024620a6e22a97140ac8c4d880aabc0f1c5 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C @@ -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); diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index 5d14c7b9e44b84a534d1705fdf7aa553dfeb9317..4d3c735d21e5499c04a4958b29b80e5d2cfae9fe 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -145,7 +145,7 @@ Foam::displacementComponentLaplacianFvMotionSolver::curPoints() const pointDisplacement_ ); - if (pointLocation_.valid()) + if (pointLocation_) { if (debug) { diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 7b23d26379b04f95c6a039ab70ad1a7121ea5e24..f7e53f1883ef8b15a8e03658eb3273409125a274 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -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) { diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/solidBodyDisplacementLaplacian/solidBodyDisplacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/solidBodyDisplacementLaplacian/solidBodyDisplacementLaplacianFvMotionSolver.C index c85279c7e1af5fd998ec6651c4c726d457d69cef..7861c2215e4e95ea8f0682bd28b223112ca0a188 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/solidBodyDisplacementLaplacian/solidBodyDisplacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/solidBodyDisplacementLaplacian/solidBodyDisplacementLaplacianFvMotionSolver.C @@ -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) { diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C index 549499a162153104fb1a81b0ead876738ed3df5e..236616cceecf45773f9852986fef2b02ab4d71b9 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C @@ -394,7 +394,7 @@ surfaceDisplacementPointPatchVectorField const Foam::searchableSurfaces& Foam::surfaceDisplacementPointPatchVectorField::surfaces() const { - if (surfacesPtr_.empty()) + if (!surfacesPtr_) { surfacesPtr_.reset ( diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 06ae45244a3442a8f3052079f6abcf8f76a817a6..b64a78cca45d3ff3049b26480f4139b4345a4075 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -380,7 +380,7 @@ surfaceSlipDisplacementPointPatchVectorField const Foam::searchableSurfaces& Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const { - if (surfacesPtr_.empty()) + if (!surfacesPtr_) { surfacesPtr_.reset ( diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C index eecf9492538a68ed299c95a25d419ea6bef4e4e4..4b5921345ee263b418a485f6d1772fde48ee554b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -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); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C index 97944dc7ab41c13404d43ac5692a8d2f4fc02702..61c6e0a1c0c028dd456b85fada8d3050421d2cf7 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C @@ -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 ( diff --git a/src/fvOptions/interRegionOption/interRegionOptionI.H b/src/fvOptions/interRegionOption/interRegionOptionI.H index 5c6e571dbf74358c68cc2e909db7b070a468d7b4..556a8db27f9bcac4b4be5c71f7cac1190284093d 100644 --- a/src/fvOptions/interRegionOption/interRegionOptionI.H +++ b/src/fvOptions/interRegionOption/interRegionOptionI.H @@ -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" diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index 1b01f2f9951e0e681e0a6fec9a835f5febc1cec8..322a6c063607ac3a6bfd8382d70c34efa28377e7 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -501,7 +501,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain const label ) { - if (invAPtr_.empty()) + if (!invAPtr_) { invAPtr_.reset ( diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C index 761b975d5908e73a0d51b9e43baf3f8c4060ce07..78c16a65d43412a41e8c71ef7b5f38bacdd043ed 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -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; diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 41ad35a514a877e7420f117d3d2a21ef805854e9..63d0af689efa7c71084d1508ae04effd3555bce2 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -237,7 +237,7 @@ void Foam::fv::meanVelocityForce::constrain const label ) { - if (rAPtr_.empty()) + if (!rAPtr_) { rAPtr_.reset ( diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C index a623cbe1ea80e8e466d4de9477e37c06f529979b..5a050a7053ba3c7e4a981732f00eadcaeaaabc1d 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C @@ -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) { diff --git a/src/fvOptions/sources/general/codedSource/CodedSource.C b/src/fvOptions/sources/general/codedSource/CodedSource.C index 9998e8a8b7572725fd564a534847df0dc51647a2..07185784871808c937ff585aa41af2a713dbd434 100644 --- a/src/fvOptions/sources/general/codedSource/CodedSource.C +++ b/src/fvOptions/sources/general/codedSource/CodedSource.C @@ -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_); diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H index 709fe921d4c24af02ea528327a84b0218b245c50..419854da57e88de948d5022c5188ed3675ccd1d4 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H @@ -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" diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedHeatTransfer/tabulatedHeatTransfer.C b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedHeatTransfer/tabulatedHeatTransfer.C index a613e44829cdd9ab0134824f433d514f2a297b8c..69d68c1843d27075057932ef8289d8bb0845c2b1 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedHeatTransfer/tabulatedHeatTransfer.C +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedHeatTransfer/tabulatedHeatTransfer.C @@ -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 ( diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C index eccd89663c06ddc1abac6ec4a890dd0ddb6d3a00..8ae0a1940b8b81a35b98480fbad1db6247c42a78 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C @@ -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_)); } diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index ac8df2139401d11794baddc07ffad880c5f0036c..6ac60ed4dfd972298c75b52b8cff71c794c74b8e 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -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. " diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index b7d6d49e4a965e3c027f2f13fec8aa3a1273e98c..f35a0cd11fcb2806876cf8018fd893fb07d8a99c 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -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(); } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 9b2ec4d6697e8d4e7a267e53c2d95ceb2031a531..65b35bde966536d7fd651fdd67db95d89e6d2612 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -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(); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 0dedfa1e904899f8f738d285f0c2d60f7ba9ff82..e1b91f54889f116f25874c92c5e50670828dc747 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -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()); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index ef6a2595d89e86598f507f9dab22cb265bf45a49..0035a7c29a49b47e9b5a063665978b303447dede 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -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()); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelTrackingDataI.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelTrackingDataI.H index d63c4771a372b304a04f14977faca2515477d025..3879e1248d4ca29e4a799d958c1e6bb5d465721e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelTrackingDataI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelTrackingDataI.H @@ -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" diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C index 3764a682ace0a2485c11150facbd5db21c38d572..351160e30531d58f20b20728c4fbf1d2d3b4b9aa 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -447,7 +447,7 @@ void Foam::ParticleCollector<CloudType>::write() sumTotalMass += faceMassTotal[facei]; sumAverageMFR += faceMassFlowRate[facei]; - if (outputFilePtr_.valid()) + if (outputFilePtr_) { outputFilePtr_() << time.timeName() diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C index a0aaae320246083ae211c79631e6698d6a8217a6..228ee73c2cfc2f4fffacc141159851562dce4761 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C @@ -33,7 +33,7 @@ License template<class CloudType> void Foam::ParticleErosion<CloudType>::resetQ() { - if (QPtr_.valid()) + if (QPtr_) { QPtr_->primitiveFieldRef() = 0.0; } @@ -82,7 +82,7 @@ Foam::label Foam::ParticleErosion<CloudType>::applyToPatch template<class CloudType> void Foam::ParticleErosion<CloudType>::write() { - if (QPtr_.valid()) + if (QPtr_) { QPtr_->write(); } diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C index 52f75c099a71edc1f577745376ce18e84ff92105..2d34c57eb285ea16988ca966c93bd8cd5647a96c 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C @@ -36,7 +36,7 @@ License template<class CloudType> void Foam::ParticleTracks<CloudType>::write() { - if (cloudPtr_.valid()) + if (cloudPtr_) { cloudPtr_->write(); @@ -94,7 +94,7 @@ void Foam::ParticleTracks<CloudType>::preEvolve const typename parcelType::trackingData& td ) { - if (!cloudPtr_.valid()) + if (!cloudPtr_) { cloudPtr_.reset ( @@ -113,10 +113,10 @@ void Foam::ParticleTracks<CloudType>::postFace(const parcelType& p, bool&) || this->owner().solution().transient() ) { - if (!cloudPtr_.valid()) + if (!cloudPtr_) { FatalErrorInFunction - << "Cloud storage not allocated" << abort(FatalError); + << "Cloud storage not allocated" << abort(FatalError); } const label count = diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C index 6e4f0b4d2f42beab628e4c1cdb5af51d067bd341..e2f8938488bc6265022764d518c97be3ed01f870 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C @@ -81,9 +81,9 @@ void Foam::ParticleTrap<CloudType>::preEvolve alphaPtr_ = α } - if (gradAlphaPtr_.valid()) + if (gradAlphaPtr_) { - gradAlphaPtr_() == fvc::grad(*alphaPtr_); + *gradAlphaPtr_ == fvc::grad(*alphaPtr_); } else { diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C index 67028c47e69c39ac937019ee8385d2c7fc2e1bc0..0c24a4c8d2252c76bb78238127461f90826b61c5 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C @@ -33,7 +33,7 @@ License template<class CloudType> void Foam::VoidFraction<CloudType>::write() { - if (thetaPtr_.valid()) + if (thetaPtr_) { thetaPtr_->write(); } @@ -79,7 +79,7 @@ void Foam::VoidFraction<CloudType>::preEvolve const typename parcelType::trackingData& td ) { - if (thetaPtr_.valid()) + if (thetaPtr_) { thetaPtr_->primitiveFieldRef() = 0.0; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForceI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForceI.H index 235444db28fbef57ca5ca7be89da53c5132705e7..ff50aa78c39d899871fa5ac639208fc1c1cc77cf 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForceI.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForceI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +32,7 @@ template<class CloudType> inline const Foam::interpolation<Foam::vector>& Foam::LiftForce<CloudType>::curlUcInterp() const { - if (!curlUcInterpPtr_.valid()) + if (!curlUcInterpPtr_) { FatalErrorInFunction << "Carrier phase curlUc interpolation object not set" diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H index 208f7aea71b7f8db600b64afe6d9395ebe0db6f4..59eca2599242403d6650982d3a1a393d18f48068 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +32,7 @@ template<class CloudType> inline const Foam::interpolation<Foam::vector>& Foam::PressureGradientForce<CloudType>::DUcDtInterp() const { - if (!DUcDtInterpPtr_.valid()) + if (!DUcDtInterpPtr_) { FatalErrorInFunction << "Carrier phase DUcDt interpolation object not set" diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 7b8b37f2b486630e7b6617b646e24428f045ac73..5ac43c4ade43027b4c9b1308500ef16eaa4c4646 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -154,7 +154,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction template<class CloudType> Foam::volScalarField& Foam::LocalInteraction<CloudType>::massEscape() { - if (!massEscapePtr_.valid()) + if (!massEscapePtr_) { const fvMesh& mesh = this->owner().mesh(); @@ -183,7 +183,7 @@ Foam::volScalarField& Foam::LocalInteraction<CloudType>::massEscape() template<class CloudType> Foam::volScalarField& Foam::LocalInteraction<CloudType>::massStick() { - if (!massStickPtr_.valid()) + if (!massStickPtr_) { const fvMesh& mesh = this->owner().mesh(); diff --git a/src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.C b/src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.C index 2575b6730382700bc8f344bfd1656a781bca11e6..08fa1186a5db81aa32cf8a516ce65af6756c93f4 100644 --- a/src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.C +++ b/src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -181,7 +182,7 @@ Foam::projectCurveEdge::position(const scalarList& lambdas) const points.last() = endPt; } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { @@ -241,7 +242,7 @@ Foam::projectCurveEdge::position(const scalarList& lambdas) const } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { diff --git a/src/mesh/blockMesh/blockEdges/projectEdge/projectEdge.C b/src/mesh/blockMesh/blockEdges/projectEdge/projectEdge.C index 904468a72a0f472cbaca2002eaa1184f248460fb..8259bc77ed6caff66a95af540171985caf4e08ef 100644 --- a/src/mesh/blockMesh/blockEdges/projectEdge/projectEdge.C +++ b/src/mesh/blockMesh/blockEdges/projectEdge/projectEdge.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -193,7 +194,7 @@ Foam::projectEdge::position(const scalarList& lambdas) const points.last() = endPt; } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { @@ -253,7 +254,7 @@ Foam::projectEdge::position(const scalarList& lambdas) const } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { diff --git a/src/mesh/blockMesh/blockFaces/projectFace/projectFace.C b/src/mesh/blockMesh/blockFaces/projectFace/projectFace.C index 20257f28bac3099034242e5f70c78007ae77fe97..7ba567067fc2c3d5f2e3d366c4b4368ebfd133b3 100644 --- a/src/mesh/blockMesh/blockFaces/projectFace/projectFace.C +++ b/src/mesh/blockMesh/blockFaces/projectFace/projectFace.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -231,7 +231,7 @@ void Foam::blockFaces::projectFace::project if (hits[i].hit()) { const point& hitPt = hits[i].hitPoint(); - if (debugStr.valid()) + if (debugStr) { debugStr().write(linePointRef(points[i], hitPt)); } @@ -299,7 +299,7 @@ void Foam::blockFaces::projectFace::project } } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { @@ -351,7 +351,7 @@ void Foam::blockFaces::projectFace::project } } - if (debugStr.valid()) + if (debugStr) { forAll(points, i) { diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.C index 09582d62f02a69f22803370e398d856ea8f8eb79..eca9d8266175aad7887d3eb00e8dc6729ee40ce0 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +70,7 @@ Foam::displacementMeshMoverMotionSolver:: Foam::externalDisplacementMeshMover& Foam::displacementMeshMoverMotionSolver::meshMover() const { - if (!meshMoverPtr_.valid()) + if (!meshMoverPtr_) { const word moverType(coeffDict().get<word>("meshMover")); @@ -122,7 +123,7 @@ void Foam::displacementMeshMoverMotionSolver::movePoints(const pointField& p) displacementMotionSolver::movePoints(p); // Update meshMover for new geometry - if (meshMoverPtr_.valid()) + if (meshMoverPtr_) { meshMover().movePoints(p); } diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C index 86d8d81f6feea4756fcaace58d6f73e76ac8ebf9..d58a1ea9626483789feb8281863c6d15d9740144 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C @@ -1555,12 +1555,12 @@ void Foam::medialAxisMeshMover::calculateDisplacement numThicknessRatioExclude++; } - if (str.valid()) + if (str) { const point& pt = mesh().points()[pointI]; str().write(linePointRef(pt, pt+patchDisp[patchPointI])); } - if (medialVecStr.valid()) + if (medialVecStr) { const point& pt = mesh().points()[pointI]; medialVecStr().write diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 6b99d7ac6963dd96893a5f7dc12ba48fb37f840a..595801c8e001abfb77324228c11c63a22e922316 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -2926,7 +2926,7 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map) pointMap ); - if (faceMap.valid()) + if (faceMap) { // (ab)use the instance() to signal current modification time geometry[i].instance() = geometry[i].time().timeName(); diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index f6db6804bfd2bb6f3a8d96c3aa131ea567192722..d9af3f11ee63579bd73774bc7497f0e36a26fecb 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -257,7 +257,7 @@ void Foam::meshRefinement::getIntersections if (hit1[i].hit() && hit2[i].hit()) { - if (str.valid()) + if (str) { str().write(linePointRef(start[i], hit1[i].rawPoint())); str().write diff --git a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C index 8f749490364f5dacd87db0c70d28a1f305e339c2..4e5edc5ea33407c30fd3911578b15fc6f66aa323 100644 --- a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C +++ b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C @@ -416,7 +416,7 @@ void Foam::refinementFeatures::findHigherLevel const Foam::PtrList<Foam::indexedOctree<Foam::treeDataEdge>>& Foam::refinementFeatures::regionEdgeTrees() const { - if (!regionEdgeTreesPtr_.valid()) + if (!regionEdgeTreesPtr_) { regionEdgeTreesPtr_.reset ( diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 386e4d42e0c76e824b12274fdc50eb5d67bf8681..5c5a91e448778ae734edafb3654fd0e5c74833c3 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -834,7 +834,7 @@ void Foam::snappyLayerDriver::handleFeatureAngle nFeats++; - if (str.valid()) + if (str) { const point& p0 = pp.localPoints()[e[0]]; const point& p1 = pp.localPoints()[e[1]]; @@ -3341,9 +3341,9 @@ void Foam::snappyLayerDriver::addLayers // be done by snapping phase { autoPtr<mapPolyMesh> map = meshRefiner_.dupNonManifoldBoundaryPoints(); - if (map.valid()) + if (map) { - const labelList& reverseFaceMap = map().reverseFaceMap(); + const labelList& reverseFaceMap = map->reverseFaceMap(); forAll(baffles, i) { label f0 = reverseFaceMap[baffles[i].first()]; @@ -3538,7 +3538,7 @@ void Foam::snappyLayerDriver::addLayers regionSide ); - if (map.valid()) + if (map) { // Store point duplication pointToMaster.setSize(mesh.nPoints(), -1); @@ -4530,7 +4530,7 @@ void Foam::snappyLayerDriver::addLayers autoPtr<mapPolyMesh> map = meshRefiner_.mergePoints(pointToMaster); - if (map.valid()) + if (map) { inplaceReorder(map().reverseCellMap(), cellNLayers); @@ -4554,7 +4554,7 @@ void Foam::snappyLayerDriver::addLayers true, // internal zones false // baffle zones ); - if (map.valid()) + if (map) { inplaceReorder(map().reverseCellMap(), cellNLayers); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index 05d9025fd496107ae4ecdfd256f971b44507a686..dac2dee240581a15c72bda27d9033d2d9e8d987a 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -1478,7 +1478,7 @@ void Foam::snappySnapDriver::detectNearSurfaces // TBD: check if the attraction (to nearest) would attract // good enough and not override attraction - if (gapStr.valid()) + if (gapStr) { const point& intPt = hit2[pointi].hitPoint(); gapStr().write(linePointRef(pt, intPt)); @@ -1620,7 +1620,7 @@ void Foam::snappySnapDriver::detectNearSurfaces ) ) { - if (gapStr.valid()) + if (gapStr) { const point& intPt = hit2[i].hitPoint(); gapStr().write(linePointRef(pt, intPt)); @@ -2982,7 +2982,7 @@ void Foam::snappySnapDriver::doSnap false // baffle zones ); - if (mapPtr.valid()) + if (mapPtr) { if (debug & meshRefinement::MESH) { diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 9db24f0e39697bcab2911ad274f5b354d1f32d88..cbe23e027faf889d346894dc3111bb66bd9eeed3 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -1253,11 +1253,11 @@ void Foam::snappySnapDriver::featureAttractionUsingReconstruction const point& pt = pp.localPoints()[pointi]; - if (patchConstraints[pointi].first() == 2 && feStr.valid()) + if (feStr && patchConstraints[pointi].first() == 2) { feStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } - else if (patchConstraints[pointi].first() == 3 && fpStr.valid()) + else if (fpStr && patchConstraints[pointi].first() == 3) { fpStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } @@ -1518,7 +1518,7 @@ void Foam::snappySnapDriver::releasePointsNextToMultiPatch patchAttraction[pointi] = rawPatchAttraction[pointi]; patchConstraints[pointi] = rawPatchConstraints[pointi]; - //if (multiPatchStr.valid()) + //if (multiPatchStr) //{ // Pout<< "Adding constraint on multiPatchPoint:" // << pp.localPoints()[pointi] @@ -1571,7 +1571,7 @@ void Foam::snappySnapDriver::releasePointsNextToMultiPatch patchConstraints[pointi] = pointConstraint(); nChanged++; - if (multiPatchStr.valid()) + if (multiPatchStr) { multiPatchStr().write(pp.localPoints()[pointi]); } @@ -2514,7 +2514,7 @@ void Foam::snappySnapDriver::determineFeatures if (info.hit()) { // Dump - if (featureEdgeStr.valid()) + if (featureEdgeStr) { featureEdgeStr().write ( @@ -2524,7 +2524,7 @@ void Foam::snappySnapDriver::determineFeatures } else { - if (missedEdgeStr.valid()) + if (missedEdgeStr) { missedEdgeStr().write ( @@ -2580,11 +2580,7 @@ void Foam::snappySnapDriver::determineFeatures hasSnapped = true; // Debug: dump missed feature point - if - ( - missedMP0Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP0Str && !nearInfo.second().hit()) { missedMP0Str().write ( @@ -2649,11 +2645,7 @@ void Foam::snappySnapDriver::determineFeatures } // Debug: dump missed feature point - if - ( - missedMP1Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP1Str && !nearInfo.second().hit()) { missedMP1Str().write ( @@ -2693,8 +2685,8 @@ void Foam::snappySnapDriver::determineFeatures { if ( - patchConstraints[pointi].first() == 3 - && featurePointStr.valid() + featurePointStr + && patchConstraints[pointi].first() == 3 ) { featurePointStr().write @@ -2704,8 +2696,8 @@ void Foam::snappySnapDriver::determineFeatures } else if ( - patchConstraints[pointi].first() == 2 - && featureEdgeStr.valid() + featureEdgeStr + && patchConstraints[pointi].first() == 2 ) { featureEdgeStr().write @@ -2716,7 +2708,7 @@ void Foam::snappySnapDriver::determineFeatures } else { - if (missedEdgeStr.valid()) + if (missedEdgeStr) { missedEdgeStr().write ( @@ -2812,7 +2804,7 @@ void Foam::snappySnapDriver::determineFeatures } const pointIndexHit& info = nearInfo.second(); - if (info.hit() && featurePointStr.valid()) + if (featurePointStr && info.hit()) { featurePointStr().write ( @@ -2935,7 +2927,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures pointStatus[e[0]] = 0; pointStatus[e[1]] = 0; - if (baffleEdgeStr.valid()) + if (baffleEdgeStr) { const point& p0 = pp.localPoints()[e[0]]; const point& p1 = pp.localPoints()[e[1]]; @@ -3831,7 +3823,7 @@ void Foam::snappySnapDriver::preventFaceSqueeze patchAttraction[pointi] = nearestAttraction[pointi]; - if (strPtr.valid()) + if (strPtr) { strPtr().write ( diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index f01f8570da98bf03348f4edf895e0affa672234c..535be315364202d8cfd3dd253a1d49725f2b3d96 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -286,7 +286,7 @@ void Foam::AMIInterpolation::agglomerate } // Agglomerate weights and indices - if (targetMapPtr.valid()) + if (targetMapPtr) { const mapDistribute& map = targetMapPtr(); diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H index 55c518bda11da33c575539064af16001ebc4acdb..861ff876a423d322042605f759d105543823be6f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +56,7 @@ class cyclicACMIPointPatchField : public coupledPointPatchField<Type> { - // Private data + // Private Data //- Local reference cast into the cyclicACMI patch const cyclicACMIPointPatch& cyclicACMIPatch_; @@ -73,7 +74,7 @@ class cyclicACMIPointPatchField //- Owner side patch interpolation const PrimitivePatchInterpolation<primitivePatch>& ppi() const { - if (!ppiPtr_.valid()) + if (!ppiPtr_) { ppiPtr_.reset ( @@ -90,7 +91,7 @@ class cyclicACMIPointPatchField //- Neighbour side patch interpolation const PrimitivePatchInterpolation<primitivePatch>& nbrPpi() const { - if (!nbrPpiPtr_.valid()) + if (!nbrPpiPtr_) { nbrPpiPtr_.reset ( diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H index 226b421a14d9519f97e9b0bc55e00ac8ba12e8db..42830aba13edeb481ba1dbccf106c186141821ae 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +56,7 @@ class cyclicAMIPointPatchField : public coupledPointPatchField<Type> { - // Private data + // Private Data //- Local reference cast into the cyclicAMI patch const cyclicAMIPointPatch& cyclicAMIPatch_; @@ -73,7 +74,7 @@ class cyclicAMIPointPatchField //- Owner side patch interpolation const PrimitivePatchInterpolation<primitivePatch>& ppi() const { - if (!ppiPtr_.valid()) + if (!ppiPtr_) { ppiPtr_.reset ( @@ -90,7 +91,7 @@ class cyclicAMIPointPatchField //- Neighbour side patch interpolation const PrimitivePatchInterpolation<primitivePatch>& nbrPpi() const { - if (!nbrPpiPtr_.valid()) + if (!nbrPpiPtr_) { nbrPpiPtr_.reset ( diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C index d8ade6e0cc2e1538157ee023229f0c64522e44f5..bc63d3ed1e51d023f45a226164ce7f6e8f66a1fa 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C @@ -331,13 +331,13 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const label iter(0); label nTransformsOld(nTransforms_); - if (ownStr.valid()) + if (ownStr) { - writeOBJ(thisPatch0, ownStr()); + writeOBJ(thisPatch0, *ownStr); } - if (neiStr.valid()) + if (neiStr) { - writeOBJ(nbrPatch0, neiStr()); + writeOBJ(nbrPatch0, *neiStr); } @@ -392,9 +392,9 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const AMIPtr_->append(thisPatch, nbrPatch0); - if (ownStr.valid()) + if (ownStr) { - writeOBJ(thisPatch, ownStr()); + writeOBJ(thisPatch, *ownStr); } } else @@ -411,9 +411,9 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const AMIPtr_->append(thisPatch0, nbrPatch); - if (neiStr.valid()) + if (neiStr) { - writeOBJ(nbrPatch, neiStr()); + writeOBJ(nbrPatch, *neiStr); } } @@ -445,15 +445,8 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const // Close debug streams - if (ownStr.valid()) - { - ownStr.clear(); - } - if (neiStr.valid()) - { - neiStr.clear(); - } - + ownStr.reset(nullptr); + neiStr.reset(nullptr); // Average the number of transformations diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index cef6859a6f9d70181524113f896a5bb342e86f47..c2fe6eb8d94f0aa8177daff70feec27fb7ea9e6c 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -517,7 +517,7 @@ void Foam::mappedPatchBase::findSamples void Foam::mappedPatchBase::calcMapping() const { static bool hasWarned = false; - if (mapPtr_.valid()) + if (mapPtr_) { FatalErrorInFunction << "Mapping already calculated" << exit(FatalError); @@ -763,7 +763,7 @@ const { const word surfType(surfDict_.getOrDefault<word>("type", "none")); - if (!surfPtr_.valid() && surfType != "none") + if (!surfPtr_ && surfType != "none") { word surfName(surfDict_.getOrDefault("name", patch_.name())); diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H index dc507b64e6c4c5e8cb411eb7958e89a368c8aff5..f8bc08307c7d97d53b3b8423feab369bbf23bcf3 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -150,10 +151,10 @@ inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const if (topoChange) { - mapPtr_.clear(); + mapPtr_.reset(nullptr); } - if (mapPtr_.empty()) + if (!mapPtr_) { calcMapping(); } diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index 7a41644d87a50d3341ba2aa83adb71aa02e01de5..ed0017ba9fae4f3269de46b72c4c19a5fd6c47ad 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -605,7 +605,7 @@ Foam::meshSearch::~meshSearch() const Foam::treeBoundBox& Foam::meshSearch::dataBoundBox() const { - if (!overallBbPtr_.valid()) + if (!overallBbPtr_) { Random rndGen(261782); overallBbPtr_.reset @@ -628,7 +628,7 @@ const Foam::treeBoundBox& Foam::meshSearch::dataBoundBox() const const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() const { - if (!boundaryTreePtr_.valid()) + if (!boundaryTreePtr_) { // All boundary faces (not just walls) labelList bndFaces @@ -662,7 +662,7 @@ Foam::meshSearch::boundaryTree() const const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::nonCoupledBoundaryTree() const { - if (!nonCoupledBoundaryTreePtr_.valid()) + if (!nonCoupledBoundaryTreePtr_) { // All non-coupled boundary faces (not just walls) const polyBoundaryMesh& patches = mesh_.boundaryMesh(); @@ -707,7 +707,7 @@ Foam::meshSearch::nonCoupledBoundaryTree() const const Foam::indexedOctree<Foam::treeDataCell>& Foam::meshSearch::cellTree() const { - if (!cellTreePtr_.valid()) + if (!cellTreePtr_) { cellTreePtr_.reset ( diff --git a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C index a74ab1a59da806b572ff5f3848e860693e480271..8cab3a7008f2a9955e387da3b6d734488622737c 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C @@ -697,7 +697,7 @@ bool Foam::searchableSurfaces::checkIntersection << " locations." << endl; - if (setWriter.valid()) + if (setWriter) { scalarField dist(mag(intersections)); coordSet track diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index f80643164b930f9d3423f99bb69e62434e8008b7..8173fec3bbd2312e537d9eb173a340204701d5d1 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -644,7 +644,7 @@ void Foam::triSurfaceMesh::movePoints(const pointField& newPoints) const Foam::indexedOctree<Foam::treeDataEdge>& Foam::triSurfaceMesh::edgeTree() const { - if (edgeTree_.empty()) + if (!edgeTree_) { if (debug) { diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index f58dc0691f23fdfc29d3d5443ea0c0e7efdbc4b9..c281014c8b1c3a4f3f559a392b8a4db523122112 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -205,7 +205,7 @@ void Foam::triSurfaceSearch::clearOut() const Foam::indexedOctree<Foam::treeDataTriSurface>& Foam::triSurfaceSearch::tree() const { - if (treePtr_.empty()) + if (!treePtr_) { // Calculate bb without constructing local point numbering. treeBoundBox bb(Zero, Zero); diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C index 2febf7f9125ba530823dd8072d0a420c1febfab3..cfcbdb63f29e91026601e159398820e565f23c97 100644 --- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -143,7 +143,7 @@ adjointBoundaryCondition<Type>::computePatchGrad(word name) template<class Type> bool adjointBoundaryCondition<Type>::addATCUaGradUTerm() { - if (addATCUaGradUTerm_.empty()) + if (!addATCUaGradUTerm_) { addATCUaGradUTerm_.reset(new bool(isA<ATCUaGradU>(getATC()))); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C index b6895320e3e9273132bd018efa69882f68e2772b..6f8ccd0b2d9464b4d86acfd8e575e7c50b994a24 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C @@ -83,7 +83,7 @@ bool objectiveForceTarget::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 5; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C index dbc0789d24bd6a9d871fdbf1426f47bee22178e4..46eee718a721972be85930ee9ed54b1330c84882 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C @@ -130,7 +130,7 @@ autoPtr<objectiveIncompressible> objectiveIncompressible::New void objectiveIncompressible::doNormalization() { - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { const scalar oneOverNorm(1./normFactor_()); @@ -191,7 +191,7 @@ void objectiveIncompressible::doNormalization() const volVectorField& objectiveIncompressible::dJdv() { - if (dJdvPtr_.empty()) + if (!dJdvPtr_) { // If pointer is not set, set it to a zero field dJdvPtr_.reset @@ -204,13 +204,13 @@ const volVectorField& objectiveIncompressible::dJdv() ) ); } - return dJdvPtr_(); + return *dJdvPtr_; } const volScalarField& objectiveIncompressible::dJdp() { - if (dJdpPtr_.empty()) + if (!dJdpPtr_) { // If pointer is not set, set it to a zero field dJdpPtr_.reset @@ -223,13 +223,13 @@ const volScalarField& objectiveIncompressible::dJdp() ) ); } - return dJdpPtr_(); + return *dJdpPtr_; } const volScalarField& objectiveIncompressible::dJdT() { - if (dJdTPtr_.empty()) + if (!dJdTPtr_) { // If pointer is not set, set it to a zero field dJdTPtr_.reset @@ -242,13 +242,13 @@ const volScalarField& objectiveIncompressible::dJdT() ) ); } - return dJdTPtr_(); + return *dJdTPtr_; } const volScalarField& objectiveIncompressible::dJdTMvar1() { - if (dJdTMvar1Ptr_.empty()) + if (!dJdTMvar1Ptr_) { // If pointer is not set, set it to a zero field dJdTMvar1Ptr_.reset @@ -261,13 +261,13 @@ const volScalarField& objectiveIncompressible::dJdTMvar1() ) ); } - return dJdTMvar1Ptr_(); + return *dJdTMvar1Ptr_; } const volScalarField& objectiveIncompressible::dJdTMvar2() { - if (dJdTMvar2Ptr_.empty()) + if (!dJdTMvar2Ptr_) { // If pointer is not set, set it to a zero field dJdTMvar2Ptr_.reset @@ -280,7 +280,7 @@ const volScalarField& objectiveIncompressible::dJdTMvar2() ) ); } - return dJdTMvar2Ptr_(); + return *dJdTMvar2Ptr_; } @@ -289,7 +289,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdv const label patchI ) { - if (bdJdvPtr_.empty()) + if (!bdJdvPtr_) { bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -302,7 +302,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdvn const label patchI ) { - if (bdJdvnPtr_.empty()) + if (!bdJdvnPtr_) { bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -315,7 +315,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdvt const label patchI ) { - if (bdJdvtPtr_.empty()) + if (!bdJdvtPtr_) { bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -328,7 +328,7 @@ const fvPatchVectorField& objectiveIncompressible::boundarydJdp const label patchI ) { - if (bdJdpPtr_.empty()) + if (!bdJdpPtr_) { bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -341,7 +341,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdT const label patchI ) { - if (bdJdTPtr_.empty()) + if (!bdJdTPtr_) { bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -354,7 +354,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar1 const label patchI ) { - if (bdJdTMvar1Ptr_.empty()) + if (!bdJdTMvar1Ptr_) { bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -367,7 +367,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2 const label patchI ) { - if (bdJdTMvar2Ptr_.empty()) + if (!bdJdTMvar2Ptr_) { bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -377,7 +377,7 @@ const fvPatchScalarField& objectiveIncompressible::boundarydJdTMvar2 const boundaryVectorField& objectiveIncompressible::boundarydJdv() { - if (bdJdvPtr_.empty()) + if (!bdJdvPtr_) { bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -387,7 +387,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdv() const boundaryScalarField& objectiveIncompressible::boundarydJdvn() { - if (bdJdvnPtr_.empty()) + if (!bdJdvnPtr_) { bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -397,7 +397,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdvn() const boundaryVectorField& objectiveIncompressible::boundarydJdvt() { - if (bdJdvtPtr_.empty()) + if (!bdJdvtPtr_) { bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -407,7 +407,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdvt() const boundaryVectorField& objectiveIncompressible::boundarydJdp() { - if (bdJdpPtr_.empty()) + if (!bdJdpPtr_) { bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -417,7 +417,7 @@ const boundaryVectorField& objectiveIncompressible::boundarydJdp() const boundaryScalarField& objectiveIncompressible::boundarydJdT() { - if (bdJdTPtr_.empty()) + if (!bdJdTPtr_) { bdJdTPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -427,7 +427,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdT() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1() { - if (bdJdTMvar1Ptr_.empty()) + if (!bdJdTMvar1Ptr_) { bdJdTMvar1Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } @@ -437,7 +437,7 @@ const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar1() const boundaryScalarField& objectiveIncompressible::boundarydJdTMvar2() { - if (bdJdTMvar2Ptr_.empty()) + if (!bdJdTMvar2Ptr_) { bdJdTMvar2Ptr_.reset(createZeroBoundaryPtr<scalar>(mesh_)); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressibleI.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressibleI.H index 7f9b54a5eaf53fdc69ddfc4882b5baf10535b5cf..4b1bb5f442fd3038d9d9f92bf36435fee58d1202 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressibleI.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressibleI.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,73 +32,73 @@ License inline bool Foam::objectiveIncompressible::hasdJdv() const { - return dJdvPtr_.valid(); + return bool(dJdvPtr_); } inline bool Foam::objectiveIncompressible::hasdJdp() const { - return dJdpPtr_.valid(); + return bool(dJdpPtr_); } inline bool Foam::objectiveIncompressible::hasdJdT() const { - return dJdTPtr_.valid(); + return bool(dJdTPtr_); } inline bool Foam::objectiveIncompressible::hasdJdTMVar1() const { - return dJdTMvar1Ptr_.valid(); + return bool(dJdTMvar1Ptr_); } inline bool Foam::objectiveIncompressible::hasdJdTMVar2() const { - return dJdTMvar2Ptr_.valid(); + return bool(dJdTMvar2Ptr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdv() const { - return bdJdvPtr_.valid(); + return bool(bdJdvPtr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdvn() const { - return bdJdvnPtr_.valid(); + return bool(bdJdvnPtr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdvt() const { - return bdJdvtPtr_.valid(); + return bool(bdJdvtPtr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdp() const { - return bdJdpPtr_.valid(); + return bool(bdJdpPtr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdT() const { - return bdJdTPtr_.valid(); + return bool(bdJdTPtr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar1() const { - return bdJdTMvar1Ptr_.valid(); + return bool(bdJdTMvar1Ptr_); } inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar2() const { - return bdJdTMvar2Ptr_.valid(); + return bool(bdJdTMvar2Ptr_); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C index 3bd600a9e8aac9b8153e8fd097fcd2cb029b6b48..6cb85fea56a62a38a5484b84b575d862367a2d05 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C @@ -137,7 +137,7 @@ bool objectivePartialVolume::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 6; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() << setw(4) << "#" << " "; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C index 53792824458558d4c7a294179b443a7cdf7f4b1e..3bbfb1817761e1db572fdb2f89f80d9ee9bbef4a 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C @@ -242,7 +242,7 @@ bool objectivePtLosses::write(const bool valid) const // in order to avoid various instantiations of the same objective // opening the same file unsigned int width = IOstream::defaultPrecision() + 5; - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); objFunctionFilePtr_() << setw(4) << "#" << " "; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C index 5a0bf4dea6d1355e6d3cdec869be103729f2ff4f..2e3e886d8c86c1d203643776a8d7b1a7037ba479 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C @@ -256,7 +256,7 @@ scalar objective::JCycle() const J -= target_; // Normalize here, in order to get the correct value for line search - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { J /= normFactor_(); } @@ -267,7 +267,7 @@ scalar objective::JCycle() const void objective::updateNormalizationFactor() { - if (normalize_ && normFactor_.empty()) + if (normalize_ && !normFactor_) { normFactor_.reset(new scalar(JCycle())); } @@ -327,7 +327,7 @@ bool objective::normalize() const void objective::doNormalization() { - if (normalize_ && normFactor_.valid()) + if (normalize_ && normFactor_) { const scalar oneOverNorm(1./normFactor_()); @@ -414,7 +414,7 @@ void objective::incrementIntegrationTimes(const scalar timeSpan) const volScalarField& objective::dJdb() { - if (dJdbPtr_.empty()) + if (!dJdbPtr_) { // If pointer is not set, set it to a zero field dJdbPtr_.reset @@ -428,13 +428,13 @@ const volScalarField& objective::dJdb() ); } - return dJdbPtr_(); + return *dJdbPtr_; } const fvPatchVectorField& objective::boundarydJdb(const label patchI) { - if (bdJdbPtr_.empty()) + if (!bdJdbPtr_) { bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -444,7 +444,7 @@ const fvPatchVectorField& objective::boundarydJdb(const label patchI) const fvPatchVectorField& objective::dSdbMultiplier(const label patchI) { - if (bdSdbMultPtr_.empty()) + if (!bdSdbMultPtr_) { bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -454,7 +454,7 @@ const fvPatchVectorField& objective::dSdbMultiplier(const label patchI) const fvPatchVectorField& objective::dndbMultiplier(const label patchI) { - if (bdndbMultPtr_.empty()) + if (!bdndbMultPtr_) { bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -464,7 +464,7 @@ const fvPatchVectorField& objective::dndbMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbMultiplier(const label patchI) { - if (bdxdbMultPtr_.empty()) + if (!bdxdbMultPtr_) { bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -474,7 +474,7 @@ const fvPatchVectorField& objective::dxdbMultiplier(const label patchI) const fvPatchVectorField& objective::dxdbDirectMultiplier(const label patchI) { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } @@ -488,7 +488,7 @@ const vectorField& objective::boundaryEdgeMultiplier const label edgeI ) { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { FatalErrorInFunction << "Unallocated boundaryEdgeMultiplier field" @@ -500,7 +500,7 @@ const vectorField& objective::boundaryEdgeMultiplier const fvPatchTensorField& objective::boundarydJdStress(const label patchI) { - if (bdJdStressPtr_.empty()) + if (!bdJdStressPtr_) { bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_)); } @@ -510,80 +510,80 @@ const fvPatchTensorField& objective::boundarydJdStress(const label patchI) const boundaryVectorField& objective::boundarydJdb() { - if (bdJdbPtr_.empty()) + if (!bdJdbPtr_) { bdJdbPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } - return bdJdbPtr_(); + return *bdJdbPtr_; } const boundaryVectorField& objective::dSdbMultiplier() { - if (bdSdbMultPtr_.empty()) + if (!bdSdbMultPtr_) { bdSdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } - return bdSdbMultPtr_(); + return *bdSdbMultPtr_; } const boundaryVectorField& objective::dndbMultiplier() { - if (bdndbMultPtr_.empty()) + if (!bdndbMultPtr_) { bdndbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } - return bdndbMultPtr_(); + return *bdndbMultPtr_; } const boundaryVectorField& objective::dxdbMultiplier() { - if (bdxdbMultPtr_.empty()) + if (!bdxdbMultPtr_) { bdxdbMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } - return bdxdbMultPtr_(); + return *bdxdbMultPtr_; } const boundaryVectorField& objective::dxdbDirectMultiplier() { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { bdxdbDirectMultPtr_.reset(createZeroBoundaryPtr<vector>(mesh_)); } - return bdxdbDirectMultPtr_(); + return *bdxdbDirectMultPtr_; } const vectorField3& objective::boundaryEdgeMultiplier() { - if (bdxdbDirectMultPtr_.empty()) + if (!bdxdbDirectMultPtr_) { FatalErrorInFunction << "Unallocated boundaryEdgeMultiplier field" << endl << endl << exit(FatalError); } - return bEdgeContribution_(); + return *bEdgeContribution_; } const boundaryTensorField& objective::boundarydJdStress() { - if (bdJdStressPtr_.empty()) + if (!bdJdStressPtr_) { bdJdStressPtr_.reset(createZeroBoundaryPtr<tensor>(mesh_)); } - return bdJdStressPtr_(); + return *bdJdStressPtr_; } const volScalarField& objective::divDxDbMultiplier() { - if (divDxDbMultPtr_.empty()) + if (!divDxDbMultPtr_) { // If pointer is not set, set it to a zero field divDxDbMultPtr_.reset @@ -598,13 +598,13 @@ const volScalarField& objective::divDxDbMultiplier() ) ); } - return divDxDbMultPtr_(); + return *divDxDbMultPtr_; } const volTensorField& objective::gradDxDbMultiplier() { - if (gradDxDbMultPtr_.empty()) + if (!gradDxDbMultPtr_) { // If pointer is not set, set it to a zero field gradDxDbMultPtr_.reset @@ -618,7 +618,7 @@ const volTensorField& objective::gradDxDbMultiplier() ) ); } - return gradDxDbMultPtr_(); + return *gradDxDbMultPtr_; } @@ -684,7 +684,7 @@ bool objective::write(const bool valid) const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (objFunctionFilePtr_.empty()) + if (!objFunctionFilePtr_) { setObjectiveFilePtr(); } @@ -703,7 +703,7 @@ void objective::writeInstantaneousValue() const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (instantValueFilePtr_.empty()) + if (!instantValueFilePtr_) { setInstantValueFilePtr(); } @@ -717,7 +717,7 @@ void objective::writeInstantaneousSeparator() const { if (Pstream::master()) { - if (instantValueFilePtr_.valid()) + if (instantValueFilePtr_) { instantValueFilePtr_() << endl; } @@ -740,7 +740,7 @@ void objective::writeMeanValue() const // File is opened only upon invocation of the write function // in order to avoid various instantiations of the same objective // opening the same file - if (meanValueFilePtr_.empty()) + if (!meanValueFilePtr_) { setMeanValueFilePtr(); } @@ -755,7 +755,7 @@ void objective::writeMeanValue() const bool objective::writeData(Ostream& os) const { os.writeEntry("JMean", JMean_); - if (normFactor_.valid()) + if (normFactor_) { os.writeEntry("normFactor", normFactor_()); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objectiveI.H b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objectiveI.H index 315308251a27667571f045499cc12347637e8fd3..960918462734b814a387f5316d8307db53c3858d 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objectiveI.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objectiveI.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,73 +38,73 @@ inline const Foam::word& Foam::objective::objectiveName() const inline bool Foam::objective::hasdJdb() const { - return dJdbPtr_.valid(); + return bool(dJdbPtr_); } inline bool Foam::objective::hasBoundarydJdb() const { - return bdJdbPtr_.valid(); + return bool(bdJdbPtr_); } inline bool Foam::objective::hasdSdbMult() const { - return bdSdbMultPtr_.valid(); + return bool(bdSdbMultPtr_); } inline bool Foam::objective::hasdndbMult() const { - return bdndbMultPtr_.valid(); + return bool(bdndbMultPtr_); } inline bool Foam::objective::hasdxdbMult() const { - return bdxdbMultPtr_.valid(); + return bool(bdxdbMultPtr_); } inline bool Foam::objective::hasdxdbDirectMult() const { - return bdxdbDirectMultPtr_.valid(); + return bool(bdxdbDirectMultPtr_); } inline bool Foam::objective::hasBoundaryEdgeContribution() const { - return bEdgeContribution_.valid(); + return bool(bEdgeContribution_); } inline bool Foam::objective::hasDivDxDbMult() const { - return divDxDbMultPtr_.valid(); + return bool(divDxDbMultPtr_); } inline bool Foam::objective::hasGradDxDbMult() const { - return gradDxDbMultPtr_.valid(); + return bool(gradDxDbMultPtr_); } inline bool Foam::objective::hasBoundarydJdStress() const { - return bdJdStressPtr_.valid(); + return bool(bdJdStressPtr_); } inline bool Foam::objective::hasIntegrationStartTime() const { - return integrationStartTimePtr_.valid(); + return bool(integrationStartTimePtr_); } inline bool Foam::objective::hasIntegrationEndTime() const { - return integrationEndTimePtr_.valid(); + return bool(integrationEndTimePtr_); } // ************************************************************************* // diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C index 4cc2993e2aff48e28c3d24f3e3168949b35ff5f3..334f1c2685c783ec8572ad8788c0c982e6eaca61 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/FIBase/FIBaseIncompressible.C @@ -55,7 +55,7 @@ void FIBase::read() ); // Allocate distance solver if needed - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( @@ -122,7 +122,7 @@ bool FIBase::readDict(const dictionary& dict) { if (sensitivity::readDict(dict)) { - if (eikonalSolver_.valid()) + if (eikonalSolver_) { eikonalSolver_().readDict(dict); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointMeshMovementSolver/adjointMeshMovementSolverIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointMeshMovementSolver/adjointMeshMovementSolverIncompressible.C index a18a831131cea0db66e910a3c06626eb90d30448..81c49c9231a06346bacd803bdd8af8ac3d16f768 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointMeshMovementSolver/adjointMeshMovementSolverIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointMeshMovementSolver/adjointMeshMovementSolverIncompressible.C @@ -122,7 +122,7 @@ void adjointMeshMovementSolver::solve() read(); // Add source from the adjoint eikonal equation - if (adjointEikonalSolverPtr_.valid()) + if (adjointEikonalSolverPtr_) { source_ -= fvc::div(adjointEikonalSolverPtr_().getFISensitivityTerm()().T()); diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointSensitivity/adjointSensitivityIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointSensitivity/adjointSensitivityIncompressible.C index 5ed9ec2fa1e5da98c3ffaa01f9d48b46faa2515d..d88acf0693174cf6749892f6ad9900061781c79c 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointSensitivity/adjointSensitivityIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/adjointSensitivity/adjointSensitivityIncompressible.C @@ -130,7 +130,7 @@ const scalarField& adjointSensitivity::getSensitivities() const void adjointSensitivity::clearSensitivities() { derivatives_ = scalar(0); - if (fieldSensPtr_.valid()) + if (fieldSensPtr_) { fieldSensPtr_().primitiveFieldRef() = scalar(0); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C index 50786bf00faa65796e7246aa1d979f8cdffb8e9b..0f111458949a71cf63dd8900849b26ce1282e9d9 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurface/sensitivitySurfaceIncompressible.C @@ -347,7 +347,7 @@ void sensitivitySurface::read() dict().getOrDefault<bool>("writeGeometricInfo", false); // Allocate new solvers if necessary - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( @@ -361,7 +361,7 @@ void sensitivitySurface::read() ) ); } - if (includeMeshMovement_ && meshMovementSolver_.empty()) + if (includeMeshMovement_ && !meshMovementSolver_) { meshMovementSolver_.reset ( @@ -382,12 +382,12 @@ bool sensitivitySurface::readDict(const dictionary& dict) { if (sensitivity::readDict(dict)) { - if (eikonalSolver_.valid()) + if (eikonalSolver_) { eikonalSolver_().readDict(dict); } - if (meshMovementSolver_.valid()) + if (meshMovementSolver_) { meshMovementSolver_().readDict(dict); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C index 264839e515301f8491ee771d612a184204762838..ce9654cf16a0bc5b56e4caabfc12fbfc34212920 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/incompressible/sensitivitySurfacePoints/sensitivitySurfacePointsIncompressible.C @@ -75,7 +75,7 @@ void sensitivitySurfacePoints::read() dict().getOrDefault<bool>("includeObjectiveContribution", true); // Allocate new solvers if necessary - if (includeDistance_ && eikonalSolver_.empty()) + if (includeDistance_ && !eikonalSolver_) { eikonalSolver_.reset ( @@ -90,7 +90,7 @@ void sensitivitySurfacePoints::read() ); } - if (includeMeshMovement_ && meshMovementSolver_.empty()) + if (includeMeshMovement_ && !meshMovementSolver_) { meshMovementSolver_.reset ( @@ -394,12 +394,12 @@ bool sensitivitySurfacePoints::readDict(const dictionary& dict) { if (sensitivity::readDict(dict)) { - if (eikonalSolver_.valid()) + if (eikonalSolver_) { eikonalSolver_().readDict(dict); } - if (meshMovementSolver_.valid()) + if (meshMovementSolver_) { meshMovementSolver_().readDict(dict); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/sensitivity/sensitivity.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/sensitivity/sensitivity.C index b69688cdb01e0f47b69d9232337b3156b900628e..6694ed50d76ccb990c0082a29be97edb70b90994 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/sensitivity/sensitivity.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/sensitivity/sensitivity.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,9 +76,9 @@ void Foam::sensitivity::computeDerivativesSize() void Foam::sensitivity::write(const word& baseName) { - if (fieldSensPtr_.valid()) + if (fieldSensPtr_) { - fieldSensPtr_().write(); + fieldSensPtr_->write(); } } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/shapeSensitivitiesBase/shapeSensitivitiesBase.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/shapeSensitivitiesBase/shapeSensitivitiesBase.C index 4170963659f4f23824f08ef9e835441de4159891..84de7ea3d4e218d7398d808203268d07ee290a69 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/shapeSensitivitiesBase/shapeSensitivitiesBase.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/shapeSensitivitiesBase/shapeSensitivitiesBase.C @@ -43,7 +43,7 @@ namespace Foam void Foam::shapeSensitivitiesBase::writeFaceBasedSens() const { // Wall face sensitivity projected to normal - if (wallFaceSensNormalPtr_.valid()) + if (wallFaceSensNormalPtr_) { constructAndWriteSensitivityField<scalar> ( @@ -55,7 +55,7 @@ void Foam::shapeSensitivitiesBase::writeFaceBasedSens() const if (writeAllSurfaceFiles_) { // Wall face sensitivity vectors - if (wallFaceSensVecPtr_.valid()) + if (wallFaceSensVecPtr_) { constructAndWriteSensitivityField<vector> ( @@ -65,7 +65,7 @@ void Foam::shapeSensitivitiesBase::writeFaceBasedSens() const } // Normal sens as vectors - if (wallFaceSensNormalVecPtr_.valid()) + if (wallFaceSensNormalVecPtr_) { constructAndWriteSensitivityField<vector> ( @@ -80,7 +80,7 @@ void Foam::shapeSensitivitiesBase::writeFaceBasedSens() const void Foam::shapeSensitivitiesBase::writePointBasedSens() const { // Wall point sensitivity projected to normal - if (wallPointSensNormalPtr_.valid()) + if (wallPointSensNormalPtr_) { constructAndWriteSensitivtyPointField<scalar> ( @@ -95,7 +95,7 @@ void Foam::shapeSensitivitiesBase::writePointBasedSens() const if (writeAllSurfaceFiles_) { // Wall point sensitivity vectors - if (wallPointSensVecPtr_.valid()) + if (wallPointSensVecPtr_) { constructAndWriteSensitivtyPointField<vector> ( @@ -105,7 +105,7 @@ void Foam::shapeSensitivitiesBase::writePointBasedSens() const } // Normal point as vectors - if (wallPointSensNormalVecPtr_.valid()) + if (wallPointSensNormalVecPtr_) { constructAndWriteSensitivtyPointField<vector> ( @@ -175,35 +175,35 @@ void Foam::shapeSensitivitiesBase::setSensitivityPatchIDs void Foam::shapeSensitivitiesBase::clearSensitivities() { // Face-based boundary sens - if (wallFaceSensVecPtr_.valid()) + if (wallFaceSensVecPtr_) { wallFaceSensVecPtr_() = vector::zero; } - if (wallFaceSensNormalVecPtr_.valid()) + if (wallFaceSensNormalVecPtr_) { wallFaceSensNormalVecPtr_() = vector::zero; } - if (wallFaceSensNormalPtr_.valid()) + if (wallFaceSensNormalPtr_) { wallFaceSensNormalPtr_() = scalar(0); } // Point-based boundary sens - if (wallPointSensVecPtr_.valid()) + if (wallPointSensVecPtr_) { for (vectorField& patchSens : wallPointSensVecPtr_()) { patchSens = vector::zero; } } - if (wallPointSensNormalVecPtr_.valid()) + if (wallPointSensNormalVecPtr_) { for (vectorField& patchSens : wallPointSensNormalVecPtr_()) { patchSens = vector::zero; } } - if (wallPointSensNormalPtr_.valid()) + if (wallPointSensNormalPtr_) { for (scalarField& patchSens : wallPointSensNormalPtr_()) { @@ -229,7 +229,7 @@ void Foam::shapeSensitivitiesBase::setSuffix(const word& suffix) Foam::tmp<Foam::volVectorField> Foam::shapeSensitivitiesBase::getWallFaceSensVec() { - if (wallFaceSensVecPtr_.valid()) + if (wallFaceSensVecPtr_) { return constructVolSensitivtyField<vector> @@ -260,7 +260,7 @@ Foam::shapeSensitivitiesBase::getWallFaceSensVec() Foam::tmp<Foam::volScalarField> Foam::shapeSensitivitiesBase::getWallFaceSensNormal() { - if (wallFaceSensNormalPtr_.valid()) + if (wallFaceSensNormalPtr_) { return constructVolSensitivtyField<scalar> @@ -290,7 +290,7 @@ Foam::shapeSensitivitiesBase::getWallFaceSensNormal() Foam::tmp<Foam::volVectorField> Foam::shapeSensitivitiesBase::getWallFaceSensNormalVec() { - if (wallFaceSensNormalVecPtr_.valid()) + if (wallFaceSensNormalVecPtr_) { return constructVolSensitivtyField<vector> diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C index 1cce17ff3bf3347a9b9d1b682c320ce652669d9b..566165c67f6398cea599513f1be26c506a380969 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C @@ -44,7 +44,7 @@ namespace Foam Foam::scalar Foam::optMeshMovement::getMaxAllowedDisplacement() const { - if (maxAllowedDisplacement_.empty()) + if (!maxAllowedDisplacement_) { FatalErrorInFunction << "maxAllowedDisplacement requested but not set" << nl diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/steadyOptimisation/steadyOptimisation.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/steadyOptimisation/steadyOptimisation.C index 470756d7f154a596593a7c73f07c97dbffdd8709..50a2507689dfa5bfad07ff11dd1b8af5ff1fd4d0 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/steadyOptimisation/steadyOptimisation.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/steadyOptimisation/steadyOptimisation.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -225,7 +225,7 @@ void Foam::steadyOptimisation::updateDesignVariables() { // Update design variables using either a line-search scheme or // a fixed-step update - if (optType_->getLineSearch().valid()) + if (optType_->getLineSearch()) { lineSearchUpdate(); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C index 06b2de5394b8a89ab1903d7cc4d99dde9ec169ff..3a1097825a992dea7b31e688501f9a7a67fc7697 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -180,7 +180,7 @@ void optimisationType::update(scalarField& direction) // Multiply with line search step, if necessary scalarField correction(direction); - if (lineSearch_.valid()) + if (lineSearch_) { correction *= lineSearch_->step(); } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/shapeOptimisation/shapeOptimisationIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/shapeOptimisation/shapeOptimisationIncompressible.C index 6af773aca9c68d93297f98bc96caff5392998c57..3ce2914ab2ffcda5b7164aae2c3d8f165bb329f8 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/shapeOptimisation/shapeOptimisationIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/shapeOptimisation/shapeOptimisationIncompressible.C @@ -91,7 +91,7 @@ void shapeOptimisation::computeEta { // In the unlikely event that eta is not set and the line search step // is not 1, multiply with it - // if (lineSearch_.valid()) correction *= lineSearch_->step(); + // if (lineSearch_) correction *= lineSearch_->step(); // Compute eta based on desirable mesh movement size scalar eta = optMeshMovement_->computeEta(correction); diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C index 0563693e97e936910660855f9f9baf8e1fb9741a..7626776fed34873a30faf807ec2e90db5a7c45af 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C @@ -427,7 +427,7 @@ void Foam::SQP::write() constraintsSize = constraintsSize*(width + 1) + 2; // Open file and write header - if (meritFunctionFile_.empty()) + if (!meritFunctionFile_) { meritFunctionFile_.reset ( diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C index 30120c035ede98891a8ba274da12cbc4f46a8c4e..25758e30bf2debfb306c48f38195e06c7f6d84cf 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DSurface/NURBS3DSurface.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -2038,7 +2038,7 @@ scalar NURBS3DSurface::lengthDerivativeV const labelList& NURBS3DSurface::getBoundaryCPIDs() { - if(boundaryCPIDs_.empty()) + if (!boundaryCPIDs_) { const label uNCPs(uBasis_.nCPs()); const label vNCPs(vBasis_.nCPs()); @@ -2082,7 +2082,7 @@ const labelList& NURBS3DSurface::getBoundaryCPIs() const label& NURBS3DSurface::whichBoundaryCPI(const label& globalCPI) { - if(whichBoundaryCPID_.empty()) + if (!whichBoundaryCPID_) { getBoundaryCPIDs(); } diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C index 908ed1ced2768bf4bb1c2d5e39e10f3f4678a905..04da7cb95ad29c70f9285416c58a90f38d5327dd 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C @@ -63,7 +63,7 @@ Foam::label Foam::NURBS3DVolume::getCPID void Foam::NURBS3DVolume::findPointsInBox(const vectorField& meshPoints) { // It is considered an error to recompute points in the control boxes - if (mapPtr_.valid() || reverseMapPtr_.valid()) + if (mapPtr_ || reverseMapPtr_) { FatalErrorInFunction << "Attempting to recompute points residing within control boxes" @@ -121,7 +121,7 @@ void Foam::NURBS3DVolume::computeParametricCoordinates { scalar timeBef = mesh_.time().elapsedCpuTime(); - if (parametricCoordinatesPtr_.valid()) + if (parametricCoordinatesPtr_) { FatalErrorInFunction << "Attempting to recompute parametric coordinates" @@ -1657,7 +1657,7 @@ Foam::scalar Foam::NURBS3DVolume::computeMaxBoundaryDisplacement Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox() { - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1672,7 +1672,7 @@ Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox() const Foam::labelList& Foam::NURBS3DVolume::getMap() { - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1683,7 +1683,7 @@ const Foam::labelList& Foam::NURBS3DVolume::getMap() const Foam::labelList& Foam::NURBS3DVolume::getReverseMap() { - if (reverseMapPtr_.empty()) + if (!reverseMapPtr_) { findPointsInBox(localSystemCoordinates_); } @@ -1695,11 +1695,11 @@ const Foam::labelList& Foam::NURBS3DVolume::getReverseMap() const Foam::pointVectorField& Foam::NURBS3DVolume::getParametricCoordinates() { // If not computed yet, compute parametric coordinates - if (parametricCoordinatesPtr_.empty()) + if (!parametricCoordinatesPtr_) { // Find mesh points inside control points box // if they have been identified yet - if (mapPtr_.empty()) + if (!mapPtr_) { findPointsInBox(localSystemCoordinates_); } diff --git a/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C b/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C index 3fe260bb6ecbd5bf3b584bc6f534bc2521b5f9c2..81336289bcf80d4bac9d1b8a7d33e27e9f5cd58e 100644 --- a/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C +++ b/src/optimisation/adjointOptimisation/adjoint/solvers/solverControl/SIMPLEControl/optimisation/SIMPLEControlOpt.C @@ -126,7 +126,7 @@ bool Foam::SIMPLEControlOpt::loop() Time& runTime = const_cast<Time&>(mesh_.time()); // Sub-cycle time if this is the first iter - if (subCycledTimePtr_.empty()) + if (!subCycledTimePtr_) { subCycledTimePtr_.reset(new subCycleTime(runTime, nIters())); Info<< "Solving equations for solver " diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C index 6e81abaa016b654bb5a182399db8c8d330b8b5e1..9412083eb0edfa4395e9914f5066868f0f33b3b5 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C @@ -66,7 +66,7 @@ void adjointRASModel::setMeanFields() const solverControl& solControl = adjointVars_.getSolverControl(); if (solControl.average()) { - if (adjointTMVariable1Ptr_.valid()) + if (adjointTMVariable1Ptr_) { adjointTMVariable1MeanPtr_.reset ( @@ -85,7 +85,7 @@ void adjointRASModel::setMeanFields() ); } - if (adjointTMVariable2Ptr_.valid()) + if (adjointTMVariable2Ptr_) { adjointTMVariable2MeanPtr_.reset ( @@ -260,7 +260,7 @@ bool adjointRASModel::read() volScalarField& adjointRASModel::getAdjointTMVariable1Inst() { - if (adjointTMVariable1Ptr_.empty()) + if (!adjointTMVariable1Ptr_) { // if pointer is not set, set it to a zero field adjointTMVariable1Ptr_.reset @@ -287,7 +287,7 @@ volScalarField& adjointRASModel::getAdjointTMVariable1Inst() volScalarField& adjointRASModel::getAdjointTMVariable2Inst() { - if (adjointTMVariable2Ptr_.empty()) + if (!adjointTMVariable2Ptr_) { // if pointer is not set, set it to a zero field adjointTMVariable2Ptr_.reset @@ -420,12 +420,12 @@ void adjointRASModel::resetMeanFields() const solverControl& solControl = adjointVars_.getSolverControl(); if (solControl.average()) { - if (adjointTMVariable1MeanPtr_.valid()) + if (adjointTMVariable1MeanPtr_) { adjointTMVariable1MeanPtr_() == dimensionedScalar(adjointTMVariable1Ptr_().dimensions(), Zero); } - if (adjointTMVariable2MeanPtr_.valid()) + if (adjointTMVariable2MeanPtr_) { adjointTMVariable2MeanPtr_() == dimensionedScalar(adjointTMVariable2Ptr_().dimensions(), Zero); @@ -443,13 +443,13 @@ void adjointRASModel::computeMeanFields() scalar avIter(iAverageIter); scalar oneOverItP1 = 1./(avIter+1); scalar mult = avIter*oneOverItP1; - if (adjointTMVariable1MeanPtr_.valid()) + if (adjointTMVariable1MeanPtr_) { adjointTMVariable1MeanPtr_() == adjointTMVariable1Ptr_()*mult + getAdjointTMVariable1Inst()*oneOverItP1; } - if (adjointTMVariable2MeanPtr_.valid()) + if (adjointTMVariable2MeanPtr_) { adjointTMVariable2MeanPtr_() == adjointTMVariable2Ptr_()*mult diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C index b6e57519d660c6dcd29ae3fb97d4678ccfe9362c..4394e4884be2b9def1bf03c3aa8475763a2fe3d2 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -153,7 +153,7 @@ RASModelVariables::autoTmp RASModelVariables::cloneAutoTmp(const autoTmp& source) const { autoTmp returnField(nullptr); - if (source.valid() && source().valid()) + if (source && source->valid()) { const volScalarField& sf = source()(); DebugInfo diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C index a2256388322bbc98a1ec5aae09aa6f479472ff49..51775fdd4a916acd4c337d3e56fea5ec9b6990e3 100644 --- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C +++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C @@ -534,7 +534,7 @@ void Foam::cellCellStencils::cellVolumeWeight::interpolatePatchTypes // Initialise to not-mapped result = -1; - if (mapPtr.valid()) + if (mapPtr) { // Pull remote data into order of addressing labelList work(patchTypes); @@ -861,9 +861,9 @@ bool Foam::cellCellStencils::cellVolumeWeight::update() label cellI = tgtCellMap[tgtCellI]; tgtGlobalCells[tgtCellI] = globalCells.toGlobal(cellI); } - if (mapper.tgtMap().valid()) + if (mapper.tgtMap()) { - mapper.tgtMap()().distribute(tgtGlobalCells); + mapper.tgtMap()->distribute(tgtGlobalCells); } } combineCellTypes @@ -904,9 +904,9 @@ bool Foam::cellCellStencils::cellVolumeWeight::update() label cellI = srcCellMap[srcCellI]; srcGlobalCells[srcCellI] = globalCells.toGlobal(cellI); } - if (mapper.srcMap().valid()) + if (mapper.srcMap()) { - mapper.srcMap()().distribute(srcGlobalCells); + mapper.srcMap()->distribute(srcGlobalCells); } } diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.H b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.H index e4deafe1b548a99521b3c577e1378deed96f7b7d..c5499280207a330c203ae41574db708b7af9a232 100644 --- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.H +++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.H @@ -207,7 +207,7 @@ public: //- Return a communication schedule virtual const mapDistribute& cellInterpolationMap() const { - if (!cellInterpolationMap_.valid()) + if (!cellInterpolationMap_) { const_cast<cellVolumeWeight&>(*this).update(); } diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H index 92f0c85f7a70312a1c6511b2e10d081f1e2f180a..2a73249016d45045a2f3fb88895232af5e865cc9 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -304,7 +304,7 @@ public: //- Return a communication schedule virtual const mapDistribute& cellInterpolationMap() const { - if (!cellInterpolationMap_.valid()) + if (!cellInterpolationMap_) { const_cast<inverseDistance&>(*this).update(); } diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C index 30479a1f07649d508c9c9e3d8ba15e5537d0f807..89013e02d846ca6502e19ddd44c219635f8e666e 100644 --- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C +++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C @@ -551,7 +551,7 @@ const Foam::lduAddressing& Foam::dynamicOversetFvMesh::lduAddr() const //return dynamicMotionSolverFvMesh::lduAddr(); return dynamicFvMesh::lduAddr(); } - if (lduPtr_.empty()) + if (!lduPtr_) { // Build extended addressing updateAddressing(); @@ -567,7 +567,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const //return dynamicMotionSolverFvMesh::interfaces(); return dynamicFvMesh::interfaces(); } - if (lduPtr_.empty()) + if (!lduPtr_) { // Build extended addressing updateAddressing(); @@ -579,7 +579,7 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const const Foam::fvMeshPrimitiveLduAddressing& Foam::dynamicOversetFvMesh::primitiveLduAddr() const { - if (lduPtr_.empty()) + if (!lduPtr_) { FatalErrorInFunction << "Extended addressing not allocated" << abort(FatalError); diff --git a/src/parallel/decompose/decompose/decompositionModel.H b/src/parallel/decompose/decompose/decompositionModel.H index b7ebe37f6a923506c4a259014dc2d9667f6177da..99e5f6bae088fef609fdc71d02b93855d2d8d360 100644 --- a/src/parallel/decompose/decompose/decompositionModel.H +++ b/src/parallel/decompose/decompose/decompositionModel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -122,7 +122,7 @@ public: decompositionMethod& decomposer() const { - if (!decomposerPtr_.valid()) + if (!decomposerPtr_) { decomposerPtr_ = decompositionMethod::New diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 7c042cc6ad26d4ed389d4286e2bf08aa7de17bc6..3740e366153a3374f246940a37d7dc1902ffbe9f 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1601,7 +1601,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs "distributedTriSurfaceMesh::independentlyDistributedBbs" ); - if (!decomposer_.valid()) + if (!decomposer_) { // Use singleton decomposeParDict. Cannot use decompositionModel // here since we've only got Time and not a mesh. @@ -1619,7 +1619,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs } else { - if (!decomposeParDict_.valid()) + if (!decomposeParDict_) { decomposeParDict_.reset ( @@ -1637,7 +1637,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs ) ); } - decomposer_ = decompositionMethod::New(decomposeParDict_()); + decomposer_ = decompositionMethod::New(*decomposeParDict_); } } @@ -2756,7 +2756,7 @@ void Foam::distributedTriSurfaceMesh::clearOut() const Foam::globalIndex& Foam::distributedTriSurfaceMesh::globalTris() const { - if (!globalTris_.valid()) + if (!globalTris_) { globalTris_.reset(new globalIndex(triSurface::size())); } diff --git a/src/parallel/distributed/patchDistMethods/exact/exactPatchDistMethod.C b/src/parallel/distributed/patchDistMethods/exact/exactPatchDistMethod.C index 7f93d6724085e9d0f20a7d3d8086d560fbe0c200..fc68b46c080d3547591ec0dd63e3867102a6754f 100644 --- a/src/parallel/distributed/patchDistMethods/exact/exactPatchDistMethod.C +++ b/src/parallel/distributed/patchDistMethods/exact/exactPatchDistMethod.C @@ -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. @@ -46,7 +46,7 @@ namespace patchDistMethods const Foam::distributedTriSurfaceMesh& Foam::patchDistMethods::exact::patchSurface() const { - if (!patchSurfPtr_.valid()) + if (!patchSurfPtr_) { const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); diff --git a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C index 2d673c7d2307b8e9a59d81cdf43141d3f6a38ca5..92f9c06aafecf1fe32b190572faac50fa7decf9c 100644 --- a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C +++ b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C @@ -646,12 +646,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs() if ( - CHFModel_.valid() - && CHFSoobModel_.valid() - && TDNBModel_.valid() - && MHFModel_.valid() - && LeidenfrostModel_.valid() - && filmBoilingModel_.valid() + CHFModel_ + && CHFSoobModel_ + && TDNBModel_ + && MHFModel_ + && LeidenfrostModel_ + && filmBoilingModel_ ) { diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C index b2b7ba703199033578d31fbd7e4729bb9a76d95d..92175160bab4138be667a5bf158d0ff3a77947b7 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +107,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate tmp<scalarGeoField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blendedInterfacialModel::interpolate<scalarGeoField> @@ -115,7 +116,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blendedInterfacialModel::interpolate<scalarGeoField> @@ -142,7 +143,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate ) ); - if (model_.valid()) + if (model_) { if (subtract) { @@ -155,12 +156,12 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate x.ref() += (model_().*method)(args ...)*(scalar(1) - f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += (model1In2_().*method)(args ...)*f1; } - if (model2In1_.valid()) + if (model2In1_) { tmp<typeGeoField> dx = (model2In1_().*method)(args ...)*f2; @@ -177,7 +178,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -300,8 +301,8 @@ bool Foam::BlendedInterfacialModel<ModelType>::hasModel { return &phase == &(phase1_) - ? model1In2_.valid() - : model2In1_.valid(); + ? bool(model1In2_) + : bool(model2In1_); } diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/InterfaceCompositionPhaseChangePhaseSystem/InterfaceCompositionPhaseChangePhaseSystem.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/InterfaceCompositionPhaseChangePhaseSystem/InterfaceCompositionPhaseChangePhaseSystem.C index 33deb560a793a1da5fe5258adea295e513d6363a..30a7010cf526d5b2ed0396dcf7a3f4e3bdc7d2b8 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/InterfaceCompositionPhaseChangePhaseSystem/InterfaceCompositionPhaseChangePhaseSystem.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/InterfaceCompositionPhaseChangePhaseSystem/InterfaceCompositionPhaseChangePhaseSystem.C @@ -155,7 +155,7 @@ InterfaceCompositionPhaseChangePhaseSystem const phasePair& uoPair = this->phasePairs_[key]; - if (!massTransferModels_[uoPair][uoPair.index(phase)].valid()) + if (!massTransferModels_[uoPair][uoPair.index(phase)]) { FatalErrorInFunction << "A mass transfer model for the " << pair.phase1().name() diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/TwoResistanceHeatTransferPhaseSystem/TwoResistanceHeatTransferPhaseSystem.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/TwoResistanceHeatTransferPhaseSystem/TwoResistanceHeatTransferPhaseSystem.C index afaf5d73c9d430c455d876f336fb4cce36931338..d2e61843e3bcdb43b9d73cbe3b55f92c48b5fd4e 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/TwoResistanceHeatTransferPhaseSystem/TwoResistanceHeatTransferPhaseSystem.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/PhaseSystems/TwoResistanceHeatTransferPhaseSystem/TwoResistanceHeatTransferPhaseSystem.C @@ -65,14 +65,14 @@ TwoResistanceHeatTransferPhaseSystem { const phasePair& pair = this->phasePairs_[heatTransferModelIter.key()]; - if (!heatTransferModels_[pair].first().valid()) + if (!heatTransferModels_[pair].first()) { FatalErrorInFunction << "A heat transfer model for the " << pair.phase1().name() << " side of the " << pair << " pair is not specified" << exit(FatalError); } - if (!heatTransferModels_[pair].second().valid()) + if (!heatTransferModels_[pair].second()) { FatalErrorInFunction << "A heat transfer model for the " << pair.phase2().name() diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C index 93981e3f67b18be1b7614306c7b68ab185d656c8..2e896f9f62a2332e5fada28d4c59f90199db0791 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C @@ -111,7 +111,9 @@ void Foam::phaseSystem::generatePairsAndSubModels forAllConstIter(typename modelTypeTable, tempModels, iter) { - if (!iter().valid()) + const autoPtr<modelType>& modelPtr = iter.val(); + + if (!modelPtr) { continue; } diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index d92a4521725ea60801fe915138df9f7cbe0c26a6..70087f338fba38c60a33e7db50f7d92941d407d1 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -121,7 +121,7 @@ void Foam::regionModels::regionModel::initialise() << "between regions will not be possible" << endl; } - if (!outputPropertiesPtr_.valid()) + if (!outputPropertiesPtr_) { const fileName uniformPath(word("uniform")/"regionModels"); diff --git a/src/regionModels/regionModel/regionModel/regionModelI.H b/src/regionModels/regionModel/regionModel/regionModelI.H index abd9a942833a374212236ea5cc8b23632b16fd87..fc101bdbe5aeba61717542d0464cdedddb0ae296 100644 --- a/src/regionModels/regionModel/regionModel/regionModelI.H +++ b/src/regionModels/regionModel/regionModel/regionModelI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,7 +105,7 @@ Foam::regionModels::regionModel::solution() const inline const Foam::IOdictionary& Foam::regionModels::regionModel::outputProperties() const { - if (!outputPropertiesPtr_.valid()) + if (!outputPropertiesPtr_) { FatalErrorInFunction << "outputProperties dictionary not available" @@ -118,7 +119,7 @@ Foam::regionModels::regionModel::outputProperties() const inline Foam::IOdictionary& Foam::regionModels::regionModel::outputProperties() { - if (!outputPropertiesPtr_.valid()) + if (!outputPropertiesPtr_) { FatalErrorInFunction << "outputProperties dictionary not available" diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1DI.H b/src/regionModels/regionModel/regionModel1D/regionModel1DI.H index 5fdc2da4ca435e2e40b362d559ff8969b90ed025..97276ca203b7dac5a19cf2b30a008c6614f8f152 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1DI.H +++ b/src/regionModels/regionModel/regionModel1D/regionModel1DI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +54,7 @@ Foam::regionModels::regionModel1D::boundaryFaceOppositeFace() const inline const Foam::surfaceScalarField& Foam::regionModels::regionModel1D::nMagSf() const { - if (!nMagSfPtr_.valid()) + if (!nMagSfPtr_) { FatalErrorInFunction << "Face normal areas not available" << abort(FatalError); diff --git a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C index 92931324a8395f8ad95d5c489f8a50e605206345..e4afd0ddfddd7a099e57fad3499504c8fb37666a 100644 --- a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C +++ b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -208,7 +209,7 @@ Foam::regionModels::singleLayerRegion::~singleLayerRegion() const Foam::volVectorField& Foam::regionModels::singleLayerRegion::nHat() const { - if (!nHatPtr_.valid()) + if (!nHatPtr_) { FatalErrorInFunction << "Region patch normal vectors not available" @@ -221,7 +222,7 @@ const Foam::volVectorField& Foam::regionModels::singleLayerRegion::nHat() const const Foam::volScalarField& Foam::regionModels::singleLayerRegion::magSf() const { - if (!magSfPtr_.valid()) + if (!magSfPtr_) { FatalErrorInFunction << "Region patch areas not available" diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index b22753658dfdcfdc7008e9058e41197d48b2922f..b9656debb481129a0265aa37b87d8dede265072e 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -110,7 +110,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField && regionName != "none" ) { - if (extrudeMeshPtr_.empty()) + if (!extrudeMeshPtr_) { createPatchMesh(); } @@ -249,14 +249,6 @@ void thermalBaffleFvPatchScalarField::createPatchMesh() regionPatches ) ); - - if (extrudeMeshPtr_.empty()) - { - WarningInFunction - << "Specified IOobject::MUST_READ_IF_MODIFIED but class" - << " patchMeshPtr not set." - << endl; - } } diff --git a/src/sampling/sampledSet/patchSeed/patchSeedSet.C b/src/sampling/sampledSet/patchSeed/patchSeedSet.C index 65a2fdfa36922a5fad7163ae2d005500944ac36b..f2f1b965ad1a10fe4335413bb325332981e20eb0 100644 --- a/src/sampling/sampledSet/patchSeed/patchSeedSet.C +++ b/src/sampling/sampledSet/patchSeed/patchSeedSet.C @@ -81,11 +81,11 @@ void Foam::patchSeedSet::calcSamples } - if (!rndGenPtr_.valid()) + if (!rndGenPtr_) { rndGenPtr_.reset(new Random(0)); } - Random& rndGen = rndGenPtr_(); + Random& rndGen = *rndGenPtr_; if (selectedLocations_.size()) diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 8a50c1c29ff7c95e6377ff140df7eccbdebb8579..6ffb818ed4ad0ad358ebf847537925e1784dfa03 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -220,7 +220,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields) const bool interpolate = interpolationScheme_ != "cell"; // Create or use existing writer - if (fields.formatter.empty()) + if (!fields.formatter) { fields = writeFormat_; } diff --git a/src/sampling/sampledSet/shortestPath/shortestPathSet.C b/src/sampling/sampledSet/shortestPath/shortestPathSet.C index 2fcbdd0ed4c7cb08e3d688c36d28ed3a8a4f5512..cd5f1c85f7b9be46c78813bd84a55e07693d8be9 100644 --- a/src/sampling/sampledSet/shortestPath/shortestPathSet.C +++ b/src/sampling/sampledSet/shortestPath/shortestPathSet.C @@ -969,7 +969,7 @@ void Foam::shortestPathSet::genSamples markLeakPath, iter, mesh, - (isBlockedFace.valid() ? isBlockedFace() : isBoundaryFace), + (isBlockedFace ? *isBlockedFace : isBoundaryFace), insidePoint, insideCelli, outsidePoint, @@ -1023,10 +1023,7 @@ void Foam::shortestPathSet::genSamples // Normal operation: walking has closed some wall-connected faces // If previous iteration was markLeakPath-mode make sure to revert // to normal operation (i.e. face marked in isLeakFace) - if (isBlockedFace.valid()) - { - isBlockedFace.clear(); - } + isBlockedFace.reset(nullptr); markLeakPath = false; } else @@ -1048,7 +1045,7 @@ void Foam::shortestPathSet::genSamples // Revert to boundaryFaces only - if (!isBlockedFace.valid()) + if (!isBlockedFace) { //Pout<< "** Starting from original boundary faces." << endl; isBlockedFace.reset(new bitSet(isBoundaryFace)); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index a857c882db4de4b749d8066277dcf778c80ca36d..76b8d181c41b1ec474b65cf93d039e32cba0a8a3 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -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. @@ -74,7 +74,7 @@ void Foam::sampledIsoSurface::getIsoFields() const if ( - storedVolFieldPtr_.empty() + !storedVolFieldPtr_ || (fvm.time().timeName() != storedVolFieldPtr_().instance()) ) { @@ -126,7 +126,7 @@ void Foam::sampledIsoSurface::getIsoFields() const // (volPointInterpolation::interpolate with cache=false deletes any // registered one or if mesh.changing()) - if (subMeshPtr_.empty()) + if (!subMeshPtr_) { const word pointFldName = "volPointInterpolate_" @@ -316,8 +316,8 @@ bool Foam::sampledIsoSurface::updateGeometry() const // Get sub-mesh if any if ( - (-1 != mesh().cellZones().findIndex(zoneNames_)) - && subMeshPtr_.empty() + !subMeshPtr_ + && (-1 != mesh().cellZones().findIndex(zoneNames_)) ) { const polyBoundaryMesh& patches = mesh().boundaryMesh(); @@ -352,7 +352,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const // Clear derived data clearGeom(); - if (subMeshPtr_.valid()) + if (subMeshPtr_) { const volScalarField& vfld = *volSubFieldPtr_; @@ -396,9 +396,9 @@ bool Foam::sampledIsoSurface::updateGeometry() const << " average : " << Switch(average_) << nl << " isoField : " << isoField_ << nl << " isoValue : " << isoVal_ << nl; - if (subMeshPtr_.valid()) + if (subMeshPtr_) { - Pout<< " zone size : " << subMeshPtr_().subMesh().nCells() + Pout<< " zone size : " << subMeshPtr_->subMesh().nCells() << nl; } Pout<< " points : " << points().size() << nl diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C index c6d8380b05d13bada7631994e924624867f16148..a5fe5b56f09c6c9dc9154063bc889b40bddbc177 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTemplates.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTemplates.C index 16e39feaeca52a650c64392b81e8e8addab97844..022c1cdd7767530b008175ea0b01800c53d1aede 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTemplates.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTemplates.C @@ -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. @@ -64,9 +64,9 @@ Foam::sampledIsoSurface::sampleOnPoints // Assume volPointInterpolation for the point field! const auto& volFld = interpolator.psi(); - if (subMeshPtr_.valid()) + if (subMeshPtr_) { - auto tvolSubFld = subMeshPtr_().interpolate(volFld); + auto tvolSubFld = subMeshPtr_->interpolate(volFld); const auto& volSubFld = tvolSubFld(); auto tpointFld = diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C index 058cf05fcf7bce2908cbd89a164bf50d2c6b0aec..a9ce4fba0154a71848e624fe6de24e5113c7f382 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceTopo::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C index f84279514175bb7b1f7274b31f0287bde6837782..cb7080d30a8959690ab8dc3d649469cec53f8a93 100644 --- a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C @@ -366,7 +366,7 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry { DebugInFunction << endl; - if (!surfPtr_.valid()) + if (!surfPtr_) { fileName meshInstance(replaceMask(meshFileName_, timeIndex)); IFstream isBinary(baseDir_/meshInstance, IOstream::BINARY); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 6718ef56e78f6b5f0747adb8d3e9bfc568fea61f..4d846848eb315f3038291aed8d46303ca90cef5e 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,8 +118,8 @@ void Foam::sampledCuttingPlane::createGeometry() // Get sub-mesh if any if ( - (-1 != mesh().cellZones().findIndex(zoneNames_)) - && subMeshPtr_.empty() + !subMeshPtr_ + && (-1 != mesh().cellZones().findIndex(zoneNames_)) ) { const polyBoundaryMesh& patches = mesh().boundaryMesh(); @@ -164,8 +164,8 @@ void Foam::sampledCuttingPlane::createGeometry() // Select either the submesh or the underlying mesh const fvMesh& mesh = ( - subMeshPtr_.valid() - ? subMeshPtr_().subMesh() + subMeshPtr_ + ? subMeshPtr_->subMesh() : fvm ); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlaneTemplates.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlaneTemplates.C index f8bcfbed1b39cbcad0c8f7860fd8c31bd14eb614..6da65243133030b3fd403ee4e52ffa2505b91a63 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlaneTemplates.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlaneTemplates.C @@ -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. @@ -60,9 +60,9 @@ Foam::sampledCuttingPlane::sampleOnPoints // Assume volPointInterpolation for the point field! const auto& volFld = interpolator.psi(); - if (subMeshPtr_.valid()) + if (subMeshPtr_) { - auto tvolSubFld = subMeshPtr_().interpolate(volFld); + auto tvolSubFld = subMeshPtr_->interpolate(volFld); const auto& volSubFld = tvolSubFld(); auto tpointFld = diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 6211ad7d6e3738e29e796b242c9b5b355529db5b..3779ff20d3c396679e015bf4d922a478330b1aa7 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -326,7 +326,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) surfDict ); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } @@ -392,7 +392,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) autoPtr<sampledSurface> surf = input.release(inputi); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 8033f189914c53ad104b5ec2e6f2ec8e415f5ab5..12ec4e647afbe54fdd7ec34d0cfc3bf949da7762 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -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. @@ -110,7 +110,7 @@ void Foam::sampledSurfaces::performAction if (s.interpolate()) { - if (interpPtr.empty()) + if (!interpPtr) { interpPtr = interpolation<Type>::New ( @@ -123,7 +123,7 @@ void Foam::sampledSurfaces::performAction } else { - if (samplePtr.empty()) + if (!samplePtr) { samplePtr = interpolation<Type>::New ( diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C index 719286664f0cddcc9fd859917f156b1b265d2048..bdf786158006addaa5ce042e5323c81fbeddaa7d 100644 --- a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -102,8 +102,9 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const fvm ); } + const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); thresholdCellFaces surf diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C index 0e33400d026d7409f61d71a0d3d756bb58724b58..556b0c4ef736cb852ccda91103879ae602724ef0 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C @@ -79,7 +79,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::restrain vector& restraintMoment ) const { - if (anchor_.empty()) + if (!anchor_) { anchor_.reset ( diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C index e60b01a0cf3cf6c3ee0b760c4d1f610140f5d426..e6cbb4d59899bb4954b1877b1ac8bf5e992793a2 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C @@ -104,7 +104,7 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const os.endBlock(); } - if (!solver_.empty()) + if (solver_) { os << indent << "solver"; solver_->write(os); diff --git a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C index 9a19491c42f72fd17a490138557fef90adae2656..2367700035c168700e0c63acbeb9336b2d58951a 100644 --- a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C +++ b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -122,7 +123,7 @@ const Foam::basicSpecieMixture& Foam::SLGThermo::carrier() const const Foam::liquidMixtureProperties& Foam::SLGThermo::liquids() const { - if (!liquids_.valid()) + if (!liquids_) { FatalErrorInFunction << "liquids requested, but object is not allocated" @@ -135,7 +136,7 @@ const Foam::liquidMixtureProperties& Foam::SLGThermo::liquids() const const Foam::solidMixtureProperties& Foam::SLGThermo::solids() const { - if (!solids_.valid()) + if (!solids_) { FatalErrorInFunction << "solids requested, but object is not allocated" @@ -230,13 +231,13 @@ bool Foam::SLGThermo::hasMultiComponentCarrier() const bool Foam::SLGThermo::hasLiquids() const { - return liquids_.valid(); + return bool(liquids_); } bool Foam::SLGThermo::hasSolids() const { - return solids_.valid(); + return bool(solids_); } diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index 12bd0c2f69d0cacfc08dfb231e15c80e3eaea23f..6d0d6677595857c903edcade84062c1b7bd95e42 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -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. @@ -225,7 +225,7 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay else { // Demand driven load the IDefault field - if (!IDefaultPtr.valid()) + if (!IDefaultPtr) { IDefaultPtr.reset ( diff --git a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C index d526f35f211753d0b9317c52e2b402e16c7bc7f9..1bd4f4a99547ffa68660da76543e1c23b68484ed 100644 --- a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C +++ b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C @@ -237,7 +237,7 @@ void Foam::radiation::radiationModel::correct() firstIter_ = false; } - if (!soot_.empty()) + if (soot_) { soot_->correct(); } @@ -306,7 +306,7 @@ Foam::tmp<Foam::fvScalarMatrix> Foam::radiation::radiationModel::ST const Foam::radiation::absorptionEmissionModel& Foam::radiation::radiationModel::absorptionEmission() const { - if (!absorptionEmission_.valid()) + if (!absorptionEmission_) { FatalErrorInFunction << "Requested radiation absorptionEmission model, but model is " @@ -320,7 +320,7 @@ Foam::radiation::radiationModel::absorptionEmission() const const Foam::radiation::sootModel& Foam::radiation::radiationModel::soot() const { - if (!soot_.valid()) + if (!soot_) { FatalErrorInFunction << "Requested radiation sootModel model, but model is " @@ -334,7 +334,7 @@ Foam::radiation::radiationModel::soot() const const Foam::radiation::transmissivityModel& Foam::radiation::radiationModel::transmissivity() const { - if (!transmissivity_.valid()) + if (!transmissivity_) { FatalErrorInFunction << "Requested radiation sootModel model, but model is " diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 944fdb14baa779442fb99917b0dbf3d79689e978..3d2eeb2d2d8eb5b8edebc5013f35e71350351d8d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,7 +58,7 @@ void Foam::radiation::solarLoad::updateReflectedRays const labelHashSet& includePatches ) { - if (reflectedFaces_.empty() && !hitFaces_.empty()) + if (!reflectedFaces_ && hitFaces_) { reflectedFaces_.reset ( @@ -117,7 +117,7 @@ void Foam::radiation::solarLoad::updateReflectedRays bool Foam::radiation::solarLoad::updateHitFaces() { - if (hitFaces_.empty()) + if (!hitFaces_) { hitFaces_.reset(new faceShading(mesh_, solarCalc_.direction())); return true; @@ -439,7 +439,7 @@ void Foam::radiation::solarLoad::calculateQdiff ); - if (finalAgglom_.size() > 0 && coarseMesh_.empty()) + if (!coarseMesh_ && !finalAgglom_.empty()) { coarseMesh_.reset ( diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C index 5b0319f8109a795aa537682276c01463e5296b1b..3e929ae6778c456aeb6c4da6113461d4f40526f7 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,7 +130,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName); - if (!lookUpTablePtr_.empty()) + if (lookUpTablePtr_) { if (lookUpTablePtr_().found(specieName)) { diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C index d359849c58f7803f15419d78ed1fbfffc3223ee7..9444a1e9a143b53c70f156dfa614dae66d95bf1a 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -140,7 +141,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission volScalarField* fldPtr = mesh.getObjectPtr<volScalarField>(specieName); - if (!lookUpTablePtr_.empty()) + if (lookUpTablePtr_) { if (lookUpTablePtr_().found(specieName)) { diff --git a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C index be0fe78bf20fa602801edaab2ddd5828190013af..3e25ef3d8f96057aede3b4bb067e6331c987fc96 100644 --- a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C +++ b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2018 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -115,7 +115,7 @@ Foam::radiation::boundaryRadiationProperties::emissivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->e ( @@ -144,7 +144,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceEmissivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->e ( @@ -174,7 +174,7 @@ Foam::radiation::boundaryRadiationProperties::absorptivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->a ( @@ -203,7 +203,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceAbsorptivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->a ( @@ -233,7 +233,7 @@ Foam::radiation::boundaryRadiationProperties::transmissivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->t ( @@ -262,7 +262,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceTransmissivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->t ( @@ -292,7 +292,7 @@ Foam::radiation::boundaryRadiationProperties::diffReflectivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rDiff ( @@ -321,7 +321,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceDiffReflectivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rDiff ( @@ -351,7 +351,7 @@ Foam::radiation::boundaryRadiationProperties::specReflectivity scalarField* T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rSpec ( @@ -380,7 +380,7 @@ Foam::scalar Foam::radiation::boundaryRadiationProperties::faceSpecReflectivity scalar T ) const { - if (!radBoundaryPropertiesPtrList_[patchi].empty()) + if (radBoundaryPropertiesPtrList_[patchi]) { return radBoundaryPropertiesPtrList_[patchi]->rSpec ( diff --git a/src/topoChangerFvMesh/dynamicMotionSolverTopoFvMesh/dynamicMotionSolverTopoFvMesh.C b/src/topoChangerFvMesh/dynamicMotionSolverTopoFvMesh/dynamicMotionSolverTopoFvMesh.C index 85ca3760592215194e3e3fa9770ed84b291d5391..1dab5568ca3e2d60c453ca82e475cdff6ffd90d8 100644 --- a/src/topoChangerFvMesh/dynamicMotionSolverTopoFvMesh/dynamicMotionSolverTopoFvMesh.C +++ b/src/topoChangerFvMesh/dynamicMotionSolverTopoFvMesh/dynamicMotionSolverTopoFvMesh.C @@ -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. @@ -73,7 +73,7 @@ bool Foam::dynamicMotionSolverTopoFvMesh::update() // Do mesh changes (not using inflation - points added directly into mesh) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(false); - if (topoChangeMap.valid()) + if (topoChangeMap) { Info << "Executing mesh topology update" << endl; motionPtr_->updateMesh(topoChangeMap()); diff --git a/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C b/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C index 4c157ccbda9c6af5eb06f587be1a1ea8072e1502..9abc753a4e19a312a1987f60cd13184e25075754 100644 --- a/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C +++ b/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C @@ -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. @@ -304,7 +304,7 @@ void Foam::linearValveFvMesh::update() msPtr_->updateMesh(); - if (topoChangeMap.valid()) + if (topoChangeMap) { if (topoChangeMap().hasMotionPoints()) { diff --git a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C index a9c5add2ffe27da3560f1775d8d8815c9457dc30..67ff38baa8f85ba2b40f1a081cfec4a30fa19a70 100644 --- a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C +++ b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C @@ -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. @@ -365,7 +365,7 @@ void Foam::linearValveLayersFvMesh::update() setMorphTimeIndex(3*time().timeIndex() + 1); updateMesh(); - if (topoChangeMap.valid()) + if (topoChangeMap) { if (topoChangeMap().hasMotionPoints()) { diff --git a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C index 5720ebe4d18e56e39c72ebc9a13913dad6620a52..3667265d292cc1682e2fe36ccf4a481efc7ba629 100644 --- a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C +++ b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C @@ -333,7 +333,7 @@ bool Foam::mixerFvMesh::update() // Make changes. Use inflation (so put new points in topoChangeMap) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true); - if (topoChangeMap.valid()) + if (topoChangeMap) { DebugInFunction << "Mesh topology is changing" << nl; diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index 4907e89cd20a37a2809fb3fcde43cfbd3a14f02f..58014383c70670a757ab35311436ddf155ba7f8b 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -321,7 +321,7 @@ bool Foam::movingConeTopoFvMesh::update() << " curLeft:" << curLeft_ << " curRight:" << curRight_ << endl; - if (topoChangeMap.valid()) + if (topoChangeMap) { Info<< "Topology change. Calculating motion points" << endl; diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C index 6c0f7b2f4273c3bc835432193e5c4dcc0cc901ce..6a19f964e23b04dc45a2e90ea116b9973b2ee2e9 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,7 +76,7 @@ bool Foam::rawTopoChangerFvMesh::update() // Do any topology changes. Sets topoChanging (through polyTopoChange) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true); - bool hasChanged = topoChangeMap.valid(); + const bool hasChanged = bool(topoChangeMap); if (hasChanged) {