This file is indexed.

/usr/include/dune/pdelab/linearsolver/stationarymatrix.hh is in libdune-pdelab-dev 2.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:

#ifndef DUNE_PDELAB_LINEARPROBLEM_STATIONARYMATRIX_HH
#define DUNE_PDELAB_LINEARPROBLEM_STATIONARYMATRIX_HH

#include <iostream>
#include <ostream>

#include <dune/common/shared_ptr.hh>
#include <dune/common/timer.hh>

#include <dune/pdelab/backend/backendselector.hh>

namespace Dune {
  namespace PDELab {

    //! A class for solving linear problems with stationary matrices.
    /**
     * In apply() it first check whether the marix has already been assembled.
     * If it hasn't,it assembles the matrix and stores it for future
     * applications.  Then it computes the right hand side and solves the
     * problem.
     *
     * \tparam GOS   GridOperatorSpace to use.
     * \tparam SB    Solver backend.
     * \tparam Coeff Type of the matrix/vector entries
     */
    template<class GOS, class SB, class Coeff>
    class StationaryMatrixLinearSolver
    {
      typedef typename GOS::template MatrixContainer<Coeff>::Type Matrix;
      typedef typename Dune::PDELab::BackendVectorSelector
        <typename GOS::Traits::TrialGridFunctionSpace, Coeff>::Type VectorU;
      typedef typename Dune::PDELab::BackendVectorSelector
        <typename GOS::Traits::TestGridFunctionSpace, Coeff>::Type VectorV;

      const GOS& gos;
      SB& sb;
      shared_ptr<Matrix> m;
      Coeff reduction;
      Coeff mindefect;

    public:
      StationaryMatrixLinearSolver(const GOS& gos_, SB& sb_, Coeff reduction_,
                                   Coeff mindefect_ = 1e-99) :
        gos(gos_), sb(sb_), reduction(reduction_), mindefect(mindefect_)
      { }

      void apply (VectorU& x) {
        Dune::Timer watch;
        double timing;

        if(!m) {
          // setup new matrix from sparsity pattern
          watch.reset();

          m.reset(new Matrix(gos));

          timing = watch.elapsed();
          if (gos.trialGridFunctionSpace().gridView().comm().rank()==0)
            std::cout << "=== matrix setup " << timing << " s" << std::endl;

          // assemble matrix
          watch.reset();

          *m = 0.0;
          gos.jacobian(x,*m);

          timing = watch.elapsed();
          if (gos.trialGridFunctionSpace().gridView().comm().rank()==0)
            std::cout << "=== matrix assembly " << timing << " s" << std::endl;
        }
        else {
          if (gos.trialGridFunctionSpace().gridView().comm().rank()==0)
            std::cout << "=== matrix setup skipped" << std::endl
                      << "=== matrix assembly skipped" << std::endl;
        }

        // assemble residual
        watch.reset();

        VectorV r(gos.testGridFunctionSpace(),0.0);
        gos.residual(x,r);  // residual is additive

        timing = watch.elapsed();
        if (gos.trialGridFunctionSpace().gridView().comm().rank()==0)
          std::cout << "=== residual assembly " << timing << " s" << std::endl;

        Coeff defect = sb.norm(r);

        // compute correction
        watch.reset();
        VectorU z(gos.trialGridFunctionSpace(),0.0);
        Coeff red = std::min(reduction,defect/mindefect);
        sb.apply(*m,z,r,red); // solver makes right hand side consistent
        timing = watch.elapsed();

        if (gos.trialGridFunctionSpace().gridView().comm().rank()==0)
          std::cout << "=== solving (reduction: " << red << ") "
                    << timing << " s" << std::endl;

        // and update
        x -= z;
      }

    };

  } // namespace PDELab
} // namespace Dune

#endif // DUNE_PDELAB_LINEARPROBLEM_STATIONARYMATRIX_HH