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
3c12c7f7
Commit
3c12c7f7
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Externalise comparison of lambertW functions
parent
2ab958ad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/compute_state.cc
+22
-0
22 additions, 0 deletions
src/compute_state.cc
src/compute_state.hh
+1
-6
1 addition, 6 deletions
src/compute_state.hh
src/one-body-sample.cc
+2
-40
2 additions, 40 deletions
src/one-body-sample.cc
with
25 additions
and
46 deletions
src/compute_state.cc
+
22
−
0
View file @
3c12c7f7
#include
<cassert>
#include
"LambertW.h"
#include
"LambertW.h"
#include
<gsl/gsl_sf_lambert.h>
#include
<gsl/gsl_sf_lambert.h>
...
@@ -51,3 +53,23 @@ double compute_state_update_lambert_gsl(double h, double unorm, double L,
...
@@ -51,3 +53,23 @@ double compute_state_update_lambert_gsl(double h, double unorm, double L,
double
const
rhs
=
unorm
/
L
-
old_state
;
double
const
rhs
=
unorm
/
L
-
old_state
;
return
gsl_sf_lambert_W0
(
h
*
std
::
exp
(
rhs
))
-
rhs
;
return
gsl_sf_lambert_W0
(
h
*
std
::
exp
(
rhs
))
-
rhs
;
}
}
double
compute_state_update
(
double
h
,
double
unorm
,
double
L
,
double
old_state
)
{
double
ret1
=
compute_state_update_bisection
(
h
,
unorm
,
L
,
old_state
);
assert
(
std
::
abs
(
1.0
/
h
*
ret1
-
(
old_state
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret1
))
<
1e-10
);
double
ret2
=
compute_state_update_lambert
(
h
,
unorm
,
L
,
old_state
);
assert
(
std
::
abs
(
1.0
/
h
*
ret2
-
(
old_state
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret2
))
<
1e-10
);
double
ret3
=
compute_state_update_lambert_gsl
(
h
,
unorm
,
L
,
old_state
);
assert
(
std
::
abs
(
1.0
/
h
*
ret3
-
(
old_state
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret3
))
<
1e-10
);
assert
(
std
::
abs
(
ret1
-
ret2
)
<
1e-14
);
assert
(
std
::
abs
(
ret1
-
ret3
)
<
1e-14
);
return
ret1
;
}
This diff is collapsed.
Click to expand it.
src/compute_state.hh
+
1
−
6
View file @
3c12c7f7
#ifndef COMPUTE_STATE_HH
#ifndef COMPUTE_STATE_HH
#define COMPUTE_STATE_HH
#define COMPUTE_STATE_HH
double
compute_state_update_bisection
(
double
h
,
double
unorm
,
double
L
,
double
compute_state_update
(
double
h
,
double
unorm
,
double
L
,
double
old_state
);
double
old_state
);
double
compute_state_update_lambert
(
double
h
,
double
unorm
,
double
L
,
double
old_state
);
double
compute_state_update_lambert_gsl
(
double
h
,
double
unorm
,
double
L
,
double
old_state
);
#endif
#endif
This diff is collapsed.
Click to expand it.
src/one-body-sample.cc
+
2
−
40
View file @
3c12c7f7
...
@@ -349,26 +349,7 @@ int main(int argc, char *argv[]) {
...
@@ -349,26 +349,7 @@ int main(int argc, char *argv[]) {
double
const
L
=
parset
.
get
<
double
>
(
"boundary.friction.ruina.L"
);
double
const
L
=
parset
.
get
<
double
>
(
"boundary.friction.ruina.L"
);
double
const
unorm
=
u4_diff
[
i
].
two_norm
();
double
const
unorm
=
u4_diff
[
i
].
two_norm
();
double
ret1
=
(
*
s4_new
)[
i
][
0
]
=
compute_state_update
(
h
,
unorm
,
L
,
s4_old
[
i
][
0
]);
compute_state_update_bisection
(
h
,
unorm
,
L
,
s4_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret1
-
(
s4_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret1
))
<
1e-10
);
double
ret2
=
compute_state_update_lambert
(
h
,
unorm
,
L
,
s4_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret2
-
(
s4_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret2
))
<
1e-10
);
double
ret3
=
compute_state_update_lambert_gsl
(
h
,
unorm
,
L
,
s4_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret3
-
(
s4_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret3
))
<
1e-10
);
assert
(
std
::
abs
(
ret1
-
ret2
)
<
1e-14
);
assert
(
std
::
abs
(
ret1
-
ret3
)
<
1e-14
);
assert
(
std
::
abs
(
ret2
-
ret3
)
<
1e-14
);
(
*
s4_new
)[
i
][
0
]
=
ret1
;
}
}
}
}
}
}
...
@@ -421,26 +402,7 @@ int main(int argc, char *argv[]) {
...
@@ -421,26 +402,7 @@ int main(int argc, char *argv[]) {
double
const
L
=
parset
.
get
<
double
>
(
"boundary.friction.ruina.L"
);
double
const
L
=
parset
.
get
<
double
>
(
"boundary.friction.ruina.L"
);
double
const
unorm
=
u5_diff
[
i
].
two_norm
();
double
const
unorm
=
u5_diff
[
i
].
two_norm
();
double
ret1
=
(
*
s5_new
)[
i
][
0
]
=
compute_state_update
(
h
,
unorm
,
L
,
s5_old
[
i
][
0
]);
compute_state_update_bisection
(
h
,
unorm
,
L
,
s5_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret1
-
(
s5_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret1
))
<
1e-12
);
double
ret2
=
compute_state_update_lambert
(
h
,
unorm
,
L
,
s5_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret2
-
(
s5_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret2
))
<
1e-12
);
double
ret3
=
compute_state_update_lambert_gsl
(
h
,
unorm
,
L
,
s4_old
[
i
][
0
]);
assert
(
std
::
abs
(
1.0
/
h
*
ret3
-
(
s4_old
[
i
]
-
unorm
/
L
)
/
h
-
std
::
exp
(
-
ret3
))
<
1e-10
);
assert
(
std
::
abs
(
ret1
-
ret2
)
<
1e-14
);
assert
(
std
::
abs
(
ret1
-
ret3
)
<
1e-14
);
assert
(
std
::
abs
(
ret2
-
ret3
)
<
1e-14
);
(
*
s5_new
)[
i
][
0
]
=
ret1
;
}
}
}
}
}
}
...
...
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