ug4
parallel_matrix.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-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__PARALLELIZATION__PARALLEL_MATRIX__
34 #define __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_MATRIX__
35 
36 #include "pcl/pcl.h"
37 #include "parallel_index_layout.h"
38 #include "parallelization_util.h"
39 #include "parallel_storage_type.h"
40 #include "algebra_layouts.h"
42 #include "parallel_vector.h"
43 
44 namespace ug
45 {
46 
48 
50 
63 template <typename TMatrix>
64 class ParallelMatrix : public TMatrix
65 {
66  public:
67  enum {rows_sorted=TMatrix::rows_sorted};
68 
69 
70  private:
71  // disallow copy constructor
73 
74  public:
77 
78  public:
82  {}
83 
87  {}
88 
90  // Storage type handling
92 
95 
98 
100 
101  void set_storage_type(uint type) {m_type = type;}
102 
104 
105  void add_storage_type(uint type) {m_type |= type;}
106 
108 
109  void remove_storage_type(uint type) {m_type &= ~type;}
110 
113 
115 
116  bool has_storage_type(uint type) const
117  {return type == PST_UNDEFINED ? m_type == PST_UNDEFINED : (m_type & type) == type;}
118 
120  uint get_storage_mask() const { return m_type; }
122 
124  // OverWritten functions
126 
128  template<typename TPVector>
129  bool apply(TPVector &res, const TPVector &x) const;
130 
132  template<typename TPVector>
133  bool apply_transposed(TPVector &res, const TPVector &x) const;
134 
136  template<typename TPVector>
137  bool matmul_minus(TPVector &res, const TPVector &x) const;
138 
140  this_type &operator =(const this_type &M);
141 
142  private:
145 
148 };
149 
150 // predaclaration.
151 // this type may already be declared somewhere else, which shouldn't hurt.
152 template<typename T>
154 
155 template<typename T>
157 {
158  enum{
160  };
161 };
162 
163 } // end namespace ug
164 
165 #include "parallel_matrix_impl.h"
166 
167 #endif /* __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_MATRIX__ */
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
Extends the HorizontalAlgebraLayouts by vertical layouts.
Definition: algebra_layouts.h:121
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
bool has_storage_type(uint type) const
returns if the current storage type has a given representation
Definition: parallel_matrix.h:116
bool apply_transposed(TPVector &res, const TPVector &x) const
calculate res = A.T x
Definition: parallel_matrix_impl.h:125
void set_storage_type(uint type)
sets the storage type
Definition: parallel_matrix.h:101
void set_layouts(ConstSmartPtr< AlgebraLayouts > layouts)
sets the algebra layouts
Definition: parallel_matrix.h:97
bool matmul_minus(TPVector &res, const TPVector &x) const
calculate res -= A x
Definition: parallel_matrix_impl.h:167
ParallelStorageType get_storage_type() const
Definition: parallel_matrix.h:121
ParallelMatrix(SmartPtr< AlgebraLayouts > layouts)
Constructor setting the layouts.
Definition: parallel_matrix.h:85
uint m_type
type of storage (i.e. consistent, additiv, additiv unique)
Definition: parallel_matrix.h:144
ConstSmartPtr< AlgebraLayouts > m_spAlgebraLayouts
algebra layouts and communicators
Definition: parallel_matrix.h:147
bool apply(TPVector &res, const TPVector &x) const
calculate res = A x
Definition: parallel_matrix_impl.h:83
ParallelMatrix(const ParallelMatrix &)
void add_storage_type(uint type)
adds a storage type
Definition: parallel_matrix.h:105
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition: parallel_matrix.h:94
uint get_storage_mask() const
returns storage type mask
Definition: parallel_matrix.h:120
@ rows_sorted
Definition: parallel_matrix.h:67
bool change_storage_type(ParallelStorageType type)
changes to the requested storage type if possible
Definition: parallel_matrix_impl.h:59
ParallelMatrix< TMatrix > this_type
own type
Definition: parallel_matrix.h:76
void remove_storage_type(uint type)
removes a storage type
Definition: parallel_matrix.h:109
this_type & operator=(const this_type &M)
assignment
Definition: parallel_matrix_impl.h:43
ParallelMatrix()
Default Constructor.
Definition: parallel_matrix.h:80
ParallelStorageType
Definition: parallel_storage_type.h:66
@ PST_UNDEFINED
Definition: parallel_storage_type.h:67
PrandtlReuss< TDomain > this_type
unsigned int uint
Definition: types.h:114
the ug namespace
@ MATRIX_USE_GLOBAL_FUNCTIONS
Definition: matrix_algebra_types.h:69
Definition: matrix_algebra_types.h:79
static const int type
Definition: matrix_algebra_types.h:80
function ProblemDisc new(problemDesc, dom)