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
c32fa788
Commit
c32fa788
authored
12 years ago
by
Elias Pipping
Committed by
Elias Pipping
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Kinks: New Function and test
parent
174cfeb4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Makefile.am
+2
-0
2 additions, 0 deletions
src/Makefile.am
src/test-gradient-kinks.cc
+57
-0
57 additions, 0 deletions
src/test-gradient-kinks.cc
src/test-gradient-method-nicefunction.hh
+40
-0
40 additions, 0 deletions
src/test-gradient-method-nicefunction.hh
with
99 additions
and
0 deletions
src/Makefile.am
+
2
−
0
View file @
c32fa788
...
@@ -4,6 +4,7 @@ check_PROGRAMS = \
...
@@ -4,6 +4,7 @@ check_PROGRAMS = \
test-gradient-horrible
\
test-gradient-horrible
\
test-gradient-horrible-logarithmic
\
test-gradient-horrible-logarithmic
\
test-gradient-identity
\
test-gradient-identity
\
test-gradient-kinks
\
test-gradient-parabola
\
test-gradient-parabola
\
test-gradient-sample
\
test-gradient-sample
\
test-gradient-sample-3d
\
test-gradient-sample-3d
\
...
@@ -21,6 +22,7 @@ test_circle_10_CPPFLAGS = $(AM_CPPFLAGS) -DDUNE_TECTONIC_TEST
...
@@ -21,6 +22,7 @@ test_circle_10_CPPFLAGS = $(AM_CPPFLAGS) -DDUNE_TECTONIC_TEST
test_gradient_horrible_SOURCES
=
test-gradient-horrible.cc
test_gradient_horrible_SOURCES
=
test-gradient-horrible.cc
test_gradient_horrible_logarithmic_SOURCES
=
test-gradient-horrible-logarithmic.cc
test_gradient_horrible_logarithmic_SOURCES
=
test-gradient-horrible-logarithmic.cc
test_gradient_identity_SOURCES
=
test-gradient-identity.cc
test_gradient_identity_SOURCES
=
test-gradient-identity.cc
test_gradient_kinks_SOURCES
=
test-gradient-kinks.cc
test_gradient_parabola_SOURCES
=
test-gradient-parabola.cc
test_gradient_parabola_SOURCES
=
test-gradient-parabola.cc
test_gradient_sample_SOURCES
=
test-gradient-sample.cc
test_gradient_sample_SOURCES
=
test-gradient-sample.cc
test_gradient_sample_3d_SOURCES
=
test-gradient-sample-3d.cc
test_gradient_sample_3d_SOURCES
=
test-gradient-sample-3d.cc
...
...
This diff is collapsed.
Click to expand it.
src/test-gradient-kinks.cc
0 → 100644
+
57
−
0
View file @
c32fa788
/* Checks if the algorithm converges regardless of where it starts */
#ifdef HAVE_CONFIG_H
#include
"config.h"
#endif
#include
<cassert>
#include
<dune/common/shared_ptr.hh>
#include
<dune/tectonic/ellipticenergy.hh>
#include
"test-gradient-method-nicefunction.hh"
#include
"test-gradient-method-helper.hh"
int
main
()
{
int
const
dim
=
2
;
typedef
Dune
::
EllipticEnergy
<
dim
>
Functional
;
typedef
Functional
::
SmallMatrix
SmallMatrix
;
typedef
Functional
::
SmallVector
SmallVector
;
SmallMatrix
const
A
=
{
{
4
,
1.5
},
{
1.5
,
3
}
};
SmallVector
const
b
=
{
-
8
,
14
};
auto
const
f
=
Dune
::
make_shared
<
Dune
::
ThreeKinkFunction
const
>
();
auto
const
phi
=
Dune
::
make_shared
<
Functional
::
NonlinearityType
const
>
(
f
);
Functional
const
J
(
A
,
b
,
phi
);
size_t
runs
=
5
;
double
ret1
;
{
SmallVector
start
=
{
17
,
34
};
ret1
=
functionTester
(
J
,
start
,
runs
);
}
double
ret2
;
{
SmallVector
start
=
{
1
,
0
};
ret2
=
functionTester
(
J
,
start
,
runs
);
}
assert
(
std
::
abs
(
ret1
-
ret2
)
<
1e-5
);
double
ret3
;
{
SmallVector
start
=
{
0
,
1
};
ret3
=
functionTester
(
J
,
start
,
runs
);
}
assert
(
std
::
abs
(
ret1
-
ret3
)
<
1e-5
);
double
ret4
;
{
SmallVector
start
=
{
0
,
0
};
ret4
=
functionTester
(
J
,
start
,
runs
);
}
assert
(
std
::
abs
(
ret1
-
ret4
)
<
1e-5
);
}
This diff is collapsed.
Click to expand it.
src/test-gradient-method-nicefunction.hh
+
40
−
0
View file @
c32fa788
...
@@ -129,5 +129,45 @@ class HorribleFunctionLogarithmic : public MyFunction {
...
@@ -129,5 +129,45 @@ class HorribleFunctionLogarithmic : public MyFunction {
return
std
::
log
(
c
+
1
);
return
std
::
log
(
c
+
1
);
}
}
};
};
class
ThreeKinkFunction
:
public
MyFunction
{
private:
std
::
vector
<
double
>
kinks
=
{
5
,
10
,
15
};
public
:
double
virtual
evaluate
(
double
x
)
const
{
double
acc
=
0
;
double
last_kink
=
0
;
int
i
;
for
(
i
=
0
;
i
<
kinks
.
size
();
++
i
)
{
if
(
x
<=
kinks
[
i
])
break
;
acc
+=
(
i
+
1
)
*
(
kinks
[
i
]
-
last_kink
);
last_kink
=
kinks
[
i
];
}
return
acc
+
(
i
+
1
)
*
(
x
-
last_kink
);
}
double
virtual
leftDifferential
(
double
x
)
const
{
if
(
x
<=
5
)
return
1
;
if
(
x
<=
10
)
return
2
;
if
(
x
<=
15
)
return
3
;
return
4
;
}
double
virtual
rightDifferential
(
double
x
)
const
{
if
(
x
<
5
)
return
1
;
if
(
x
<
10
)
return
2
;
if
(
x
<
15
)
return
3
;
return
4
;
}
};
}
}
#endif
#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