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
24861f51
Commit
24861f51
authored
Jan 07, 2019
by
Mark Olesen
Committed by
Andrew Heather
Jan 07, 2019
Browse files
ENH: for-range, forAllIters() ... in functionObjects/
- reduced clutter when iterating over containers
parent
60234ab0
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017
-2019
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -106,17 +106,16 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField
// Note: looks up all window fields from the registry
meanField
=
0
*
baseField
;
FIFOStack
<
scalar
>::
const_iterator
timeIter
=
windowTimes_
.
begin
();
FIFOStack
<
word
>::
const_iterator
nameIter
=
windowFieldNames_
.
begin
();
auto
timeIter
=
windowTimes_
.
cbegin
();
auto
nameIter
=
windowFieldNames_
.
cbegin
();
const
Type
*
wOld
=
nullptr
;
for
(
;
timeIter
!=
windowTimes_
.
en
d
();
timeIter
.
goo
d
();
++
timeIter
,
++
nameIter
)
{
...
...
@@ -223,10 +222,9 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
{
// Not storing old time mean fields - treat all as TIME (integrated)
prime2MeanField
=
0
*
prime2MeanField
;
FIFOStack
<
scalar
>::
const_iterator
timeIter
=
windowTimes_
.
begin
();
FIFOStack
<
word
>::
const_iterator
nameIter
=
windowFieldNames_
.
begin
();
auto
timeIter
=
windowTimes_
.
cbegin
();
auto
nameIter
=
windowFieldNames_
.
cbegin
();
switch
(
base_
)
{
...
...
@@ -236,7 +234,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
++
timeIter
;
++
nameIter
;
if
(
timeIter
==
windowTimes_
.
en
d
())
return
false
;
if
(
!
timeIter
.
goo
d
())
return
false
;
break
;
}
...
...
@@ -252,7 +250,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
for
(
;
timeIter
!=
windowTimes_
.
en
d
();
timeIter
.
goo
d
();
++
timeIter
,
++
nameIter
)
{
...
...
@@ -272,7 +270,6 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
prime2MeanField
/=
windowLength
;
break
;
}
default:
...
...
src/functionObjects/field/nearWallFields/nearWallFields.C
View file @
24861f51
...
...
@@ -160,9 +160,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
);
InfoInFunction
<<
"Dumping tracks to "
<<
str
.
name
()
<<
endl
;
for
AllConstIter
(
Cloud
<
findCellParticle
>
,
cloud
,
iter
)
for
(
const
findCellParticle
&
tp
:
cloud
)
{
const
findCellParticle
&
tp
=
iter
();
str
.
write
(
linePointRef
(
tp
.
position
(),
tp
.
end
()));
}
}
...
...
@@ -186,9 +185,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
{
start
.
setSize
(
nPatchFaces
);
nPatchFaces
=
0
;
for
AllConstIter
(
Cloud
<
findCellParticle
>
,
cloud
,
iter
)
for
(
const
findCellParticle
&
tp
:
cloud
)
{
const
findCellParticle
&
tp
=
iter
();
start
[
nPatchFaces
++
]
=
tp
.
position
();
}
}
...
...
src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2016 OpenFOAM Foundation
...
...
@@ -121,7 +121,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
// Knock out any cell not in patchRegions
forAll
(
liquidCore
,
celli
)
{
label
regioni
=
regions
[
celli
];
const
label
regioni
=
regions
[
celli
];
if
(
patchRegions
.
found
(
regioni
))
{
backgroundAlpha
[
celli
]
=
0
;
...
...
@@ -130,7 +130,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
{
liquidCore
[
celli
]
=
0
;
scalar
regionVol
=
regionVolume
[
regioni
];
const
scalar
regionVol
=
regionVolume
[
regioni
];
if
(
regionVol
<
maxDropletVol
)
{
backgroundAlpha
[
celli
]
=
0
;
...
...
@@ -144,8 +144,8 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
{
Info
<<
" Volume of liquid-core = "
<<
fvc
::
domainIntegrate
(
liquidCore
).
value
()
<<
endl
;
Info
<<
" Volume of background = "
<<
nl
<<
" Volume of background = "
<<
fvc
::
domainIntegrate
(
backgroundAlpha
).
value
()
<<
endl
;
}
...
...
@@ -549,19 +549,18 @@ bool Foam::functionObjects::regionSizeDistribution::write()
<<
token
::
TAB
<<
"Volume(mesh)"
<<
token
::
TAB
<<
"Volume("
<<
alpha
.
name
()
<<
"):"
<<
token
::
TAB
<<
"nCells"
<<
end
l
;
<<
n
l
;
scalar
meshSumVol
=
0
.
0
;
scalar
alphaSumVol
=
0
.
0
;
label
nCells
=
0
;
Map
<
scalar
>::
const_iter
ato
r
vIter
=
allRegionVolume
.
begin
();
Map
<
scalar
>::
const_iter
ato
r
aIter
=
allRegionAlphaVolume
.
begin
();
Map
<
label
>::
const_iter
ato
r
numIter
=
allRegionNumCells
.
begin
();
a
u
to
vIter
=
allRegionVolume
.
c
begin
();
a
u
to
aIter
=
allRegionAlphaVolume
.
c
begin
();
a
u
to
numIter
=
allRegionNumCells
.
c
begin
();
for
(
;
vIter
!=
allRegionVolume
.
end
()
&&
aIter
!=
allRegionAlphaVolume
.
end
();
vIter
.
good
()
&&
aIter
.
good
();
++
vIter
,
++
aIter
,
++
numIter
)
{
...
...
@@ -569,7 +568,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
<<
token
::
TAB
<<
vIter
()
<<
token
::
TAB
<<
aIter
()
<<
token
::
TAB
<<
numIter
()
<<
end
l
;
<<
n
l
;
meshSumVol
+=
vIter
();
alphaSumVol
+=
aIter
();
...
...
@@ -583,20 +582,20 @@ bool Foam::functionObjects::regionSizeDistribution::write()
}
if
(
log
)
{
Info
<<
" Patch connected regions (liquid core):"
<<
end
l
;
Info
<<
" Patch connected regions (liquid core):"
<<
n
l
;
Info
<<
token
::
TAB
<<
" Region"
<<
token
::
TAB
<<
"Volume(mesh)"
<<
token
::
TAB
<<
"Volume("
<<
alpha
.
name
()
<<
"):"
<<
endl
;
<<
nl
;
forAllConstIters
(
patchRegions
,
iter
)
{
const
label
regioni
=
iter
.
key
();
Info
<<
" "
<<
token
::
TAB
<<
regioni
<<
token
::
TAB
<<
allRegionVolume
[
regioni
]
<<
token
::
TAB
<<
allRegionAlphaVolume
[
regioni
]
<<
end
l
;
<<
token
::
TAB
<<
allRegionAlphaVolume
[
regioni
]
<<
n
l
;
}
Info
<<
endl
;
...
...
@@ -604,19 +603,19 @@ bool Foam::functionObjects::regionSizeDistribution::write()
if
(
log
)
{
Info
<<
" Background regions:"
<<
end
l
;
Info
<<
" Background regions:"
<<
n
l
;
Info
<<
" "
<<
token
::
TAB
<<
"Region"
<<
token
::
TAB
<<
"Volume(mesh)"
<<
token
::
TAB
<<
"Volume("
<<
alpha
.
name
()
<<
"):"
<<
endl
;
Map
<
scalar
>::
const_iterator
vIter
=
allRegionVolume
.
begin
();
Map
<
scalar
>::
const_iterator
aIter
=
allRegionAlphaVolume
.
begin
();
<<
nl
;
auto
vIter
=
allRegionVolume
.
cbegin
();
auto
aIter
=
allRegionAlphaVolume
.
cbegin
();
for
(
;
vIter
!=
allRegionVolume
.
end
()
&&
aIter
!=
allRegionAlphaVolume
.
end
();
vIter
.
good
()
&&
aIter
.
good
();
++
vIter
,
++
aIter
)
{
...
...
@@ -628,7 +627,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
{
Info
<<
" "
<<
token
::
TAB
<<
vIter
.
key
()
<<
token
::
TAB
<<
vIter
()
<<
token
::
TAB
<<
aIter
()
<<
end
l
;
<<
token
::
TAB
<<
aIter
()
<<
n
l
;
}
}
Info
<<
endl
;
...
...
@@ -651,9 +650,9 @@ bool Foam::functionObjects::regionSizeDistribution::write()
// allRegionAlphaVolume since background might not have alpha in it.
// Deleting regions where the volume-alpha-weighted is lower than
// threshold
forAllIter
(
Map
<
scalar
>
,
allRegionVolume
,
vIter
)
forAllIter
s
(
allRegionVolume
,
vIter
)
{
label
regioni
=
vIter
.
key
();
const
label
regioni
=
vIter
.
key
();
if
(
patchRegions
.
found
(
regioni
)
...
...
@@ -783,14 +782,14 @@ bool Foam::functionObjects::regionSizeDistribution::write()
<<
" "
<<
token
::
TAB
<<
"Bin"
<<
token
::
TAB
<<
"Min distance"
<<
token
::
TAB
<<
"Count:"
<<
end
l
;
<<
n
l
;
scalar
delta
=
0
.
0
;
forAll
(
binDownCount
,
bini
)
{
Info
<<
" "
<<
token
::
TAB
<<
bini
<<
token
::
TAB
<<
delta
<<
token
::
TAB
<<
binDownCount
[
bini
]
<<
end
l
;
<<
token
::
TAB
<<
binDownCount
[
bini
]
<<
n
l
;
delta
+=
deltaX
;
}
Info
<<
endl
;
...
...
@@ -836,14 +835,14 @@ bool Foam::functionObjects::regionSizeDistribution::write()
<<
" "
<<
token
::
TAB
<<
"Bin"
<<
token
::
TAB
<<
"Min diameter"
<<
token
::
TAB
<<
"Count:"
<<
end
l
;
<<
n
l
;
scalar
diam
=
0
.
0
;
forAll
(
binCount
,
bini
)
{
Info
<<
" "
<<
token
::
TAB
<<
bini
<<
token
::
TAB
<<
diam
<<
token
::
TAB
<<
binCount
[
bini
]
<<
end
l
;
<<
token
::
TAB
<<
binCount
[
bini
]
<<
n
l
;
diam
+=
delta
;
}
...
...
src/functionObjects/field/regionSizeDistribution/regionSizeDistributionTemplates.C
View file @
24861f51
...
...
@@ -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) 2012-2016 OpenFOAM Foundation
...
...
@@ -43,18 +43,10 @@ Foam::Map<Type> Foam::functionObjects::regionSizeDistribution::regionSum
forAll
(
fld
,
celli
)
{
label
regioni
=
regions
[
celli
];
typename
Map
<
Type
>::
iterator
fnd
=
regionToSum
.
find
(
regioni
);
if
(
fnd
==
regionToSum
.
end
())
{
regionToSum
.
insert
(
regioni
,
fld
[
celli
]);
}
else
{
fnd
()
+=
fld
[
celli
];
}
const
label
regioni
=
regions
[
celli
];
regionToSum
(
regioni
,
Type
(
Zero
))
+=
fld
[
celli
];
}
Pstream
::
mapCombineGather
(
regionToSum
,
plusEqOp
<
Type
>
());
Pstream
::
mapCombineScatter
(
regionToSum
);
...
...
src/functionObjects/field/streamLine/streamLineParticle.C
View file @
24861f51
...
...
@@ -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
...
...
@@ -389,11 +389,11 @@ void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
c
.
checkFieldIOobject
(
c
,
sampledPositions
);
label
i
=
0
;
for
AllIter
(
Cloud
<
streamLineParticle
>
,
c
,
iter
)
for
(
streamLineParticle
&
p
:
c
)
{
iter
()
.
lifeTime_
=
lifeTime
[
i
];
iter
()
.
sampledPositions_
.
transfer
(
sampledPositions
[
i
]);
i
++
;
p
.
lifeTime_
=
lifeTime
[
i
];
p
.
sampledPositions_
.
transfer
(
sampledPositions
[
i
]);
++
i
;
}
}
...
...
@@ -402,7 +402,7 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
{
particle
::
writeFields
(
c
);
label
np
=
c
.
size
();
const
label
np
=
c
.
size
();
IOField
<
label
>
lifeTime
(
...
...
@@ -416,11 +416,11 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
);
label
i
=
0
;
for
AllConstIter
(
Cloud
<
streamLineParticle
>
,
c
,
iter
)
for
(
const
streamLineParticle
&
p
:
c
)
{
lifeTime
[
i
]
=
iter
()
.
lifeTime_
;
sampledPositions
[
i
]
=
iter
()
.
sampledPositions_
;
i
++
;
lifeTime
[
i
]
=
p
.
lifeTime_
;
sampledPositions
[
i
]
=
p
.
sampledPositions_
;
++
i
;
}
lifeTime
.
write
(
np
>
0
);
...
...
src/functionObjects/field/surfaceInterpolate/surfaceInterpolateTemplates.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
...
...
@@ -46,7 +46,7 @@ void Foam::functionObjects::surfaceInterpolate::interpolateFields()
HashTable
<
const
VolFieldType
*>
flds
(
obr_
.
lookupClass
<
VolFieldType
>
());
forAllConstIter
(
typename
HashTable
<
const
VolFieldType
*>
,
flds
,
iter
)
forAllConstIter
s
(
flds
,
iter
)
{
const
VolFieldType
&
fld
=
*
iter
();
...
...
src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-201
7
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
...
...
@@ -305,16 +305,8 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
forAll
(
f
,
fp
)
{
const
edge
e
(
f
[
fp
],
f
.
nextLabel
(
fp
));
EdgeMap
<
label
>::
iterator
eFnd
=
numFacesPerEdge
.
find
(
e
);
if
(
eFnd
!=
numFacesPerEdge
.
end
())
{
eFnd
()
++
;
}
else
{
numFacesPerEdge
.
insert
(
e
,
1
);
}
++
(
numFacesPerEdge
(
e
,
0
));
}
}
...
...
src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017
-2019
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
...
...
@@ -218,11 +218,11 @@ void Foam::wallBoundedStreamLineParticle::readFields
c
.
checkFieldIOobject
(
c
,
sampledPositions
);
label
i
=
0
;
for
AllIter
(
Cloud
<
wallBoundedStreamLineParticle
>
,
c
,
iter
)
for
(
wallBoundedStreamLineParticle
&
p
:
c
)
{
iter
()
.
lifeTime_
=
lifeTime
[
i
];
iter
()
.
sampledPositions_
.
transfer
(
sampledPositions
[
i
]);
i
++
;
p
.
lifeTime_
=
lifeTime
[
i
];
p
.
sampledPositions_
.
transfer
(
sampledPositions
[
i
]);
++
i
;
}
}
...
...
@@ -234,7 +234,7 @@ void Foam::wallBoundedStreamLineParticle::writeFields
{
wallBoundedParticle
::
writeFields
(
c
);
label
np
=
c
.
size
();
const
label
np
=
c
.
size
();
IOField
<
label
>
lifeTime
(
...
...
@@ -248,11 +248,11 @@ void Foam::wallBoundedStreamLineParticle::writeFields
);
label
i
=
0
;
for
AllConstIter
(
Cloud
<
wallBoundedStreamLineParticle
>
,
c
,
iter
)
for
(
const
wallBoundedStreamLineParticle
&
p
:
c
)
{
lifeTime
[
i
]
=
iter
()
.
lifeTime_
;
sampledPositions
[
i
]
=
iter
()
.
sampledPositions_
;
i
++
;
lifeTime
[
i
]
=
p
.
lifeTime_
;
sampledPositions
[
i
]
=
p
.
sampledPositions_
;
++
i
;
}
lifeTime
.
write
();
...
...
src/functionObjects/forces/forces/forces.C
View file @
24861f51
...
...
@@ -240,7 +240,7 @@ void Foam::functionObjects::forces::initialiseBins()
const
scalarField
dd
(
mesh_
.
C
()
&
binDir_
);
forAllConstIter
(
HashTable
<
const
porosityModel
*>
,
models
,
iter
)
forAllConstIter
s
(
models
,
iter
)
{
const
porosityModel
&
pm
=
*
iter
();
const
labelList
&
cellZoneIDs
=
pm
.
cellZoneIDs
();
...
...
src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageConditionTemplates.C
View file @
24861f51
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2016
, 2019
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015 OpenFOAM Foundation
...
...
@@ -121,10 +121,8 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
windowValues
.
push
(
currentValue
);
// Calculate the window average
typename
FIFOStack
<
scalar
>::
const_iterator
timeIter
=
windowTimes
.
begin
();
typename
FIFOStack
<
Type
>::
const_iterator
valueIter
=
windowValues
.
begin
();
auto
timeIter
=
windowTimes
.
cbegin
();
auto
valueIter
=
windowValues
.
cbegin
();
meanValue
=
pTraits
<
Type
>::
zero
;
Type
valueOld
(
pTraits
<
Type
>::
zero
);
...
...
@@ -132,7 +130,7 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
for
(
label
i
=
0
;
timeIter
!=
windowTimes
.
en
d
();
timeIter
.
goo
d
();
++
i
,
++
timeIter
,
++
valueIter
)
{
...
...
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