diff --git a/dune/tectonic/ellipticenergy.hh b/dune/tectonic/ellipticenergy.hh index 31551ad5fe646c3b6ebf1c0e83758ac69585e391..32319aefaa83f65a6cd58cbdef0a34c7ac65b484 100644 --- a/dune/tectonic/ellipticenergy.hh +++ b/dune/tectonic/ellipticenergy.hh @@ -8,7 +8,7 @@ #include <dune/fufem/interval.hh> #include <dune/fufem/arithmetic.hh> -#include "localnonlinearity.hh" +#include "localfriction.hh" namespace Dune { template <int dim> class EllipticEnergy { @@ -16,14 +16,12 @@ template <int dim> class EllipticEnergy { using SmallVector = FieldVector<double, dim>; using SmallMatrix = FieldMatrix<double, dim, dim>; - using NonlinearityType = LocalNonlinearity<dim>; + using NonlinearityType = LocalFriction<dim>; EllipticEnergy(SmallMatrix const &A, SmallVector const &b, shared_ptr<NonlinearityType const> phi, int ignore = dim) : A(A), b(b), phi(phi), ignore(ignore) {} - std::vector<double> const &get_kinks() const { return phi->get_kinks(); } - double operator()(SmallVector const &v) const { SmallVector y(0); Arithmetic::addProduct(y, 0.5, A, v); diff --git a/dune/tectonic/frictionpotential.hh b/dune/tectonic/frictionpotential.hh index d01659d10ff8a84c26f23e48a44f8bc546ed3d49..d542c67043000cd362e59f5c6d3272107d044656 100644 --- a/dune/tectonic/frictionpotential.hh +++ b/dune/tectonic/frictionpotential.hh @@ -13,17 +13,7 @@ namespace Dune { class FrictionPotentialWrapper { -protected: - FrictionPotentialWrapper(std::vector<double> const &_kinks) : kinks(_kinks) {} - -private: - std::vector<double> const kinks; - public: - std::vector<double> const &get_kinks() const { return kinks; } - - FrictionPotentialWrapper() : kinks() {} - virtual ~FrictionPotentialWrapper() {} double virtual leftDifferential(double s) const = 0; @@ -112,8 +102,6 @@ class FrictionPotential : public FrictionPotentialWrapper { class TrivialFunction : public FrictionPotentialWrapper { public: - TrivialFunction() : FrictionPotentialWrapper() {} - double virtual evaluate(double) const { return 0; } double virtual leftDifferential(double) const { return 0; } diff --git a/dune/tectonic/globalnonlinearity.hh b/dune/tectonic/globalnonlinearity.hh index 38a7e4d8420fa34f2754e1e184002bff81eaad95..0a1c53dc40ae75521d155e4b67efbe61bdc77022 100644 --- a/dune/tectonic/globalnonlinearity.hh +++ b/dune/tectonic/globalnonlinearity.hh @@ -9,7 +9,7 @@ #include <dune/istl/matrixindexset.hh> #include "frictionpotential.hh" -#include "localnonlinearity.hh" +#include "localfriction.hh" namespace Dune { template <class MatrixTypeTEMPLATE, class VectorTypeTEMPLATE> @@ -31,7 +31,7 @@ class GlobalNonlinearity { /* Return a restriction of the outer function to the i'th node. */ - virtual shared_ptr<LocalNonlinearity<dim> const> restriction(int i) const = 0; + virtual shared_ptr<LocalFriction<dim> const> restriction(int i) const = 0; void addHessian(VectorType const &v, MatrixType &hessian) const { for (size_t i = 0; i < v.size(); ++i) { diff --git a/dune/tectonic/globalruinanonlinearity.hh b/dune/tectonic/globalruinanonlinearity.hh index 0d9350c0a9b59cf20b587d2f0dda49133bee0eec..19b3e7dcb2074d323faa00f6b8178bc4d26c74c2 100644 --- a/dune/tectonic/globalruinanonlinearity.hh +++ b/dune/tectonic/globalruinanonlinearity.hh @@ -10,7 +10,7 @@ #include <dune/istl/bvector.hh> #include "globalnonlinearity.hh" -#include "localnonlinearity.hh" +#include "localfriction.hh" #include "frictionpotential.hh" namespace Dune { @@ -26,12 +26,12 @@ class GlobalRuinaNonlinearity GlobalRuinaNonlinearity(dataref nodalIntegrals, FrictionData const &fd, dataref state) : restrictions(nodalIntegrals.size()) { - auto trivialNonlinearity = make_shared<LocalNonlinearity<dim> const>( + auto trivialNonlinearity = make_shared<LocalFriction<dim> const>( make_shared<TrivialFunction const>()); for (size_t i = 0; i < restrictions.size(); ++i) { restrictions[i] = nodalIntegrals[i] == 0 ? trivialNonlinearity - : make_shared<LocalNonlinearity<dim> const>( + : make_shared<LocalFriction<dim> const>( make_shared<FrictionPotential const>( nodalIntegrals[i], fd, state[i])); } @@ -40,12 +40,12 @@ class GlobalRuinaNonlinearity /* Return a restriction of the outer function to the i'th node. */ - virtual shared_ptr<LocalNonlinearity<dim> const> restriction(int i) const { + virtual shared_ptr<LocalFriction<dim> const> restriction(int i) const { return restrictions[i]; } private: - std::vector<shared_ptr<LocalNonlinearity<dim> const>> restrictions; + std::vector<shared_ptr<LocalFriction<dim> const>> restrictions; }; } #endif diff --git a/dune/tectonic/localnonlinearity.hh b/dune/tectonic/localfriction.hh similarity index 93% rename from dune/tectonic/localnonlinearity.hh rename to dune/tectonic/localfriction.hh index eef910c7cc93bba932a64f1922d83e3e13d09f0b..f30f625e9e31b4cad0e209e09a9802dc87933d8f 100644 --- a/dune/tectonic/localnonlinearity.hh +++ b/dune/tectonic/localfriction.hh @@ -1,5 +1,5 @@ -#ifndef DUNE_TECTONIC_LOCAL_NONLINEARITY_HH -#define DUNE_TECTONIC_LOCAL_NONLINEARITY_HH +#ifndef DUNE_TECTONIC_LOCAL_FRICTION_HH +#define DUNE_TECTONIC_LOCAL_FRICTION_HH #include <cmath> #include <limits> @@ -13,15 +13,12 @@ #include "frictionpotential.hh" namespace Dune { -template <int dimension> class LocalNonlinearity { +template <int dimension> class LocalFriction { public: using VectorType = FieldVector<double, dimension>; using MatrixType = FieldMatrix<double, dimension, dimension>; - LocalNonlinearity(shared_ptr<FrictionPotentialWrapper const> func) - : func(func) {} - - std::vector<double> const &get_kinks() const { return func->get_kinks(); } + LocalFriction(shared_ptr<FrictionPotentialWrapper const> func) : func(func) {} double operator()(VectorType const &x) const { return func->evaluate(x.two_norm()); diff --git a/dune/tectonic/minimisation2.hh b/dune/tectonic/minimisation2.hh deleted file mode 100644 index 86441ed58bf43ef6db08c2543ff8a67a8e85a923..0000000000000000000000000000000000000000 --- a/dune/tectonic/minimisation2.hh +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MINIMISATION2_HH -#define MINIMISATION2_HH - -#include <dune/common/fmatrix.hh> -#include <dune/common/fvector.hh> - -#include <dune/tnnmg/problem-classes/bisection.hh> - -#include "minimisation.hh" - -namespace Dune { -// NOTE: only works for the 2D case -template <class Functional> -void minimise2(Functional const &J, typename Functional::SmallVector &x, - size_t steps, Bisection const &bisection) { - using SmallVector = typename Functional::SmallVector; - minimisationInitialiser(J, bisection, x); - - { // Make a single step where we already know we're not differentiable - SmallVector descDir; - if (x == SmallVector(0)) - J.descentAtZero(descDir); - else - J.descentDirectionNew(x, descDir); - descentMinimisation(J, x, descDir, bisection); - } - - // From here on, we're in a C1 region and stay there. - for (size_t i = 1; i < steps; ++i) { - SmallVector descDir; - J.descentDirectionNew(x, descDir); - descentMinimisation(J, x, descDir, bisection); - } -} - -template <class Functional> -void minimisationInitialiser(Functional const &J, Bisection const &bisection, - typename Functional::SmallVector &startingPoint) { - using SmallVector = typename Functional::SmallVector; - - std::vector<double> const &kinks = J.get_kinks(); - - SmallVector x_old(0); - double Jx_old = J(x_old); - - for (auto &kink : kinks) { - SmallVector x1 = { kink, 0 }; // Random vector that has the right norm - SmallVector const descDir1 = { x1[1], -x1[0] }; - tangentialMinimisation(J, x1, descDir1, bisection); - double const Jx1 = J(x1); - - SmallVector x2(0); - x2.axpy(-1, x1); - SmallVector const descDir2 = { x2[1], -x2[0] }; - tangentialMinimisation(J, x2, descDir2, bisection); - double const Jx2 = J(x2); - - double const Jx = (Jx2 < Jx1 ? Jx2 : Jx1); - SmallVector const x = (Jx2 < Jx1 ? x2 : x1); - - if (Jx >= Jx_old) - break; - - Jx_old = Jx; - x_old = x; - } - startingPoint = x_old; -} -} -#endif diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index cb4bf43af9999bfb6d9885991a003a1e59236331..1742770e468e6ce94caa5bd278403e58549849c6 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -14,7 +14,6 @@ #include <dune/tnnmg/problem-classes/bisection.hh> #include "globalnonlinearity.hh" -#include "localnonlinearity.hh" #include "minimisation.hh" #include "mydirectionalconvexfunction.hh" #include "ellipticenergy.hh"