Skip to content
Snippets Groups Projects
Select Git revision
  • 2022-Strikeslip-Benchmark
  • 2016-PippingKornhuberRosenauOncken default
  • 2021-GraeserKornhuberPodlesny
  • Dissertation2021 protected
  • separate-deformation
  • AverageCrosspoints
  • old_solver_new_datastructure
  • last_working
  • 2014-Dissertation-Pipping
  • 2013-PippingSanderKornhuber
10 results

test-gradient-identity.cc

Blame
  • Forked from agnumpde / dune-tectonic
    784 commits behind the upstream repository.
    user avatar
    Elias Pipping authored and Elias Pipping committed
    6df1fb1a
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test-gradient-identity.cc 1.06 KiB
    /* 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/samplefunctional.hh>
    
    #include "test-gradient-method-nicefunction.hh"
    #include "test-gradient-method-helper.hh"
    
    int main() {
      int const dim = 2;
      typedef Dune::SampleFunctional<dim> Functional;
    
      Functional::SmallMatrix A;
      A[0][0] = 3;
      A[0][1] = A[1][0] = 1.5;
      A[1][1] = 4;
      Functional::SmallVector b;
      b[0] = 1;
      b[1] = 2;
    
      auto f = Dune::make_shared<Dune::LinearFunction const>(1);
      auto phi = Dune::make_shared<Functional::NonlinearityType const>(f);
      Functional J(A, b, phi);
    
      Functional::SmallVector start = b;
      start *= 17;
    
      double const ret1 = functionTester(J, start, 6);
    
      // Something random
      start[0] = 279;
      start[1] = -96;
    
      double const ret2 = functionTester(J, start, 10);
      assert(std::abs(ret1 - ret2) < 1e-5);
    
      start[0] = 0;
      start[1] = 0;
    
      double const ret3 = functionTester(J, start, 3);
      assert(std::abs(ret1 - ret3) < 1e-5);
    }