Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
podlesny
dune-tectonic
Commits
bb8ffa36
Commit
bb8ffa36
authored
12 years ago
by
Elias Pipping
Committed by
Elias Pipping
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Be smarter about damping
parent
cc41c309
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/one-body-sample.cc
+22
-6
22 additions, 6 deletions
src/one-body-sample.cc
src/one-body-sample.parset
+2
-1
2 additions, 1 deletion
src/one-body-sample.parset
with
24 additions
and
7 deletions
src/one-body-sample.cc
+
22
−
6
View file @
bb8ffa36
...
@@ -134,6 +134,13 @@ template <class FunctionMap> void initPython(FunctionMap &functions) {
...
@@ -134,6 +134,13 @@ template <class FunctionMap> void initPython(FunctionMap &functions) {
.
toC
<
typename
FunctionMap
::
Base
>
(
functions
);
.
toC
<
typename
FunctionMap
::
Base
>
(
functions
);
}
}
template
<
class
VectorType
>
double
diff_two_norm
(
VectorType
const
&
v1
,
VectorType
const
&
v2
)
{
VectorType
tmp
=
v1
;
tmp
-=
v2
;
return
tmp
.
two_norm
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
try
{
Dune
::
Timer
timer
;
Dune
::
Timer
timer
;
...
@@ -343,11 +350,12 @@ int main(int argc, char *argv[]) {
...
@@ -343,11 +350,12 @@ int main(int argc, char *argv[]) {
};
};
VectorType
ud
=
ud_initial
;
VectorType
ud
=
ud_initial
;
SingletonVectorType
alpha
=
alpha_initial
;
auto
const
state_fpi_max
=
auto
const
state_fpi_max
=
parset
.
get
<
size_t
>
(
"solver.tnnmg.fixed_point_iterations"
);
parset
.
get
<
size_t
>
(
"solver.tnnmg.fixed_point_iterations"
);
for
(
size_t
run
=
1
;
run
<=
timesteps
;
++
run
)
{
for
(
size_t
run
=
1
;
run
<=
timesteps
;
++
run
)
{
VectorType
u
;
VectorType
u
;
SingletonVectorType
alpha
;
double
lastCorrection
;
stateUpdater
->
nextTimeStep
();
stateUpdater
->
nextTimeStep
();
timeSteppingScheme
->
nextTimeStep
();
timeSteppingScheme
->
nextTimeStep
();
...
@@ -393,15 +401,23 @@ int main(int argc, char *argv[]) {
...
@@ -393,15 +401,23 @@ int main(int argc, char *argv[]) {
double
const
fixedPointTolerance
=
double
const
fixedPointTolerance
=
parset
.
get
<
double
>
(
"solver.tnnmg.fixed_point_tolerance"
);
parset
.
get
<
double
>
(
"solver.tnnmg.fixed_point_tolerance"
);
double
const
damping
=
parset
.
get
<
double
>
(
"solver.damping"
);
double
const
damping
=
parset
.
get
<
double
>
(
"solver.damping"
);
double
const
minimalCorrectionReduction
=
parset
.
get
<
double
>
(
"solver.minimal_correction_reduction"
);
for
(
size_t
state_fpi
=
1
;
state_fpi
<=
state_fpi_max
;
++
state_fpi
)
{
for
(
size_t
state_fpi
=
1
;
state_fpi
<=
state_fpi_max
;
++
state_fpi
)
{
stateUpdater
->
solve
(
ud
);
stateUpdater
->
solve
(
ud
);
if
(
state_fpi
==
1
)
{
stateUpdater
->
extractState
(
alpha
);
else
{
SingletonVectorType
computed_state
;
SingletonVectorType
computed_state
;
stateUpdater
->
extractState
(
computed_state
);
stateUpdater
->
extractState
(
computed_state
);
alpha
*=
damping
;
double
const
correction
=
diff_two_norm
(
computed_state
,
alpha
);
alpha
.
axpy
(
1.0
-
damping
,
computed_state
);
if
(
state_fpi
<=
2
// Let the first two steps pass through unchanged
||
correction
<
minimalCorrectionReduction
*
lastCorrection
)
alpha
=
computed_state
;
else
{
alpha
*=
damping
;
alpha
.
axpy
(
1.0
-
damping
,
computed_state
);
}
lastCorrection
=
correction
;
}
}
solveDisplacementProblem
(
problem_iterate
,
alpha
);
solveDisplacementProblem
(
problem_iterate
,
alpha
);
...
...
This diff is collapsed.
Click to expand it.
src/one-body-sample.parset
+
2
−
1
View file @
bb8ffa36
...
@@ -23,7 +23,8 @@ width = 5
...
@@ -23,7 +23,8 @@ width = 5
[
solver
]
[
solver
]
tolerance
=
1
e
-
10
tolerance
=
1
e
-
10
damping
=
0
.
0
damping
=
0
.
5
minimal_correction_reduction
=
0
.
5
[
solver
.
tnnmg
]
[
solver
.
tnnmg
]
maxiterations
=
1000000
maxiterations
=
1000000
...
...
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