Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
dumux-repositories
dumux
Commits
684c4c19
Commit
684c4c19
authored
5 years ago
by
Dennis Gläser
Committed by
Timo Koch
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[integrate] do not do component-wise error squares
parent
5d5d7e68
No related branches found
No related tags found
1 merge request
!1636
Feature/l2 norm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/common/integrate.hh
+14
-37
14 additions, 37 deletions
dumux/common/integrate.hh
with
14 additions
and
37 deletions
dumux/common/integrate.hh
+
14
−
37
View file @
684c4c19
...
...
@@ -57,23 +57,6 @@ template<class F>
static
constexpr
bool
hasLocalFunction
()
{
return
Dune
::
models
<
HasLocalFunction
,
F
>
();
}
template
<
class
Error
,
typename
std
::
enable_if_t
<
IsIndexable
<
Error
>
::
value
,
int
>
=
0
>
auto
localErrorSqrImpl
(
const
Error
&
error
)
{
Error
sqr
=
error
;
sqr
=
0.0
;
for
(
int
i
=
0
;
i
<
sqr
.
size
();
++
i
)
sqr
[
i
]
+=
error
[
i
]
*
error
[
i
];
return
sqr
;
}
template
<
class
Error
,
typename
std
::
enable_if_t
<!
IsIndexable
<
Error
>
::
value
,
int
>
=
0
>
auto
localErrorSqrImpl
(
const
Error
&
error
)
{
return
error
*
error
;
}
template
<
class
Error
,
typename
std
::
enable_if_t
<
IsIndexable
<
Error
>
::
value
,
int
>
=
0
>
Error
sqrtNorm
(
const
Error
&
error
)
...
...
@@ -123,11 +106,10 @@ auto integrateGridFunction(const GridGeometry& gg,
SolutionVector
&&
sol
,
std
::
size_t
order
)
{
using
PrimaryVariables
=
std
::
decay_t
<
decltype
(
sol
[
0
])
>
;
using
GridView
=
typename
GridGeometry
::
GridView
;
using
Scalar
=
typename
Impl
::
FieldType
<
PrimaryVariables
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
std
::
decay_t
<
decltype
(
sol
[
0
])
>
>
;
PrimaryVariables
integral
=
0.0
;
Scalar
integral
(
0.0
)
;
for
(
const
auto
&
element
:
elements
(
gg
.
gridView
()))
{
const
auto
elemSol
=
elementSolution
(
element
,
sol
,
gg
);
...
...
@@ -158,11 +140,10 @@ auto integrateL2Error(const GridGeometry& gg,
const
Sol2
&
sol2
,
std
::
size_t
order
)
{
using
PrimaryVariables
=
std
::
decay_t
<
decltype
(
sol1
[
0
])
>
;
using
GridView
=
typename
GridGeometry
::
GridView
;
using
Scalar
=
typename
Impl
::
FieldType
<
PrimaryVariables
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
std
::
decay_t
<
decltype
(
sol1
[
0
])
>
>
;
PrimaryVariables
l2norm
=
0.0
;
Scalar
l2norm
(
0.0
)
;
for
(
const
auto
&
element
:
elements
(
gg
.
gridView
()))
{
const
auto
elemSol1
=
elementSolution
(
element
,
sol1
,
gg
);
...
...
@@ -176,13 +157,12 @@ auto integrateL2Error(const GridGeometry& gg,
const
auto
value1
=
evalSolution
(
element
,
geometry
,
gg
,
elemSol1
,
globalPos
);
const
auto
value2
=
evalSolution
(
element
,
geometry
,
gg
,
elemSol2
,
globalPos
);
const
auto
error
=
(
value1
-
value2
);
auto
value
=
Impl
::
localErrorSqrImpl
(
error
);
value
*=
qp
.
weight
()
*
geometry
.
integrationElement
(
qp
.
position
());
l2norm
+=
value
;
l2norm
+=
(
error
*
error
)
*
qp
.
weight
()
*
geometry
.
integrationElement
(
qp
.
position
());
}
}
return
Impl
::
sqrtNorm
(
l2norm
);
using
std
::
sqrt
;
return
sqrt
(
l2norm
);
}
#if HAVE_DUNE_FUNCTIONS
...
...
@@ -204,10 +184,9 @@ auto integrateGridFunction(const GridView& gv,
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
LocalPosition
=
typename
Element
::
Geometry
::
LocalCoordinate
;
using
PrimaryVariables
=
std
::
decay_t
<
decltype
(
fLocal
(
std
::
declval
<
LocalPosition
>
()))
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
PrimaryVariables
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
std
::
decay_t
<
decltype
(
fLocal
(
std
::
declval
<
LocalPosition
>
()))
>
>
;
PrimaryVariables
integral
=
0.0
;
Scalar
integral
(
0.0
)
;
for
(
const
auto
&
element
:
elements
(
gv
))
{
fLocal
.
bind
(
element
);
...
...
@@ -247,10 +226,9 @@ auto integrateL2Error(const GridView& gv,
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
LocalPosition
=
typename
Element
::
Geometry
::
LocalCoordinate
;
using
PrimaryVariables
=
std
::
decay_t
<
decltype
(
fLocal
(
std
::
declval
<
LocalPosition
>
()))
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
PrimaryVariables
>
;
using
Scalar
=
typename
Impl
::
FieldType
<
std
::
decay_t
<
decltype
(
fLocal
(
std
::
declval
<
LocalPosition
>
()))
>
>
;
PrimaryVariables
l2norm
=
0.0
;
Scalar
l2norm
(
0.0
)
;
for
(
const
auto
&
element
:
elements
(
gv
))
{
fLocal
.
bind
(
element
);
...
...
@@ -261,16 +239,15 @@ auto integrateL2Error(const GridView& gv,
for
(
auto
&&
qp
:
quad
)
{
const
auto
error
=
fLocal
(
qp
.
position
())
-
gLocal
(
qp
.
position
());
auto
value
=
Impl
::
localErrorSqrImpl
(
error
);
value
*=
qp
.
weight
()
*
geometry
.
integrationElement
(
qp
.
position
());
l2norm
+=
value
;
l2norm
+=
(
error
*
error
)
*
qp
.
weight
()
*
geometry
.
integrationElement
(
qp
.
position
());
}
gLocal
.
unbind
();
fLocal
.
unbind
();
}
return
Impl
::
sqrtNorm
(
l2norm
);
using
std
::
sqrt
;
return
sqrt
(
l2norm
);
}
#endif
...
...
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