hypre-space / hypre

Parallel solvers for sparse linear systems featuring multigrid methods.
https://www.llnl.gov/casc/hypre/
Other
709 stars 194 forks source link

BoomerAMG setup parameters for systems of PDEs #259

Open fw407 opened 3 years ago

fw407 commented 3 years ago

Hello,

I am solving 3D Navier-Stokes equations for steady compressible flows implicitly. For each pseudo time step, there will be a linearized system Ax=B to solve, My intention is to use BoomerAMG as a linear multigrid to solve this linear system. I have tried hypre_ilu and it works reasonably well for me, so the construction of A and B is good.

For the moment I have no success on using BoomerAMG to solve my linear system despite a few attempts to tune the parameters. My current setup is listed below. I would be grateful if you could shine some light on this.

Many thanks for your help in advance,

Feng

     int coarsen_type = 10; //10:  HMIS-coarsening
     int interp_type = 6;  //6: extended+i
     int relax_type = 6; //hybrid SGS
     int num_sweeps = 1;
     int restri_type = 2; //1: AIR-1; 2: AIR-2
     double tol = 1.0e-3; //also tried 1e-7, it also failed
     int mg_max_inter = 20;
     double strong_threshold = 0.55;
     int p_max_elmts = 4;

     HYPRE_Int *dof_func;
     dof_func = hypre_CTAlloc(HYPRE_Int, local_size, HYPRE_MEMORY_HOST);
     build_amg_dof_func(local_size, ilower, nv, dof_func); // test_ij.c: 1857-1876

     //set up amg
     HYPRE_BoomerAMGSetPrintLevel(amg_solver, 1);
     HYPRE_BoomerAMGSetCoarsenType(amg_solver, coarsen_type);
     HYPRE_BoomerAMGSetInterpType(amg_solver, interp_type);
     HYPRE_BoomerAMGSetRestriction(amg_solver, restri_type);
     HYPRE_BoomerAMGSetRelaxType(amg_solver, relax_type);
     HYPRE_BoomerAMGSetNumSweeps(amg_solver, num_sweeps);
     HYPRE_BoomerAMGSetTol(amg_solver, tol);
     HYPRE_BoomerAMGSetMaxIter(amg_solver, mg_max_inter);
     HYPRE_BoomerAMGSetNumFunctions(amg_solver, nv);
     HYPRE_BoomerAMGSetStrongThreshold(amg_solver, strong_threshold);
     HYPRE_BoomerAMGSetPMaxElmts(amg_solver, p_max_elmts);
     HYPRE_BoomerAMGSetNodal(amg_solver, 2); //not sure which one to use
     HYPRE_BoomerAMGSetDofFunc(amg_solver, dof_func);

     //solver
     HYPRE_BoomerAMGSetup(amg_solver, parcsr_A, par_b, par_dsol);
     HYPRE_BoomerAMGSolve(amg_solver, parcsr_A, par_b, par_dsol);
ulrikeyang commented 3 years ago

Hi Feng, I would use BoomerAMG as a preconitioner to a Krylov solver, like CG if the system is symmetric, or GMRES if it is nonsymmetric. I also suggest to use relax_type 8 instead of 6. Have you tried nodal to be 0? I would try this first. Ulrike

From: Feng notifications@github.com Sent: Thursday, January 21, 2021 5:30 AM To: hypre-space/hypre hypre@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [hypre-space/hypre] BoomerAMG setup parameters for systems of PDEs (#259)

Hello,

I am solving 3D Navier-Stokes equations for steady compressible flows implicitly. For each pseudo time step, there will be a linearized system Ax=B to solve, My intention is to use BoomerAMG as a linear multigrid to solve this linear system. I have tried hypre_ilu and it works reasonably well for me, so the construction of A and B is good.

For the moment I have no success on using BoomerAMG to solve my linear system despite a few attempts to tune the parameters. My current setup is listed below. I would be grateful if you could shine some light on this.

Many thanks for your help in advance,

Feng

 int coarsen_type = 10; //10:  HMIS-coarsening

 int interp_type = 6;  //6: extended+i

 int relax_type = 6; //hybrid SGS

 int num_sweeps = 1;

 int restri_type ?= 2; //1: AIR-1; 2: AIR-2

 double tol = 1.0e-3; //also tried 1e-7, it also failed

 int mg_max_inter = 20;

 double strong_threshold = 0.55;

 int p_max_elmts = 4;

 HYPRE_Int *dof_func;

 dof_func = hypre_CTAlloc(HYPRE_Int, local_size, HYPRE_MEMORY_HOST);

 build_amg_dof_func(local_size, ilower, nv, dof_func); // test_ij.c: 1857-1876

 //set up amg

 HYPRE_BoomerAMGSetPrintLevel(amg_solver, 1);

 HYPRE_BoomerAMGSetCoarsenType(amg_solver, coarsen_type);

 HYPRE_BoomerAMGSetInterpType(amg_solver, interp_type);

 HYPRE_BoomerAMGSetRestriction(amg_solver, restri_type);

 HYPRE_BoomerAMGSetRelaxType(amg_solver, relax_type);

 HYPRE_BoomerAMGSetNumSweeps(amg_solver, num_sweeps);

 HYPRE_BoomerAMGSetTol(amg_solver, tol);

 HYPRE_BoomerAMGSetMaxIter(amg_solver, mg_max_inter);

 HYPRE_BoomerAMGSetNumFunctions(amg_solver, nv);

 HYPRE_BoomerAMGSetStrongThreshold(amg_solver, strong_threshold);

 HYPRE_BoomerAMGSetPMaxElmts(amg_solver, p_max_elmts);

 HYPRE_BoomerAMGSetNodal(amg_solver, 2); //not sure which one to use

 HYPRE_BoomerAMGSetDofFunc(amg_solver, dof_func);

 //solver

 HYPRE_BoomerAMGSetup(amg_solver, parcsr_A, par_b, par_dsol);

 HYPRE_BoomerAMGSolve(amg_solver, parcsr_A, par_b, par_dsol);

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/hypre-space/hypre/issues/259, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD4NLLLLRRYZRA2YD7EI2ULS3AT4RANCNFSM4WM3TOXA.

fw407 commented 3 years ago

Hi @Ulrike,

Thanks for your help. I really appreciate it. I have tried your suggested parameters, BoomerAMG is still diverging somehow.

It was my curiosity to see if BoomerAMG would do linear multigrid in my case. My left-hand-side is nonsymmetric, but I do have tried GMRES pre-conditioned with ILU(0) or ILUT using hypre and I have some success on it. I have not tried using BoomerAMG as a pre-conditioner, but I would give it a shot. Do you think it would be more efficient than using ILU(0) or ILUT as pre-conditioners if parameters are tuned properly?

Besides, I have a question on memory management for dof_func for system PDEs. The code snippet in my previous post is inside a for-loop. If I move

 HYPRE_Int *dof_func;
 dof_func = hypre_CTAlloc(HYPRE_Int, local_size, HYPRE_MEMORY_HOST);
 build_amg_dof_func(local_size, ilower, nv, dof_func); // test_ij.c: 1857-1876

outside of this for-loop (which is what I prefer), I got a seg-fault on BoomerAMGSetup in the 2nd iteration for double-free, I don't know why. I end up with doing it for each iteration.

Many thanks, Feng