Skip to content
Snippets Groups Projects
Commit b966f636 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Move headers to namespace Dune

parent 23187aed
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "properscalarincreasingconvexfunction.hh" #include "properscalarincreasingconvexfunction.hh"
template <int dimension, class OuterFunction = TrivialFunction> namespace Dune {
template <int dimension, class OuterFunction = Dune::TrivialFunction>
class MyNonlinearity { class MyNonlinearity {
public: public:
typedef Dune::FieldVector<double, dimension> SmallVector; typedef Dune::FieldVector<double, dimension> SmallVector;
...@@ -52,3 +53,4 @@ class MyNonlinearity { ...@@ -52,3 +53,4 @@ class MyNonlinearity {
private: private:
OuterFunction func_; OuterFunction func_;
}; };
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#ifndef PROPER_SCALAR_INCREASING_CONVEX_FUNCTION_HH #ifndef PROPER_SCALAR_INCREASING_CONVEX_FUNCTION_HH
#define PROPER_SCALAR_INCREASING_CONVEX_FUNCTION_HH #define PROPER_SCALAR_INCREASING_CONVEX_FUNCTION_HH
namespace Dune {
class ProperScalarIncreasingConvexFunction { class ProperScalarIncreasingConvexFunction {
public: public:
virtual double operator()(const double s) const = 0; virtual double operator()(const double s) const = 0;
...@@ -27,5 +28,5 @@ class TrivialFunction : public ProperScalarIncreasingConvexFunction { ...@@ -27,5 +28,5 @@ class TrivialFunction : public ProperScalarIncreasingConvexFunction {
double rightDifferential(const double) const { return 0; } double rightDifferential(const double) const { return 0; }
}; };
}
#endif #endif
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "mynonlinearity.cc" #include "mynonlinearity.cc"
#include "properscalarincreasingconvexfunction.hh" #include "properscalarincreasingconvexfunction.hh"
namespace Dune {
template <int dimension, class Function = TrivialFunction> template <int dimension, class Function = TrivialFunction>
class SampleFunctional { class SampleFunctional {
public: public:
...@@ -139,5 +141,5 @@ void minimise(const Functional J, const typename Functional::SmallVector x, ...@@ -139,5 +141,5 @@ void minimise(const Functional J, const typename Functional::SmallVector x,
corr = descDir; corr = descDir;
corr *= stepsize; corr *= stepsize;
} }
}
#endif #endif
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
template <int dim, class Function> template <int dim, class Function>
void functionTester( void functionTester(
SampleFunctional<dim, Function> J, Dune::SampleFunctional<dim, Function> J,
typename SampleFunctional<dim, Function>::SmallVector &start, size_t runs) { typename Dune::SampleFunctional<dim, Function>::SmallVector &start,
typename SampleFunctional<dim, Function>::SmallVector correction; size_t runs) {
typename Dune::SampleFunctional<dim, Function>::SmallVector correction;
std::cout << "Old value: J(...) = " << J(start) << std::endl; std::cout << "Old value: J(...) = " << J(start) << std::endl;
for (size_t i = 1; i <= runs; ++i) { for (size_t i = 1; i <= runs; ++i) {
minimise(J, start, correction); Dune::minimise(J, start, correction);
start += correction; start += correction;
if (i != runs) if (i != runs)
std::cout << "New value: J(...) = " << J(start) << std::endl; std::cout << "New value: J(...) = " << J(start) << std::endl;
...@@ -25,7 +26,7 @@ void functionTester( ...@@ -25,7 +26,7 @@ void functionTester(
void testSampleFunction() { void testSampleFunction() {
int const dim = 2; int const dim = 2;
typedef SampleFunctional<dim, SampleFunction> SampleFunctional; typedef Dune::SampleFunctional<dim, Dune::SampleFunction> SampleFunctional;
SampleFunctional::SmallMatrix A; SampleFunctional::SmallMatrix A;
A[0][0] = 3; A[0][0] = 3;
...@@ -46,7 +47,7 @@ void testSampleFunction() { ...@@ -46,7 +47,7 @@ void testSampleFunction() {
void testTrivialFunction() { void testTrivialFunction() {
int const dim = 2; int const dim = 2;
typedef SampleFunctional<dim> SampleFunctional; typedef Dune::SampleFunctional<dim> SampleFunctional;
SampleFunctional::SmallMatrix A; SampleFunctional::SmallMatrix A;
A[0][0] = 3; A[0][0] = 3;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment