3 #ifndef DUNE_ISTL_LDL_HH 4 #define DUNE_ISTL_LDL_HH 6 #if HAVE_SUITESPARSE_LDL || defined DOXYGEN 19 #include <dune/common/exceptions.hh> 20 #include <dune/common/unused.hh> 39 template<
class M,
class T,
class TM,
class TD,
class TA>
40 class SeqOverlappingSchwarz;
42 template<
class T,
bool tag>
43 struct SeqOverlappingSchwarzAssemblerHelper;
51 template<
class Matrix>
68 template<
typename T,
typename A,
int n,
int m>
70 :
public InverseOperator<BlockVector<FieldVector<T,m>, typename A::template rebind<FieldVector<T,m> >::other>,
71 BlockVector<FieldVector<T,n>, typename A::template rebind<FieldVector<T,n> >::other> >
95 LDL(
const Matrix& matrix,
int verbose=0) : matrixIsLoaded_(false), verbose_(verbose)
98 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
111 LDL(
const Matrix& matrix,
int verbose,
bool) : matrixIsLoaded_(false), verbose_(verbose)
114 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
119 LDL() : matrixIsLoaded_(false), verbose_(0)
125 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
132 const int dimMat(ldlMatrix_.N());
133 ldl_perm(dimMat, Y_, reinterpret_cast<double*>(&b[0]), P_);
134 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
135 ldl_dsolve(dimMat, Y_, D_);
136 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
137 ldl_permt(dimMat, reinterpret_cast<double*>(&x[0]), Y_, P_);
146 DUNE_UNUSED_PARAMETER(reduction);
157 const int dimMat(ldlMatrix_.N());
158 ldl_perm(dimMat, Y_, b, P_);
159 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
160 ldl_dsolve(dimMat, Y_, D_);
161 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
162 ldl_permt(dimMat, x, Y_, P_);
167 DUNE_UNUSED_PARAMETER(option);
168 DUNE_UNUSED_PARAMETER(value);
174 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
183 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
185 ldlMatrix_.setMatrix(matrix,rowIndexSet);
221 matrixIsLoaded_ =
false;
267 template<
class M,
class X,
class TM,
class TD,
class T1>
276 const int dimMat(ldlMatrix_.N());
277 D_ =
new double [dimMat];
278 Y_ =
new double [dimMat];
279 Lp_ =
new int [dimMat + 1];
280 Parent_ =
new int [dimMat];
281 Lnz_ =
new int [dimMat];
282 Flag_ =
new int [dimMat];
283 Pattern_ =
new int [dimMat];
284 P_ =
new int [dimMat];
285 Pinv_ =
new int [dimMat];
287 double Info [AMD_INFO];
288 if(amd_order (dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), P_, (
double *) NULL, Info) < AMD_OK)
289 DUNE_THROW(InvalidStateException,
"Error: AMD failed!");
293 ldl_symbolic(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), Lp_, Parent_, Lnz_, Flag_, P_, Pinv_);
295 Lx_ =
new double [Lp_[dimMat]];
296 Li_ =
new int [Lp_[dimMat]];
298 const int rank(ldl_numeric(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), ldlMatrix_.getValues(),
299 Lp_, Parent_, Lnz_, Li_, Lx_, D_, Y_, Pattern_, Flag_, P_, Pinv_));
307 DUNE_THROW(InvalidStateException,
"Error: LDL factorisation failed!");
310 LDLMatrix ldlMatrix_;
311 bool matrixIsLoaded_;
326 template<
typename T,
typename A,
int n,
int m>
332 template<
typename T,
typename A,
int n,
int m>
340 #endif //HAVE_SUITESPARSE_LDL 341 #endif //DUNE_ISTL_LDL_HH void apply(T *x, T *b)
Additional apply method with c-arrays in analogy to superlu.
Definition: ldl.hh:155
Definition: solvertype.hh:27
const char * name()
Get method name.
Definition: ldl.hh:225
void setSubMatrix(const Matrix &matrix, const S &rowIndexSet)
Definition: ldl.hh:181
A vector of blocks with memory management.
Definition: bvector.hh:312
void setVerbosity(int v)
Sets the verbosity level for the solver.
Definition: ldl.hh:193
Implementations of the inverse operator interface.
Inititializer for the ColCompMatrix as needed by OverlappingSchwarz.
Definition: colcompmatrix.hh:153
void free()
Free allocated space.
Definition: ldl.hh:211
int * getLi()
Get factorization Li.
Definition: ldl.hh:252
LDLMatrix & getInternalMatrix()
Return the column compress matrix.
Definition: ldl.hh:202
virtual ~LDL()
Default constructor.
Definition: ldl.hh:123
Templates characterizing the type of a solver.
Definition: colcompmatrix.hh:160
Abstract base class for all solvers.
Definition: solver.hh:79
void setMatrix(const Matrix &matrix)
Initialize data from given matrix.
Definition: ldl.hh:172
Dune::ColCompMatrix< Matrix > LDLMatrix
The corresponding SuperLU Matrix type.
Definition: ldl.hh:78
LDL()
Default constructor.
Definition: ldl.hh:119
Definition: matrixutils.hh:25
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:422
double * getLx()
Get factorization Lx.
Definition: ldl.hh:261
Definition: basearray.hh:19
bool converged
True if convergence criterion has been met.
Definition: solver.hh:56
Dune::BlockVector< FieldVector< T, n >, typename A::template rebind< FieldVector< T, n > >::other > range_type
The type of the range of the solver.
Definition: ldl.hh:84
Definition: solvertype.hh:13
Dune::BlockVector< FieldVector< T, m >, typename A::template rebind< FieldVector< T, m > >::other > domain_type
The type of the domain of the solver.
Definition: ldl.hh:82
LDL(const Matrix &matrix, int verbose, bool)
Constructor for compatibility with SuperLU standard constructor.
Definition: ldl.hh:111
virtual void apply(domain_type &x, range_type &b, InverseOperatorResult &res)
Apply inverse operator,.
Definition: ldl.hh:130
void setOption(unsigned int option, double value)
Definition: ldl.hh:165
int iterations
Number of iterations.
Definition: solver.hh:50
int * getLp()
Get factorization Lp.
Definition: ldl.hh:243
LDL(const Matrix &matrix, int verbose=0)
Construct a solver object from a BCRSMatrix.
Definition: ldl.hh:95
virtual void apply(domain_type &x, range_type &b, double reduction, InverseOperatorResult &res)
apply inverse operator, with given convergence criteria.
Definition: ldl.hh:144
double * getD()
Get factorization diagonal matrix D.
Definition: ldl.hh:234
Definition: colcompmatrix.hh:250
Sequential overlapping Schwarz preconditioner.
Definition: colcompmatrix.hh:157
Use the LDL package to directly solve linear systems – empty default class.
Definition: ldl.hh:52
Statistics about the application of an inverse operator.
Definition: solver.hh:31