34 #ifndef __H__UG__PLUGINS__NAVIER_STOKES__INCOMPRESSIBLE__FVCR__CRILUT__
35 #define __H__UG__PLUGINS__NAVIER_STOKES__INCOMPRESSIBLE__FVCR__CRILUT__
86 template <
typename TAlgebra>
150 newInst->set_damp(this->
damping());
152 newInst->set_info(this->
m_info);
202 virtual const char*
name()
const {
return "CRILUTPreconditioner";}
207 STATIC_ASSERT(matrix_type::rows_sorted, Matrix_has_to_have_sorted_rows);
212 typedef typename matrix_type::connection connection;
213 m_L.resize_and_clear(A->num_rows(), A->num_cols());
214 m_U.resize_and_clear(A->num_rows(), A->num_cols());
217 std::vector<typename matrix_type::connection> con;
221 static const size_t velocity=0;
222 static const size_t pressure=1;
225 for(
typename matrix_type::row_iterator i_it = A->begin_row(0); i_it != A->end_row(0); ++i_it)
226 con.push_back(connection(i_it.index(), i_it.value()));
227 m_U.set_matrix_row(0, &con[0], con.size());
229 size_t totalentries=0;
232 for(
size_t i=1; i<A->num_rows(); i++)
235 if ((*A)(i,i)!=0) itype=velocity;
else itype=pressure;
244 for(
typename matrix_type::row_iterator i_it = A->begin_row(i); i_it != A->end_row(i); ++i_it)
246 con.push_back(connection(i_it.index(), i_it.value()));
251 typename matrix_type::row_iterator i_it = A->begin_row(i);
252 con.push_back(connection(i_it.index(), i_it.value()));
254 for(; i_it != A->end_row(i); ++i_it)
256 if (i_it.value()==0)
continue;
257 con.push_back(connection(i_it.index(), i_it.value()));
263 for(
size_t i_it = 0; i_it < con.size(); ++i_it)
265 size_t k = con[i_it].iIndex;
272 if(con[i_it].dValue == 0.0)
continue;
273 UG_ASSERT(
m_U.num_connections(k) != 0 &&
m_U.begin_row(k).index() == k,
"");
279 block_type &d = con[i_it].dValue = con[i_it].dValue / ukk;
281 typename matrix_type::row_iterator k_it =
m_U.begin_row(k);
284 while(k_it !=
m_U.end_row(k) && j < con.size())
288 if(k_it.index() == con[j].iIndex)
291 con[j].dValue -= k_it.value() * d;
294 else if(k_it.index() < con[j].iIndex)
299 typename matrix_type::connection
300 c(k_it.index(), k_it.value() * d * -1.0);
305 if ((*A)(k_it.index(),k_it.index())!=0) kitType=velocity;
else kitType=pressure;
307 if ((itype==velocity)&&(kitType==velocity)){
311 con.insert(con.begin()+j, c);
315 if ((itype==velocity)&&(kitType==pressure)){
319 con.insert(con.begin()+j, c);
323 if ((itype==pressure)&&(kitType==velocity)){
327 con.insert(con.begin()+j, c);
331 if ((itype==pressure)&&(kitType==pressure)){
335 con.insert(con.begin()+j, c);
350 if (k_it!=
m_U.end_row(k)){
351 for (;k_it!=
m_U.end_row(k);++k_it){
352 typename matrix_type::connection c(k_it.index(),-k_it.value()*d);
355 if ((*A)(k_it.index(),k_it.index())!=0) kitType=velocity;
else kitType=pressure;
356 if ((itype==velocity)&&(kitType==velocity)){
362 if ((itype==velocity)&&(kitType==pressure)){
368 if ((itype==pressure)&&(kitType==velocity)){
389 totalentries+=con.size();
390 if(maxentries < con.size()) maxentries = con.size();
393 m_L.set_matrix_row(i, &con[0], u_part);
394 m_U.set_matrix_row(i, &con[u_part], con.size()-u_part);
402 UG_LOG(
"\n CRILUT storage information:\n");
403 UG_LOG(
" A nr of connections: " << A->total_num_connections() <<
"\n");
404 UG_LOG(
" L+U nr of connections: " <<
m_L.total_num_connections()+
m_U.total_num_connections() <<
"\n");
405 UG_LOG(
" Increase factor: " << (
float)(
m_L.total_num_connections() +
m_U.total_num_connections() )/A->total_num_connections() <<
"\n");
420 for(
size_t i=0; i <
m_L.num_rows(); i++)
424 for(
typename matrix_type::row_iterator it =
m_L.begin_row(i); it !=
m_L.end_row(i); ++it)
425 MatMultAdd(c[i], 1.0, c[i], -1.0, it.value(), c[it.index()] );
433 size_t i=
m_U.num_rows()-1;
434 typename matrix_type::row_iterator it =
m_U.begin_row(i);
443 UG_LOG(
"Warning: zero entry in last row of U with corresponding non-zero rhs entry (" <<
BlockNorm(
s) <<
")\n");
451 for(
size_t i=
m_U.num_rows()-2; ; i--)
453 typename matrix_type::row_iterator it =
m_U.begin_row(i);
459 for(; it !=
m_U.end_row(i); ++it)
461 MatMultAdd(
s, 1.0,
s, -1.0, it.value(), c[it.index()] );
494 template <
typename TAlgebra>
496 template <
typename TAlgebra>
CRILUTPreconditioner class.
Definition: cr_ilut.h:88
matrix_type::value_type block_type
Definition: cr_ilut.h:103
TAlgebra algebra_type
Definition: cr_ilut.h:91
virtual bool postprocess()
Definition: cr_ilut.h:478
static const number m_small_lower
Definition: cr_ilut.h:490
CRILUTPreconditioner(double eps=1e-6)
Definition: cr_ilut.h:109
bool m_remove_zeros
Definition: cr_ilut.h:489
number m_eps_pv
Definition: cr_ilut.h:486
virtual const char * name() const
Definition: cr_ilut.h:202
void set_threshold(number threshvv, number thresh_vp_pv_pp)
sets threshold for incomplete LU factorisation
Definition: cr_ilut.h:175
virtual bool preprocess(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp)
Definition: cr_ilut.h:205
SmartPtr< ILinearIterator< vector_type > > clone()
Definition: cr_ilut.h:146
void set_threshold(number threshvv, number threshvp, number threshpv, number threshpp)
sets threshold for incomplete LU factorisation
Definition: cr_ilut.h:165
number m_eps_pp
Definition: cr_ilut.h:487
matrix_type m_L
Definition: cr_ilut.h:481
virtual ~CRILUTPreconditioner()
Definition: cr_ilut.h:157
void set_info(bool info)
sets storage information output to true or false
Definition: cr_ilut.h:194
number m_eps_vp
Definition: cr_ilut.h:485
number m_eps_vv
Definition: cr_ilut.h:484
number m_eps
Definition: cr_ilut.h:483
IPreconditioner< TAlgebra >::matrix_operator_type matrix_operator_type
Matrix Operator type.
Definition: cr_ilut.h:100
virtual bool step(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp, vector_type &c, const vector_type &d)
Definition: cr_ilut.h:416
CRILUTPreconditioner(number threshvv, number threshvp, number threshpv, number threshpp, bool info)
Definition: cr_ilut.h:138
void set_threshold(number thresh)
Definition: cr_ilut.h:184
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: cr_ilut.h:162
CRILUTPreconditioner(number threshvv, number thresh_vp_pv_pp, bool info)
Definition: cr_ilut.h:132
TAlgebra::matrix_type matrix_type
Definition: cr_ilut.h:97
matrix_type m_U
Definition: cr_ilut.h:482
CRILUTPreconditioner(number threshvv, number thresh_vp_pv_pp)
Definition: cr_ilut.h:115
CRILUTPreconditioner(number threshvv, number threshvp, number threshpv, number threshpp)
Definition: cr_ilut.h:121
bool m_info
Definition: cr_ilut.h:488
static const number m_small_upper
Definition: cr_ilut.h:491
CRILUTPreconditioner(double eps, bool info)
Definition: cr_ilut.h:127
TAlgebra::vector_type vector_type
Definition: cr_ilut.h:94
TAlgebra::vector_type vector_type
SmartPtr< IDebugWriter< algebra_type > > debug_writer()
TAlgebra::matrix_type matrix_type
SmartPtr< IDamping< TAlgebra::vector_type, TAlgebra::vector_type > > damping()
TVector::value_type value_type
ParallelMatrix< SparseMatrix< double > > matrix_type
ParallelVector< Vector< double > > vector_type
bool InverseMatMult(DenseVector< FixedArray1< double, 1 > > &dest, double beta1, const DenseMatrix< FixedArray2< double, 1, 1 > > &A1, const DenseVector< FixedArray1< double, 1 > > &w1)
void MatMultAdd(DenseVector< vector_t > &dest, const number &alpha1, const DenseVector< vector_t > &v1, const number &beta1, const DenseMatrix< matrix_t > &A1, const DenseVector< vector_t > &w1)
#define UG_ASSERT(expr, msg)
#define STATIC_ASSERT(expr, msg)
number BlockNorm(const number &a)