Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-solvers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
agnumpde
dune-solvers
Commits
27c600da
"git@git.imp.fu-berlin.de:luvaseva/wikifilters.git" did not exist on "8871b7ff7940a1bef39aa0b9df7ff560b4d7f01b"
Commit
27c600da
authored
7 years ago
by
Jonathan Youett
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup using range-based for-loops and keyword 'auto'
parent
980ce9de
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/test/common.hh
+17
-38
17 additions, 38 deletions
dune/solvers/test/common.hh
with
17 additions
and
38 deletions
dune/solvers/test/common.hh
+
17
−
38
View file @
27c600da
...
@@ -92,17 +92,13 @@ void addToDiagonal(Dune::FieldMatrix<T, n, m>& M, const F& x)
...
@@ -92,17 +92,13 @@ void addToDiagonal(Dune::FieldMatrix<T, n, m>& M, const F& x)
template
<
class
GridView
,
class
Matrix
>
template
<
class
GridView
,
class
Matrix
>
void
assemblePQ1Stiffness
(
const
GridView
&
gridView
,
Matrix
&
matrix
)
void
assemblePQ1Stiffness
(
const
GridView
&
gridView
,
Matrix
&
matrix
)
{
{
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
static
const
expr
int
dim
=
GridView
::
Grid
::
dimension
;
static
const
int
dimworld
=
GridView
::
Grid
::
dimensionworld
;
static
const
expr
int
dimworld
=
GridView
::
Grid
::
dimensionworld
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Entity
Element
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Entity
::
Geometry
Geometry
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
Dune
::
FieldVector
<
double
,
dim
>
LocalCoordinate
;
typedef
typename
Dune
::
FieldVector
<
double
,
dimworld
>
GlobalCoordinate
;
typedef
typename
Dune
::
FieldVector
<
double
,
dimworld
>
GlobalCoordinate
;
typedef
typename
Element
::
Geometry
::
JacobianInverseTransposed
JacobianInverseTransposed
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
JacobianType
JacobianType
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
JacobianType
JacobianType
;
const
auto
&
indexSet
=
gridView
.
indexSet
();
const
auto
&
indexSet
=
gridView
.
indexSet
();
...
@@ -110,7 +106,7 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
...
@@ -110,7 +106,7 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
for
(
const
auto
&
element
:
elements
(
gridView
))
for
(
const
auto
&
element
:
elements
(
gridView
))
{
{
const
Geometry
geometry
=
element
.
geometry
();
const
auto
&
geometry
=
element
.
geometry
();
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
int
localSize
=
fe
.
size
();
int
localSize
=
fe
.
size
();
...
@@ -125,13 +121,13 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
...
@@ -125,13 +121,13 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
std
::
vector
<
JacobianType
>
referenceGradients
(
localSize
);
std
::
vector
<
JacobianType
>
referenceGradients
(
localSize
);
std
::
vector
<
GlobalCoordinate
>
gradients
(
localSize
);
std
::
vector
<
GlobalCoordinate
>
gradients
(
localSize
);
for
(
size_t
pt
=
0
;
pt
<
quad
.
size
();
++
pt
)
for
(
const
auto
&
pt
:
quad
)
{
{
// get quadrature point
// get quadrature point
const
LocalCoordinate
&
quadPos
=
quad
[
pt
]
.
position
();
const
auto
&
quadPos
=
pt
.
position
();
// get transposed inverse of Jacobian of transformation
// get transposed inverse of Jacobian of transformation
const
JacobianInverseTransposed
invJacobian
=
geometry
.
jacobianInverseTransposed
(
quadPos
);
const
auto
invJacobian
=
geometry
.
jacobianInverseTransposed
(
quadPos
);
// get integration factor
// get integration factor
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
...
@@ -144,7 +140,7 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
...
@@ -144,7 +140,7 @@ void assemblePQ1Stiffness(const GridView& gridView, Matrix& matrix)
invJacobian
.
mv
(
referenceGradients
[
i
][
0
],
gradients
[
i
]);
invJacobian
.
mv
(
referenceGradients
[
i
][
0
],
gradients
[
i
]);
// compute matrix entries
// compute matrix entries
double
z
=
quad
[
pt
]
.
weight
()
*
integrationElement
;
double
z
=
pt
.
weight
()
*
integrationElement
;
for
(
int
i
=
0
;
i
<
localSize
;
++
i
)
for
(
int
i
=
0
;
i
<
localSize
;
++
i
)
{
{
int
iGlobal
=
indexSet
.
subIndex
(
element
,
fe
.
localCoefficients
().
localKey
(
i
).
subEntity
(),
dim
);
int
iGlobal
=
indexSet
.
subIndex
(
element
,
fe
.
localCoefficients
().
localKey
(
i
).
subEntity
(),
dim
);
...
@@ -169,11 +165,9 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
...
@@ -169,11 +165,9 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
{
{
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Entity
::
Geometry
Geometry
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
Dune
::
FieldVector
<
double
,
dim
>
LocalCoordinate
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
RangeType
RangeType
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
RangeType
RangeType
;
const
auto
&
indexSet
=
gridView
.
indexSet
();
const
auto
&
indexSet
=
gridView
.
indexSet
();
...
@@ -181,7 +175,7 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
...
@@ -181,7 +175,7 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
for
(
const
auto
&
element
:
elements
(
gridView
))
for
(
const
auto
&
element
:
elements
(
gridView
))
{
{
const
Geometry
geometry
=
element
.
geometry
();
const
auto
&
geometry
=
element
.
geometry
();
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
int
localSize
=
fe
.
size
();
int
localSize
=
fe
.
size
();
...
@@ -198,7 +192,7 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
...
@@ -198,7 +192,7 @@ void assemblePQ1Mass(const GridView& gridView, Matrix& matrix)
for
(
size_t
pt
=
0
;
pt
<
quad
.
size
();
++
pt
)
for
(
size_t
pt
=
0
;
pt
<
quad
.
size
();
++
pt
)
{
{
// get quadrature point
// get quadrature point
const
LocalCoordinate
&
quadPos
=
quad
[
pt
].
position
();
const
auto
&
quadPos
=
quad
[
pt
].
position
();
// get integration factor
// get integration factor
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
...
@@ -233,11 +227,9 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
...
@@ -233,11 +227,9 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
{
{
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Entity
::
Geometry
Geometry
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
Dune
::
template
FieldVector
<
double
,
dim
>
LocalCoordinate
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
RangeType
RangeType
;
typedef
typename
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
RangeType
RangeType
;
typedef
typename
Function
::
RangeType
FunctionRangeType
;
typedef
typename
Function
::
RangeType
FunctionRangeType
;
...
@@ -246,7 +238,7 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
...
@@ -246,7 +238,7 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
for
(
const
auto
&
element
:
elements
(
gridView
))
for
(
const
auto
&
element
:
elements
(
gridView
))
{
{
const
Geometry
geometry
=
element
.
geometry
();
const
auto
&
geometry
=
element
.
geometry
();
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
const
FiniteElement
&
fe
=
cache
.
get
(
element
.
type
());
int
localSize
=
fe
.
size
();
int
localSize
=
fe
.
size
();
...
@@ -261,10 +253,10 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
...
@@ -261,10 +253,10 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
// store values of shape functions
// store values of shape functions
std
::
vector
<
RangeType
>
values
(
localSize
);
std
::
vector
<
RangeType
>
values
(
localSize
);
for
(
size_t
pt
=
0
;
pt
<
quad
.
size
();
++
pt
)
for
(
const
auto
&
pt
:
quad
)
{
{
// get quadrature point
// get quadrature point
const
LocalCoordinate
&
quadPos
=
quad
[
pt
]
.
position
();
const
auto
&
quadPos
=
pt
.
position
();
// get integration factor
// get integration factor
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
const
double
integrationElement
=
geometry
.
integrationElement
(
quadPos
);
...
@@ -277,7 +269,7 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
...
@@ -277,7 +269,7 @@ void assemblePQ1RHS(const GridView& gridView, Vector& r, const Function& f)
f
.
evaluate
(
geometry
.
global
(
quadPos
),
fAtPos
);
f
.
evaluate
(
geometry
.
global
(
quadPos
),
fAtPos
);
// add vector entries
// add vector entries
double
z
=
quad
[
pt
]
.
weight
()
*
integrationElement
;
double
z
=
pt
.
weight
()
*
integrationElement
;
for
(
int
i
=
0
;
i
<
localSize
;
++
i
)
for
(
int
i
=
0
;
i
<
localSize
;
++
i
)
{
{
int
iGlobal
=
indexSet
.
subIndex
(
element
,
fe
.
localCoefficients
().
localKey
(
i
).
subEntity
(),
dim
);
int
iGlobal
=
indexSet
.
subIndex
(
element
,
fe
.
localCoefficients
().
localKey
(
i
).
subEntity
(),
dim
);
...
@@ -296,8 +288,7 @@ bool intersectionContainsVertex(const Intersection& i, int vertexInInsideElement
...
@@ -296,8 +288,7 @@ bool intersectionContainsVertex(const Intersection& i, int vertexInInsideElement
int
faceIdx
=
i
.
indexInInside
();
int
faceIdx
=
i
.
indexInInside
();
const
Dune
::
ReferenceElement
<
double
,
dim
>&
refElement
const
auto
&
refElement
=
Dune
::
ReferenceElements
<
double
,
dim
>::
general
(
i
.
inside
().
type
());
=
Dune
::
ReferenceElements
<
double
,
dim
>::
general
(
i
.
inside
().
type
());
for
(
int
j
=
0
;
j
<
refElement
.
size
(
faceIdx
,
1
,
dim
);
++
j
)
for
(
int
j
=
0
;
j
<
refElement
.
size
(
faceIdx
,
1
,
dim
);
++
j
)
{
{
...
@@ -316,31 +307,19 @@ void markBoundaryDOFs(const GridView& gridView, BitVector& isBoundary)
...
@@ -316,31 +307,19 @@ void markBoundaryDOFs(const GridView& gridView, BitVector& isBoundary)
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
static
const
int
dim
=
GridView
::
Grid
::
dimension
;
typedef
typename
GridView
::
IndexSet
IndexSet
;
typedef
typename
GridView
::
IndexSet
IndexSet
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Iterator
ElementIterator
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Entity
Element
;
typedef
typename
GridView
::
IntersectionIterator
IntersectionIterator
;
typedef
typename
GridView
::
Intersection
Intersection
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
Dune
::
PQkLocalFiniteElementCache
<
double
,
double
,
dim
,
1
>
FiniteElementCache
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
typedef
typename
FiniteElementCache
::
FiniteElementType
FiniteElement
;
const
IndexSet
&
indexSet
=
gridView
.
indexSet
();
const
IndexSet
&
indexSet
=
gridView
.
indexSet
();
FiniteElementCache
cache
;
FiniteElementCache
cache
;
ElementIterator
it
=
gridView
.
template
begin
<
0
>();
for
(
const
auto
&
e
:
elements
(
gridView
))
ElementIterator
end
=
gridView
.
template
end
<
0
>();
for
(;
it
!=
end
;
++
it
)
{
{
const
Element
&
e
=
*
it
;
const
FiniteElement
&
fe
=
cache
.
get
(
e
.
type
());
const
FiniteElement
&
fe
=
cache
.
get
(
e
.
type
());
int
localSize
=
fe
.
localBasis
().
size
();
int
localSize
=
fe
.
localBasis
().
size
();
IntersectionIterator
nIt
=
gridView
.
ibegin
(
e
);
for
(
const
auto
&
i
:
intersections
(
gridView
,
e
))
IntersectionIterator
nEnd
=
gridView
.
iend
(
e
);
for
(;
nIt
!=
nEnd
;
++
nIt
)
{
{
const
Intersection
&
i
=
*
nIt
;
if
(
i
.
boundary
())
if
(
i
.
boundary
())
{
{
for
(
int
j
=
0
;
j
<
localSize
;
++
j
)
for
(
int
j
=
0
;
j
<
localSize
;
++
j
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment