Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Sander, Oliver
dune-gfe
Commits
b61bc8d9
Commit
b61bc8d9
authored
12 years ago
by
Oliver Sander
Committed by
sander@FU-BERLIN.DE
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implement method 'secondDerivativeOfDistanceSquaredWRTSecondArgument'
Not tested yet. [[Imported from SVN: r9082]]
parent
0d9e0c26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/gfe/hyperbolichalfspacepoint.hh
+59
-17
59 additions, 17 deletions
dune/gfe/hyperbolichalfspacepoint.hh
with
59 additions
and
17 deletions
dune/gfe/hyperbolichalfspacepoint.hh
+
59
−
17
View file @
b61bc8d9
...
...
@@ -54,6 +54,15 @@ class HyperbolicHalfspacePoint
return
2
/
(
1
-
x
*
x
)
-
2
*
x
*
std
::
acos
(
x
)
/
std
::
pow
(
1
-
x
*
x
,
1.5
);
}
/** \brief Compute the second derivative of arccosh^2 without getting unstable for x close to 1 */
static
T
secondDerivativeOfArcCosHSquared
(
const
T
&
x
)
{
const
T
eps
=
1e-4
;
if
(
x
<
1
+
eps
)
{
// regular expression is unstable, use the series expansion instead
return
-
2.0
/
3
+
8
*
(
x
-
1
)
/
15
;
}
else
return
2
/
(
x
*
x
-
1
)
-
2
*
x
*
std
::
acosh
(
x
)
/
std
::
pow
(
x
*
x
-
1
,
1.5
);
}
/** \brief Compute the third derivative of arccos^2 without getting unstable for x close to 1 */
static
T
thirdDerivativeOfArcCosSquared
(
const
T
&
x
)
{
const
T
eps
=
1e-4
;
...
...
@@ -183,29 +192,62 @@ public:
Unlike the distance itself the squared distance is differentiable at zero
*/
static
Dune
::
FieldMatrix
<
T
,
N
,
N
>
secondDerivativeOfDistanceSquaredWRTSecondArgument
(
const
HyperbolicHalfspacePoint
&
p
,
const
HyperbolicHalfspacePoint
&
q
)
{
static
Dune
::
FieldMatrix
<
T
,
N
,
N
>
secondDerivativeOfDistanceSquaredWRTSecondArgument
(
const
HyperbolicHalfspacePoint
&
a
,
const
HyperbolicHalfspacePoint
&
b
)
{
T
sp
=
p
.
data_
*
q
.
data_
;
// abbreviate notation
const
Dune
::
FieldVector
<
T
,
N
>&
p
=
a
.
data_
;
const
Dune
::
FieldVector
<
T
,
N
>&
q
=
b
.
data_
;
Dune
::
FieldVector
<
T
,
N
>
pProjected
=
q
.
projectOntoTangentSpace
(
p
.
globalCoordinates
()
);
T
diffNormSquared
=
(
p
-
q
).
two_norm2
(
);
Dune
::
FieldMatrix
<
T
,
N
,
N
>
A
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
in
t
j
=
0
;
j
<
N
;
j
++
)
A
[
i
][
j
]
=
pProjected
[
i
]
*
pProjected
[
j
]
;
// Compute first derivative of F
Dune
::
FieldVector
<
T
,
N
>
dFdq
;
for
(
size_
t
i
=
0
;
i
<
N
-
1
;
i
++
)
dFdq
[
i
]
=
(
b
.
data_
[
i
]
-
a
.
data_
[
i
]
)
/
(
a
.
data_
[
N
-
1
]
*
b
.
data_
[
N
-
1
])
;
A
*=
secondDerivativeOfArcCosSquared
(
sp
);
dFdq
[
N
-
1
]
=
-
diffNormSquared
/
(
2
*
a
.
data_
[
N
-
1
]
*
b
.
data_
[
N
-
1
]
*
b
.
data_
[
N
-
1
])
-
(
a
.
data_
[
N
-
1
]
-
b
.
data_
[
N
-
1
])
/
(
a
.
data_
[
N
-
1
]
*
b
.
data_
[
N
-
1
]
);
// Compute matrix B (see notes)
Dune
::
FieldMatrix
<
T
,
N
,
N
>
Pq
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
Pq
[
i
][
j
]
=
(
i
==
j
)
-
q
.
data_
[
i
]
*
q
.
data_
[
j
];
// Bring it all together
A
.
axpy
(
-
1
*
derivativeOfArcCosSquared
(
sp
)
*
sp
,
Pq
);
// Compute second derivatives of F
Dune
::
FieldMatrix
<
T
,
N
,
N
>
dFdqdq
;
for
(
size_t
i
=
0
;
i
<
N
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
N
;
j
++
)
{
if
(
i
!=
N
-
1
and
j
!=
N
-
1
)
{
dFdqdq
[
i
][
j
]
=
(
i
==
j
)
/
(
p
[
N
-
1
]
*
q
[
N
-
1
]);
}
else
if
(
i
!=
N
-
1
and
j
==
N
-
1
)
{
dFdqdq
[
i
][
j
]
=
(
p
[
i
]
-
q
[
i
])
/
(
p
[
N
-
1
]
*
q
[
N
-
1
]
*
q
[
N
-
1
]);
}
else
if
(
i
!=
N
-
1
and
j
==
N
-
1
)
{
dFdqdq
[
i
][
j
]
=
(
p
[
j
]
-
q
[
j
])
/
(
p
[
N
-
1
]
*
q
[
N
-
1
]
*
q
[
N
-
1
]);
}
else
if
(
i
==
N
-
1
and
j
==
N
-
1
)
{
dFdqdq
[
i
][
j
]
=
1
/
(
q
[
N
-
1
]
*
q
[
N
-
1
])
+
(
p
[
N
-
1
]
*
q
[
N
-
1
])
/
(
p
[
N
-
1
]
*
q
[
N
-
1
]
*
q
[
N
-
1
])
+
diffNormSquared
/
(
p
[
N
-
1
]
*
q
[
N
-
1
]
*
q
[
N
-
1
]
*
q
[
N
-
1
]);
}
}
}
//
T
x
=
1
+
diffNormSquared
/
(
2
*
p
[
N
-
1
]
*
q
[
N
-
1
]);
T
alphaPrime
=
derivativeOfArcCosHSquared
(
x
);
T
alphaPrimePrime
=
secondDerivativeOfArcCosHSquared
(
x
);
return
A
;
// Sum it all together
Dune
::
FieldMatrix
<
T
,
N
,
N
>
result
;
for
(
size_t
i
=
0
;
i
<
N
;
i
++
)
for
(
size_t
j
=
0
;
j
<
N
;
j
++
)
result
[
i
][
j
]
=
alphaPrimePrime
*
dFdq
[
i
]
*
dFdq
[
j
]
+
alphaPrime
*
dFdqdq
[
i
][
j
];
return
result
;
}
/** \brief Compute the mixed second derivate \partial d^2 / \partial da db
...
...
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