ug4
Loading...
Searching...
No Matches
operator_inverse_iterator.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 __H__UG__LIB_DISC__OPERATOR__ITERATOR_OPERATOR_INVERSE__
34#define __H__UG__LIB_DISC__OPERATOR__ITERATOR_OPERATOR_INVERSE__
35
36#include <string>
37
42
43#include "common/log.h"
44
45#ifdef UG_PARALLEL
47#endif
48
49namespace ug{
50
63template <typename TAlgebra>
64class OperatorInverseIterator : public ILinearIterator<typename TAlgebra::vector_type>
65{
66 public:
68 typedef TAlgebra algebra_type;
69
71 typedef typename TAlgebra::vector_type vector_type;
72
74 typedef typename TAlgebra::matrix_type matrix_type;
75
78
81
82 protected:
84
85 public:
87 {
88 UG_ASSERT(0, "not implemented since ILinearOperatorInverse::clone not implemented");
89 return SPNULL;
90 }
93 {
94 m_name = std::string("OperatorInverseIterator(") + std::string(m_opInv->name()) + std::string(")");
95 }
100
101 std::string m_name;
102
104 virtual bool supports_parallel() const
105 {
106 return m_opInv->supports_parallel();
107 }
108
109 virtual const char* name() const
110 {
111 return m_name.c_str();
112 }
113
115 {
116 if(!m_opInv->init(L))
117 {
118 UG_LOG("ERROR in '" << name() << "::init'.\n");
119 return false;
120 }
121 return true;
122 }
123
125 {
126 if(!m_opInv->init(J, u))
127 {
128 UG_LOG("ERROR in '" << name() << "::init'.\n");
129 return false;
130 }
131 return true;
132 }
133
134 virtual bool apply(vector_type& c, const vector_type& d)
135 {
136 if(m_opInv->apply(c, d))
137 {
138 //UG_LOG("ERROR in '" << name() << "::apply'\n");
139 return false;
140 }
141 return true;
142 }
143
145 {
147 {
148 //UG_LOG("ERROR in '" << name() << "::apply_update_defect'\n");
149 return false;
150 }
151 return true;
152 }
153
154};
155
156
157} // end namespace ug
158
159#endif // __H__UG__LIB_DISC__OPERATOR__ITERATOR_OPERATOR_INVERSE__
Definition smart_pointer.h:108
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
virtual bool apply(Y &u, const X &f)=0
applies inverse operator, i.e. returns u = A^{-1} f
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 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
describes a linear iterator that is based on a matrix operator
Definition preconditioner.h:103
Definition operator_inverse_iterator.h:65
TAlgebra::vector_type vector_type
Vector type.
Definition operator_inverse_iterator.h:71
IPreconditioner< TAlgebra > base_type
Base type.
Definition operator_inverse_iterator.h:80
std::string m_name
Definition operator_inverse_iterator.h:101
virtual SmartPtr< ILinearIterator< vector_type, vector_type > > clone()
clone
Definition operator_inverse_iterator.h:86
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition operator_inverse_iterator.h:104
TAlgebra::matrix_type matrix_type
Matrix type.
Definition operator_inverse_iterator.h:74
virtual bool apply(vector_type &c, const vector_type &d)
compute new correction c = B*d
Definition operator_inverse_iterator.h:134
virtual const char * name() const
returns the name of iterator
Definition operator_inverse_iterator.h:109
virtual bool init(SmartPtr< ILinearOperator< vector_type > > L)
Definition operator_inverse_iterator.h:114
SmartPtr< ILinearOperatorInverse< vector_type > > m_opInv
Definition operator_inverse_iterator.h:83
virtual bool apply_update_defect(vector_type &c, vector_type &d)
compute new correction c = B*d and update defect d := d - A*c
Definition operator_inverse_iterator.h:144
IPreconditioner< TAlgebra >::matrix_operator_type matrix_operator_type
Matrix Operator type.
Definition operator_inverse_iterator.h:77
OperatorInverseIterator(SmartPtr< ILinearOperatorInverse< vector_type > > opInv)
default constructor
Definition operator_inverse_iterator.h:92
TAlgebra algebra_type
Algebra type.
Definition operator_inverse_iterator.h:68
virtual bool init(SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
Definition operator_inverse_iterator.h:124
~OperatorInverseIterator()
Definition operator_inverse_iterator.h:96
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition smart_pointer.h:90
#define UG_ASSERT(expr, msg)
Definition assert.h:70
#define UG_LOG(msg)
Definition log.h:367
the ug namespace