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
Commits
8d589417
Commit
8d589417
authored
Jan 07, 2019
by
Mark Olesen
Committed by
Andrew Heather
Jan 07, 2019
Browse files
ENH: for-range, forAllIters() ... in conversion/
- reduced clutter when iterating over containers
parent
e3e0d7c8
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/conversion/common/reader/meshReader.C
View file @
8d589417
...
...
@@ -52,7 +52,7 @@ void Foam::meshReader::addFaceZones(polyMesh& mesh) const
}
nZone
=
0
;
forAllConstIter
(
HashTable
<
labelList
>
,
monitoringSets_
,
iter
)
forAllConstIter
s
(
monitoringSets_
,
iter
)
{
Info
<<
"faceZone "
<<
nZone
<<
" (size: "
<<
iter
().
size
()
<<
") name: "
...
...
src/conversion/common/reader/meshReaderAux.C
View file @
8d589417
...
...
@@ -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-2017 OpenFOAM Foundation
...
...
@@ -41,26 +41,26 @@ void Foam::meshReader::warnDuplicates
HashTable
<
label
>
hashed
(
list
.
size
());
bool
duplicates
=
false
;
for
All
(
list
,
list
I
)
for
(
const
word
&
w
:
list
)
{
//
c
heck duplicate name
HashTable
<
label
>::
iter
ato
r
iter
=
hashed
.
find
(
list
[
listI
]
);
if
(
iter
!=
hashed
.
e
nd
())
//
C
heck duplicate name
a
u
to
iter
=
hashed
.
find
(
w
);
if
(
iter
.
fou
nd
())
{
(
*
iter
)
++
;
++
(
*
iter
);
duplicates
=
true
;
}
else
{
hashed
.
insert
(
list
[
listI
]
,
1
);
hashed
.
insert
(
w
,
1
);
}
}
//
w
arn about duplicate names
//
W
arn about duplicate names
if
(
duplicates
)
{
Info
<<
nl
<<
"WARNING: "
<<
context
<<
" with identical names:"
;
forAllConstIter
(
HashTable
<
label
>
,
hashed
,
iter
)
forAllConstIter
s
(
hashed
,
iter
)
{
if
(
*
iter
>
1
)
{
...
...
src/conversion/common/tables/boundaryRegion.C
View file @
8d589417
...
...
@@ -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 OpenFOAM Foundation
...
...
@@ -55,7 +55,7 @@ Foam::boundaryRegion::boundaryRegion
Foam
::
label
Foam
::
boundaryRegion
::
append
(
const
dictionary
&
dict
)
{
label
maxId
=
-
1
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
if
(
maxId
<
iter
.
key
())
{
...
...
@@ -72,7 +72,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::names() const
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
lookup
.
insert
(
...
...
@@ -96,7 +96,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::names
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
const
word
lookupName
=
iter
().
lookupOrDefault
<
word
>
(
...
...
@@ -118,7 +118,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::boundaryTypes() const
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
lookup
.
insert
(
...
...
@@ -138,7 +138,7 @@ Foam::label Foam::boundaryRegion::findIndex(const word& name) const
return
-
1
;
}
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
if
(
iter
().
lookupOrDefault
<
word
>
(
"Label"
,
word
::
null
)
==
name
)
{
...
...
@@ -258,18 +258,18 @@ void Foam::boundaryRegion::rename(const dictionary& mapDict)
// This avoid re-matching any renamed regions
Map
<
word
>
mapping
;
for
AllConstIter
(
dictionary
,
mapDict
,
iter
)
for
(
const
entry
&
dEntry
:
mapDict
)
{
word
oldName
(
iter
()
.
stream
());
const
word
oldName
(
dEntry
.
stream
());
label
id
=
this
->
findIndex
(
oldName
);
const
label
id
=
this
->
findIndex
(
oldName
);
if
(
id
>=
0
)
{
mapping
.
insert
(
id
,
iter
()
.
keyword
());
mapping
.
insert
(
id
,
dEntry
.
keyword
());
}
}
forAllConstIter
(
Map
<
word
>
,
mapping
,
iter
)
forAllConstIter
s
(
mapping
,
iter
)
{
dictionary
&
dict
=
operator
[](
iter
.
key
());
...
...
src/conversion/common/tables/cellTable.C
View file @
8d589417
...
...
@@ -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
...
...
@@ -40,10 +40,10 @@ Foam::Map<Foam::label> Foam::cellTable::zoneMap() const
{
Map
<
label
>
lookup
;
label
zone
I
=
0
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
label
zone
i
=
0
;
forAllConstIter
s
(
*
this
,
iter
)
{
lookup
.
insert
(
iter
.
key
(),
zone
I
++
);
lookup
.
insert
(
iter
.
key
(),
zone
i
++
);
}
return
lookup
;
...
...
@@ -53,21 +53,21 @@ Foam::Map<Foam::label> Foam::cellTable::zoneMap() const
Foam
::
wordList
Foam
::
cellTable
::
namesList
()
const
{
Map
<
word
>
lookup
=
names
();
wordList
lst
(
lookup
.
size
());
wordList
l
i
st
(
lookup
.
size
());
label
zone
I
=
0
;
forAllConstIter
(
Map
<
word
>
,
lookup
,
iter
)
label
zone
i
=
0
;
forAllConstIter
s
(
lookup
,
iter
)
{
lst
[
zone
I
++
]
=
iter
()
;
l
i
st
[
zone
i
++
]
=
*
iter
;
}
return
lst
;
return
l
i
st
;
}
void
Foam
::
cellTable
::
addDefaults
()
{
forAllIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllIter
s
(
*
this
,
iter
)
{
if
(
!
iter
().
found
(
"MaterialType"
))
{
...
...
@@ -88,7 +88,7 @@ void Foam::cellTable::setEntry
dict
.
add
(
keyWord
,
value
);
iterator
iter
=
find
(
id
);
if
(
iter
!=
e
nd
())
if
(
iter
.
fou
nd
())
{
iter
().
merge
(
dict
);
}
...
...
@@ -125,7 +125,7 @@ Foam::cellTable::cellTable
Foam
::
label
Foam
::
cellTable
::
append
(
const
dictionary
&
dict
)
{
label
maxId
=
-
1
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
if
(
maxId
<
iter
.
key
())
{
...
...
@@ -142,7 +142,7 @@ Foam::Map<Foam::word> Foam::cellTable::names() const
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
lookup
.
insert
(
...
...
@@ -166,7 +166,7 @@ Foam::Map<Foam::word> Foam::cellTable::names
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
const
word
lookupName
=
iter
().
lookupOrDefault
<
word
>
(
...
...
@@ -188,8 +188,8 @@ Foam::word Foam::cellTable::name(const label id) const
{
word
theName
(
"cellTable_"
+
Foam
::
name
(
id
));
const_iterator
iter
=
find
(
id
);
if
(
iter
!=
e
nd
())
const_iterator
iter
=
c
find
(
id
);
if
(
iter
.
fou
nd
())
{
iter
().
readIfPresent
(
"Label"
,
theName
);
}
...
...
@@ -205,7 +205,7 @@ Foam::label Foam::cellTable::findIndex(const word& name) const
return
-
1
;
}
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
if
(
iter
().
lookupOrDefault
<
word
>
(
"Label"
,
word
::
null
)
==
name
)
{
...
...
@@ -221,7 +221,7 @@ Foam::Map<Foam::word> Foam::cellTable::materialTypes() const
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
lookup
.
insert
(
...
...
@@ -238,7 +238,7 @@ Foam::Map<Foam::word> Foam::cellTable::selectType(const word& matl) const
{
Map
<
word
>
lookup
;
forAllConstIter
(
Map
<
dictionary
>
,
*
this
,
iter
)
forAllConstIter
s
(
*
this
,
iter
)
{
const
label
index
=
iter
.
key
();
const
dictionary
&
dict
=
iter
.
val
();
...
...
@@ -300,7 +300,7 @@ void Foam::cellTable::setName(const label id)
{
iterator
iter
=
find
(
id
);
if
(
iter
==
e
nd
()
||
!
iter
().
found
(
"Label"
))
if
(
!
iter
.
fou
nd
()
||
!
iter
().
found
(
"Label"
))
{
setName
(
id
,
"cellTable_"
+
Foam
::
name
(
id
));
}
...
...
@@ -446,10 +446,10 @@ void Foam::cellTable::addCellZones
forAll
(
tableIds
,
celli
)
{
Map
<
label
>::
const_itera
to
r
iter
=
typeToZone
.
find
(
tableIds
[
celli
]);
if
(
iter
!=
typeToZone
.
e
nd
())
const
au
to
iter
=
typeToZone
.
c
find
(
tableIds
[
celli
]);
if
(
iter
.
fou
nd
())
{
zoneCells
[
iter
()
].
append
(
celli
);
zoneCells
[
*
iter
].
append
(
celli
);
}
}
...
...
@@ -513,13 +513,13 @@ void Foam::cellTable::combine(const dictionary& mapDict, labelList& tableIds)
labelList
mapping
(
identity
(
max
(
origNames
.
toc
())
+
1
));
bool
remap
=
false
;
forAllConstIter
(
dictionary
,
mapDict
,
iter
)
forAllConstIter
s
(
mapDict
,
iter
)
{
wordRes
patterns
(
iter
().
stream
());
// find all matches
Map
<
word
>
matches
;
forAllConstIter
(
Map
<
word
>
,
origNames
,
namesIter
)
forAllConstIter
s
(
origNames
,
namesIter
)
{
if
(
patterns
.
match
(
namesIter
()))
{
...
...
@@ -554,7 +554,7 @@ void Foam::cellTable::combine(const dictionary& mapDict, labelList& tableIds)
this
->
erase
(
matches
);
origNames
.
erase
(
matches
);
forAllConstIter
(
Map
<
word
>
,
matches
,
matchIter
)
forAllConstIter
s
(
matches
,
matchIter
)
{
mapping
[
matchIter
.
key
()]
=
targetId
;
Info
<<
" "
<<
matchIter
();
...
...
src/fileFormats/sampledSetWriters/csv/csvSetWriter.C
View file @
8d589417
...
...
@@ -140,7 +140,7 @@ namespace Foam
forAll
(
valueSetNames
,
i
)
{
if
(
i
>
0
)
if
(
i
)
{
writeSeparator
(
os
);
}
...
...
@@ -166,7 +166,7 @@ void Foam::csvSetWriter<Type>::writeHeader
{
for
(
label
j
=
0
;
j
<
Type
::
nComponents
;
j
++
)
{
if
(
i
>
0
||
j
>
0
)
if
(
i
||
j
)
{
writeSeparator
(
os
);
}
...
...
@@ -189,12 +189,7 @@ void Foam::csvSetWriter<Type>::writeCoordHeader
if
(
points
.
hasVectorAxis
())
{
for
(
word
::
const_iterator
iter
=
axisName
.
begin
();
iter
!=
axisName
.
end
();
++
iter
)
for
(
auto
iter
=
axisName
.
cbegin
();
iter
!=
axisName
.
cend
();
++
iter
)
{
os
<<
*
iter
;
writeSeparator
(
os
);
...
...
src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C
View file @
8d589417
...
...
@@ -85,7 +85,7 @@ void Foam::gnuplotSetWriter<Type>::write
forAll
(
valueSets
,
i
)
{
if
(
i
!=
0
)
if
(
i
)
{
os
<<
','
;
}
...
...
src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C
View file @
8d589417
...
...
@@ -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
...
...
@@ -159,15 +159,12 @@ void Foam::nastranSetWriter<Type>::write
// }
label
globalPti
=
0
;
for
All
(
tracks
,
track
i
)
for
(
const
coordSet
&
points
:
track
s
)
{
const
coordSet
&
points
=
tracks
[
tracki
];
forAll
(
points
,
pointi
)
for
(
const
point
&
pt
:
points
)
{
fileFormats
::
NASCore
::
writeKeyword
(
os
,
"GRID"
,
fieldFormat
::
FREE
);
const
point
&
pt
=
points
[
pointi
];
//os.setf(std::ios_base::right);
//os << setw(8) << globalPti++
// << setw(8) << ' '
...
...
@@ -190,10 +187,8 @@ void Foam::nastranSetWriter<Type>::write
// Write ids of track points to file
label
globalEdgei
=
0
;
label
globalPointi
=
0
;
for
All
(
tracks
,
track
i
)
for
(
const
coordSet
&
points
:
track
s
)
{
const
coordSet
&
points
=
tracks
[
tracki
];
const
label
nEdges
=
points
.
size
()
-
1
;
for
(
label
edgei
=
0
;
edgei
<
nEdges
;
++
edgei
)
{
...
...
src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C
View file @
8d589417
...
...
@@ -95,7 +95,7 @@ void Foam::vtkSetWriter<Type>::write
forAll
(
fld
,
pointi
)
{
if
(
pointi
!=
0
)
if
(
pointi
)
{
os
<<
' '
;
}
...
...
@@ -137,9 +137,8 @@ void Foam::vtkSetWriter<Type>::write
<<
"DATASET POLYDATA"
<<
nl
<<
"POINTS "
<<
nPoints
<<
" double"
<<
nl
;
for
All
(
tracks
,
track
I
)
for
(
const
coordSet
&
points
:
track
s
)
{
const
coordSet
&
points
=
tracks
[
trackI
];
for
(
const
point
&
pt
:
points
)
{
os
<<
float
(
pt
.
x
())
<<
' '
...
...
@@ -158,11 +157,13 @@ void Foam::vtkSetWriter<Type>::write
{
const
coordSet
&
points
=
tracks
[
trackI
];
os
<<
points
.
size
();
forAll
(
points
,
i
)
const
label
len
=
points
.
size
();
os
<<
len
;
for
(
label
i
=
0
;
i
<
len
;
++
i
)
{
os
<<
' '
<<
globalPtI
;
globalPtI
++
;
++
globalPtI
;
}
os
<<
nl
;
}
...
...
@@ -179,13 +180,11 @@ void Foam::vtkSetWriter<Type>::write
const
List
<
Field
<
Type
>>&
fieldVals
=
valueSets
[
setI
];
for
All
(
fieldVals
,
i
)
for
(
const
Field
<
Type
>&
vals
:
fieldVals
)
{
const
Field
<
Type
>&
vals
=
fieldVals
[
i
];
forAll
(
vals
,
j
)
{
if
(
j
!=
0
)
if
(
j
)
{
os
<<
' '
;
}
...
...
src/fileFormats/vtk/part/foamVtuSizingTemplates.C
View file @
8d589417
...
...
@@ -622,14 +622,14 @@ void Foam::vtk::vtuSizing::populateArrays
if
(
sizing
.
nFaceLabels
())
{
// End face offsets, leaving -1 untouched
l
abel
prev
=
0
;
for
All
(
faceOffset
,
i
)
L
abel
Type
prev
=
0
;
for
(
LabelType
&
off
:
faceOffset
)
{
const
label
sz
=
faceOffset
[
i
]
;
const
auto
sz
=
off
;
if
(
sz
>
0
)
{
prev
+=
sz
;
faceOffset
[
i
]
=
prev
;
off
=
prev
;
}
}
}
...
...
@@ -639,10 +639,10 @@ void Foam::vtk::vtuSizing::populateArrays
{
// Has prefix, determine begin offsets
label
beg
=
0
;
for
All
(
vertOffset
,
i
)
for
(
LabelType
&
off
:
vertOffset
)
{
const
label
sz
=
vertOffset
[
i
]
;
vertOffset
[
i
]
=
beg
;
const
auto
sz
=
off
;
off
=
beg
;
beg
+=
1
+
sz
;
}
...
...
@@ -650,12 +650,12 @@ void Foam::vtk::vtuSizing::populateArrays
if
(
sizing
.
nFaceLabels
())
{
beg
=
0
;
for
All
(
faceOffset
,
i
)
for
(
LabelType
&
off
:
faceOffset
)
{
const
label
sz
=
faceOffset
[
i
]
;
const
auto
sz
=
off
;
if
(
sz
>
0
)
{
faceOffset
[
i
]
=
beg
;
off
=
beg
;
beg
+=
sz
;
}
}
...
...
src/fileFormats/vtk/read/vtkUnstructuredReader.C
View file @
8d589417
...
...
@@ -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) 2012-2016 OpenFOAM Foundation
...
...
@@ -186,9 +186,9 @@ void Foam::vtkUnstructuredReader::extractCells
lineMap_
[
lineI
]
=
i
;
labelList
&
segment
=
lines_
[
lineI
++
];
segment
.
setSize
(
nRead
);
for
All
(
segment
,
i
)
for
(
label
&
pointi
:
segment
)
{
segment
[
i
]
=
cellVertData
[
dataIndex
++
];
pointi
=
cellVertData
[
dataIndex
++
];
}
}
break
;
...
...
@@ -236,9 +236,9 @@ void Foam::vtkUnstructuredReader::extractCells
face
&
f
=
faces_
[
facei
++
];
label
nRead
=
cellVertData
[
dataIndex
++
];
f
.
setSize
(
nRead
);
for
All
(
f
,
fp
)
for
(
label
&
pointi
:
f
)
{
f
[
fp
]
=
cellVertData
[
dataIndex
++
];
pointi
=
cellVertData
[
dataIndex
++
];
}
}
break
;
...
...
@@ -398,9 +398,9 @@ void Foam::vtkUnstructuredReader::readField
inFile
.
getLine
(
fieldVals
()[
0
]);
// Read without parsing
for
All
(
fieldVals
()
,
i
)
for
(
string
&
s
:
fieldVals
())
{
inFile
.
getLine
(
fieldVals
()[
i
]
);
inFile
.
getLine
(
s
);
}
regIOobject
::
store
(
fieldVals
);
}
...
...
@@ -627,9 +627,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
lineMap_
[
lineI
]
=
lineI
;
labelList
&
f
=
lines_
[
lineI
];
f
.
setSize
(
lineVerts
[
elemI
++
]);
for
All
(
f
,
fp
)
for
(
label
&
pointi
:
f
)
{
f
[
fp
]
=
lineVerts
[
elemI
++
];
pointi
=
lineVerts
[
elemI
++
];
}
lineI
++
;
}
...
...
@@ -656,9 +656,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
faceMap_
[
facei
]
=
facei
;
face
&
f
=
faces_
[
facei
];
f
.
setSize
(
faceVerts
[
elemI
++
]);
for
All
(
f
,
fp
)
for
(
label
&
pointi
:
f
)
{
f
[
fp
]
=
faceVerts
[
elemI
++
];
pointi
=
faceVerts
[
elemI
++
];
}
facei
++
;
}
...
...
@@ -769,11 +769,11 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
);
label
elemI
=
0
;
for
All
(
fieldVals
()
,
i
)
for
(
vector
&
val
:
fieldVals
())
{
fieldVals
()[
i
]
.
x
()
=
s
[
elemI
++
];
fieldVals
()[
i
]
.
y
()
=
s
[
elemI
++
];
fieldVals
()[
i
]
.
z
()
=
s
[
elemI
++
];
val
.
x
()
=
s
[
elemI
++
];
val
.
y
()
=
s
[
elemI
++
];
val
.
z
()
=
s
[
elemI
++
];
}
regIOobject
::
store
(
fieldVals
);
}
...
...
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