ug4
Loading...
Searching...
No Matches
schur_complement_operator.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_COMPLEMENT_OPERATOR__
34#define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_COMPLEMENT_OPERATOR__
35
36
37#ifdef UG_PARALLEL
38
39#include <iostream>
40#include <sstream>
41#include <string>
42#include <set>
43
54#include "pcl/pcl.h"
55
56#include "common/log.h"
57
58#include "schur.h"
59
60namespace ug{
61
62
63
64
65template <typename TAlgebra>
67 : public ILinearOperator< typename TAlgebra::vector_type,
68 typename TAlgebra::vector_type>
69{
70 public:
71
72 // Algebra type
73 typedef TAlgebra algebra_type;
74
75 // Vector type
76 typedef typename TAlgebra::vector_type vector_type;
77
78 // Matrix type
79 typedef typename TAlgebra::matrix_type matrix_type;
80
81
82
83 public:
96
97 // destructor
99
101 virtual const char* name() const {return "My local Schur complement Solver";}
102
103
105 void init(const vector_type& u) {init();}
106
108 virtual void init();
109
112 virtual void apply(vector_type& f, const vector_type& u);
113
116 virtual void apply_sub(vector_type& f, const vector_type& u);
117
118 // save current operator
121
125
126
127 matrix_type &sub_matrix(int r, int c)
128 {return sub_operator(r,c)->get_matrix();}
129
132
134 {return m_slicing.get_num_elems(type);}
135
137 {return m_slicing;}
138
139
140 // for debugging: computes schur operator
142
143 void compute_matrix(matrix_type &schur_matrix, double threshold=0.0);
144 virtual void set_debug(SmartPtr<IDebugWriter<algebra_type> > spDebugWriter);
145
146 template<typename T>
148 {
149 if(!m_spDebugWriterInner.valid()) return;
151 = op.template cast_dynamic<VectorDebugWritingObject<vector_type> >();
152 if(dvwo.valid())
153 dvwo->set_debug(m_spDebugWriterInner);
154 }
155
156 template<typename T>
158 {
159 if(!m_spDebugWriterSkeleton.valid()) return;
161 = op.template cast_dynamic<VectorDebugWritingObject<vector_type> >();
162 if(dvwo.valid())
163 dvwo->set_debug(m_spDebugWriterSkeleton);
164 }
165
166protected:
167 // Operator that is inverted by this Inverse Operator
169
170 // slices from matrix
172
173 // Linear Solver to invert the local Dirichlet problems
175
176
177
178 // sub matrices/operator (will be set by init)
180
181
182 template<int dim> void set_debug_dim();
183
187
189
190};
191
192
193
194} // end namespace ug
195
196#endif /* UG_PARALLEL */
197
198#endif /* __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_COMPLEMENT_OPERATOR__ */
Definition smart_pointer.h:107
bool valid() const
returns true if the pointer is valid, false if not.
Definition smart_pointer.h:206
base class for all debug writer
Definition debug_writer.h:244
describes a linear mapping X->Y
Definition linear_operator.h:80
describes an inverse linear mapping X->Y
Definition linear_operator_inverse.h:80
Definition matrix_operator.h:49
virtual M & get_matrix()
Definition matrix_operator.h:74
Definition schur_complement_operator.h:69
SmartPtr< AlgebraDebugWriter< algebra_type > > m_spDebugWriterInner
Definition schur_complement_operator.h:184
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_op[2][2]
Definition schur_complement_operator.h:179
SmartPtr< IDebugWriter< algebra_type > > m_spDebugWriter
Definition schur_complement_operator.h:186
void set_debug_dim()
Definition schur_complement_operator.cpp:401
virtual const char * name() const
name of solver
Definition schur_complement_operator.h:101
TAlgebra::vector_type vector_type
Definition schur_complement_operator.h:76
matrix_type & sub_matrix(int r, int c)
Definition schur_complement_operator.h:127
const SchurSlicingData m_slicing
Definition schur_complement_operator.h:171
SchurComplementOperator(SmartPtr< MatrixOperator< matrix_type, vector_type > > Alocal, SchurSlicingData::slice_desc_type_vector &sdv)
constructor
Definition schur_complement_operator.h:85
void compute_matrix(matrix_type &schur_matrix, double threshold=0.0)
Definition schur_complement_operator.cpp:330
virtual void apply(vector_type &f, const vector_type &u)
apply schur complement
Definition schur_complement_operator.cpp:177
virtual void apply_sub(vector_type &f, const vector_type &u)
Definition schur_complement_operator.cpp:277
void debug_compute_matrix()
Definition schur_complement_operator.cpp:294
SmartPtr< MatrixOperator< matrix_type, vector_type > > sub_operator(int r, int c)
Definition schur_complement_operator.h:130
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_spOperator
Definition schur_complement_operator.h:168
void set_matrix(SmartPtr< MatrixOperator< matrix_type, vector_type > > A)
Definition schur_complement_operator.h:119
void set_inner_debug(SmartPtr< T > op)
Definition schur_complement_operator.h:147
virtual void init()
initializes the solver for operator A
Definition schur_complement_operator.cpp:97
const SchurSlicingData & slicing() const
Definition schur_complement_operator.h:136
TAlgebra algebra_type
Definition schur_complement_operator.h:73
void set_skeleton_debug(SmartPtr< T > op)
Definition schur_complement_operator.h:157
void init(const vector_type &u)
implementation of the operator for the solution dependent initialization.
Definition schur_complement_operator.h:105
void set_dirichlet_solver(SmartPtr< ILinearOperatorInverse< vector_type > > dirichletSolver)
sets a Dirichlet solver
Definition schur_complement_operator.h:123
virtual ~SchurComplementOperator()
Definition schur_complement_operator.h:98
SmartPtr< AlgebraDebugWriter< algebra_type > > m_spDebugWriterSkeleton
Definition schur_complement_operator.h:185
SmartPtr< ILinearOperatorInverse< vector_type > > m_spDirichletSolver
Definition schur_complement_operator.h:174
virtual void set_debug(SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
Definition schur_complement_operator.cpp:430
TAlgebra::matrix_type matrix_type
Definition schur_complement_operator.h:79
size_t sub_size(schur_slice_desc_type type)
Definition schur_complement_operator.h:133
int m_applyCnt
Definition schur_complement_operator.h:188
function util d3f check type(param, name, typ)
the ug namespace
schur_slice_desc_type
Definition schur.h:63
SlicingData< SchurSliceDescVector, 2 > SchurSlicingData
Definition schur.h:66
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition smart_pointer.h:839