Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ag-ohlberger
dune-community
dune-gdt
Commits
0087e17b
Commit
0087e17b
authored
6 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[operators] implement automatic dampening in newton
parent
a32f0491
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/gdt/operators/interfaces.hh
+26
-9
26 additions, 9 deletions
dune/gdt/operators/interfaces.hh
with
26 additions
and
9 deletions
dune/gdt/operators/interfaces.hh
+
26
−
9
View file @
0087e17b
...
@@ -375,7 +375,7 @@ invert_options(some_type).get<std::string>("type") == some_type
...
@@ -375,7 +375,7 @@ invert_options(some_type).get<std::string>("type") == some_type
virtual
XT
::
Common
::
Configuration
invert_options
(
const
std
::
string
&
type
)
const
virtual
XT
::
Common
::
Configuration
invert_options
(
const
std
::
string
&
type
)
const
{
{
if
(
type
==
"newton"
)
{
if
(
type
==
"newton"
)
{
return
{{
"type"
,
type
},
{
"precision"
,
"1e-7"
},
{
"max_iter"
,
"100"
},
{
"
lambda
"
,
"1
.
"
}};
return
{{
"type"
,
type
},
{
"precision"
,
"1e-7"
},
{
"max_iter"
,
"100"
},
{
"
max_dampening_iter
"
,
"1
000
"
}};
}
else
}
else
DUNE_THROW
(
Exceptions
::
operator_error
,
"type = "
<<
type
);
DUNE_THROW
(
Exceptions
::
operator_error
,
"type = "
<<
type
);
}
// ... invert_options(...)
}
// ... invert_options(...)
...
@@ -399,6 +399,7 @@ invert_options(some_type).get<std::string>("type") == some_type
...
@@ -399,6 +399,7 @@ invert_options(some_type).get<std::string>("type") == some_type
auto
residual_op
=
*
this
-
range
;
auto
residual_op
=
*
this
-
range
;
auto
residual
=
range
.
copy
();
auto
residual
=
range
.
copy
();
auto
update
=
source
.
copy
();
auto
update
=
source
.
copy
();
auto
candidate
=
source
.
copy
();
// one matrix for all jacobians
// one matrix for all jacobians
MatrixOperatorType
jacobian_op
(
this
->
source_space
().
grid_view
(),
MatrixOperatorType
jacobian_op
(
this
->
source_space
().
grid_view
(),
this
->
source_space
(),
this
->
source_space
(),
...
@@ -408,7 +409,7 @@ invert_options(some_type).get<std::string>("type") == some_type
...
@@ -408,7 +409,7 @@ invert_options(some_type).get<std::string>("type") == some_type
XT
::
LA
::
Solver
<
M
>
jacobian_solver
(
jacobian_op
.
matrix
());
XT
::
LA
::
Solver
<
M
>
jacobian_solver
(
jacobian_op
.
matrix
());
const
auto
precision
=
opts
.
get
(
"precision"
,
default_opts
.
get
<
double
>
(
"precision"
));
const
auto
precision
=
opts
.
get
(
"precision"
,
default_opts
.
get
<
double
>
(
"precision"
));
const
auto
max_iter
=
opts
.
get
(
"max_iter"
,
default_opts
.
get
<
size_t
>
(
"max_iter"
));
const
auto
max_iter
=
opts
.
get
(
"max_iter"
,
default_opts
.
get
<
size_t
>
(
"max_iter"
));
const
auto
lambda
=
opts
.
get
(
"lambda
"
,
default_opts
.
get
<
double
>
(
"lambda
"
));
const
auto
max_dampening_iter
=
opts
.
get
(
"max_dampening_iter
"
,
default_opts
.
get
<
size_t
>
(
"max_iter
"
));
size_t
l
=
0
;
size_t
l
=
0
;
Timer
timer
;
Timer
timer
;
while
(
true
)
{
while
(
true
)
{
...
@@ -423,8 +424,8 @@ invert_options(some_type).get<std::string>("type") == some_type
...
@@ -423,8 +424,8 @@ invert_options(some_type).get<std::string>("type") == some_type
}
}
DUNE_THROW_IF
(
l
>=
max_iter
,
DUNE_THROW_IF
(
l
>=
max_iter
,
Exceptions
::
operator_error
,
Exceptions
::
operator_error
,
"max iterations
"
<<
max_iter
<<
"
reached!
\n
|residual|_l2 = "
<<
res
<<
"
\n
opts:
\n
"
"max iterations reached!
\n
|residual|_l2 = "
<<
res
<<
"
\n
opts:
\n
"
<<
opts
);
<<
opts
);
logger
.
debug
()
<<
" computing jacobi matrix ... "
<<
std
::
flush
;
logger
.
debug
()
<<
" computing jacobi matrix ... "
<<
std
::
flush
;
timer
.
reset
();
timer
.
reset
();
jacobian_op
.
matrix
()
*=
0.
;
jacobian_op
.
matrix
()
*=
0.
;
...
@@ -440,12 +441,28 @@ invert_options(some_type).get<std::string>("type") == some_type
...
@@ -440,12 +441,28 @@ invert_options(some_type).get<std::string>("type") == some_type
residual
,
residual
,
update
,
update
,
{{
"type"
,
jacobian_solver
.
types
().
at
(
0
)},
{
"precision"
,
XT
::
Common
::
to_string
(
0.1
*
precision
)}});
{{
"type"
,
jacobian_solver
.
types
().
at
(
0
)},
{
"precision"
,
XT
::
Common
::
to_string
(
0.1
*
precision
)}});
logger
.
debug
()
<<
"took "
<<
timer
.
elapsed
()
<<
"s"
logger
.
debug
()
<<
"took "
<<
timer
.
elapsed
()
<<
"s
\n
computing update ... "
<<
std
::
flush
;
<<
"
\n
"
<<
" computing update ... "
<<
std
::
flush
;
timer
.
reset
();
timer
.
reset
();
source
+=
update
*
lambda
;
// try the automatic dampening strategy proposed in [DF2015, Sec. 8.4.4.1, p. 432]
logger
.
debug
()
<<
"took "
<<
timer
.
elapsed
()
<<
"s"
<<
std
::
endl
;
size_t
k
=
0
;
auto
candidate_res
=
2
*
res
;
// any number such that we enter the while loop at least once
double
lambda
=
1
;
while
(
!
(
candidate_res
/
res
<
1
))
{
DUNE_THROW_IF
(
k
>=
max_dampening_iter
,
Exceptions
::
operator_error
,
"max iterations reached when trying to compute automatic dampening!
\n
|residual|_l2 = "
<<
res
<<
"
\n
l = "
<<
l
<<
"
\n
opts:
\n
"
<<
opts
);
candidate
=
source
+
update
*
lambda
;
residual_op
.
apply
(
candidate
,
residual
,
param
);
candidate_res
=
residual
.
l2_norm
();
lambda
/=
2
;
k
+=
1
;
}
source
=
candidate
;
logger
.
debug
()
<<
"took "
<<
timer
.
elapsed
()
<<
"s and a dampening of "
<<
2
*
lambda
<<
std
::
endl
;
l
+=
1
;
l
+=
1
;
}
}
}
else
}
else
...
...
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