LCOV - code coverage report
Current view: top level - ugbase/lib_algebra/operator - fixed_convergence_check.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 40 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 63 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2013-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Martin Rupp
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef FIXED_CONVERGENCE_CHECK_H_
      34              : #define FIXED_CONVERGENCE_CHECK_H_
      35              : #include "convergence_check.h"
      36              : 
      37              : namespace ug{
      38              : 
      39              : template <typename TVector>
      40              : class FixedConvergenceCheck : public IConvergenceCheck<TVector>
      41              : {
      42              :         public:
      43            0 :                 FixedConvergenceCheck(int numIterations)
      44            0 :                 {
      45            0 :                         m_numIterations = numIterations;
      46              :                 }
      47              : 
      48              :                 /// sets the given start defect
      49            0 :                 virtual void start_defect(number defect)
      50              :                 {
      51            0 :                         m_currentStep=0;
      52            0 :                 }
      53              : 
      54              :                 /// computes the start defect and set it
      55            0 :                 virtual void start(const TVector& d)
      56              :                 {
      57            0 :                         m_currentStep=0;
      58            0 :                 }
      59              : 
      60              :                 /// sets the update for the current defect
      61            0 :                 virtual void update_defect(number defect)
      62              :                 {
      63            0 :                         m_currentStep++;
      64            0 :                 }
      65              : 
      66              :                 /// computes the defect and sets it a the next defect value
      67            0 :                 virtual void update(const TVector& d)
      68              :                 {
      69            0 :                         m_currentStep++;
      70            0 :                 }
      71              : 
      72              :                 /** iteration_ended
      73              :                  *
      74              :                  *      Checks if the iteration must be ended.
      75              :                  *      This can be due to convergence or divergence.
      76              :                  *
      77              :                  * \return      true            if iteration ended
      78              :                  *                      false           if iteration can and must be continued until convergence
      79              :                  */
      80            0 :                 virtual bool iteration_ended()
      81              :                 {
      82            0 :                         if(step() >= m_numIterations) return true;
      83              :                         return false;
      84              :                 }
      85              : 
      86              :                 /** post
      87              :                  *
      88              :                  * post-processes the iteration. Some informative outputs of the status of
      89              :                  * the iteration after finishing the iteration can be placed here
      90              :                  *
      91              :                  * \return      true            if iteration was successful
      92              :                  *                      false           if iteration did not lead to a satisfying result
      93              :                  */
      94            0 :                 virtual bool post()
      95              :                 {
      96            0 :                         return true;
      97              :                 }
      98              : 
      99              :                 /////////////////////////////////////
     100              :                 // informations about current status
     101              :                 /////////////////////////////////////
     102              : 
     103              :                 /// returns the current defect
     104            0 :                 virtual number defect() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck"); return 0;}
     105              : 
     106              :                 /// returns the current number of steps
     107            0 :                 virtual int step() const { return m_currentStep; }
     108              : 
     109              :                 // returns the current relative reduction
     110            0 :                 virtual number reduction() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck");  return 0;}
     111              : 
     112              :                 // returns the current convergence rate
     113            0 :                 virtual number rate() const { return 0;}
     114              : 
     115              :                 // returns the averaged convergence rate
     116            0 :                 virtual number avg_rate() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck");  return 0;}
     117              : 
     118            0 :                 virtual void print_line(std::string line)
     119              :                 {
     120            0 :                 }
     121              :                 ////////////////
     122              :                 // output style
     123              :                 ////////////////
     124              : 
     125            0 :                 int get_offset() const {return m_offset;}
     126            0 :                 void set_offset(int offset){m_offset = offset;}
     127            0 :                 void set_symbol(char symbol){ }
     128            0 :                 void set_name(std::string name) {}
     129            0 :                 void set_info(std::string info) {}
     130              : 
     131              :                 /// clone the object
     132            0 :                 virtual SmartPtr<IConvergenceCheck<TVector> > clone()
     133              :                 {
     134            0 :                         SmartPtr<FixedConvergenceCheck<TVector> > newInst(new FixedConvergenceCheck<TVector>(m_numIterations));
     135            0 :                         return newInst;
     136              :                 }
     137              : 
     138            0 :                 virtual std::string config_string() const
     139              :                 {
     140            0 :                         std::stringstream ss;
     141            0 :                         ss << "FixedConvergenceCheck( fix # steps = " << m_numIterations << ")";
     142            0 :                         return ss.str();
     143            0 :                 }
     144              : 
     145              :                 /// virtual destructor
     146            0 :                 virtual ~FixedConvergenceCheck() {};
     147              : 
     148              :         private:
     149              :                 int m_offset;
     150              :                 int m_numIterations;
     151              :                 int m_currentStep;
     152              : };
     153              : 
     154              : 
     155              : }
     156              : #endif /* FIXED_CONVERGENCE_CHECK_H_ */
        

Generated by: LCOV version 2.0-1