6 #ifdef HAVE_SAAMG_SOLVER
8 #ifndef MG_POISSON_SOLVER_H_
9 #define MG_POISSON_SOLVER_H_
15 #include "ml_include.h"
19 #include "Epetra_MpiComm.h"
21 #include "Epetra_SerialComm.h"
24 #if defined(HAVE_ML_EPETRA) && defined(HAVE_ML_TEUCHOS) && defined(HAVE_ML_AZTECOO)
26 #include "Epetra_Map.h"
27 #include "Epetra_Vector.h"
28 #include "Epetra_CrsMatrix.h"
29 #include "Epetra_MpiComm.h"
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
33 #include "Teuchos_ParameterList.hpp"
39 #include "BelosTypes.hpp"
42 template <
class ScalarType,
class MV,
class OP>
45 template <
class ScalarType,
class MV,
class OP>
48 template<
class ScalarType,
class MV>
51 template<
class ScalarType,
class MV,
class OP>
56 template <
class ScalarType,
class MV,
class OP>
57 class StatusTestGenResNorm;
61 class MultiLevelPreconditioner;
63 int SetDefaults(std::string ProblemType, Teuchos::ParameterList &
List,
64 int * options,
double * params,
const bool OverWrite);
67 #pragma GCC diagnostic pop
101 MGPoissonSolver(
PartBunch *beam,
Mesh_t *mesh,
FieldLayout_t *fl, std::vector<BoundaryGeometry *> geometries, std::string itsolver, std::string interpl,
double tol,
int maxiters, std::string precmode);
112 void setGeometry(std::vector<BoundaryGeometry *> geometries);
115 void recomputeMap() { hasParallelDecompositionChanged_m =
true; }
117 double getXRangeMin(
unsigned short level) {
return bp->getXRangeMin(); }
118 double getXRangeMax(
unsigned short level) {
return bp->getXRangeMax(); }
119 double getYRangeMin(
unsigned short level) {
return bp->getYRangeMin(); }
120 double getYRangeMax(
unsigned short level) {
return bp->getYRangeMax(); }
121 double getZRangeMin(
unsigned short level) {
return bp->getZRangeMin(); }
122 double getZRangeMax(
unsigned short level) {
return bp->getZRangeMax(); }
125 void printLoadBalanceStats();
127 void extrapolateLHS();
139 std::vector<BoundaryGeometry *> geometries_m;
142 bool hasGeometryChanged_m;
144 bool hasParallelDecompositionChanged_m;
162 int tolerableIterationsCount_m;
164 bool forcePreconditionerRecomputation_m;
174 Teuchos::RCP<Epetra_Vector> RHS;
176 Teuchos::RCP<Epetra_Vector> LHS;
178 Teuchos::RCP<Epetra_CrsMatrix> A;
181 ML_Epetra::MultiLevelPreconditioner *MLPrec;
189 Teuchos::RCP<Epetra_MultiVector> P;
190 std::deque< Epetra_Vector > OldLHS;
194 typedef Epetra_Operator OP;
195 typedef Epetra_MultiVector MV;
196 typedef Belos::OperatorTraits<ST, MV, OP> OPT;
197 typedef Belos::MultiVecTraits<ST, MV> MVT;
200 typedef Belos::LinearProblem<ST, MV, OP> problem;
201 Teuchos::RCP< problem > problem_ptr;
203 typedef Belos::SolverManager<ST, MV, OP> solver;
204 Teuchos::RCP< solver > solver_ptr;
206 Teuchos::RCP< Belos::EpetraPrecOp > prec_m;
207 Teuchos::RCP< Belos::StatusTestGenResNorm< ST, MV, OP > > convStatusTest;
210 Teuchos::ParameterList MLList_m;
212 Teuchos::ParameterList belosList;
260 void ComputeStencil(
Vector_t hr, Teuchos::RCP<Epetra_Vector> RHS);
267 inline void SetupBelosList() {
268 belosList.set(
"Maximum Iterations", maxiters_m);
269 belosList.set(
"Convergence Tolerance", tol_m);
271 if(numBlocks_m != 0 && recycleBlocks_m != 0){
272 belosList.set(
"Num Blocks", numBlocks_m);
273 belosList.set(
"Num Recycled Blocks", recycleBlocks_m);
276 belosList.set(
"Verbosity", Belos::Errors + Belos::Warnings + Belos::TimingDetails + Belos::FinalSummary + Belos::StatusTestDetails);
277 belosList.set(
"Output Frequency", 1);
279 belosList.set(
"Verbosity", Belos::Errors + Belos::Warnings);
283 inline void SetupMLList() {
284 ML_Epetra::SetDefaults(
"SA", MLList_m, 0, 0,
true);
286 MLList_m.set(
"max levels", 8);
287 MLList_m.set(
"increasing or decreasing",
"increasing");
290 MLList_m.set(
"prec type",
"MGV");
294 MLList_m.set(
"aggregation: type",
"Uncoupled");
297 MLList_m.set(
"smoother: type",
"Chebyshev");
298 MLList_m.set(
"smoother: sweeps", 3);
299 MLList_m.set(
"smoother: pre or post",
"both");
308 MLList_m.set(
"coarse: type",
"Amesos-KLU");
319 MLList_m.set(
"ML output", 10);
322 int coarsest_size =
std::max(Comm.NumProc() * 10, 1024);
323 MLList_m.set(
"coarse: max size", coarsest_size);
343 int main(
int argc,
char *argv[]) {
345 MPI_Init(&argc, &argv);
348 puts(
"Please configure ML with:");
349 puts(
"--enable-epetra");
350 puts(
"--enable-teuchos");
351 puts(
"--enable-aztecoo");
357 return(EXIT_SUCCESS);
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
Field< double, 3, Mesh_t, Center_t > Field_t
virtual double getXRangeMin(unsigned short level=0)=0
virtual double getXRangeMax(unsigned short level=0)=0
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
CenteredFieldLayout< 3, Mesh_t, Center_t > FieldLayout_t
virtual double getZRangeMax(unsigned short level=0)=0
Vektor< double, 3 > Vector_t
virtual void computePotential(Field_t &rho, Vector_t hr)=0
virtual double getYRangeMin(unsigned short level=0)=0
virtual double getYRangeMax(unsigned short level=0)=0
int main(int argc, char *argv[])
virtual double getZRangeMin(unsigned short level=0)=0
Timing::TimerRef TimerRef
ParticleSpatialLayout< double, 3, Mesh_t > Layout_t
UniformCartesian< 3, double > Mesh_t
virtual void test(PartBunchBase< double, 3 > *bunch)=0