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> >
89 return SolverCategory::Category::sequential;
101 LDL(
const Matrix& matrix,
int verbose=0) : matrixIsLoaded_(false), verbose_(verbose)
104 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
117 LDL(
const Matrix& matrix,
int verbose,
bool) : matrixIsLoaded_(false), verbose_(verbose)
120 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
125 LDL() : matrixIsLoaded_(false), verbose_(0)
131 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
138 const int dimMat(ldlMatrix_.N());
139 ldl_perm(dimMat, Y_, reinterpret_cast<double*>(&b[0]), P_);
140 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
141 ldl_dsolve(dimMat, Y_, D_);
142 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
143 ldl_permt(dimMat, reinterpret_cast<double*>(&x[0]), Y_, P_);
152 DUNE_UNUSED_PARAMETER(reduction);
163 const int dimMat(ldlMatrix_.N());
164 ldl_perm(dimMat, Y_, b, P_);
165 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
166 ldl_dsolve(dimMat, Y_, D_);
167 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
168 ldl_permt(dimMat, x, Y_, P_);
173 DUNE_UNUSED_PARAMETER(option);
174 DUNE_UNUSED_PARAMETER(value);
180 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
189 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
191 ldlMatrix_.setMatrix(matrix,rowIndexSet);
227 matrixIsLoaded_ =
false;
273 template<
class M,
class X,
class TM,
class TD,
class T1>
282 const int dimMat(ldlMatrix_.N());
283 D_ =
new double [dimMat];
284 Y_ =
new double [dimMat];
285 Lp_ =
new int [dimMat + 1];
286 Parent_ =
new int [dimMat];
287 Lnz_ =
new int [dimMat];
288 Flag_ =
new int [dimMat];
289 Pattern_ =
new int [dimMat];
290 P_ =
new int [dimMat];
291 Pinv_ =
new int [dimMat];
293 double Info [AMD_INFO];
294 if(amd_order (dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), P_, (
double *) NULL, Info) < AMD_OK)
295 DUNE_THROW(InvalidStateException,
"Error: AMD failed!");
299 ldl_symbolic(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), Lp_, Parent_, Lnz_, Flag_, P_, Pinv_);
301 Lx_ =
new double [Lp_[dimMat]];
302 Li_ =
new int [Lp_[dimMat]];
304 const int rank(ldl_numeric(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), ldlMatrix_.getValues(),
305 Lp_, Parent_, Lnz_, Li_, Lx_, D_, Y_, Pattern_, Flag_, P_, Pinv_));
313 DUNE_THROW(InvalidStateException,
"Error: LDL factorisation failed!");
316 LDLMatrix ldlMatrix_;
317 bool matrixIsLoaded_;
332 template<
typename T,
typename A,
int n,
int m>
338 template<
typename T,
typename A,
int n,
int m>
346 #endif //HAVE_SUITESPARSE_LDL 347 #endif //DUNE_ISTL_LDL_HH Dune::ColCompMatrix< Matrix > LDLMatrix
The corresponding SuperLU Matrix type.
Definition: ldl.hh:78
virtual ~LDL()
Default constructor.
Definition: ldl.hh:129
const char * name()
Get method name.
Definition: ldl.hh:231
void setSubMatrix(const Matrix &matrix, const S &rowIndexSet)
Definition: ldl.hh:187
Inititializer for the ColCompMatrix as needed by OverlappingSchwarz.
Definition: colcompmatrix.hh:153
Definition: allocator.hh:7
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
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:422
LDL()
Default constructor.
Definition: ldl.hh:125
Use the LDL package to directly solve linear systems – empty default class.
Definition: ldl.hh:52
Implementations of the inverse operator interface.
Definition: colcompmatrix.hh:160
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
void setVerbosity(int v)
Sets the verbosity level for the solver.
Definition: ldl.hh:199
Definition: solvertype.hh:27
double * getD()
Get factorization diagonal matrix D.
Definition: ldl.hh:240
void setMatrix(const Matrix &matrix)
Initialize data from given matrix.
Definition: ldl.hh:178
Definition: matrixutils.hh:25
Definition: colcompmatrix.hh:250
Sequential overlapping Schwarz preconditioner.
Definition: colcompmatrix.hh:157
void free()
Free allocated space.
Definition: ldl.hh:217
virtual void apply(domain_type &x, range_type &b, InverseOperatorResult &res)
Apply inverse operator,.
Definition: ldl.hh:136
bool converged
True if convergence criterion has been met.
Definition: solver.hh:65
Abstract base class for all solvers.
Definition: solver.hh:91
int * getLp()
Get factorization Lp.
Definition: ldl.hh:249
Category
Definition: solvercategory.hh:21
Definition: solvertype.hh:13
LDL(const Matrix &matrix, int verbose, bool)
Constructor for compatibility with SuperLU standard constructor.
Definition: ldl.hh:117
LDL(const Matrix &matrix, int verbose=0)
Construct a solver object from a BCRSMatrix.
Definition: ldl.hh:101
A vector of blocks with memory management.
Definition: bvector.hh:316
double * getLx()
Get factorization Lx.
Definition: ldl.hh:267
Statistics about the application of an inverse operator.
Definition: solver.hh:40
virtual SolverCategory::Category category() const
Category of the solver (see SolverCategory::Category)
Definition: ldl.hh:87
virtual void apply(domain_type &x, range_type &b, double reduction, InverseOperatorResult &res)
apply inverse operator, with given convergence criteria.
Definition: ldl.hh:150
LDLMatrix & getInternalMatrix()
Return the column compress matrix.
Definition: ldl.hh:208
int * getLi()
Get factorization Li.
Definition: ldl.hh:258
int iterations
Number of iterations.
Definition: solver.hh:59
Templates characterizing the type of a solver.
void setOption(unsigned int option, double value)
Definition: ldl.hh:171
void apply(T *x, T *b)
Additional apply method with c-arrays in analogy to superlu.
Definition: ldl.hh:161