Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
16aaf5b5
Commit
16aaf5b5
authored
Jan 10, 2009
by
Mark Olesen
Browse files
autoPtr gets "empty()" method that can be used instead of "! ...valid()"
parent
5ba68da7
Changes
25
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/memory/Xfer/XferI.H
View file @
16aaf5b5
...
...
@@ -24,6 +24,16 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template
<
class
T
>
inline
const
Foam
::
Xfer
<
T
>&
Foam
::
Xfer
<
T
>::
null
()
{
Xfer
<
T
>*
nullPtr
=
reinterpret_cast
<
Xfer
<
T
>*>
(
0
);
return
*
nullPtr
;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
T
>
...
...
@@ -79,13 +89,6 @@ inline Foam::Xfer<T>::~Xfer()
// * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * //
template
<
class
T
>
inline
const
Foam
::
Xfer
<
T
>&
Foam
::
Xfer
<
T
>::
null
()
{
Xfer
<
T
>*
nullPtr
=
reinterpret_cast
<
Xfer
<
T
>*>
(
0
);
return
*
nullPtr
;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
...
...
src/OpenFOAM/memory/autoPtr/autoPtr.H
View file @
16aaf5b5
...
...
@@ -77,37 +77,41 @@ public:
// Member Functions
// Check
// Check
//- Is the autoPtr valid, i.e. is the
pointer set
inline
bool
valid
()
const
;
//- Return true if the autoPtr is empty (ie, no
pointer set
).
inline
bool
empty
()
const
;
//- Return true if the autoPtr valid (ie, the pointer is set).
inline
bool
valid
()
const
;
// Edit
//- Return object pointer for reuse
inline
T
*
ptr
();
// Edit
//- Set pointer to that given.
// If object pointer already set issue a FatalError.
inline
void
set
(
T
*
);
//- Return object pointer for reuse
inline
T
*
ptr
();
//- If object pointer already set delete object and
// set pointer to that given
inline
void
re
set
(
T
*
=
0
);
//- Set pointer to that given.
// If object pointer already set issue a FatalError.
inline
void
set
(
T
*
);
//- If object pointer points to valid object:
// delete object and set pointer to NULL
inline
void
clear
();
//- If object pointer already set, delete object and set to given pointer
inline
void
reset
(
T
*
=
0
);
//- Delete object and set pointer to NULL, if the pointer is valid.
inline
void
clear
();
// Member operators
//- Return reference to the object data
inline
T
&
operator
()();
//- Return const reference to the object data
inline
const
T
&
operator
()()
const
;
//inline T
ref
operator*();
//inline const T
ref
operator*() const;
//
inline T
&
operator*();
//
inline const T
&
operator*() const;
inline
operator
const
T
&
()
const
;
...
...
@@ -117,6 +121,7 @@ public:
//- Return const object pointer
inline
const
T
*
operator
->
()
const
;
//- Take over object pointer from parameter
inline
void
operator
=
(
const
autoPtr
<
T
>&
);
};
...
...
src/OpenFOAM/memory/autoPtr/autoPtrI.H
View file @
16aaf5b5
...
...
@@ -53,6 +53,13 @@ inline Foam::autoPtr<T>::~autoPtr()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
T
>
inline
bool
Foam
::
autoPtr
<
T
>::
empty
()
const
{
return
!
ptr_
;
}
template
<
class
T
>
inline
bool
Foam
::
autoPtr
<
T
>::
valid
()
const
{
...
...
src/OpenFOAM/memory/tmp/refCount.H
View file @
16aaf5b5
...
...
@@ -41,7 +41,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class refCount Declaration
Class refCount Declaration
\*---------------------------------------------------------------------------*/
class
refCount
...
...
@@ -63,6 +63,7 @@ public:
// Constructors
//- Construct null with zero count
refCount
()
:
count_
(
0
)
...
...
@@ -71,18 +72,21 @@ public:
// Member Functions
//- Return the reference count
int
count
()
const
{
return
count_
;
}
//- Return true if the reference count is zero
bool
okToDelete
()
const
{
return
(
count_
==
0
);
return
(
count_
==
0
);
}
//- Reset the reference count to zero
void
resetRefCount
()
{
count_
=
0
;
...
...
@@ -91,22 +95,25 @@ public:
// Member Operators
//- Increment the reference count
void
operator
++
()
{
count_
++
;
}
//- Increment the reference count
void
operator
++
(
int
)
{
count_
++
;
}
//- Decrement the reference count
void
operator
--
()
{
count_
--
;
}
//- Decrement the reference count
void
operator
--
(
int
)
{
count_
--
;
...
...
src/OpenFOAM/memory/tmp/tmp.H
View file @
16aaf5b5
...
...
@@ -49,7 +49,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tmp Declaration
Class tmp Declaration
\*---------------------------------------------------------------------------*/
template
<
class
T
>
...
...
@@ -91,11 +91,15 @@ public:
// Access
//-
Is th
is really a temporary object
//-
Return true if this
is really a temporary object
inline
bool
isTmp
()
const
;
//- Is this temporary object valid, i.e. is it a reference
// or a temporary that has been allocated
//- Return true if this temporary object empty,
// ie, a temporary without allocation
inline
bool
empty
()
const
;
//- Is this temporary object valid,
// ie, it is a reference or a temporary that has been allocated
inline
bool
valid
()
const
;
// Edit
...
...
src/OpenFOAM/memory/tmp/tmpI.H
View file @
16aaf5b5
...
...
@@ -96,6 +96,13 @@ inline bool Foam::tmp<T>::isTmp() const
}
template
<
class
T
>
inline
bool
Foam
::
tmp
<
T
>::
empty
()
const
{
return
(
isTmp_
&&
!
ptr_
);
}
template
<
class
T
>
inline
bool
Foam
::
tmp
<
T
>::
valid
()
const
{
...
...
@@ -132,7 +139,7 @@ inline T* Foam::tmp<T>::ptr() const
template
<
class
T
>
inline
void
Foam
::
tmp
<
T
>::
clear
()
const
{
if
(
isTmp_
&&
ptr_
)
// && ptr_->okToDelete())
if
(
isTmp_
&&
ptr_
)
//
skip this bit:
&& ptr_->okToDelete())
{
delete
ptr_
;
ptr_
=
0
;
...
...
@@ -161,8 +168,11 @@ inline T& Foam::tmp<T>::operator()()
// Note: const is cast away!
// Perhaps there should be two refs, one for const and one for non const
// and if the ref is actually const then you cannot return it here.
//
// Another possibility would be to store a const ref and a flag to say
// wether the tmp was constructed with a const or a non-const argument.
// whether the tmp was constructed with a const or a non-const argument.
//
// eg, enum refType { POINTER = 0, REF = 1, CONSTREF = 2 };
return
const_cast
<
T
&>
(
ref_
);
}
}
...
...
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C
View file @
16aaf5b5
...
...
@@ -152,7 +152,7 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule
const
Foam
::
List
<
Foam
::
labelPair
>&
Foam
::
mapDistribute
::
schedule
()
const
{
if
(
!
schedulePtr_
.
valid
())
if
(
schedulePtr_
.
empty
())
{
schedulePtr_
.
reset
(
...
...
src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
View file @
16aaf5b5
...
...
@@ -62,6 +62,7 @@ void Foam::refinementHistory::writeEntry
<<
" no subcells"
<<
endl
;
}
if
(
split
.
parent_
>=
0
)
{
Pout
<<
"parent data:"
<<
endl
;
...
...
@@ -234,7 +235,7 @@ Foam::label Foam::refinementHistory::allocateSplitCell
{
splitCell8
&
parentSplit
=
splitCells_
[
parent
];
if
(
!
parentSplit
.
addedCellsPtr_
.
valid
())
if
(
parentSplit
.
addedCellsPtr_
.
empty
())
{
// Allocate storage on parent for the 8 subcells.
parentSplit
.
addedCellsPtr_
.
reset
(
new
FixedList
<
label
,
8
>
(
-
1
));
...
...
@@ -406,7 +407,7 @@ Foam::refinementHistory::refinementHistory
)
{
readStream
(
typeName
)
>>
*
this
;
close
();
close
();
}
else
{
...
...
@@ -497,7 +498,7 @@ void Foam::refinementHistory::resize(const label size)
}
}
void
Foam
::
refinementHistory
::
updateMesh
(
const
mapPolyMesh
&
map
)
{
if
(
active
())
...
...
@@ -514,7 +515,7 @@ void Foam::refinementHistory::updateMesh(const mapPolyMesh& map)
{
label
index
=
visibleCells_
[
cellI
];
// Check
// Check
not already set
if
(
splitCells_
[
index
].
addedCellsPtr_
.
valid
())
{
FatalErrorIn
...
...
@@ -974,7 +975,7 @@ void Foam::refinementHistory::compact()
else
if
(
splitCells_
[
index
].
parent_
==
-
1
&&
!
splitCells_
[
index
].
addedCellsPtr_
.
valid
()
&&
splitCells_
[
index
].
addedCellsPtr_
.
empty
()
)
{
// recombined cell. No need to keep since no parent and no subsplits
...
...
@@ -989,7 +990,7 @@ void Foam::refinementHistory::compact()
// Now oldToNew is fully complete and compacted elements are in
// newSplitCells.
// newSplitCells.
// Renumber contents of newSplitCells and visibleCells.
forAll
(
newSplitCells
,
index
)
{
...
...
src/dynamicMesh/polyTopoChange/repatchPolyTopoChanger/repatchPolyTopoChanger.C
View file @
16aaf5b5
...
...
@@ -40,7 +40,7 @@ Description
Foam
::
polyTopoChange
&
Foam
::
repatchPolyTopoChanger
::
meshMod
()
{
if
(
!
meshModPtr_
.
valid
())
if
(
meshModPtr_
.
empty
())
{
meshModPtr_
.
reset
(
new
polyTopoChange
(
mesh_
));
}
...
...
src/edgeMesh/edgeMesh.C
View file @
16aaf5b5
...
...
@@ -30,12 +30,9 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void
edgeMesh
::
calcPointEdges
()
const
void
Foam
::
edgeMesh
::
calcPointEdges
()
const
{
if
(
pointEdgesPtr_
.
valid
())
{
...
...
@@ -81,7 +78,7 @@ void edgeMesh::calcPointEdges() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// construct from components
edgeMesh
::
edgeMesh
(
const
pointField
&
points
,
const
edgeList
&
edges
)
Foam
::
edgeMesh
::
edgeMesh
(
const
pointField
&
points
,
const
edgeList
&
edges
)
:
points_
(
points
),
edges_
(
edges
)
...
...
@@ -89,7 +86,7 @@ edgeMesh::edgeMesh(const pointField& points, const edgeList& edges)
// construct as copy
edgeMesh
::
edgeMesh
(
const
edgeMesh
&
em
)
Foam
::
edgeMesh
::
edgeMesh
(
const
edgeMesh
&
em
)
:
points_
(
em
.
points_
),
edges_
(
em
.
edges_
),
...
...
@@ -99,7 +96,7 @@ edgeMesh::edgeMesh(const edgeMesh& em)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
label
edgeMesh
::
regions
(
labelList
&
edgeRegion
)
const
Foam
::
label
Foam
::
edgeMesh
::
regions
(
labelList
&
edgeRegion
)
const
{
edgeRegion
.
setSize
(
edges_
.
size
());
edgeRegion
=
-
1
;
...
...
@@ -165,7 +162,7 @@ label edgeMesh::regions(labelList& edgeRegion) const
}
void
edgeMesh
::
mergePoints
(
const
scalar
mergeDist
)
void
Foam
::
edgeMesh
::
mergePoints
(
const
scalar
mergeDist
)
{
pointField
newPoints
;
labelList
pointMap
;
...
...
@@ -245,7 +242,7 @@ void edgeMesh::mergePoints(const scalar mergeDist)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void
edgeMesh
::
operator
=
(
const
edgeMesh
&
rhs
)
void
Foam
::
edgeMesh
::
operator
=
(
const
edgeMesh
&
rhs
)
{
points_
=
rhs
.
points_
;
edges_
=
rhs
.
edges_
;
...
...
@@ -253,8 +250,4 @@ void edgeMesh::operator=(const edgeMesh& rhs)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
src/edgeMesh/edgeMeshI.H
View file @
16aaf5b5
...
...
@@ -24,10 +24,6 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...
...
@@ -40,21 +36,21 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline
const
pointField
&
edgeMesh
::
points
()
const
inline
const
Foam
::
pointField
&
Foam
::
edgeMesh
::
points
()
const
{
return
points_
;
}
inline
const
edgeList
&
edgeMesh
::
edges
()
const
inline
const
Foam
::
edgeList
&
Foam
::
edgeMesh
::
edges
()
const
{
return
edges_
;
}
inline
const
labelListList
&
edgeMesh
::
pointEdges
()
const
inline
const
Foam
::
labelListList
&
Foam
::
edgeMesh
::
pointEdges
()
const
{
if
(
!
pointEdgesPtr_
.
valid
())
if
(
pointEdgesPtr_
.
empty
())
{
calcPointEdges
();
}
...
...
@@ -73,6 +69,4 @@ inline const labelListList& edgeMesh::pointEdges() const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
src/edgeMesh/edgeMeshIO.C
View file @
16aaf5b5
...
...
@@ -27,15 +27,11 @@ License
#include
"edgeMesh.H"
#include
"IFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// construct from file
edgeMesh
::
edgeMesh
(
const
fileName
&
fname
)
Foam
::
edgeMesh
::
edgeMesh
(
const
fileName
&
fname
)
:
points_
(
0
),
edges_
(
0
),
...
...
@@ -57,7 +53,7 @@ edgeMesh::edgeMesh(const fileName& fname)
// construct from Istream
edgeMesh
::
edgeMesh
(
Istream
&
is
)
Foam
::
edgeMesh
::
edgeMesh
(
Istream
&
is
)
:
points_
(
is
),
edges_
(
is
),
...
...
@@ -70,7 +66,7 @@ edgeMesh::edgeMesh(Istream& is)
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Ostream
&
operator
<<
(
Ostream
&
os
,
const
edgeMesh
&
em
)
Foam
::
Ostream
&
Foam
::
operator
<<
(
Ostream
&
os
,
const
edgeMesh
&
em
)
{
os
<<
em
.
points_
<<
nl
<<
em
.
edges_
<<
endl
;
...
...
@@ -81,7 +77,7 @@ Ostream& operator<<(Ostream& os, const edgeMesh& em)
}
Istream
&
operator
>>
(
Istream
&
is
,
edgeMesh
&
em
)
Foam
::
Istream
&
Foam
::
operator
>>
(
Istream
&
is
,
edgeMesh
&
em
)
{
is
>>
em
.
points_
>>
em
.
edges_
;
...
...
@@ -92,8 +88,4 @@ Istream& operator>>(Istream& is, edgeMesh& em)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C
View file @
16aaf5b5
...
...
@@ -48,7 +48,7 @@ namespace Foam
bool
Foam
::
fvMeshSubset
::
checkCellSubset
()
const
{
if
(
!
fvMeshSubsetPtr_
.
valid
())
if
(
fvMeshSubsetPtr_
.
empty
())
{
FatalErrorIn
(
"bool fvMeshSubset::checkCellSubset() const"
)
<<
"Mesh subset not set. Please set the cell map using "
...
...
@@ -161,11 +161,11 @@ void Foam::fvMeshSubset::doCoupledPatches
nCellsUsingFace
[
pp
.
start
()
+
i
]
=
3
;
nUncoupled
++
;
}
}
}
}
}
}
// Do same for cyclics.
forAll
(
oldPatches
,
oldPatchI
)
{
...
...
src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
View file @
16aaf5b5
...
...
@@ -136,10 +136,10 @@ surfaceSlipDisplacementPointPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const
searchableSurfaces
&
surfaceSlipDisplacementPointPatchVectorField
::
surfaces
()
const
const
searchableSurfaces
&
surfaceSlipDisplacementPointPatchVectorField
::
surfaces
()
const
{
if
(
!
surfacesPtr_
.
valid
())
if
(
surfacesPtr_
.
empty
())
{
surfacesPtr_
.
reset
(
...
...
src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H
View file @
16aaf5b5
...
...
@@ -292,7 +292,7 @@ public:
//- Access to communication.
const
List
<
labelPair
>&
schedule
()
const
{
if
(
!
schedulePtr_
.
valid
())
if
(
schedulePtr_
.
empty
())
{
calcMapping
();
}
...
...
@@ -307,7 +307,7 @@ public:
Pout
<<
"Asking for sendLabels."
<<
endl
;
}
if
(
!
sendLabelsPtr_
.
valid
())
if
(
sendLabelsPtr_
.
empty
())
{
if
(
debug
)
{
...
...
@@ -326,7 +326,7 @@ public:
Pout
<<
"Asking for receiveFaceLabels."
<<
endl
;
}
if
(
!
receiveFaceLabelsPtr_
.
valid
())
if
(
receiveFaceLabelsPtr_
.
empty
())
{
if
(
debug
)
{
...
...
src/meshTools/searchableSurface/distributedTriSurfaceMesh.C
View file @
16aaf5b5
...
...
@@ -1260,7 +1260,7 @@ void Foam::distributedTriSurfaceMesh::clearOut()
const
Foam
::
globalIndex
&
Foam
::
distributedTriSurfaceMesh
::
globalTris
()
const
{
if
(
!
globalTris_
.
valid
())
if
(
globalTris_
.
empty
())
{
globalTris_
.
reset
(
new
globalIndex
(
triSurface
::
size
()));
}
...
...
src/meshTools/searchableSurface/triSurfaceMesh.C
View file @
16aaf5b5
...
...
@@ -229,7 +229,7 @@ void Foam::triSurfaceMesh::movePoints(const pointField& newPoints)
const
Foam
::
indexedOctree
<
Foam
::
treeDataTriSurface
>&
Foam
::
triSurfaceMesh
::
tree
()
const
{
if
(
!
tree_
.
valid
())
if
(
tree_
.
empty
())
{
treeBoundBox
bb
(
points
(),
meshPoints
());
...
...
@@ -256,7 +256,7 @@ const Foam::indexedOctree<Foam::treeDataTriSurface>&
const
Foam
::
indexedOctree
<
Foam
::
treeDataEdge
>&
Foam
::
triSurfaceMesh
::
edgeTree
()
const
{
if
(
!
edgeTree_
.
valid
())
if
(
edgeTree_
.
empty
())
{
treeBoundBox
bb
(
localPoints
());
...
...
src/postProcessing/functionObjects/forces/forces/forces.C
View file @
16aaf5b5
...
...
@@ -220,7 +220,7 @@ void Foam::forces::read(const dictionary& dict)
void
Foam
::
forces
::
makeFile
()
{
// Create the forces file if not already created
if
(
!
forcesFilePtr_
.
valid
())
if
(
forcesFilePtr_
.
empty
())
{
if
(
debug
)
{
...
...
src/postProcessing/functionObjects/minMaxFields/minMaxFields.C
View file @
16aaf5b5
...
...
@@ -93,7 +93,7 @@ void Foam::minMaxFields::read(const dictionary& dict)
void
Foam
::
minMaxFields
::
makeFile
()
{
// Create the minMaxFields file if not already created
if
(
!
minMaxFieldsFilePtr_
.
valid
())
if
(
minMaxFieldsFilePtr_
.
empty
())
{
if
(
debug
)
{
...
...
src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C
View file @
16aaf5b5
...
...
@@ -227,7 +227,7 @@ void Foam::sampledSets::sampleAndWrite
bool
interpolate
=
interpolationScheme_
!=
"cell"
;
// Create or use existing writer
if
(
!
fields
.
formatter
.
valid
())
if
(
fields
.
formatter
.
empty
())
{
fields
.
formatter
=
writer
<
Type
>::
New
(
writeFormat_
);
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment