44 #if defined(HAVE_EUCLID) && defined(HAVE_MPI)
48 #include "Epetra_MpiComm.h"
49 #include "Epetra_IntVector.h"
50 #include "Epetra_Import.h"
51 #include "Teuchos_ParameterList.hpp"
52 #include "Teuchos_RCP.hpp"
62 IsInitialized_(
false),
70 ApplyInverseTime_(0.0),
72 ApplyInverseFlops_(0.0),
84 for(
int i = 0; i < A_->NumMyRows(); i++){
87 A_->Graph().ExtractMyRowView(i, len, indices);
88 for(
int j = 0; j < len; j++){
89 indices[j] = A_->GCID(indices[j]);
95 void Ifpack_Euclid::Destroy(){
110 for(
int i = 0; i < A_->NumMyRows(); i++){
113 A_->Graph().ExtractMyRowView(i, len, indices);
114 for(
int j = 0; j < len; j++){
115 indices[j] = A_->LCID(indices[j]);
121 int Ifpack_Euclid::Initialize(){
126 Time_.ResetStartTime();
141 NumInitialize_ = NumInitialize_ + 1;
142 InitializeTime_ = InitializeTime_ + Time_.ElapsedTime();
149 SetLevel_ = list.
get(
"SetLevel", (
int)1);
150 SetBJ_ = list.
get(
"SetBJ", (
int)0);
151 SetStats_ = list.
get(
"SetStats", (
int)0);
152 SetMem_ = list.
get(
"SetMem", (
int)0);
153 SetSparse_ = list.
get(
"SetSparse", (
double)0.0);
154 SetRowScale_ = list.
get(
"SetRowScale", (
int)0);
155 SetILUT_ = list.
get(
"SetILUT", (
double)0.0);
160 int Ifpack_Euclid::SetParameter(std::string name,
int value){
163 for(
size_t i = 0; i < name.length(); i++){
164 name[i] = (char) tolower(name[i], loc);
166 if(name.compare(
"setlevel") == 0){
168 }
else if(name.compare(
"setbj") == 0){
170 }
else if(name.compare(
"setstats") == 0){
172 }
else if(name.compare(
"setmem") == 0){
174 }
else if(name.compare(
"setrowscale") == 0){
175 SetRowScale_ = value;
180 cout <<
"\nThe string " << name <<
" is not an available option." << endl;
187 int Ifpack_Euclid::SetParameter(std::string name,
double value){
190 for(
size_t i; i < name.length(); i++){
191 name[i] = (char) tolower(name[i], loc);
193 if(name.compare(
"setsparse") == 0){
195 }
else if(name.compare(
"setilut") == 0){
201 cout <<
"\nThe string " << name <<
" is not an available option." << endl;
208 int Ifpack_Euclid::Compute(){
209 if(IsInitialized() ==
false){
212 Time_.ResetStartTime();
213 sprintf(Label_,
"IFPACK_Euclid (level=%d, bj=%d, stats=%d, mem=%d, sparse=%f, rowscale=%d, ilut=%f)",
214 SetLevel_, SetBJ_, SetStats_, SetMem_, SetSparse_, SetRowScale_, SetILUT_);
216 eu->level = SetLevel_;
218 strcpy(
"bj", eu->algo_par);
220 if(SetSparse_ != 0.0){
221 eu->sparseTolA = SetSparse_;
223 if(SetRowScale_ != 0){
227 eu->droptol = SetILUT_;
229 if(SetStats_ != 0 || SetMem_ != 0){
234 eu->A = (
void*) A_.get();
235 eu->m = A_->NumMyRows();
236 eu->n = A_->NumGlobalRows();
239 NumCompute_ = NumCompute_ + 1;
240 ComputeTime_ = ComputeTime_ + Time_.ElapsedTime();
246 if(IsComputed() ==
false){
250 if(NumVectors != Y.NumVectors()){
253 Time_.ResetStartTime();
255 for(
int vecNum = 0; vecNum <
NumVectors; vecNum++){
256 CallEuclid(X[vecNum], Y[vecNum]);
261 NumApplyInverse_ = NumApplyInverse_ + 1;
262 ApplyInverseTime_ = ApplyInverseTime_ + Time_.ElapsedTime();
267 int Ifpack_Euclid::CallEuclid(
double *x,
double *y)
const{
273 std::ostream&
operator << (std::ostream& os,
const Ifpack_Euclid& A){
274 if (!A.Comm().MyPID()) {
276 os <<
"================================================================================" << endl;
277 os <<
"Ifpack_Euclid: " << A.Label () << endl << endl;
278 os <<
"Using " << A.Comm().NumProc() <<
" processors." << endl;
279 os <<
"Global number of rows = " << A.Matrix().NumGlobalRows() << endl;
280 os <<
"Global number of nonzeros = " << A.Matrix().NumGlobalNonzeros() << endl;
281 os <<
"Condition number estimate = " << A.Condest() << endl;
283 os <<
"Phase # calls Total Time (s) Total MFlops MFlops/s" << endl;
284 os <<
"----- ------- -------------- ------------ --------" << endl;
285 os <<
"Initialize() " << std::setw(5) << A.NumInitialize()
286 <<
" " << std::setw(15) << A.InitializeTime()
287 <<
" 0.0 0.0" << endl;
288 os <<
"Compute() " << std::setw(5) << A.NumCompute()
289 <<
" " << std::setw(15) << A.ComputeTime()
290 <<
" " << std::setw(15) << 1.0e-6 * A.ComputeFlops();
291 if (A.ComputeTime() != 0.0)
292 os <<
" " << std::setw(15) << 1.0e-6 * A.ComputeFlops() / A.ComputeTime() << endl;
294 os <<
" " << std::setw(15) << 0.0 << endl;
295 os <<
"ApplyInverse() " << std::setw(5) << A.NumApplyInverse()
296 <<
" " << std::setw(15) << A.ApplyInverseTime()
297 <<
" " << std::setw(15) << 1.0e-6 * A.ApplyInverseFlops();
298 if (A.ApplyInverseTime() != 0.0)
299 os <<
" " << std::setw(15) << 1.0e-6 * A.ApplyInverseFlops() / A.ApplyInverseTime() << endl;
301 os <<
" " << std::setw(15) << 0.0 << endl;
302 os <<
"================================================================================" << endl;
318 #endif // HAVE_EUCLID && HAVE_MPI
void Parser_dhCreate(Parser_dh *p)
void Mem_dhDestroy(Mem_dh m)
T & get(ParameterList &l, const std::string &name)
void TimeLog_dhCreate(TimeLog_dh *t)
void TimeLog_dhDestroy(TimeLog_dh t)
void Euclid_dhApply(Euclid_dh ctx, double *rhs, double *lhs)
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
void Parser_dhInsert(Parser_dh p, char *option, char *value)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void Parser_dhDestroy(Parser_dh p)
void Euclid_dhPrintTestData(Euclid_dh ctx, FILE *fp)
void Euclid_dhCreate(Euclid_dh *ctxOUT)
std::ostream & operator<<(std::ostream &os, const Ifpack_Container &obj)
void Parser_dhInit(Parser_dh p, int argc, char *argv[])
void Euclid_dhDestroy(Euclid_dh ctx)
void Mem_dhCreate(Mem_dh *m)
#define IFPACK_CHK_ERR(ifpack_err)
void Euclid_dhSetup(Euclid_dh ctx)