3#ifndef DUNE_ISTL_SUPERMATRIX_HH
4#define DUNE_ISTL_SUPERMATRIX_HH
35#include"colcompmatrix.hh"
41 struct SuperMatrixCreateSparseChooser
45 struct SuperMatrixPrinter
50 struct SuperMatrixCreateSparseChooser<float>
52 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
53 float *values,
int *rowindex,
int* colindex,
54 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
56 sCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
62 struct SuperMatrixPrinter<float>
64 static void print(
char* name, SuperMatrix* mat)
66 sPrint_CompCol_Matrix(name, mat);
73 struct SuperMatrixCreateSparseChooser<double>
75 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
76 double *values,
int *rowindex,
int* colindex,
77 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
79 dCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
85 struct SuperMatrixPrinter<double>
87 static void print(
char* name, SuperMatrix* mat)
89 dPrint_CompCol_Matrix(name, mat);
96 struct SuperMatrixCreateSparseChooser<
std::complex<float> >
98 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
99 std::complex<float> *values,
int *rowindex,
int* colindex,
100 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
102 cCreate_CompCol_Matrix(mat, n, m, offset,
reinterpret_cast< ::complex*
>(values),
103 rowindex, colindex, stype, dtype, mtype);
108 struct SuperMatrixPrinter<
std::complex<float> >
110 static void print(
char* name, SuperMatrix* mat)
112 cPrint_CompCol_Matrix(name, mat);
119 struct SuperMatrixCreateSparseChooser<
std::complex<double> >
121 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
122 std::complex<double> *values,
int *rowindex,
int* colindex,
123 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
125 zCreate_CompCol_Matrix(mat, n, m, offset,
reinterpret_cast<doublecomplex*
>(values),
126 rowindex, colindex, stype, dtype, mtype);
131 struct SuperMatrixPrinter<
std::complex<double> >
133 static void print(
char* name, SuperMatrix* mat)
135 zPrint_CompCol_Matrix(name, mat);
141 struct BaseGetSuperLUType
143 static const Dtype_t type;
147 struct GetSuperLUType
151 const Dtype_t BaseGetSuperLUType<T>::type =
152 std::is_same<T,float>::value ? SLU_S :
153 ( std::is_same<T,std::complex<double> >::value ? SLU_Z :
154 ( std::is_same<T,std::complex<float> >::value ? SLU_C : SLU_D ));
157 struct GetSuperLUType<double>
158 :
public BaseGetSuperLUType<double>
160 typedef double float_type;
164 struct GetSuperLUType<float>
165 :
public BaseGetSuperLUType<float>
167 typedef float float_type;
171 struct GetSuperLUType<
std::complex<double> >
172 :
public BaseGetSuperLUType<std::complex<double> >
174 typedef double float_type;
178 struct GetSuperLUType<
std::complex<float> >
179 :
public BaseGetSuperLUType<std::complex<float> >
181 typedef float float_type;
194 struct SuperMatrixInitializer
203 template<
class B,
class TA,
int n,
int m>
207 template<
class M,
class X,
class TM,
class TD,
class T1>
214 friend struct SeqOverlappingSchwarzAssemblerHelper<SuperLU<
Matrix>, true>;
231 if (this->N_+this->M_*this->Nnz_ != 0)
236 operator SuperMatrix&()
242 operator const SuperMatrix&()
const
250 SuperMatrixCreateSparseChooser<B>
251 ::create(&A, this->N_, this->M_, this->colstart[this->N_],
252 this->values,this->rowindex, this->colstart, SLU_NC,
253 static_cast<Dtype_t
>(GetSuperLUType<B>::type), SLU_GE);
257 SuperLUMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >& operator=(
const SuperLUMatrix <BCRSMatrix<FieldMatrix<B,n,m>,TA> >& mat)
259 this->ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::operator=(mat);
260 SuperMatrixCreateSparseChooser<B>
261 ::create(&A, this->N_, this->M_, this->colstart[this->N_],
262 this->values,this->rowindex, this->colstart, SLU_NC,
263 static_cast<Dtype_t
>(GetSuperLUType<B>::type), SLU_GE);
275 if(this->N_+this->M_+this->Nnz_!=0)
277 this->N_=mrs.size()*n;
278 this->M_=mrs.size()*m;
279 SuperMatrixInitializer<Matrix> initializer(*
this);
289 SuperMatrixInitializer<Matrix> initializer(*
this);
298 SUPERLU_FREE(A.Store);
304 template<
class T,
class A,
int n,
int m>
305 class SuperMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >
306 :
public ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >
308 template<
class I,
class S,
class D>
309 friend class OverlappingSchwarzInitializer;
311 typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Matrix;
314 SuperMatrixInitializer(SuperLUMatrix& lum) : ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >(lum)
318 SuperMatrixInitializer() : ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >()
321 virtual void createMatrix()
const
323 ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >::createMatrix();
324 SuperMatrixCreateSparseChooser<T>
325 ::create(&slumat->A, slumat->N_, slumat->M_, slumat->colstart[this->cols],
326 slumat->values,slumat->rowindex, slumat->colstart, SLU_NC,
327 static_cast<Dtype_t
>(GetSuperLUType<T>::type), SLU_GE);
330 SuperLUMatrix* slumat;
Implementation of the BCRSMatrix class.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:423
A::size_type size_type
The type for the index access and the size.
Definition: bcrsmatrix.hh:457
A dense n x m matrix.
Definition: fmatrix.hh:68
Provides access to an iterator over all matrix rows.
Definition: colcompmatrix.hh:22
Provides access to an iterator over an arbitrary subset of matrix rows.
Definition: colcompmatrix.hh:60
Sequential overlapping Schwarz preconditioner.
Definition: overlappingschwarz.hh:742
virtual void setMatrix(const Matrix &mat)
Initialize data from given matrix.
Definition: supermatrix.hh:285
virtual ~SuperLUMatrix()
Destructor.
Definition: supermatrix.hh:229
SuperLUMatrix(const Matrix &mat)
Constructor that initializes the data.
Definition: supermatrix.hh:222
BCRSMatrix< FieldMatrix< B, n, m >, TA > Matrix
The type of the matrix to convert.
Definition: supermatrix.hh:212
virtual void setMatrix(const Matrix &mat, const std::set< std::size_t > &mrs)
Initialize data from a given set of matrix rows and columns.
Definition: supermatrix.hh:273
virtual void free()
free allocated space.
Definition: supermatrix.hh:295
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignment.hh:11
Utility class for converting an ISTL Matrix into a column-compressed matrix.
Definition: colcompmatrix.hh:145
Utility class for converting an ISTL Matrix into a SuperLU Matrix.
Definition: supermatrix.hh:191
Traits for type conversions and type information.