Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fixed_convergence_check.h
Go to the documentation of this file.
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
37namespace ug{
38
39template <typename TVector>
41{
42 public:
43 FixedConvergenceCheck(int numIterations)
44 {
45 m_numIterations = numIterations;
46 }
47
50 {
52 }
53
55 virtual void start(const TVector& d)
56 {
58 }
59
62 {
64 }
65
67 virtual void update(const TVector& d)
68 {
70 }
71
80 virtual bool iteration_ended()
81 {
82 if(step() >= m_numIterations) return true;
83 return false;
84 }
85
94 virtual bool post()
95 {
96 return true;
97 }
98
100 // informations about current status
102
104 virtual number defect() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck"); return 0;}
105
107 virtual int step() const { return m_currentStep; }
108
109 // returns the current relative reduction
110 virtual number reduction() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck"); return 0;}
111
112 // returns the current convergence rate
113 virtual number rate() const { return 0;}
114
115 // returns the averaged convergence rate
116 virtual number avg_rate() const { UG_ASSERT(0, "not provided by FixedConvergenceCheck"); return 0;}
117
118 virtual void print_line(std::string line)
119 {
120 }
122 // output style
124
125 int get_offset() const {return m_offset;}
126 void set_offset(int offset){m_offset = offset;}
127 void set_symbol(char symbol){ }
128 void set_name(std::string name) {}
129 void set_info(std::string info) {}
130
137
138 virtual std::string config_string() const
139 {
140 std::stringstream ss;
141 ss << "FixedConvergenceCheck( fix # steps = " << m_numIterations << ")";
142 return ss.str();
143 }
144
147
148 private:
152};
153
154
155}
156#endif /* FIXED_CONVERGENCE_CHECK_H_ */
location name
Definition checkpoint_util.lua:128
Definition smart_pointer.h:108
Definition fixed_convergence_check.h:41
int get_offset() const
get the current offset
Definition fixed_convergence_check.h:125
virtual SmartPtr< IConvergenceCheck< TVector > > clone()
clone the object
Definition fixed_convergence_check.h:132
virtual void update_defect(number defect)
sets the update for the current defect
Definition fixed_convergence_check.h:61
virtual bool post()
Definition fixed_convergence_check.h:94
void set_info(std::string info)
sets info string
Definition fixed_convergence_check.h:129
virtual void update(const TVector &d)
computes the defect and sets it a the next defect value
Definition fixed_convergence_check.h:67
virtual std::string config_string() const
returns information about configuration parameters
Definition fixed_convergence_check.h:138
virtual void start(const TVector &d)
computes the start defect and set it
Definition fixed_convergence_check.h:55
virtual void print_line(std::string line)
prints a line
Definition fixed_convergence_check.h:118
virtual number defect() const
returns the current defect
Definition fixed_convergence_check.h:104
virtual bool iteration_ended()
Definition fixed_convergence_check.h:80
virtual number avg_rate() const
Definition fixed_convergence_check.h:116
virtual number rate() const
Definition fixed_convergence_check.h:113
int m_offset
Definition fixed_convergence_check.h:149
FixedConvergenceCheck(int numIterations)
Definition fixed_convergence_check.h:43
virtual void start_defect(number defect)
sets the given start defect
Definition fixed_convergence_check.h:49
void set_offset(int offset)
sets the number of spaces printed before output information
Definition fixed_convergence_check.h:126
virtual int step() const
returns the current number of steps
Definition fixed_convergence_check.h:107
virtual number reduction() const
Definition fixed_convergence_check.h:110
virtual ~FixedConvergenceCheck()
virtual destructor
Definition fixed_convergence_check.h:146
void set_name(std::string name)
sets the name of the iteration
Definition fixed_convergence_check.h:128
int m_currentStep
Definition fixed_convergence_check.h:151
void set_symbol(char symbol)
sets the symbol used for output
Definition fixed_convergence_check.h:127
int m_numIterations
Definition fixed_convergence_check.h:150
Definition convergence_check.h:72
#define UG_ASSERT(expr, msg)
Definition assert.h:70
double number
Definition types.h:124
the ug namespace