Skip to content
Snippets Groups Projects
Select Git revision
  • 5f122e17ee1dfdc4524aa7cfe55ecaff74e5e910
  • master default
  • releases/2.10
  • feature/update-buildsystem
  • releases/2.9
  • more-features-for-cholmodsolver
  • releases/2.8
  • fix/error-norm
  • releases/2.7
  • implement-overlappingblockgsstep
  • make-getiterationstep-return-shared-ptr
  • feature/blockgssteps_autoCopy
  • releases/2.6-1
  • feature/use-smart-ptr-ignorenodes
  • feature/update-to-clang-7
  • feature/whitespace-fix
  • flexible-loopsolver-max
  • releases/2.5-1
  • feature/incomplete-cholesky-rebased
  • feature/istl-preconditioners
  • feature/optional-ignore
  • subversion->git
22 results

iterationstep.hh

  • user avatar
    Carsten Gräser authored
    This is the first step towards getting rid of the infamous
    getSol() method which has several problems: It returns
    a copy, it's non-const, it allows that iteration steps
    bypass the x_ member which is dedicated to storing the
    iterate.
    
    Having the default implementation allows to remove the
    implementation of this method from most interation
    steps.
    4fc93204
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    iterationstep.hh 2.14 KiB
    // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
    // vi: set et ts=8 sw=4 sts=4:
    #ifndef ITERATIONSTEP_HH
    #define ITERATIONSTEP_HH
    
    #include <vector>
    #include <string>
    
    #include <dune/common/bitsetvector.hh>
    #include <dune/solvers/common/canignore.hh>
    #include <dune/solvers/common/numproc.hh>
    
        //! Base class for iteration steps being called by an iterative solver
    template<class VectorType, class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> >
    class IterationStep : virtual public NumProc, public CanIgnore<BitVectorType>
        {
        public:
            typedef VectorType Vector;
            typedef BitVectorType BitVector;
    
            //! Default constructor
            IterationStep()
            {}
    
            /** \brief Destructor */
            virtual ~IterationStep() {}
    
            //! Constructor being given the current iterate
            IterationStep(VectorType& x) :
                x_(&x)
            {}
    
            //! Set the current iterate
            virtual void setProblem(VectorType& x) {
                x_ = &x;
            }
    
            //! to be called before iteration
            virtual void preprocess() {}
    
            //! Do the actual iteration
            virtual void iterate() = 0;
    
            //! Access the stored pointer to iterate
            virtual const Vector* getIterate() const
            {
                return x_;
            }
    
            //! Access the stored pointer to iterate
            virtual Vector* getIterate()
            {
                return x_;
            }
    
            //! Return solution object
            virtual VectorType getSol()
            {
                return *getIterate();
            }
    
            /** \brief Checks whether all relevant member variables are set
             * \exception SolverError if the iteration step is not set up properly
             */
            virtual void check() const {
    #if 0
                if (!x_)
                    DUNE_THROW(SolverError, "Iteration step has no solution vector");
    #endif
            }
    
            //! get output of last iteration step
            virtual std::string getOutput() const
            {
                return "";
            }
    
            //! The solution container
            VectorType* x_;
    
    
            using CanIgnore<BitVectorType>::ignoreNodes_;
    
        };
    
    #endif