ug4
Loading...
Searching...
No Matches
linear_operator_inverse.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
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 __H__LIB_ALGEBRA__OPERATOR__INTERFACE__LINEAR_OPERATOR_INVERSE__
34#define __H__LIB_ALGEBRA__OPERATOR__INTERFACE__LINEAR_OPERATOR_INVERSE__
35
36#include "linear_operator.h"
37#include "linear_iterator.h"
39#include "common/error.h"
41
42namespace ug{
43
44
46// Inverse of a Linear Operator
48
50
78template <typename X, typename Y = X>
80{
81 public:
84
87
88 public:
91 : m_spLinearOperator(NULL),
92 m_spConvCheck(new StdConvCheck<X>(100, 1e-12, 1e-12, true))
93 {}
94
100
103
105
112 virtual const char* name() const = 0;
113
114
116
122 virtual std::string config_string() const { return name(); }
123
125 virtual bool supports_parallel() const = 0;
126
128
136 {
137 // remember operator
139 return true;
140 }
141
143
154 virtual bool init(SmartPtr<ILinearOperator<Y,X> > J, const Y& u)
155 {
156 // remember operator
158 return true;
159 }
160
162
172 virtual bool apply(Y& u, const X& f) = 0;
173
175
188 virtual bool apply_return_defect(Y& u, X& f) = 0;
189
190 virtual bool apply_update_defect(Y& u, X& f)
191 {
192 return apply_return_defect(u,f);
193 }
194
196 {
197 UG_THROW("No cloning implemented.");
198 return SPNULL;
199 }
200
203
206
208 number defect() const {return convergence_check()->defect();}
209
211 int step() const {return convergence_check()->step();}
212
214 number reduction() const {return convergence_check()->reduction();}
215
217 virtual int standard_offset() const {return 3;}
218
221 {
222 m_spConvCheck = spConvCheck;
223 m_spConvCheck->set_offset(standard_offset());
224 };
225
228 {
229 if(m_spLinearOperator.invalid())
230 UG_THROW(name() << ": Linear Operator that should be "
231 "inverted has not been set.");
232
233 return m_spLinearOperator;
234 }
235
236 protected:
239
242};
243
244}
245#endif /* __H__LIB_ALGEBRA__OPERATOR__INTERFACE__LINEAR_OPERATOR_INVERSE__ */
Definition smart_pointer.h:296
Definition smart_pointer.h:108
Definition convergence_check.h:72
describes a linear iterator
Definition linear_iterator.h:81
describes a linear mapping X->Y
Definition linear_operator.h:80
describes an inverse linear mapping X->Y
Definition linear_operator_inverse.h:80
virtual const char * name() const =0
returns the name of the operator inverse
number reduction() const
returns the current relative reduction
Definition linear_operator_inverse.h:214
SmartPtr< ILinearOperator< Y, X > > m_spLinearOperator
Operator that is inverted by this Inverse Operator.
Definition linear_operator_inverse.h:238
number defect() const
returns the current defect
Definition linear_operator_inverse.h:208
ILinearOperatorInverse()
constructor setting convergence check to (100, 1e-12, 1e-12, true)
Definition linear_operator_inverse.h:90
ConstSmartPtr< IConvergenceCheck< X > > convergence_check() const
returns the convergence check
Definition linear_operator_inverse.h:202
virtual bool apply_update_defect(Y &u, X &f)
compute new correction c = B*d and update defect d := d - A*c
Definition linear_operator_inverse.h:190
ILinearOperatorInverse(SmartPtr< IConvergenceCheck< X > > spConvCheck)
Default constructor.
Definition linear_operator_inverse.h:96
virtual bool apply(Y &u, const X &f)=0
applies inverse operator, i.e. returns u = A^{-1} f
void set_convergence_check(SmartPtr< IConvergenceCheck< X > > spConvCheck)
set the convergence check
Definition linear_operator_inverse.h:220
virtual std::string config_string() const
returns information about configuration parameters
Definition linear_operator_inverse.h:122
Y codomain_function_type
Range space.
Definition linear_operator_inverse.h:86
virtual ~ILinearOperatorInverse()
virtual destructor
Definition linear_operator_inverse.h:102
virtual bool init(SmartPtr< ILinearOperator< Y, X > > J, const Y &u)
initializes for the inverse for a linearized operator at linearization point u
Definition linear_operator_inverse.h:154
int step() const
returns the current number of steps
Definition linear_operator_inverse.h:211
X domain_function_type
Domain space.
Definition linear_operator_inverse.h:83
virtual bool apply_return_defect(Y &u, X &f)=0
applies inverse operator, i.e. returns u = A^{-1} f and returns defect d := f - A*u
virtual int standard_offset() const
returns the standard offset for output
Definition linear_operator_inverse.h:217
virtual SmartPtr< ILinearIterator< X, Y > > clone()
clone
Definition linear_operator_inverse.h:195
SmartPtr< ILinearOperator< Y, X > > linear_operator()
returns the current Operator this Inverse Operator is initialized for
Definition linear_operator_inverse.h:227
virtual bool supports_parallel() const =0
returns if parallel solving is supported
virtual bool init(SmartPtr< ILinearOperator< Y, X > > L)
initializes for the inverse for a linear operator
Definition linear_operator_inverse.h:135
SmartPtr< IConvergenceCheck< X > > m_spConvCheck
smart pointer holding the convergence check
Definition linear_operator_inverse.h:241
SmartPtr< IConvergenceCheck< X > > convergence_check()
returns the convergence check
Definition linear_operator_inverse.h:205
Definition convergence_check.h:179
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition smart_pointer.h:90
#define UG_THROW(msg)
Definition error.h:57
double number
Definition types.h:124
the ug namespace
function ProblemDisc new(problemDesc, dom)