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
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
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
agnumpde
dune-tectonic
Commits
9cfd8843
Commit
9cfd8843
authored
11 years ago
by
Elias Pipping
Committed by
Elias Pipping
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
SmoothesNorm -> SmallestPositivePoint
parent
53028a9c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/tectonic/frictionpotential.hh
+8
-6
8 additions, 6 deletions
dune/tectonic/frictionpotential.hh
dune/tectonic/localfriction.hh
+13
-11
13 additions, 11 deletions
dune/tectonic/localfriction.hh
with
21 additions
and
17 deletions
dune/tectonic/frictionpotential.hh
+
8
−
6
View file @
9cfd8843
...
...
@@ -18,15 +18,15 @@ class FrictionPotentialWrapper {
double
virtual
differential
(
double
s
)
const
=
0
;
double
virtual
second_deriv
(
double
x
)
const
=
0
;
double
virtual
regularity
(
double
s
)
const
=
0
;
// Whether H(|.|) is smooth at zero
bool
virtual
smoothesNorm
()
const
{
return
false
;
}
double
virtual
evaluate
(
double
x
)
const
{
DUNE_THROW
(
NotImplemented
,
"evaluation not implemented"
);
}
// Between 0 and this point, the function is constantly zero (and
// thus so are all derivatives)
double
virtual
smallestPositivePoint
()
const
=
0
;
};
// phi(V) = V log(V/V_m) - V + V_m if V >= V_m
...
...
@@ -87,7 +87,7 @@ class FrictionPotential : public FrictionPotentialWrapper {
return
std
::
abs
(
second_deriv
(
V
));
}
bool
virtual
sm
oothesNorm
()
const
{
return
true
;
}
double
virtual
sm
allestPositivePoint
()
const
{
return
V_m
;
}
private
:
double
const
coefficientProduct
;
...
...
@@ -104,7 +104,9 @@ class TrivialFunction : public FrictionPotentialWrapper {
double
virtual
regularity
(
double
)
const
{
return
0
;
}
bool
virtual
smoothesNorm
()
const
{
return
true
;
}
double
virtual
smallestPositivePoint
()
const
{
return
std
::
numeric_limits
<
double
>::
infinity
();
}
};
}
#endif
This diff is collapsed.
Click to expand it.
dune/tectonic/localfriction.hh
+
13
−
11
View file @
9cfd8843
...
...
@@ -18,16 +18,16 @@ template <int dimension> class LocalFriction {
using
VectorType
=
FieldVector
<
double
,
dimension
>
;
using
MatrixType
=
FieldMatrix
<
double
,
dimension
,
dimension
>
;
LocalFriction
(
shared_ptr
<
FrictionPotentialWrapper
const
>
func
)
:
func
(
func
)
{}
LocalFriction
(
shared_ptr
<
FrictionPotentialWrapper
const
>
func
)
:
func
(
func
),
smp
(
func
->
smallestPositivePoint
())
{}
double
operator
()(
VectorType
const
&
x
)
const
{
return
func
->
evaluate
(
x
.
two_norm
());
}
double
regularity
(
VectorType
const
&
x
)
const
{
if
(
!
func
->
smoothesNorm
()
&&
x
.
two_norm
()
<
1e-14
)
// TODO: Make this
// controllable
// (truncationRadius?)
double
const
xnorm
=
x
.
two_norm
();
if
(
xnorm
<
1e-14
&&
xnorm
>=
smp
)
return
std
::
numeric_limits
<
double
>::
infinity
();
return
func
->
regularity
(
x
.
two_norm
());
...
...
@@ -37,12 +37,11 @@ template <int dimension> class LocalFriction {
// u and v are assumed to be non-zero
void
directionalSubDiff
(
VectorType
const
&
x
,
VectorType
const
&
v
,
Interval
<
double
>
&
D
)
const
{
if
(
x
.
two_norm
()
==
0
)
{
D
[
0
]
=
D
[
1
]
=
func
->
differential
(
0
)
*
v
.
two_norm
();
return
;
}
double
const
un
=
x
.
two_norm
();
D
[
0
]
=
D
[
1
]
=
func
->
differential
(
un
)
*
(
x
*
v
)
/
un
;
double
const
xnorm
=
x
.
two_norm
();
if
(
xnorm
<
smp
)
D
[
0
]
=
D
[
1
]
=
0
;
else
D
[
0
]
=
D
[
1
]
=
func
->
differential
(
xnorm
)
/
xnorm
*
(
x
*
v
);
}
/** Formula for the derivative:
...
...
@@ -64,6 +63,8 @@ template <int dimension> class LocalFriction {
void
addHessian
(
VectorType
const
&
x
,
MatrixType
&
A
)
const
{
double
const
xnorm2
=
x
.
two_norm2
();
double
const
xnorm
=
std
::
sqrt
(
xnorm2
);
if
(
xnorm
<
smp
)
return
;
double
const
xnorm3
=
xnorm
*
xnorm2
;
double
const
H1
=
func
->
differential
(
xnorm
);
...
...
@@ -110,7 +111,7 @@ template <int dimension> class LocalFriction {
void
addGradient
(
VectorType
const
&
x
,
VectorType
&
y
)
const
{
double
const
xnorm
=
x
.
two_norm
();
if
(
xnorm
==
0
or
std
::
isinf
(
func
->
regularity
(
xnorm
)))
if
(
std
::
isinf
(
func
->
regularity
(
xnorm
)))
return
;
y
.
axpy
(
func
->
differential
(
xnorm
)
/
xnorm
,
x
);
...
...
@@ -129,6 +130,7 @@ template <int dimension> class LocalFriction {
private
:
shared_ptr
<
FrictionPotentialWrapper
const
>
const
func
;
double
const
smp
;
};
}
#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