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
a43eb01b
Commit
a43eb01b
authored
Jan 07, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Jan 07, 2019
Browse files
ENH: for-range, forAllIters() ... in finiteVolume/
- reduced clutter when iterating over containers
parent
bd78da22
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControlTemplates.C
View file @
a43eb01b
...
...
@@ -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-2013 OpenFOAM Foundation
...
...
@@ -36,24 +36,23 @@ void Foam::solutionControl::storePrevIter() const
{
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
GeoField
;
HashTable
<
GeoField
*>
flds
(
mesh_
.
objectRegistry
::
lookupClass
<
GeoField
>
());
HashTable
<
GeoField
*>
flds
(
mesh_
.
objectRegistry
::
lookupClass
<
GeoField
>
());
forAllIter
(
typename
HashTable
<
GeoField
*>
,
flds
,
iter
)
forAllIter
s
(
flds
,
iter
)
{
GeoField
&
fld
=
*
iter
();
const
word
&
fName
=
fld
.
name
();
const
word
&
f
ld
Name
=
fld
.
name
();
size_t
prevIterField
=
fName
.
find
(
"PrevIter"
);
if
((
prevIterField
==
word
::
npos
)
&&
mesh_
.
relaxField
(
fName
))
if
(
(
fldName
.
find
(
"PrevIter"
)
==
std
::
string
::
npos
)
&&
mesh_
.
relaxField
(
fldName
)
)
{
if
(
debug
)
{
Info
<<
algorithmName_
<<
": storing previous iter for "
<<
fName
<<
endl
;
}
DebugInfo
<<
algorithmName_
<<
": storing previous iter for "
<<
fldName
<<
endl
;
fld
.
storePrevIter
();
}
...
...
src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C
View file @
a43eb01b
...
...
@@ -104,18 +104,12 @@ void Foam::singleCellFvMesh::agglomerateMesh
label
myZone
=
agglom
[
patchi
][
i
];
label
nbrZone
=
nbrAgglom
[
bFacei
];
Map
<
label
>::
const_itera
to
r
iter
=
localToNbr
.
find
(
myZone
);
const
au
to
iter
=
localToNbr
.
c
find
(
myZone
);
if
(
iter
==
localToNbr
.
end
())
{
// First occurrence of this zone. Store correspondence
// to remote zone number.
localToNbr
.
insert
(
myZone
,
nbrZone
);
}
else
if
(
iter
.
found
())
{
// Check that zone numbers are still the same.
if
(
iter
()
!=
nbrZone
)
if
(
iter
.
val
()
!=
nbrZone
)
{
FatalErrorInFunction
<<
"agglomeration is not synchronised across"
...
...
@@ -126,6 +120,12 @@ void Foam::singleCellFvMesh::agglomerateMesh
<<
exit
(
FatalError
);
}
}
else
{
// First occurrence of this zone. Store correspondence
// to remote zone number.
localToNbr
.
insert
(
myZone
,
nbrZone
);
}
}
}
}
...
...
src/finiteVolume/interpolation/surfaceInterpolation/multivariateSchemes/multivariateScheme/multivariateScheme.C
View file @
a43eb01b
...
...
@@ -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
...
...
@@ -62,15 +62,14 @@ Foam::multivariateScheme<Type, Scheme>::multivariateScheme
dimless
)
{
typename
multivariateSurfaceInterpolationScheme
<
Type
>::
fieldTable
::
const_iterator
iter
=
this
->
fields
().
begin
();
auto
iter
=
this
->
fields
().
cbegin
();
surfaceScalarField
limiter
(
Scheme
(
mesh
,
faceFlux_
,
*
this
).
limiter
(
*
iter
())
);
for
(
++
iter
;
iter
!=
this
->
fields
().
en
d
();
++
iter
)
for
(
++
iter
;
iter
.
goo
d
();
++
iter
)
{
limiter
=
min
(
...
...
src/finiteVolume/interpolation/surfaceInterpolation/multivariateSchemes/multivariateSelectionScheme/multivariateSelectionScheme.C
View file @
a43eb01b
...
...
@@ -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
...
...
@@ -65,8 +65,7 @@ Foam::multivariateSelectionScheme<Type>::multivariateSelectionScheme
dimless
)
{
typename
multivariateSurfaceInterpolationScheme
<
Type
>::
fieldTable
::
const_iterator
iter
=
this
->
fields
().
begin
();
auto
iter
=
this
->
fields
().
cbegin
();
surfaceScalarField
limiter
(
...
...
@@ -78,7 +77,7 @@ Foam::multivariateSelectionScheme<Type>::multivariateSelectionScheme
)().
limiter
(
*
iter
())
);
for
(
++
iter
;
iter
!=
this
->
fields
().
en
d
();
++
iter
)
for
(
++
iter
;
iter
.
goo
d
();
++
iter
)
{
limiter
=
min
(
...
...
src/finiteVolume/interpolation/volPointInterpolation/pointConstraints.C
View file @
a43eb01b
...
...
@@ -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) 2013-2016 OpenFOAM Foundation
...
...
@@ -109,21 +109,21 @@ void Foam::pointConstraints::makePatchPatchAddressing()
forAll
(
bp
,
pointi
)
{
label
ppp
=
meshPoints
[
bp
[
pointi
]];
const
label
ppp
=
meshPoints
[
bp
[
pointi
]];
Map
<
label
>::
itera
to
r
iter
=
patchPatchPointSet
.
find
(
ppp
);
const
au
to
iter
=
patchPatchPointSet
.
c
find
(
ppp
);
label
constraintI
=
-
1
;
if
(
iter
==
patchPatchPointSet
.
e
nd
())
if
(
iter
.
fou
nd
())
{
patchPatchPointSet
.
insert
(
ppp
,
pppi
);
patchPatchPoints
[
pppi
]
=
ppp
;
constraintI
=
pppi
++
;
constraintI
=
iter
.
val
();
}
else
{
constraintI
=
iter
();
patchPatchPointSet
.
insert
(
ppp
,
pppi
);
patchPatchPoints
[
pppi
]
=
ppp
;
constraintI
=
pppi
++
;
}
// Apply to patch constraints
...
...
@@ -169,14 +169,15 @@ void Foam::pointConstraints::makePatchPatchAddressing()
forAll
(
bp
,
pointi
)
{
label
ppp
=
meshPoints
[
bp
[
pointi
]];
const
label
ppp
=
meshPoints
[
bp
[
pointi
]];
const
auto
iter
=
cpPointMap
.
cfind
(
ppp
);
Map
<
label
>::
const_iterator
fnd
=
cpPointMap
.
find
(
ppp
);
if
(
fnd
!=
cpPointMap
.
end
())
if
(
iter
.
found
())
{
// Can just copy (instead of apply) constraint
// will already be consistent across multiple patches.
constraints
[
fnd
()]
=
patchPatchPointConstraints_
constraints
[
iter
.
val
()]
=
patchPatchPointConstraints_
[
patchPatchPointSet
[
ppp
]
];
...
...
@@ -219,11 +220,22 @@ void Foam::pointConstraints::makePatchPatchAddressing()
{
label
meshPointi
=
cpMeshPoints
[
coupledPointi
];
Map
<
label
>::
itera
to
r
iter
=
patchPatchPointSet
.
find
(
meshPointi
);
const
au
to
iter
=
patchPatchPointSet
.
c
find
(
meshPointi
);
label
constraintI
=
-
1
;
if
(
iter
==
patchPatchPointSet
.
end
())
if
(
iter
.
found
())
{
//Pout<< indent << "on meshpoint:" << meshPointi
// << " coupled:" << coupledPointi
// << " at:" << mesh.points()[meshPointi]
// << " have possibly extended constraint:"
// << constraints[coupledPointi]
// << endl;
constraintI
=
iter
.
val
();
}
else
{
//Pout<< indent << "on meshpoint:" << meshPointi
// << " coupled:" << coupledPointi
...
...
@@ -250,17 +262,6 @@ void Foam::pointConstraints::makePatchPatchAddressing()
patchPatchPoints
[
pppi
]
=
meshPointi
;
constraintI
=
pppi
++
;
}
else
{
//Pout<< indent << "on meshpoint:" << meshPointi
// << " coupled:" << coupledPointi
// << " at:" << mesh.points()[meshPointi]
// << " have possibly extended constraint:"
// << constraints[coupledPointi]
// << endl;
constraintI
=
iter
();
}
// Combine (new or existing) constraint with one
// on coupled.
...
...
src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C
View file @
a43eb01b
...
...
@@ -129,7 +129,7 @@ void Foam::pairPatchAgglomeration::setEdgeWeights
edgeHashSet
fineFeaturedFaces
(
coarsePatch
.
nEdges
()
/
10
);
// Map fine faces with featured edge into coarse faces
forAllConstIter
(
EdgeMap
<
scalar
>
,
facePairWeight_
,
iter
)
forAllConstIter
s
(
facePairWeight_
,
iter
)
{
if
(
iter
()
==
-
1
.
0
)
{
...
...
src/overset/oversetPolyPatch/oversetGAMGInterface.C
View file @
a43eb01b
...
...
@@ -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
...
...
@@ -81,17 +81,17 @@ Foam::oversetGAMGInterface::oversetGAMGInterface
label
coarseCelli
=
localRestrictAddressing
[
ffi
];
// Do we have coarse face for it?
Map
<
label
>::
itera
to
r
iter
=
cellToCoarseFace
.
find
(
coarseCelli
);
if
(
iter
==
cellToCoarseFace
.
e
nd
())
const
au
to
iter
=
cellToCoarseFace
.
c
find
(
coarseCelli
);
if
(
iter
.
fou
nd
())
{
label
coarseFacei
=
dynFaceCells
.
size
();
cellToCoarseFace
.
insert
(
coarseCelli
,
coarseFacei
);
dynFaceCells
.
append
(
coarseCelli
);
dynFaceRestrictAddressing
.
append
(
coarseFacei
);
dynFaceRestrictAddressing
.
append
(
iter
.
val
());
}
else
{
dynFaceRestrictAddressing
.
append
(
iter
());
const
label
coarseFacei
=
dynFaceCells
.
size
();
cellToCoarseFace
.
insert
(
coarseCelli
,
coarseFacei
);
dynFaceCells
.
append
(
coarseCelli
);
dynFaceRestrictAddressing
.
append
(
coarseFacei
);
}
}
...
...
src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C
View file @
a43eb01b
...
...
@@ -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-2017 OpenFOAM Foundation
...
...
@@ -43,7 +43,7 @@ filmModel() const
HashTable
<
const
filmModelType
*>
models
=
db
().
time
().
lookupClass
<
filmModelType
>
();
forAllConstIter
(
HashTable
<
const
filmModelType
*>
,
models
,
iter
)
forAllConstIter
s
(
models
,
iter
)
{
if
(
iter
()
->
regionMesh
().
name
()
==
filmRegionName_
)
{
...
...
@@ -52,7 +52,7 @@ filmModel() const
}
DynamicList
<
word
>
modelNames
;
forAllConstIter
(
HashTable
<
const
filmModelType
*>
,
models
,
iter
)
forAllConstIter
s
(
models
,
iter
)
{
modelNames
.
append
(
iter
()
->
regionMesh
().
name
());
}
...
...
@@ -74,7 +74,7 @@ pyrModel() const
HashTable
<
const
pyrolysisModelType
*>
models
=
db
().
time
().
lookupClass
<
pyrolysisModelType
>
();
forAllConstIter
(
HashTable
<
const
pyrolysisModelType
*>
,
models
,
iter
)
forAllConstIter
s
(
models
,
iter
)
{
if
(
iter
()
->
regionMesh
().
name
()
==
pyrolysisRegionName_
)
{
...
...
@@ -83,7 +83,7 @@ pyrModel() const
}
DynamicList
<
word
>
modelNames
;
forAllConstIter
(
HashTable
<
const
pyrolysisModelType
*>
,
models
,
iter
)
forAllConstIter
s
(
models
,
iter
)
{
modelNames
.
append
(
iter
()
->
regionMesh
().
name
());
}
...
...
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