3#ifndef DUNE_ISTL_SUPERMATRIX_HH
4#define DUNE_ISTL_SUPERMATRIX_HH
7#ifdef SUPERLU_POST_2005_VERSION
10#define SUPERLU_NTYPE 1
55#include"colcompmatrix.hh"
61 struct SuperMatrixCreateSparseChooser
65 struct SuperMatrixPrinter
70 struct SuperMatrixCreateSparseChooser<float>
72 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
73 float *values,
int *rowindex,
int* colindex,
74 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
76 sCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
82 struct SuperMatrixPrinter<float>
84 static void print(
char* name, SuperMatrix* mat)
86 sPrint_CompCol_Matrix(name, mat);
93 struct SuperMatrixCreateSparseChooser<double>
95 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
96 double *values,
int *rowindex,
int* colindex,
97 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
99 dCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
100 stype, dtype, mtype);
105 struct SuperMatrixPrinter<double>
107 static void print(
char* name, SuperMatrix* mat)
109 dPrint_CompCol_Matrix(name, mat);
116 struct SuperMatrixCreateSparseChooser<
std::complex<float> >
118 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
119 std::complex<float> *values,
int *rowindex,
int* colindex,
120 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
122 cCreate_CompCol_Matrix(mat, n, m, offset,
reinterpret_cast< ::complex*
>(values),
123 rowindex, colindex, stype, dtype, mtype);
128 struct SuperMatrixPrinter<
std::complex<float> >
130 static void print(
char* name, SuperMatrix* mat)
132 cPrint_CompCol_Matrix(name, mat);
139 struct SuperMatrixCreateSparseChooser<
std::complex<double> >
141 static void create(SuperMatrix *mat,
int n,
int m,
int offset,
142 std::complex<double> *values,
int *rowindex,
int* colindex,
143 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
145 zCreate_CompCol_Matrix(mat, n, m, offset,
reinterpret_cast<doublecomplex*
>(values),
146 rowindex, colindex, stype, dtype, mtype);
151 struct SuperMatrixPrinter<
std::complex<double> >
153 static void print(
char* name, SuperMatrix* mat)
155 zPrint_CompCol_Matrix(name, mat);
161 struct BaseGetSuperLUType
163 static const Dtype_t type;
167 struct GetSuperLUType
171 const Dtype_t BaseGetSuperLUType<T>::type =
172 Dune::is_same<T,float>::value ? SLU_S :
173 ( Dune::is_same<T,std::complex<double> >::value ? SLU_Z :
174 ( Dune::is_same<T,std::complex<float> >::value ? SLU_C : SLU_D ));
177 struct GetSuperLUType<double>
178 :
public BaseGetSuperLUType<double>
180 typedef double float_type;
184 struct GetSuperLUType<float>
185 :
public BaseGetSuperLUType<float>
187 typedef float float_type;
191 struct GetSuperLUType<
std::complex<double> >
192 :
public BaseGetSuperLUType<std::complex<double> >
194 typedef double float_type;
198 struct GetSuperLUType<
std::complex<float> >
199 :
public BaseGetSuperLUType<std::complex<float> >
201 typedef float float_type;
214 struct SuperMatrixInitializer
223 template<
class B,
class TA,
int n,
int m>
227 template<
class M,
class X,
class TM,
class TD,
class T1>
234 friend struct SeqOverlappingSchwarzAssembler<SuperLU<
Matrix> >;
251 if (this->N_+this->M_*this->Nnz_ != 0)
256 operator SuperMatrix&()
262 operator const SuperMatrix&()
const
270 SuperMatrixCreateSparseChooser<B>
271 ::create(&A, this->N_, this->M_, this->colstart[this->N_],
272 this->values,this->rowindex, this->colstart, SLU_NC,
273 static_cast<Dtype_t
>(GetSuperLUType<B>::type), SLU_GE);
277 SuperLUMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >& operator=(
const SuperLUMatrix <BCRSMatrix<FieldMatrix<B,n,m>,TA> >& mat)
279 this->ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::operator=(mat);
280 SuperMatrixCreateSparseChooser<B>
281 ::create(&A, this->N_, this->M_, this->colstart[this->N_],
282 this->values,this->rowindex, this->colstart, SLU_NC,
283 static_cast<Dtype_t
>(GetSuperLUType<B>::type), SLU_GE);
295 if(this->N_+this->M_+this->Nnz_!=0)
297 this->N_=mrs.size()*n;
298 this->M_=mrs.size()*m;
299 SuperMatrixInitializer<Matrix> initializer(*
this);
309 SuperMatrixInitializer<Matrix> initializer(*
this);
318 SUPERLU_FREE(A.Store);
324 template<
class T,
class A,
int n,
int m>
325 class SuperMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >
326 :
public ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >
328 template<
class I,
class S,
class D>
329 friend class OverlappingSchwarzInitializer;
331 typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Matrix;
334 SuperMatrixInitializer(SuperLUMatrix& lum) : ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >(lum)
338 SuperMatrixInitializer() : ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >()
341 virtual void createMatrix()
const
343 ColCompMatrixInitializer<BCRSMatrix<FieldMatrix<T,n,m>,A> >::createMatrix();
344 SuperMatrixCreateSparseChooser<T>
345 ::create(&slumat->A, slumat->N_, slumat->M_, slumat->colstart[this->cols],
346 slumat->values,slumat->rowindex, slumat->colstart, SLU_NC,
347 static_cast<Dtype_t
>(GetSuperLUType<T>::type), SLU_GE);
350 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:413
A::size_type size_type
The type for the index access and the size.
Definition: bcrsmatrix.hh:447
A dense n x m matrix.
Definition: fmatrix.hh:67
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:753
virtual void setMatrix(const Matrix &mat)
Initialize data from given matrix.
Definition: supermatrix.hh:305
virtual ~SuperLUMatrix()
Destructor.
Definition: supermatrix.hh:249
SuperLUMatrix(const Matrix &mat)
Constructor that initializes the data.
Definition: supermatrix.hh:242
BCRSMatrix< FieldMatrix< B, n, m >, TA > Matrix
The type of the matrix to convert.
Definition: supermatrix.hh:232
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:293
virtual void free()
free allocated space.
Definition: supermatrix.hh:315
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:10
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:211
Traits for type conversions and type information.