Commit 078e3474 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

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.
parent 0800e021
......@@ -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
......
......@@ -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
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -60,6 +60,7 @@ void Foam::pointPatchMapper::calcAddressing() const
if (addr[i] < 0)
{
hasUnmapped_ = true;
break;
}
}
}
......
......@@ -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]
);
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment