61
// ML_Set_PrintLevel(3);
63
63
ML_Create(&ml_handle,N_levels);
65
65
// wrap Epetra Matrix into ML matrix (data is NOT copied)
66
66
EpetraMatrix2MLMatrix(ml_handle, 0, &(A.mat()));
68
// as we are interested in smoothed aggregation, create a ML_Aggregate object
69
// to store the aggregates
68
// create a ML_Aggregate object to store the aggregates
70
69
ML_Aggregate *agg_object;
71
70
ML_Aggregate_Create(&agg_object);
73
// specify max coarse size (ML will not coarse further is the matrix at a given level is
74
// smaller than specified here)
72
// specify max coarse size
75
73
ML_Aggregate_Set_MaxCoarseSize(agg_object,1);
77
75
// generate the hierady
78
N_levels = ML_Gen_MGHierarchy_UsingAggregation(ml_handle, 0,
79
ML_INCREASING, agg_object);
76
N_levels = ML_Gen_MGHierarchy_UsingAggregation(ml_handle, 0, ML_INCREASING, agg_object);
81
// Set a symmetric Gauss-Seidel smoother for the MG method (change
82
// if the matrix is not symmetric)
83
ML_Gen_Smoother_SymGaussSeidel(ml_handle, ML_ALL_LEVELS,
84
ML_BOTH, 1, ML_DEFAULT);
78
// Set a symmetric Gauss-Seidel smoother for the MG method
79
ML_Gen_Smoother_SymGaussSeidel(ml_handle, ML_ALL_LEVELS, ML_BOTH, 1, ML_DEFAULT);
87
ML_Gen_Solver (ml_handle, ML_MGV, 0, N_levels-1);
82
ML_Gen_Solver(ml_handle, ML_MGV, 0, N_levels-1);
89
84
// wrap ML_Operator into Epetra_Operator
90
85
ML_Epetra::MultiLevelOperator MLop(ml_handle,A.mat().Comm(),A.mat().DomainMap(),A.mat().RangeMap());
92
// ===================== E N D O F M L S E C T I O N ========================= //
94
87
// set this operator as preconditioner for AztecOO
95
88
linear_solver.SetPrecOperator(&MLop);