/usr/include/trilinos/Ifpack_IC.h is in libtrilinos-ifpack-dev 12.12.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | /*@HEADER
// ***********************************************************************
//
// Ifpack: Object-Oriented Algebraic Preconditioner Package
// Copyright (2002) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
//@HEADER
*/
#ifndef IFPACK_IC_H
#define IFPACK_IC_H
#include "Ifpack_ConfigDefs.h"
#include "Ifpack_CondestType.h"
#include "Ifpack_ScalingType.h"
#include "Ifpack_Preconditioner.h"
#include "Epetra_Vector.h"
#include "Epetra_CrsMatrix.h"
#include "Epetra_RowMatrix.h"
#include "Epetra_Time.h"
#include "Teuchos_RefCountPtr.hpp"
class Epetra_Comm;
class Epetra_Map;
class Epetra_MultiVector;
namespace Teuchos {
class ParameterList;
}
//! Ifpack_IC: A class for constructing and using an incomplete Cholesky factorization of a given Epetra_RowMatrix.
/*! The Ifpack_IC class computes a threshold (not level) based incomplete
LDL^T factorization of a given Epetra_RowMatrix. The factorization
that is produced is a function of several parameters:
<ol>
<li> Level of fill ratio. This defines the maximum number of entries per row/column in the factor, relative to the average number of nonzeros per row/col in A. The default value of 1.0 keeps the IC factor as sparse as A.
<li> Diagonal perturbation - Prior to computing the factorization, it is possible to modify the diagonal entries of the matrix
for which the factorization will be computing. If the absolute and relative perturbation values are zero and one,
respectively, the
factorization will be compute for the original user matrix A. Otherwise, the factorization
will computed for a matrix that differs from the original user matrix in the diagonal values only. Details can be found in \ref ifp_diag_pert.
</ol>
*/
class Ifpack_IC: public Ifpack_Preconditioner {
public:
//! Ifpack_IC constuctor with variable number of indices per row.
/*! Creates a Ifpack_IC object and allocates storage.
\param In
A - User matrix to be factored.
\param In
Graph - Graph generated by Ifpack_IlukGraph.
*/
Ifpack_IC(Epetra_RowMatrix* A);
//! Ifpack_IC Destructor
virtual ~Ifpack_IC();
//! Set absolute threshold value
void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
//! Set relative threshold value
void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
//! Set parameters using a Teuchos::ParameterList object.
/* This method is only available if the Teuchos package is enabled.
This method recognizes five parameter names: level_fill, drop_tolerance,
absolute_threshold, relative_threshold and overlap_mode. These names are
case insensitive. For level_fill the ParameterEntry must have type int, the
threshold entries must have type double and overlap_mode must have type
Epetra_CombineMode.
*/
int SetParameters(Teuchos::ParameterList& parameterlis);
int SetParameter(const std::string Name, const int Value)
{
IFPACK_CHK_ERR(-98);
}
int SetParameter(const std::string Name, const double Value)
{
IFPACK_CHK_ERR(-98);
}
const Epetra_RowMatrix& Matrix() const
{
return(*A_);
}
Epetra_RowMatrix& Matrix()
{
return(*A_);
}
bool IsInitialized() const
{
return(IsInitialized_);
}
//! Initialize L and U with values from user matrix A.
/*! Copies values from the user's matrix into the nonzero pattern of L and U.
\param In
A - User matrix to be factored.
\warning The graph of A must be identical to the graph passed in to Ifpack_IlukGraph constructor.
*/
int Initialize();
//! Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parameters.
/*! This function computes the RILU(k) factors L and U using the current:
<ol>
<li> Ifpack_IlukGraph specifying the structure of L and U.
<li> Value for the RILU(k) relaxation parameter.
<li> Value for the \e a \e priori diagonal threshold values.
</ol>
InitValues() must be called before the factorization can proceed.
*/
int Compute();
int ComputeSetup();
//! If factor is completed, this query returns true, otherwise it returns false.
bool IsComputed() const {return(IsComputed_);};
// Mathematical functions.
//! Returns the result of a Ifpack_IC forward/back solve on a Epetra_MultiVector X in Y.
/*!
\param In
Trans -If true, solve transpose problem.
\param In
X - A Epetra_MultiVector of dimension NumVectors to solve for.
\param Out
Y -A Epetra_MultiVector of dimension NumVectorscontaining result.
\return Integer error code, set to 0 if successful.
*/
int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
//! Returns the maximum over all the condition number estimate for each local ILU set of factors.
/*! This functions computes a local condition number estimate on each processor and return the
maximum over all processor of the estimate.
\param In
Trans -If true, solve transpose problem.
\param Out
ConditionNumberEstimate - The maximum across all processors of
the infinity-norm estimate of the condition number of the inverse of LDU.
*/
double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
const int MaxIters = 1550,
const double Tol = 1e-9,
Epetra_RowMatrix* Matrix_in = 0);
double Condest() const
{
return(Condest_);
}
// Attribute access functions
//! Get absolute threshold value
double GetAbsoluteThreshold() {return Athresh_;}
//! Get relative threshold value
double GetRelativeThreshold() {return Rthresh_;}
//! Returns the number of nonzero entries in the global graph.
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int NumGlobalNonzeros() const {return(U().NumGlobalNonzeros()+D().GlobalLength());};
#endif
long long NumGlobalNonzeros64() const {return(U().NumGlobalNonzeros64()+D().GlobalLength64());};
//! Returns the number of nonzero entries in the local graph.
int NumMyNonzeros() const {return(U().NumMyNonzeros()+D().MyLength());};
//! Returns the address of the D factor associated with this factored matrix.
const Epetra_Vector & D() const {return(*D_);};
//! Returns the address of the U factor associated with this factored matrix.
const Epetra_CrsMatrix & U() const {return(*U_);};
//@{ \name Additional methods required to support the Epetra_Operator interface.
//! If set true, transpose of this operator will be applied.
/*! This flag allows the transpose of the given operator to be used implicitly. Setting this flag
affects only the Apply() and ApplyInverse() methods. If the implementation of this interface
does not support transpose use, this method should return a value of -1.
\param In
UseTranspose_in -If true, multiply by the transpose of operator, otherwise just use operator.
\return Always returns 0.
*/
int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
//! Returns 0.0 because this class cannot compute Inf-norm.
double NormInf() const {return(0.0);};
//! Returns false because this class cannot compute an Inf-norm.
bool HasNormInf() const {return(false);};
//! Returns the current UseTranspose setting.
bool UseTranspose() const {return(UseTranspose_);};
//! Returns the Epetra_Map object associated with the domain of this operator.
const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
//! Returns the Epetra_Map object associated with the range of this operator.
const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
//! Returns the Epetra_BlockMap object associated with the range of this matrix operator.
const Epetra_Comm & Comm() const{return(Comm_);};
//@}
const char* Label() const
{
return(Label_);
}
int SetLabel(const char* Label_in)
{
strcpy(Label_,Label_in);
return(0);
}
//! Prints basic information on iostream. This function is used by operator<<.
virtual std::ostream& Print(std::ostream& os) const;
//! Returns the number of calls to Initialize().
virtual int NumInitialize() const
{
return(NumInitialize_);
}
//! Returns the number of calls to Compute().
virtual int NumCompute() const
{
return(NumCompute_);
}
//! Returns the number of calls to ApplyInverse().
virtual int NumApplyInverse() const
{
return(NumApplyInverse_);
}
//! Returns the time spent in Initialize().
virtual double InitializeTime() const
{
return(InitializeTime_);
}
//! Returns the time spent in Compute().
virtual double ComputeTime() const
{
return(ComputeTime_);
}
//! Returns the time spent in ApplyInverse().
virtual double ApplyInverseTime() const
{
return(ApplyInverseTime_);
}
//! Returns the number of flops in the initialization phase.
virtual double InitializeFlops() const
{
return(0.0);
}
virtual double ComputeFlops() const
{
return(ComputeFlops_);
}
virtual double ApplyInverseFlops() const
{
return(ApplyInverseFlops_);
}
private:
double LevelOfFill() const
{
return(Lfil_);
}
double AbsoluteThreshold() const
{
return(Athresh_);
}
double RelativeThreshold() const
{
return(Rthresh_);
}
double DropTolerance() const
{
return(Droptol_);
}
Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
const Epetra_Comm & Comm_;
Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
Teuchos::RefCountPtr<Epetra_Vector> D_;
bool UseTranspose_;
double Condest_;
double Athresh_;
double Rthresh_;
double Droptol_;
double Lfil_;
void * Aict_;
void * Lict_;
double * Ldiag_;
char Label_[160];
bool IsInitialized_;
bool IsComputed_;
//! Contains the number of successful calls to Initialize().
int NumInitialize_;
//! Contains the number of successful call to Compute().
int NumCompute_;
//! Contains the number of successful call to ApplyInverse().
mutable int NumApplyInverse_;
//! Contains the time for all successful calls to Initialize().
double InitializeTime_;
//! Contains the time for all successful calls to Compute().
double ComputeTime_;
//! Contains the time for all successful calls to ApplyInverse().
mutable double ApplyInverseTime_;
//! Used for timing purposes.
mutable Epetra_Time Time_;
//! Contains the number of flops for Compute().
double ComputeFlops_;
//! Contain sthe number of flops for ApplyInverse().
mutable double ApplyInverseFlops_;
};
#endif /* IFPACK_IC_H */
|