Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SparseDiagBlkMatrix.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: SparseDiagBlkMatrix.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Diagonal block sparse matrix class templated by underlying
32 // sparse
33 // storage format
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SPARSE_DIAG_BLK_MATRIX_HPP
38 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SPARSE_DIAG_BLK_MATRIX_HPP
39 
40 #include <algorithm>
41 #include <fstream>
42 #include <map>
43 #include <utility>
44 #include <vector>
45 
48 
49 #include <boost/call_traits.hpp>
50 
51 namespace Nektar
52 {
53 
54 /*
55  * This is a class-container to diagonal block matrix
56  * with elements being sparse matrices. The type of
57  * sparse entries is defined with template parameter.
58  *
59  */
60 template <typename SparseStorageType> class NekSparseDiagBlkMatrix
61 {
62 public:
63  typedef SparseStorageType StorageType;
64  typedef typename SparseStorageType::DataType DataType;
65  typedef std::shared_ptr<SparseStorageType> SparseStorageSharedPtr;
69 
71  const SparseStorageSharedPtrVector &sparseStoragePtrVector);
73  const NekSparseDiagBlkMatrix &src);
75 
80 
86 
87  LIB_UTILITIES_EXPORT typename boost::call_traits<DataType>::const_reference
88  operator()(const IndexType row, const IndexType column) const;
89  LIB_UTILITIES_EXPORT typename boost::call_traits<DataType>::const_reference
90  operator()(const IndexType block, const IndexType row,
91  const IndexType column) const;
92 
93  // typename SparseStorageType::const_iterator begin() const;
94  // typename SparseStorageType::const_iterator end() const;
95 
97  DataVectorType &out);
98  LIB_UTILITIES_EXPORT void Multiply(const DataType *in, DataType *out);
100  DataType *in, DataType *out);
101 
104 
105  LIB_UTILITIES_EXPORT unsigned long GetMulCallsCounter() const;
112 
113  LIB_UTILITIES_EXPORT void writeSparsityPatternTo(std::ostream &out,
114  IndexType blockSize = 64);
116  std::ostream &out, const IndexType subMatrixIdx,
117  IndexType blockSize = 64);
119  std::ostream &out, const IndexType blk_row = 0,
120  const IndexType blk_col = 0, IndexType blockSize = 64);
122  std::ostream &out, const IndexType subMatrixIdx,
123  const IndexType blk_row = 0, const IndexType blk_col = 0,
124  IndexType blockSize = 64);
125 
126 protected:
130  unsigned long m_mulCallsCounter;
132 
133 private:
134 };
135 
136 } // namespace Nektar
137 
138 #endif // NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SPARSE_DIAG_BLK_MATRIX_HPP
#define LIB_UTILITIES_EXPORT
1D Array of constant elements with garbage collection and bounds checking.
Definition: SharedArray.hpp:58
Array< OneD, SparseStorageSharedPtr > SparseStorageSharedPtrVector
SparseStorageType::DataType DataType
boost::call_traits< DataType >::const_reference operator()(const IndexType row, const IndexType column) const
std::shared_ptr< SparseStorageType > SparseStorageSharedPtr
Array< OneD, const DataType > ConstDataVectorType
void MultiplySubMatrix(const IndexType blockNum, DataType *in, DataType *out)
void writeSubmatrixBlockSparsityPatternTo(std::ostream &out, const IndexType subMatrixIdx, const IndexType blk_row=0, const IndexType blk_col=0, IndexType blockSize=64)
Complementary routine to the previous. It generates exact non-zero pattern of a given block matrix en...
unsigned long GetMulCallsCounter() const
Array< OneD, DataType > DataVectorType
void writeSubmatrixSparsityPatternTo(std::ostream &out, const IndexType subMatrixIdx, IndexType blockSize=64)
void writeSparsityPatternTo(std::ostream &out, IndexType blockSize=64)
void Multiply(const DataVectorType &in, DataVectorType &out)
SparseStorageSharedPtrVector m_submatrix
void writeBlockSparsityPatternTo(std::ostream &out, const IndexType blk_row=0, const IndexType blk_col=0, IndexType blockSize=64)
NekSparseDiagBlkMatrix(const SparseStorageSharedPtrVector &sparseStoragePtrVector)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< COOMatType > COOMatTypeSharedPtr
unsigned int IndexType