ENH: code adjustments for updated NullObject

- can now safely use labelList::null() instead of emptyLabelList for
  return values. No special treatment required for lists.

  Possible replacements:

      if (notNull(list) && list.size())  ->  if (list.size())
      if (isNull(list) || list.empty())  ->  if (list.empty())

  The receiver may still wish to handle differently to distinguish
  between a null list and an empty list, but no additional special
  protection is required when obtaining sizes, traversing, outputting
  etc.
This commit is contained in:
Mark Olesen
2019-02-07 13:04:24 +01:00
committed by Andrew Heather
parent 0800e021ad
commit 078e34746e
30 changed files with 84 additions and 117 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015 OpenFOAM Foundation
@ -66,22 +66,12 @@ public:
:
directAddressing_(directAddressing),
distMap_(distMap),
hasUnmapped_(false)
{
if
(
notNull(directAddressing_)
&& directAddressing_.size()
&& min(directAddressing_) < 0
)
{
hasUnmapped_ = true;
}
}
hasUnmapped_(directAddressing_.size() && min(directAddressing_) < 0)
{}
//- Destructor
virtual ~distributedUnallocatedDirectFieldMapper()
{}
virtual ~distributedUnallocatedDirectFieldMapper() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015 OpenFOAM Foundation
@ -68,22 +68,12 @@ public:
:
directAddressing_(directAddressing),
distMap_(distMap),
hasUnmapped_(false)
{
if
(
notNull(directAddressing_)
&& directAddressing_.size()
&& min(directAddressing_) < 0
)
{
hasUnmapped_ = true;
}
}
hasUnmapped_(directAddressing_.size() && min(directAddressing_) < 0)
{}
//- Destructor
virtual ~distributedUnallocatedDirectFvPatchFieldMapper()
{}
virtual ~distributedUnallocatedDirectFvPatchFieldMapper() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -2400,7 +2400,7 @@ const Foam::labelList& Foam::dynamicIndexedOctree<Type>::findIndices
return *(contents_[getContent(contentIndex)]);
}
return Foam::emptyLabelList;
return labelList::null();
}

View File

@ -2662,7 +2662,7 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
{
if (nodes_.empty())
{
return Foam::emptyLabelList;
return labelList::null();
}
labelBits index = findNode(0, sample);
@ -2677,7 +2677,7 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
return contents_[getContent(contentIndex)];
}
return Foam::emptyLabelList;
return labelList::null();
}

View File

@ -76,6 +76,7 @@ typedef List<char> charList;
typedef List<label> labelList;
//- A zero-sized list of labels
// \deprecated(2019-02) use labelList::null() instead
extern const labelList emptyLabelList;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2018 OpenFOAM Foundation
@ -59,17 +59,12 @@ public:
directFieldMapper(const labelUList& directAddressing)
:
directAddressing_(directAddressing),
hasUnmapped_(false)
{
if (directAddressing_.size() && min(directAddressing_) < 0)
{
hasUnmapped_ = true;
}
}
hasUnmapped_(directAddressing_.size() && min(directAddressing_) < 0)
{}
//- Destructor
virtual ~directFieldMapper()
{}
virtual ~directFieldMapper() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013 OpenFOAM Foundation
@ -65,17 +65,12 @@ public:
directPointPatchFieldMapper(const labelUList& directAddressing)
:
directAddressing_(directAddressing),
hasUnmapped_(false)
{
if (directAddressing_.size() && min(directAddressing_) < 0)
{
hasUnmapped_ = true;
}
}
hasUnmapped_(directAddressing_.size() && min(directAddressing_) < 0)
{}
//- Destructor
virtual ~directPointPatchFieldMapper()
{}
virtual ~directPointPatchFieldMapper() = default;
// Member Functions

View File

@ -60,6 +60,7 @@ void Foam::pointPatchMapper::calcAddressing() const
if (addr[i] < 0)
{
hasUnmapped_ = true;
break;
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -56,7 +56,7 @@ void Foam::globalMeshData::syncData
const labelList& transformSlavePoints =
(
transformedSlaves.empty()
? Foam::emptyLabelList
? labelList::null()
: transformedSlaves[i]
);
@ -119,7 +119,7 @@ void Foam::globalMeshData::syncData
const labelList& transformSlavePoints =
(
transformedSlaves.empty()
? Foam::emptyLabelList
? labelList::null()
: transformedSlaves[i]
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013 OpenFOAM Foundation
@ -65,17 +65,12 @@ public:
directFvPatchFieldMapper(const labelUList& directAddressing)
:
directAddressing_(directAddressing),
hasUnmapped_(false)
{
if (directAddressing_.size() && min(directAddressing_) < 0)
{
hasUnmapped_ = true;
}
}
hasUnmapped_(directAddressing_.size() && min(directAddressing_) < 0)
{}
//- Destructor
virtual ~directFvPatchFieldMapper()
{}
virtual ~directFvPatchFieldMapper() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -113,9 +113,9 @@ public:
weights_(weights),
hasUnmapped_(false)
{
forAll(addressing_, i)
for (const labelList& addr : addressing)
{
if (addressing_[i].empty())
if (addr.empty())
{
hasUnmapped_ = true;
break;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015-2016 OpenFOAM Foundation
@ -79,11 +79,12 @@ public:
weights_(weights),
hasUnmapped_(false)
{
forAll(addressing_, i)
for (const labelList& addr : addressing)
{
if (addressing_[i].size() == 0)
if (addr.empty())
{
hasUnmapped_ = true;
break;
}
}
@ -99,8 +100,7 @@ public:
}
//- Destructor
virtual ~distributedWeightedFvPatchFieldMapper()
{}
virtual ~distributedWeightedFvPatchFieldMapper() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -155,10 +155,10 @@ public:
return surface().surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area vectors

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -217,10 +217,10 @@ public:
return surface().surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -186,10 +186,10 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2018 OpenFOAM Foundation
@ -181,10 +181,10 @@ public:
return *this;
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -216,10 +216,10 @@ public:
return surface().surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -166,11 +166,11 @@ public:
return cuttingSurface::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
// Could instead return meshCells or cellZoneId of the meshCells.
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -108,10 +108,10 @@ public:
return Mesh::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -193,8 +193,8 @@ bool Foam::sampledPatch::update()
// remap action on triangulation
void Foam::sampledPatch::remapFaces(const labelUList& faceMap)
{
// recalculate the cells cut
if (notNull(faceMap) && faceMap.size())
// Recalculate the cells cut
if (!faceMap.empty())
{
MeshStorage::remapFaces(faceMap);
patchFaceLabels_ = labelList

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -216,10 +216,10 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area vectors

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -192,11 +192,11 @@ public:
return cuttingPlane::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
// Could instead return meshCells or cellZoneId of the meshCells.
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area magnitudes

View File

@ -297,7 +297,7 @@ public:
//- when hasFaceIds is true.
virtual const labelList& originalIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}

View File

@ -265,7 +265,7 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return zoneIds_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -181,10 +181,10 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
return labelList::null();
}
//- Face area vectors (normals)

View File

@ -157,7 +157,7 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return MeshStorage::zoneIds();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,7 @@ void Foam::cuttingSurfaceBase::performCut
void Foam::cuttingSurfaceBase::remapFaces(const labelUList& faceMap)
{
if (notNull(faceMap) && !faceMap.empty())
if (!faceMap.empty())
{
MeshStorage::remapFaces(faceMap);

View File

@ -270,7 +270,7 @@ public:
bool update(const treeBoundBox&);
//- Const access to per-face zone/region information
//- Per-face zone/region information
virtual const labelList& zoneIds() const
{
return zoneIds_;

View File

@ -466,7 +466,7 @@ void Foam::MeshedSurface<Face>::remapFaces
const labelUList& faceMap
)
{
if (isNull(faceMap) || faceMap.empty())
if (faceMap.empty())
{
return;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -386,7 +386,7 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
)
{
// Re-assign the zone Ids
if (isNull(faceMap) || faceMap.empty())
if (faceMap.empty())
{
return;
}