Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
684c4c19
Commit
684c4c19
authored
Jun 03, 2019
by
Dennis Gläser
Committed by
Timo Koch
Jun 17, 2019
Browse files
[integrate] do not do component-wise error squares
parent
5d5d7e68
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/common/integrate.hh
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
...
...
Write
Preview
Supports
Markdown
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