Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
OpenFOAM-plus
Commits
0d71fdf7
Commit
0d71fdf7
authored
Jan 26, 2018
by
Mark Olesen
Browse files
ENH: avoid xfer on simple data types
- in many places can use move construcors or rely on RVO
parent
14f0cf32
Changes
18
Hide whitespace changes
Inline
Side-by-side
applications/test/fileName/Test-fileName.C
View file @
0d71fdf7
...
...
@@ -194,6 +194,7 @@ int main(int argc, char *argv[])
argList
::
addBoolOption
(
"ext"
,
"test handing of file extensions"
);
argList
::
addBoolOption
(
"construct"
,
"test constructors"
);
argList
::
addBoolOption
(
"relative"
,
"test relative operations"
);
argList
::
addBoolOption
(
"system"
,
"test filesystem operations"
);
argList
::
addBoolOption
(
"default"
,
"reinstate default tests"
);
argList
::
addNote
(
"runs default tests or specified ones only"
);
...
...
@@ -485,72 +486,8 @@ int main(int argc, char *argv[])
}
if
(
!
defaultTests
)
{
return
0
;
}
DynamicList
<
word
>
wrdList
{
"hello"
,
"hello1"
,
"hello2"
,
"hello3"
,
"hello4.hmm"
};
fileName
pathName
(
wrdList
);
Info
<<
"pathName = "
<<
pathName
<<
nl
<<
"pathName.name() = >"
<<
pathName
.
name
()
<<
"<
\n
"
<<
"pathName.path() = "
<<
pathName
.
path
()
<<
nl
<<
"pathName.ext() = >"
<<
pathName
.
ext
()
<<
"<
\n
"
<<
"pathName.name(true) = >"
<<
pathName
.
name
(
true
)
<<
"<
\n
"
;
Info
<<
"pathName.components() = "
<<
pathName
.
components
()
<<
nl
<<
"pathName.component(2) = "
<<
pathName
.
component
(
2
)
<<
nl
<<
endl
;
// try with different combination
// The final one should emit warnings
for
(
label
start
=
0
;
start
<=
wrdList
.
size
();
++
start
)
{
fileName
instance
,
local
;
word
name
;
fileName
path
(
SubList
<
word
>
(
wrdList
,
wrdList
.
size
()
-
start
,
start
));
fileName
path2
=
"."
/
path
;
IOobject
::
fileNameComponents
(
path
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
IOobject
::
fileNameComponents
(
path2
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path2
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
}
// Test some copying and deletion
if
(
args
.
found
(
"system"
))
{
const
fileName
dirA
(
"dirA"
);
const
fileName
lnA
(
"lnA"
);
...
...
@@ -663,6 +600,71 @@ int main(int argc, char *argv[])
}
if
(
!
defaultTests
)
{
return
0
;
}
DynamicList
<
word
>
wrdList
{
"hello"
,
"hello1"
,
"hello2"
,
"hello3"
,
"hello4.hmm"
};
fileName
pathName
(
wrdList
);
Info
<<
"pathName = "
<<
pathName
<<
nl
<<
"pathName.name() = >"
<<
pathName
.
name
()
<<
"<
\n
"
<<
"pathName.path() = "
<<
pathName
.
path
()
<<
nl
<<
"pathName.ext() = >"
<<
pathName
.
ext
()
<<
"<
\n
"
<<
"pathName.name(true) = >"
<<
pathName
.
name
(
true
)
<<
"<
\n
"
;
Info
<<
"pathName.components() = "
<<
pathName
.
components
()
<<
nl
<<
"pathName.component(2) = "
<<
pathName
.
component
(
2
)
<<
nl
<<
endl
;
// try with different combination
// The final one should emit warnings
for
(
label
start
=
0
;
start
<=
wrdList
.
size
();
++
start
)
{
fileName
instance
,
local
;
word
name
;
fileName
path
(
SubList
<
word
>
(
wrdList
,
wrdList
.
size
()
-
start
,
start
));
fileName
path2
=
"."
/
path
;
IOobject
::
fileNameComponents
(
path
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
IOobject
::
fileNameComponents
(
path2
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path2
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
}
// test findEtcFile
Info
<<
"
\n\n
findEtcFile tests:"
<<
nl
<<
" controlDict => "
<<
findEtcFile
(
"controlDict"
)
<<
nl
...
...
applications/test/fileNameClean/Test-fileNameClean.C
View file @
0d71fdf7
...
...
@@ -46,6 +46,9 @@ void printCleaning(fileName& pathName)
<<
" name() = "
<<
pathName
.
name
()
<<
nl
<<
" joined = "
<<
pathName
.
path
()
/
pathName
.
name
()
<<
nl
<<
nl
;
Info
<<
"components = "
<<
flatOutput
(
pathName
.
components
())
<<
nl
;
Info
<<
"component 2 = "
<<
pathName
.
component
(
2
)
<<
nl
;
pathName
.
clean
();
Info
<<
"cleaned = "
<<
pathName
<<
nl
...
...
src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
View file @
0d71fdf7
...
...
@@ -1458,7 +1458,7 @@ Foam::instantList Foam::fileOperations::masterUncollatedFileOperation::findTimes
}
Pstream
::
scatter
(
times
);
instantList
*
tPtr
=
new
instantList
(
times
.
xfer
(
));
instantList
*
tPtr
=
new
instantList
(
std
::
move
(
times
));
times_
.
insert
(
directory
,
tPtr
);
...
...
src/OpenFOAM/meshes/meshShapes/cell/cell.H
View file @
0d71fdf7
...
...
@@ -69,11 +69,11 @@ public:
//- Construct given size, with invalid point labels (-1)
explicit
inline
cell
(
const
label
sz
);
//- Construct from list of labels
//- Co
py co
nstruct from list of labels
explicit
inline
cell
(
const
labelUList
&
lst
);
//-
C
onstruct
by transferring
list of labels
explicit
inline
cell
(
const
Xfer
<
labelList
>
&
lst
);
//-
Move c
onstruct
from
list of labels
explicit
inline
cell
(
labelList
&
&
lst
);
//- Construct from Istream
inline
cell
(
Istream
&
is
);
...
...
src/OpenFOAM/meshes/meshShapes/cell/cellI.H
View file @
0d71fdf7
...
...
@@ -41,9 +41,9 @@ inline Foam::cell::cell(const labelUList& lst)
{}
inline
Foam
::
cell
::
cell
(
const
Xfer
<
labelList
>
&
lst
)
inline
Foam
::
cell
::
cell
(
labelList
&
&
lst
)
:
labelList
(
lst
)
labelList
(
std
::
move
(
lst
)
)
{}
...
...
src/OpenFOAM/meshes/meshShapes/face/face.C
View file @
0d71fdf7
...
...
@@ -606,23 +606,26 @@ Foam::face Foam::face::reverseFace() const
// Reverse the label list and return
// The starting points of the original and reverse face are identical.
const
labelList
&
f
=
*
this
;
labelList
newList
(
size
()
)
;
const
label
U
List
&
origFace
=
*
this
;
const
label
len
=
origFace
.
size
();
newList
[
0
]
=
f
[
0
];
for
(
label
pointi
=
1
;
pointi
<
newList
.
size
();
pointi
++
)
face
newFace
(
len
);
if
(
len
)
{
newList
[
pointi
]
=
f
[
size
()
-
pointi
];
newFace
[
0
]
=
origFace
[
0
];
for
(
label
i
=
1
;
i
<
len
;
++
i
)
{
newFace
[
i
]
=
origFace
[
len
-
i
];
}
}
return
face
(
xferMove
(
newList
))
;
return
newFace
;
}
Foam
::
label
Foam
::
face
::
which
(
const
label
globalIndex
)
const
{
const
labelList
&
f
=
*
this
;
const
label
U
List
&
f
=
*
this
;
forAll
(
f
,
localIdx
)
{
...
...
src/OpenFOAM/meshes/meshShapes/face/face.H
View file @
0d71fdf7
...
...
@@ -150,20 +150,17 @@ public:
//- Construct given size, with invalid point labels (-1)
explicit
inline
face
(
const
label
sz
);
//- Construct from list of labels
//- Co
py co
nstruct from list of labels
explicit
inline
face
(
const
labelUList
&
lst
);
//- Construct from list of labels
//- Co
py co
nstruct from list of labels
template
<
unsigned
Size
>
explicit
inline
face
(
const
FixedList
<
label
,
Size
>&
lst
);
//- Construct from an initializer list of labels
//- Co
py co
nstruct from an initializer list of labels
explicit
inline
face
(
std
::
initializer_list
<
label
>
lst
);
//- Transfer (move) construct
explicit
inline
face
(
const
Xfer
<
labelList
>&
lst
);
//- Move construct
//- Move construct from list of labels
explicit
inline
face
(
labelList
&&
lst
);
//- Copy construct from triFace
...
...
src/OpenFOAM/meshes/meshShapes/face/faceI.H
View file @
0d71fdf7
...
...
@@ -70,12 +70,6 @@ inline Foam::face::face(std::initializer_list<label> lst)
{}
inline
Foam
::
face
::
face
(
const
Xfer
<
labelList
>&
lst
)
:
labelList
(
lst
)
{}
inline
Foam
::
face
::
face
(
labelList
&&
lst
)
:
labelList
(
std
::
move
(
lst
))
...
...
src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C
View file @
0d71fdf7
...
...
@@ -94,12 +94,6 @@ Foam::globalIndex::globalIndex(const label localSize)
}
Foam
::
globalIndex
::
globalIndex
(
const
labelList
&
offsets
)
:
offsets_
(
offsets
)
{}
Foam
::
globalIndex
::
globalIndex
(
Istream
&
is
)
{
is
>>
offsets_
;
...
...
src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H
View file @
0d71fdf7
...
...
@@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
inline
globalIndex
();
globalIndex
()
=
default
;
//- Construct from local max size. Does communication with default
// communicator and message tag.
...
...
@@ -90,11 +90,11 @@ public:
const
bool
parallel
// use parallel comms
);
//- Construct from
component
s
globalIndex
(
const
labelList
&
offsets
);
//- Co
py co
nstruct from
list of label
s
inline
globalIndex
(
const
label
U
List
&
offsets
);
//-
C
onstruct from
component
s
inline
globalIndex
(
const
Xfer
<
labelList
>
&
offsets
);
//-
Move c
onstruct from
list of label
s
inline
globalIndex
(
labelList
&
&
offsets
);
//- Construct from Istream
globalIndex
(
Istream
&
is
);
...
...
src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H
View file @
0d71fdf7
...
...
@@ -27,13 +27,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
globalIndex
::
globalIndex
()
inline
Foam
::
globalIndex
::
globalIndex
(
const
labelUList
&
offsets
)
:
offsets_
(
offsets
)
{}
Foam
::
globalIndex
::
globalIndex
(
const
Xfer
<
labelList
>
&
offsets
)
inline
Foam
::
globalIndex
::
globalIndex
(
labelList
&
&
offsets
)
:
offsets_
(
offsets
)
offsets_
(
std
::
move
(
offsets
)
)
{}
...
...
src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
View file @
0d71fdf7
...
...
@@ -1545,9 +1545,8 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
}
boundaryCellsPtr_
.
reset
(
new
labelList
());
boundaryCellsPtr_
.
reset
(
new
labelList
(
std
::
move
(
cellMap
)
));
labelList
&
boundaryCells
=
boundaryCellsPtr_
();
boundaryCells
.
transfer
(
cellMap
.
shrink
());
// Convert point-cells to global (boundary)cell numbers
...
...
src/OpenFOAM/primitives/strings/fileName/fileName.C
View file @
0d71fdf7
...
...
@@ -29,6 +29,7 @@ License
#include "OSspecific.H"
#include "wordRe.H"
#include "fileOperation.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -463,28 +464,20 @@ bool Foam::fileName::hasExt(const wordRe& ending) const
Foam
::
wordList
Foam
::
fileName
::
components
(
const
char
delimiter
)
const
{
DynamicList
<
word
>
wrdList
(
20
);
const
auto
parsed
=
stringOps
::
split
<
string
>
(
*
this
,
delimiter
);
size_type
beg
=
0
,
end
=
0
;
wordList
words
(
parsed
.
size
())
;
while
((
end
=
find
(
delimiter
,
beg
))
!=
npos
)
label
i
=
0
;
for
(
const
auto
&
sub
:
parsed
)
{
// Avoid empty element (caused by doubled slashes)
if
(
beg
<
end
)
{
wrdList
.
append
(
substr
(
beg
,
end
-
beg
));
}
beg
=
end
+
1
;
}
// Avoid empty trailing element
if
(
beg
<
size
())
{
wrdList
.
append
(
substr
(
beg
));
// Could easily filter out '.' here too
words
[
i
]
=
sub
.
str
();
++
i
;
}
//
Transfer to
wordList
return
word
List
(
wrdList
.
xfer
())
;
//
As a plain
wordList
return
word
s
;
}
...
...
@@ -494,7 +487,14 @@ Foam::word Foam::fileName::component
const
char
delimiter
)
const
{
return
components
(
delimiter
)[
cmpt
];
const
auto
parsed
=
stringOps
::
split
<
string
>
(
*
this
,
delimiter
);
if
(
cmpt
<
parsed
.
size
())
{
return
parsed
[
cmpt
].
str
();
}
return
word
();
}
...
...
src/conversion/polyDualMesh/polyDualMesh.C
View file @
0d71fdf7
...
...
@@ -545,8 +545,6 @@ void Foam::polyDualMesh::splitFace
if
(
subFace
.
size
()
>
2
)
{
// Enough vertices to create a face from.
subFace
.
shrink
();
dualFaces
.
append
(
face
(
subFace
));
dualOwner
.
append
(
meshPointi
);
dualNeighbour
.
append
(
-
1
);
...
...
@@ -559,8 +557,6 @@ void Foam::polyDualMesh::splitFace
if
(
subFace
.
size
()
>
2
)
{
// Enough vertices to create a face from.
subFace
.
shrink
();
dualFaces
.
append
(
face
(
subFace
));
dualOwner
.
append
(
meshPointi
);
dualNeighbour
.
append
(
-
1
);
...
...
@@ -1194,18 +1190,10 @@ void Foam::polyDualMesh::calcDual
// Transfer face info to straight lists
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
faceList
dualFaces
(
dynDualFaces
.
shrink
(),
true
);
dynDualFaces
.
clear
();
labelList
dualOwner
(
dynDualOwner
.
shrink
(),
true
);
dynDualOwner
.
clear
();
labelList
dualNeighbour
(
dynDualNeighbour
.
shrink
(),
true
);
dynDualNeighbour
.
clear
();
labelList
dualRegion
(
dynDualRegion
.
shrink
(),
true
);
dynDualRegion
.
clear
();
faceList
dualFaces
(
std
::
move
(
dynDualFaces
));
labelList
dualOwner
(
std
::
move
(
dynDualOwner
));
labelList
dualNeighbour
(
std
::
move
(
dynDualNeighbour
));
labelList
dualRegion
(
std
::
move
(
dynDualRegion
));
// Dump faces.
...
...
src/lagrangian/molecularDynamics/potential/potential/potential.C
View file @
0d71fdf7
...
...
@@ -89,7 +89,7 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
}
}
siteIdList_
.
transfer
(
pairPotentialSiteIdList
.
shrink
()
);
siteIdList_
.
transfer
(
pairPotentialSiteIdList
);
}
...
...
src/meshTools/regionSplit/regionSplit.C
View file @
0d71fdf7
...
...
@@ -172,7 +172,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
{
offsets
[
i
]
=
mesh
().
nFaces
();
}
const
globalIndex
globalRegions
(
offsets
.
xfer
(
));
const
globalIndex
globalRegions
(
std
::
move
(
offsets
));
// Minimise regions across connected cells
// Note: still uses global decisions so all processors are running
...
...
@@ -215,7 +215,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
compactOffsets
[
i
]
=
globalToCompact
.
size
();
}
return
autoPtr
<
globalIndex
>
(
new
globalIndex
(
compactOffsets
.
xfer
(
)));
return
autoPtr
<
globalIndex
>
(
new
globalIndex
(
std
::
move
(
compactOffsets
)));
}
...
...
src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C
View file @
0d71fdf7
...
...
@@ -285,7 +285,7 @@ Foam::searchableSurfaceCollection::~searchableSurfaceCollection()
const
Foam
::
wordList
&
Foam
::
searchableSurfaceCollection
::
regions
()
const
{
if
(
regions_
.
size
()
==
0
)
if
(
regions_
.
empty
()
)
{
regionOffset_
.
setSize
(
subGeom_
.
size
());
...
...
@@ -309,7 +309,7 @@ const Foam::wordList& Foam::searchableSurfaceCollection::regions() const
}
}
}
regions_
.
transfer
(
allRegions
.
shrink
()
);
regions_
.
transfer
(
allRegions
);
}
return
regions_
;
}
...
...
src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C
View file @
0d71fdf7
...
...
@@ -298,8 +298,8 @@ Foam::distributedTriSurfaceMesh::distributeSegments
sendMap
[
proci
].
transfer
(
dynSendMap
[
proci
]);
}
allSegments
.
transfer
(
dynAllSegments
.
shrink
()
);
allSegmentMap
.
transfer
(
dynAllSegmentMap
.
shrink
()
);
allSegments
.
transfer
(
dynAllSegments
);
allSegmentMap
.
transfer
(
dynAllSegmentMap
);
}
...
...
@@ -743,9 +743,9 @@ Foam::distributedTriSurfaceMesh::calcLocalQueries
sendMap
[
proci
].
transfer
(
dynSendMap
[
proci
]);
}
allCentres
.
transfer
(
dynAllCentres
.
shrink
()
);
allRadiusSqr
.
transfer
(
dynAllRadiusSqr
.
shrink
()
);
allSegmentMap
.
transfer
(
dynAllSegmentMap
.
shrink
()
);
allCentres
.
transfer
(
dynAllCentres
);
allRadiusSqr
.
transfer
(
dynAllRadiusSqr
);
allSegmentMap
.
transfer
(
dynAllSegmentMap
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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