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
8b343d92
Commit
8b343d92
authored
14 years ago
by
Oliver Sander
Committed by
sander@FU-BERLIN.DE
14 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test mixed second derivative
[[Imported from SVN: r6312]]
parent
c4871290
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unitvectortest.cc
+31
-0
31 additions, 0 deletions
test/unitvectortest.cc
with
31 additions
and
0 deletions
test/unitvectortest.cc
+
31
−
0
View file @
8b343d92
...
...
@@ -23,6 +23,12 @@ double energy(const UnitVector<dim>& a, const FieldVector<double,dim>& b)
return
UnitVector
<
dim
>::
distance
(
a
,
b
)
*
UnitVector
<
dim
>::
distance
(
a
,
b
);
}
template
<
int
dim
>
double
energy
(
const
FieldVector
<
double
,
dim
>&
a
,
const
FieldVector
<
double
,
dim
>&
b
)
{
return
UnitVector
<
dim
>::
distance
(
a
,
b
)
*
UnitVector
<
dim
>::
distance
(
a
,
b
);
}
template
<
int
dim
>
void
testDerivativesOfSquaredDistance
(
const
UnitVector
<
dim
>&
a
,
const
UnitVector
<
dim
>&
b
)
{
...
...
@@ -92,6 +98,31 @@ void testDerivativesOfSquaredDistance(const UnitVector<dim>& a, const UnitVector
FieldMatrix
<
double
,
dim
,
dim
>
d1d2
=
UnitVector
<
dim
>::
secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument
(
a
,
b
);
// finite-difference approximation
FieldMatrix
<
double
,
dim
,
dim
>
d1d2_fd
;
for
(
size_t
i
=
0
;
i
<
dim
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
dim
;
j
++
)
{
FieldVector
<
double
,
dim
>
aPlus
=
a
.
globalCoordinates
();
FieldVector
<
double
,
dim
>
aMinus
=
a
.
globalCoordinates
();
aPlus
[
i
]
+=
eps
;
aMinus
[
i
]
-=
eps
;
FieldVector
<
double
,
dim
>
bPlus
=
b
.
globalCoordinates
();
FieldVector
<
double
,
dim
>
bMinus
=
b
.
globalCoordinates
();
bPlus
[
i
]
+=
eps
;
bMinus
[
i
]
-=
eps
;
d1d2_fd
[
i
][
j
]
=
(
energy
(
aPlus
,
bPlus
)
+
energy
(
aMinus
,
bMinus
)
-
energy
(
aPlus
,
bMinus
)
-
energy
(
aMinus
,
bPlus
))
/
(
4
*
eps
*
eps
);
}
}
std
::
cout
<<
"Analytical:
\n
"
<<
d1d2
<<
std
::
endl
;
std
::
cout
<<
"FD :
\n
"
<<
d1d2_fd
<<
std
::
endl
;
/////////////////////////////////////////////////////////////////////////////////////////////
// Test mixed third derivative with respect to first (once) and second (twice) argument
...
...
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