Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nl_gauss_seidel.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 * Author: Raphael Prohl
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/*
34 * (main parts are based on the structure of
35 * newton.h and some ideas of Sebastian Reiter & Andreas Vogel)
36 */
37
38#ifndef __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__NL_GAUSS_SEIDEL__NL_GAUSS_SEIDEL_H_
39#define __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__NL_GAUSS_SEIDEL__NL_GAUSS_SEIDEL_H_
40
42
43// modul intern headers
47
48namespace ug {
49
50template <typename TAlgebra>
52{
53 public:
55 typedef TAlgebra algebra_type;
56
58 typedef typename algebra_type::matrix_type matrix_type;
59
61 typedef typename algebra_type::vector_type vector_type;
62
63 public:
66
68 void add_local_vec_to_global(vector_type& vec, const LocalVector& lvec,
70
72 void add_local_mat_to_global(matrix_type& mat, const LocalMatrix& lmat,
74
77
79 void set_assembling_index(const size_t assIndex){ m_assemblingIndex = assIndex;}
80
83
84 private:
86};
87
89
117template <typename TDomain, typename TAlgebra>
119 : public IOperatorInverse<typename TAlgebra::vector_type>,
120 public DebugWritingObject<TAlgebra>
121{
122 private:
125
126 public:
128 typedef TAlgebra algebra_type;
129
131 typedef typename TAlgebra::matrix_type matrix_type;
132
134 typedef typename TAlgebra::vector_type vector_type;
135
137 typedef typename vector_type::value_type value_type;
138
140 typedef TDomain domain_type;
141
144
147
148 protected:
150
151 public:
154
158
160 {m_spApproxSpace = spApproxSpace;}
161
163
164 void set_damp(const number damp) {m_damp = damp;}
165
166 void set_constraint(const vector_type& cons) {m_ConsVec = cons; m_bProjectedGS = true;}
167
169 // OperatorInverse interface methods
171
173 virtual bool init(SmartPtr<IOperator<vector_type> > op);
174
176 virtual bool prepare(vector_type& u);
177
179 virtual bool apply(vector_type& u);
180
182 virtual std::string config_string() const
183 {
184 std::stringstream ss;
185 ss << "NonlinearGaussSeidelSolver( damp = " << m_damp << ")\n";
186 ss << " ConvergenceCheck: ";
187 if(m_spConvCheck.valid()) ss << ConfigShift(m_spConvCheck->config_string()) << "\n";
188 else ss << " NOT SET!\n";
189
190 return ss.str();
191 }
192
193 private:
196 void write_debug(const vector_type& vec, const char* filename);
197 void write_debug(const matrix_type& mat, const char* filename);
199
200 private:
203
207
210
212
216
219
223
226
227 /* TODO: hier alle typen von grid_base_object zulassen?
228 typedef Attachment<vector<grid_base_object*> > AElemList; //attachment type: attachment of ElemDatas
229 AElemList m_aElemList; //the instance of the attachment type
230 typedef Grid::VertexAttachmentAccessor<AElemList> ElemListAccessor;
231 ElemListAccessor m_aaElemList;
233 void attach_attachments()
234 {
235 typename TDomain::grid_type& grid = *this->domain().grid();
236 grid.attach_to_vertices(m_aElemList);
237 m_aaElemList.access(grid, m_aElemList);
238 }*/
239
240 // TODO: hier alle typen von grid_base_object zulassen?
241 typedef std::vector<grid_base_object*> elemList;
242 std::vector<elemList> m_vElemList;
243
246
249};
250
251}
252
253#include "nl_gauss_seidel_impl.h"
254
255#endif /* __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__NL_GAUSS_SEIDEL__NL_GAUSS_SEIDEL_H_ */
Definition smart_pointer.h:296
Definition smart_pointer.h:108
base class for approximation spaces without type of algebra or dof distribution
Definition approximation_space.h:279
Definition debug_writer.h:354
Definition grid_level.h:42
Definition convergence_check.h:72
interface for definition of special LocalToGlobal mappings
Definition local_to_global_mapper.h:50
describes a mapping X->Y
Definition operator.h:86
describes an inverse mapping X->Y
Definition operator_inverse.h:79
Definition local_algebra.h:422
Definition nl_gauss_seidel.h:52
size_t m_assemblingIndex
Definition nl_gauss_seidel.h:85
void modify_LocalSol(LocalVector &vecMod, const LocalVector &lvec, ConstSmartPtr< DoFDistribution > dd)
modifies local solution vector for adapted defect computation
Definition nl_gauss_seidel.h:76
LocalToGlobalMapperNLGS()
default constructor
Definition nl_gauss_seidel.h:65
TAlgebra algebra_type
Algebra type.
Definition nl_gauss_seidel.h:55
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition nl_gauss_seidel.h:58
void add_local_vec_to_global(vector_type &vec, const LocalVector &lvec, ConstSmartPtr< DoFDistribution > dd)
adds a local vector to the global rhs
Definition nl_gauss_seidel_impl.h:63
~LocalToGlobalMapperNLGS()
destructor
Definition nl_gauss_seidel.h:82
void add_local_mat_to_global(matrix_type &mat, const LocalMatrix &lmat, ConstSmartPtr< DoFDistribution > dd)
adds a local matrix to the global matrix
Definition nl_gauss_seidel_impl.h:82
void set_assembling_index(const size_t assIndex)
sets assembling index
Definition nl_gauss_seidel.h:79
algebra_type::vector_type vector_type
Type of algebra vector.
Definition nl_gauss_seidel.h:61
Definition local_algebra.h:198
Nonlinear GaussSeidel-method.
Definition nl_gauss_seidel.h:121
virtual bool prepare(vector_type &u)
prepare Operator
Definition nl_gauss_seidel_impl.h:183
int m_dgbCall
call counter
Definition nl_gauss_seidel.h:225
void set_approximation_space(SmartPtr< approx_space_type > spApproxSpace)
Definition nl_gauss_seidel.h:159
vector_type m_ConsVec
vector describing a constraint
Definition nl_gauss_seidel.h:221
Selector m_sel
selector of elements with contributions to a specific DoF
Definition nl_gauss_seidel.h:245
void set_damp(const number damp)
Definition nl_gauss_seidel.h:164
SmartPtr< AssembledLinearOperator< algebra_type > > m_spJBlock
Definition nl_gauss_seidel.h:214
NLGaussSeidelSolver()
constructor
Definition nl_gauss_seidel_impl.h:125
TAlgebra::vector_type vector_type
Vector type.
Definition nl_gauss_seidel.h:134
ApproximationSpace< domain_type > approx_space_type
Type of approximation space.
Definition nl_gauss_seidel.h:143
TAlgebra algebra_type
Algebra type.
Definition nl_gauss_seidel.h:128
TAlgebra::matrix_type matrix_type
Matrix type.
Definition nl_gauss_seidel.h:131
domain_traits< TDomain::dim >::grid_base_object grid_base_object
Type of geometric base object.
Definition nl_gauss_seidel.h:146
bool m_bProjectedGS
Definition nl_gauss_seidel.h:222
SmartPtr< IConvergenceCheck< vector_type > > m_spConvCheck
Definition nl_gauss_seidel.h:211
ConstSmartPtr< DoFDistribution > m_spSurfDD
Definition nl_gauss_seidel.h:206
GridLevel m_gridLevel
DoF Distribution used.
Definition nl_gauss_seidel.h:209
number m_damp
damping factor
Definition nl_gauss_seidel.h:218
SmartPtr< approx_space_type > m_spApproxSpace
Approximation Space.
Definition nl_gauss_seidel.h:202
SmartPtr< IAssemble< TAlgebra > > m_spAss
Definition nl_gauss_seidel.h:215
std::vector< grid_base_object * > elemList
Definition nl_gauss_seidel.h:241
LocalToGlobalMapperNLGS< TAlgebra > m_map
LocalToGlobal-Mapper which accounts for index-wise assembling.
Definition nl_gauss_seidel.h:248
DebugWritingObject< TAlgebra > base_writer_type
Definition nl_gauss_seidel.h:149
virtual bool apply(vector_type &u)
apply Operator, i.e. op^{-1}(0) = u
Definition nl_gauss_seidel_impl.h:268
vector_type::value_type value_type
Value type.
Definition nl_gauss_seidel.h:137
virtual std::string config_string() const
returns information about configuration parameters
Definition nl_gauss_seidel.h:182
std::vector< elemList > m_vElemList
Definition nl_gauss_seidel.h:242
SmartPtr< AssembledOperator< algebra_type > > m_spAssOp
Definition nl_gauss_seidel.h:213
void set_convergence_check(SmartPtr< IConvergenceCheck< vector_type > > spConvCheck)
Definition nl_gauss_seidel_impl.h:136
void set_constraint(const vector_type &cons)
Definition nl_gauss_seidel.h:166
NLGaussSeidelSolver< TDomain, TAlgebra > this_type
own type
Definition nl_gauss_seidel.h:124
ConstSmartPtr< DoFDistribution > m_spLevDD
DoF distribution pointer.
Definition nl_gauss_seidel.h:205
void write_debug(const vector_type &vec, const char *filename)
Definition nl_gauss_seidel_impl.h:456
TDomain domain_type
Domain type.
Definition nl_gauss_seidel.h:140
specialization of ISelector for a grid of class Grid.
Definition selector_grid.h:96
virtual void init()
double number
Definition types.h:124
the ug namespace
string ConfigShift(string s)
Definition string_util.cpp:457
Definition domain_traits.h:53