ug4
Loading...
Searching...
No Matches
schur_precond.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3 * Author: Arne Nägel
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__LINEAR_OPERATOR__SCHUR_PRECOND__
34#define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_PRECOND__
35
36
37#ifdef UG_PARALLEL
38
39#include <iostream>
40#include <sstream>
41#include <string>
42#include <set>
43
53#include "pcl/pcl.h"
54
55#include "common/log.h"
56
57#include "schur.h"
58
59
60#define PROFILE_SCHUR
61#ifdef PROFILE_SCHUR
62 #define SCHUR_PROFILE_FUNC() PROFILE_FUNC_GROUP("algebra schur")
63 #define SCHUR_PROFILE_BEGIN(name) PROFILE_BEGIN_GROUP(name, "algebra schur")
64 #define SCHUR_PROFILE_END_(name) PROFILE_END_(name)
65#else
66 #define SCHUR_PROFILE_FUNC()
67 #define SCHUR_PROFILE_BEGIN(name)
68 #define SCHUR_PROFILE_END_(name)
69#endif
70
71namespace ug{
72
73extern DebugID SchurDebug;
74
75
77
79//template <typename TAlgebra>
80//class SchurSolver : public IMatrixOperatorInverse< typename TAlgebra::matrix_type,
81// typename TAlgebra::vector_type>,
82// public DebugWritingObject<TAlgebra>
83
84template <typename TAlgebra>
85class SchurPrecond: public IPreconditioner<TAlgebra>
86{
87 public:
88 // Algebra type
89 typedef TAlgebra algebra_type;
90
91 // Vector type
92 typedef typename TAlgebra::vector_type vector_type;
93
94 // Matrix type
95 typedef typename TAlgebra::matrix_type matrix_type;
96
99
100 protected:
101 //using base_type::set_debug;
104
105 public:
107 SchurPrecond();
108
115
117 {
118 return make_sp(new SchurPrecond<algebra_type>(*this));
119 }
120
121 protected:
123 virtual const char* name() const {return "Schur complement";}
124
125 // Preprocess routine
127
128 // Stepping routine
130
131 // Postprocess routine
132 virtual bool postprocess();// {return true;}
133
135 virtual bool supports_parallel() const
136 {
139 return false;
140
141 if(m_spSkeletonSolver.valid()
142 && (!m_spSkeletonSolver->supports_parallel()))
143 return false;
144
145 return true;
146 }
147
148public:
149
153
157
160
161
162 // set debug output
164 {
165 base_type::set_debug(spDebugWriter);
166 //m_spSchurComplementOp->set_debug(spDebugWriter);
167 }
168
169 virtual std::string config_string() const
170 {
171 std::stringstream ss; ss << name() << "\n";
172 ss << " Dirichlet Solver: ";
174 else ss << " NOT SET!\n";
175 ss << " Skeleton Solver: ";
176 if(m_spSkeletonSolver.valid()) ss << ConfigShift(m_spSkeletonSolver->config_string()) << "\n";
177 else ss << " NOT SET!\n";
178
179 return ss.str();
180 }
181
182public:
186 {
187 matrix_type &Amat = m_pA->get_matrix();
188 ConstSmartPtr<AlgebraLayouts> layouts = Amat.layouts();
189 return layouts->proc_comm().allreduce(m_myMasterSkeleton, PCL_RO_SUM);
190 }
195 {
196 return m_myTotalSkeleton;
197 }
198
199
200private:
202 std::vector<schur_slice_desc_type> &skeletonMark);
203
205 bool check_requirements();
207 std::vector<schur_slice_desc_type> &skeletonMark);
208
209 void create_aux_vectors(const vector_type& d);
210 void schur_solver_forward(vector_type &u_inner, vector_type &f_inner);
211 void schur_solve_skeleton(vector_type &u_skeleton, const vector_type &f_skeleton);
212 void schur_solver_backward(vector_type &u_inner, vector_type &f_inner, vector_type &u_skeleton);
213
214
215 protected:
216 // Reference to operator that is inverted by this Inverse Operator
217 // SmartPtr<MatrixOperator<matrix_type,vector_type> > m_spOperator;
218
221
224
227
228 // temporary vectors for correction/defect
231
234 // pointer to Domain decomposition info object
235 // pcl::IDomainDecompositionInfo* m_pDDInfo;
236};
237
238
239}
240#endif /* UG_PARALLEL */
241#endif /* __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_PRECOND__ */
Definition smart_pointer.h:296
Definition smart_pointer.h:108
bool valid() const
returns true if the pointer is valid, false if not.
Definition smart_pointer.h:206
virtual void set_debug(SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
set debug writer
Definition debug_writer.h:384
void write_debug(const matrix_type &mat, const char *filename)
write debug output for a matrix (if debug writer set)
Definition debug_writer.h:399
SmartPtr< IDebugWriter< algebra_type > > debug_writer()
returns the debug writer
Definition debug_writer.h:391
base class for all debug writer
Definition debug_writer.h:244
describes an inverse linear mapping X->Y
Definition linear_operator_inverse.h:80
virtual std::string config_string() const
returns information about configuration parameters
Definition linear_operator_inverse.h:122
virtual bool supports_parallel() const =0
returns if parallel solving is supported
describes a linear iterator that is based on a matrix operator
Definition preconditioner.h:103
Definition schur_complement_inverse_interface.h:46
Definition matrix_operator.h:49
virtual M & get_matrix()
Definition matrix_operator.h:74
Definition schur_complement_operator.h:69
operator implementation of the DD Schur complement solver
Definition schur_precond.h:86
SmartPtr< SchurComplementOperator< algebra_type > > m_spSchurComplementOp
Local Schur complement for each subdomain.
Definition schur_precond.h:226
SchurPrecond(const SchurPrecond< TAlgebra > &parent)
Definition schur_precond.h:109
SmartPtr< vector_type > m_aux_rhs[2]
Definition schur_precond.h:229
size_t m_myTotalSkeleton
Definition schur_precond.h:232
size_t num_local_skeleton()
Definition schur_precond.h:194
void set_schur_complement_operator(SmartPtr< SchurComplementOperator< algebra_type > > scop)
Definition schur_precond.h:158
void create_aux_vectors(const vector_type &d)
Definition schur_precond.cpp:238
IPreconditioner< TAlgebra > base_type
Base type.
Definition schur_precond.h:98
TAlgebra algebra_type
Definition schur_precond.h:89
SmartPtr< ILinearOperatorInverse< vector_type > > m_spDirichletSolver
Solver Dirichlet problems (also used in Schur complement)
Definition schur_precond.h:220
void schur_solve_skeleton(vector_type &u_skeleton, const vector_type &f_skeleton)
Definition schur_precond.cpp:303
void set_skeleton_solver(SmartPtr< ISchurComplementInverse< algebra_type > > skeletonSolver)
sets the coarse problem solver
Definition schur_precond.h:155
virtual const char * name() const
name of solver
Definition schur_precond.h:123
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition schur_precond.h:135
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_pA
Definition schur_precond.h:233
void schur_solver_backward(vector_type &u_inner, vector_type &f_inner, vector_type &u_skeleton)
Definition schur_precond.cpp:324
void schur_solver_forward(vector_type &u_inner, vector_type &f_inner)
Definition schur_precond.cpp:283
virtual bool preprocess(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp)
initializes the preconditioner
Definition schur_precond.cpp:203
bool create_and_init_local_schur_complement(SmartPtr< MatrixOperator< matrix_type, vector_type > > A, std::vector< schur_slice_desc_type > &skeletonMark)
Definition schur_precond.cpp:97
virtual std::string config_string() const
Definition schur_precond.h:169
virtual bool step(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp, vector_type &c, const vector_type &d)
computes a new correction c = B*d
Definition schur_precond.cpp:336
bool check_requirements()
Definition schur_precond.cpp:162
SmartPtr< vector_type > m_aux_sol[2]
Definition schur_precond.h:230
SmartPtr< ISchurComplementInverse< TAlgebra > > m_spSkeletonSolver
Solver for coarse (skeleton) problem.
Definition schur_precond.h:223
void get_skeleton_slicing(SmartPtr< MatrixOperator< matrix_type, vector_type > > A, std::vector< schur_slice_desc_type > &skeletonMark)
Definition schur_precond.cpp:182
size_t m_myMasterSkeleton
Definition schur_precond.h:232
TAlgebra::matrix_type matrix_type
Definition schur_precond.h:95
void init_skeleton_solver()
Definition schur_precond.cpp:139
SchurPrecond()
constructor
Definition schur_precond.cpp:72
void set_dirichlet_solver(SmartPtr< ILinearOperatorInverse< vector_type > > dirichletSolver)
sets the Dirichlet solver (forward to Schur complement)
Definition schur_precond.h:151
void set_debug(SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
set debug writer
Definition schur_precond.h:163
virtual bool postprocess()
cleans the operator
Definition schur_precond.cpp:86
virtual SmartPtr< ILinearIterator< vector_type > > clone()
clone
Definition schur_precond.h:116
TAlgebra::vector_type vector_type
Definition schur_precond.h:92
size_t num_global_skeleton()
Definition schur_precond.h:185
#define PCL_RO_SUM
Definition pcl_methods.h:63
the ug namespace
string ConfigShift(string s)
Definition string_util.cpp:457
DebugID SchurDebug
todo: replace DebugID
Definition schur.h:55
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition smart_pointer.h:836