added new option which allows to set a minimal coarse grid size

This commit is contained in:
ulrikey 2012-05-08 21:33:00 +00:00
parent d37625d46e
commit df01ecf036
10 changed files with 242 additions and 12 deletions

View File

@ -185,6 +185,38 @@ hypre_F90_IFACE(hypre_boomeramggetmaxcoarsesize, HYPRE_BOOMERAMGGETMAXCOARSESIZE
}
/*--------------------------------------------------------------------------
* HYPRE_BoomerAMGSetMinCoarseSize, HYPRE_BoomerAMGGetMinCoarseSize
*--------------------------------------------------------------------------*/
void
hypre_F90_IFACE(hypre_boomeramgsetmincoarsesize, HYPRE_BOOMERAMGSETMINCOARSESIZE)
( hypre_F90_Obj *solver,
hypre_F90_Int *min_coarse_size,
hypre_F90_Int *ierr )
{
*ierr = (hypre_F90_Int)
( HYPRE_BoomerAMGSetMinCoarseSize(
hypre_F90_PassObj (HYPRE_Solver, solver),
hypre_F90_PassInt (min_coarse_size) ) );
}
void
hypre_F90_IFACE(hypre_boomeramggetmincoarsesize, HYPRE_BOOMERAMGGETMINCOARSESIZE)
( hypre_F90_Obj *solver,
hypre_F90_Int *min_coarse_size,
hypre_F90_Int *ierr )
{
*ierr = (hypre_F90_Int)
( HYPRE_BoomerAMGGetMinCoarseSize(
hypre_F90_PassObj (HYPRE_Solver, solver),
hypre_F90_PassIntRef (min_coarse_size) ) );
}
/*--------------------------------------------------------------------------

View File

@ -138,6 +138,24 @@ HYPRE_BoomerAMGGetMaxCoarseSize( HYPRE_Solver solver,
return( hypre_BoomerAMGGetMaxCoarseSize( (void *) solver, max_coarse_size ) );
}
/*--------------------------------------------------------------------------
* HYPRE_BoomerAMGSetMinCoarseSize, HYPRE_BoomerAMGGetMinCoarseSize
*--------------------------------------------------------------------------*/
HYPRE_Int
HYPRE_BoomerAMGSetMinCoarseSize( HYPRE_Solver solver,
HYPRE_Int min_coarse_size )
{
return( hypre_BoomerAMGSetMinCoarseSize( (void *) solver, min_coarse_size ) );
}
HYPRE_Int
HYPRE_BoomerAMGGetMinCoarseSize( HYPRE_Solver solver,
HYPRE_Int * min_coarse_size )
{
return( hypre_BoomerAMGGetMinCoarseSize( (void *) solver, min_coarse_size ) );
}
/*--------------------------------------------------------------------------
* HYPRE_BoomerAMGSetSeqThreshold, HYPRE_BoomerAMGGetSeqThreshold
*--------------------------------------------------------------------------*/

View File

@ -428,6 +428,17 @@ HYPRE_ParCSRHybridSetMaxCoarseSize( HYPRE_Solver solver,
return( hypre_AMGHybridSetMaxCoarseSize( (void *) solver, max_coarse_size ) );
}
/*--------------------------------------------------------------------------
* HYPRE_ParCSRHybridSetMinCoarseSize
*--------------------------------------------------------------------------*/
HYPRE_Int
HYPRE_ParCSRHybridSetMinCoarseSize( HYPRE_Solver solver,
HYPRE_Int min_coarse_size )
{
return( hypre_AMGHybridSetMinCoarseSize( (void *) solver, min_coarse_size ) );
}
/*--------------------------------------------------------------------------
* HYPRE_ParCSRHybridSetSeqThreshold
*--------------------------------------------------------------------------*/

View File

@ -168,6 +168,13 @@ HYPRE_Int HYPRE_BoomerAMGSetMaxLevels(HYPRE_Solver solver,
HYPRE_Int HYPRE_BoomerAMGSetMaxCoarseSize(HYPRE_Solver solver,
HYPRE_Int max_coarse_size);
/**
* (Optional) Sets minimum size of coarsest grid.
* The default is 1.
**/
HYPRE_Int HYPRE_BoomerAMGSetMinCoarseSize(HYPRE_Solver solver,
HYPRE_Int min_coarse_size);
/**
* (Optional) Sets maximal size for redundant coarse grid solve.
* When the system is smaller than this threshold, sequential AMG is used
@ -2598,6 +2605,14 @@ HYPRE_Int
HYPRE_ParCSRHybridSetMaxCoarseSize(HYPRE_Solver solver,
HYPRE_Int max_coarse_size);
/**
* (Optional) Defines the minimal coarse grid size.
* The default is 1.
**/
HYPRE_Int
HYPRE_ParCSRHybridSetMinCoarseSize(HYPRE_Solver solver,
HYPRE_Int min_coarse_size);
/**
* (Optional) enables redundant coarse grid size. If the system size becomes
* smaller than seq_threshold, sequential AMG is used on all remaining processors.

View File

@ -10,17 +10,13 @@
* $Revision$
***********************************************************************EHEADER*/
#ifndef hypre_PARCSR_LS_HEADER
#define hypre_PARCSR_LS_HEADER
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <HYPRE_config.h>
#include "HYPRE_parcsr_ls.h"
#ifndef hypre_PARCSR_LS_HEADER
#define hypre_PARCSR_LS_HEADER
#include "_hypre_utilities.h"
#include "krylov.h"
#include "seq_mv.h"
@ -93,6 +89,7 @@ typedef struct
HYPRE_Int CR_use_CG;
HYPRE_Int cgc_its;
HYPRE_Int max_coarse_size;
HYPRE_Int min_coarse_size;
HYPRE_Int seq_threshold;
/* solve params */
@ -264,6 +261,7 @@ typedef struct
#define hypre_ParAMGDataL1Norms(amg_data) ((amg_data)->l1_norms)
#define hypre_ParAMGDataCGCIts(amg_data) ((amg_data)->cgc_its)
#define hypre_ParAMGDataMaxCoarseSize(amg_data) ((amg_data)->max_coarse_size)
#define hypre_ParAMGDataMinCoarseSize(amg_data) ((amg_data)->min_coarse_size)
#define hypre_ParAMGDataSeqThreshold(amg_data) ((amg_data)->seq_threshold)
/* solve params */
@ -410,6 +408,7 @@ HYPRE_Int hypre_ADSDestroy ( void *solver );
HYPRE_Int hypre_ADSSetDiscreteCurl ( void *solver , hypre_ParCSRMatrix *C );
HYPRE_Int hypre_ADSSetDiscreteGradient ( void *solver , hypre_ParCSRMatrix *G );
HYPRE_Int hypre_ADSSetCoordinateVectors ( void *solver , hypre_ParVector *x , hypre_ParVector *y , hypre_ParVector *z );
HYPRE_Int hypre_ADSSetInterpolations ( void *solver , hypre_ParCSRMatrix *RT_Pi , hypre_ParCSRMatrix *RT_Pix , hypre_ParCSRMatrix *RT_Piy , hypre_ParCSRMatrix *RT_Piz , hypre_ParCSRMatrix *ND_Pi , hypre_ParCSRMatrix *ND_Pix , hypre_ParCSRMatrix *ND_Piy , hypre_ParCSRMatrix *ND_Piz );
HYPRE_Int hypre_ADSSetMaxIter ( void *solver , HYPRE_Int maxit );
HYPRE_Int hypre_ADSSetTol ( void *solver , double tol );
HYPRE_Int hypre_ADSSetCycleType ( void *solver , HYPRE_Int cycle_type );
@ -478,6 +477,7 @@ HYPRE_Int hypre_AMGHybridSetRelaxType ( void *AMGhybrid_vdata , HYPRE_Int relax_
HYPRE_Int hypre_AMGHybridSetCycleRelaxType ( void *AMGhybrid_vdata , HYPRE_Int relax_type , HYPRE_Int k );
HYPRE_Int hypre_AMGHybridSetRelaxOrder ( void *AMGhybrid_vdata , HYPRE_Int relax_order );
HYPRE_Int hypre_AMGHybridSetMaxCoarseSize ( void *AMGhybrid_vdata , HYPRE_Int max_coarse_size );
HYPRE_Int hypre_AMGHybridSetMinCoarseSize ( void *AMGhybrid_vdata , HYPRE_Int min_coarse_size );
HYPRE_Int hypre_AMGHybridSetSeqThreshold ( void *AMGhybrid_vdata , HYPRE_Int seq_threshold );
HYPRE_Int hypre_AMGHybridSetNumGridSweeps ( void *AMGhybrid_vdata , HYPRE_Int *num_grid_sweeps );
HYPRE_Int hypre_AMGHybridSetGridRelaxType ( void *AMGhybrid_vdata , HYPRE_Int *grid_relax_type );
@ -516,7 +516,7 @@ HYPRE_Int hypre_AMSSetDimension ( void *solver , HYPRE_Int dim );
HYPRE_Int hypre_AMSSetDiscreteGradient ( void *solver , hypre_ParCSRMatrix *G );
HYPRE_Int hypre_AMSSetCoordinateVectors ( void *solver , hypre_ParVector *x , hypre_ParVector *y , hypre_ParVector *z );
HYPRE_Int hypre_AMSSetEdgeConstantVectors ( void *solver , hypre_ParVector *Gx , hypre_ParVector *Gy , hypre_ParVector *Gz );
HYPRE_Int hypre_AMSSetInterpolations ( void *solver , hypre_ParCSRMatrix *Pi , hypre_ParCSRMatrix *Pix , hypre_ParCSRMatrix *Piy , hypre_ParCSRMatrix *Piz);
HYPRE_Int hypre_AMSSetInterpolations ( void *solver , hypre_ParCSRMatrix *Pi , hypre_ParCSRMatrix *Pix , hypre_ParCSRMatrix *Piy , hypre_ParCSRMatrix *Piz );
HYPRE_Int hypre_AMSSetAlphaPoissonMatrix ( void *solver , hypre_ParCSRMatrix *A_Pi );
HYPRE_Int hypre_AMSSetBetaPoissonMatrix ( void *solver , hypre_ParCSRMatrix *A_G );
HYPRE_Int hypre_AMSSetInteriorNodes ( void *solver , hypre_ParVector *interior_nodes );
@ -587,7 +587,7 @@ HYPRE_Int HYPRE_ADSSolve ( HYPRE_Solver solver , HYPRE_ParCSRMatrix A , HYPRE_Pa
HYPRE_Int HYPRE_ADSSetDiscreteCurl ( HYPRE_Solver solver , HYPRE_ParCSRMatrix C );
HYPRE_Int HYPRE_ADSSetDiscreteGradient ( HYPRE_Solver solver , HYPRE_ParCSRMatrix G );
HYPRE_Int HYPRE_ADSSetCoordinateVectors ( HYPRE_Solver solver , HYPRE_ParVector x , HYPRE_ParVector y , HYPRE_ParVector z );
HYPRE_Int hypre_ADSSetInterpolations ( void *solver , hypre_ParCSRMatrix *RT_Pi , hypre_ParCSRMatrix *RT_Pix , hypre_ParCSRMatrix *RT_Piy , hypre_ParCSRMatrix *RT_Piz , hypre_ParCSRMatrix *ND_Pi , hypre_ParCSRMatrix *ND_Pix , hypre_ParCSRMatrix *ND_Piy , hypre_ParCSRMatrix *ND_Piz );
HYPRE_Int HYPRE_ADSSetInterpolations ( HYPRE_Solver solver , HYPRE_ParCSRMatrix RT_Pi , HYPRE_ParCSRMatrix RT_Pix , HYPRE_ParCSRMatrix RT_Piy , HYPRE_ParCSRMatrix RT_Piz , HYPRE_ParCSRMatrix ND_Pi , HYPRE_ParCSRMatrix ND_Pix , HYPRE_ParCSRMatrix ND_Piy , HYPRE_ParCSRMatrix ND_Piz );
HYPRE_Int HYPRE_ADSSetMaxIter ( HYPRE_Solver solver , HYPRE_Int maxit );
HYPRE_Int HYPRE_ADSSetTol ( HYPRE_Solver solver , double tol );
HYPRE_Int HYPRE_ADSSetCycleType ( HYPRE_Solver solver , HYPRE_Int cycle_type );
@ -622,6 +622,7 @@ HYPRE_Int HYPRE_AMSSetDimension ( HYPRE_Solver solver , HYPRE_Int dim );
HYPRE_Int HYPRE_AMSSetDiscreteGradient ( HYPRE_Solver solver , HYPRE_ParCSRMatrix G );
HYPRE_Int HYPRE_AMSSetCoordinateVectors ( HYPRE_Solver solver , HYPRE_ParVector x , HYPRE_ParVector y , HYPRE_ParVector z );
HYPRE_Int HYPRE_AMSSetEdgeConstantVectors ( HYPRE_Solver solver , HYPRE_ParVector Gx , HYPRE_ParVector Gy , HYPRE_ParVector Gz );
HYPRE_Int HYPRE_AMSSetInterpolations ( HYPRE_Solver solver , HYPRE_ParCSRMatrix Pi , HYPRE_ParCSRMatrix Pix , HYPRE_ParCSRMatrix Piy , HYPRE_ParCSRMatrix Piz );
HYPRE_Int HYPRE_AMSSetAlphaPoissonMatrix ( HYPRE_Solver solver , HYPRE_ParCSRMatrix A_alpha );
HYPRE_Int HYPRE_AMSSetBetaPoissonMatrix ( HYPRE_Solver solver , HYPRE_ParCSRMatrix A_beta );
HYPRE_Int HYPRE_AMSSetInteriorNodes ( HYPRE_Solver solver , HYPRE_ParVector interior_nodes );
@ -652,6 +653,8 @@ HYPRE_Int HYPRE_BoomerAMGSetMaxLevels ( HYPRE_Solver solver , HYPRE_Int max_leve
HYPRE_Int HYPRE_BoomerAMGGetMaxLevels ( HYPRE_Solver solver , HYPRE_Int *max_levels );
HYPRE_Int HYPRE_BoomerAMGSetMaxCoarseSize ( HYPRE_Solver solver , HYPRE_Int max_coarse_size );
HYPRE_Int HYPRE_BoomerAMGGetMaxCoarseSize ( HYPRE_Solver solver , HYPRE_Int *max_coarse_size );
HYPRE_Int HYPRE_BoomerAMGSetMinCoarseSize ( HYPRE_Solver solver , HYPRE_Int min_coarse_size );
HYPRE_Int HYPRE_BoomerAMGGetMinCoarseSize ( HYPRE_Solver solver , HYPRE_Int *min_coarse_size );
HYPRE_Int HYPRE_BoomerAMGSetSeqThreshold ( HYPRE_Solver solver , HYPRE_Int seq_threshold );
HYPRE_Int HYPRE_BoomerAMGGetSeqThreshold ( HYPRE_Solver solver , HYPRE_Int *seq_threshold );
HYPRE_Int HYPRE_BoomerAMGSetStrongThreshold ( HYPRE_Solver solver , double strong_threshold );
@ -900,6 +903,7 @@ HYPRE_Int HYPRE_ParCSRHybridSetRelaxType ( HYPRE_Solver solver , HYPRE_Int relax
HYPRE_Int HYPRE_ParCSRHybridSetCycleRelaxType ( HYPRE_Solver solver , HYPRE_Int relax_type , HYPRE_Int k );
HYPRE_Int HYPRE_ParCSRHybridSetRelaxOrder ( HYPRE_Solver solver , HYPRE_Int relax_order );
HYPRE_Int HYPRE_ParCSRHybridSetMaxCoarseSize ( HYPRE_Solver solver , HYPRE_Int max_coarse_size );
HYPRE_Int HYPRE_ParCSRHybridSetMinCoarseSize ( HYPRE_Solver solver , HYPRE_Int min_coarse_size );
HYPRE_Int HYPRE_ParCSRHybridSetSeqThreshold ( HYPRE_Solver solver , HYPRE_Int seq_threshold );
HYPRE_Int HYPRE_ParCSRHybridSetRelaxWt ( HYPRE_Solver solver , double relax_wt );
HYPRE_Int HYPRE_ParCSRHybridSetLevelRelaxWt ( HYPRE_Solver solver , double relax_wt , HYPRE_Int level );
@ -1033,6 +1037,8 @@ HYPRE_Int hypre_BoomerAMGSetMaxLevels ( void *data , HYPRE_Int max_levels );
HYPRE_Int hypre_BoomerAMGGetMaxLevels ( void *data , HYPRE_Int *max_levels );
HYPRE_Int hypre_BoomerAMGSetMaxCoarseSize ( void *data , HYPRE_Int max_coarse_size );
HYPRE_Int hypre_BoomerAMGGetMaxCoarseSize ( void *data , HYPRE_Int *max_coarse_size );
HYPRE_Int hypre_BoomerAMGSetMinCoarseSize ( void *data , HYPRE_Int min_coarse_size );
HYPRE_Int hypre_BoomerAMGGetMinCoarseSize ( void *data , HYPRE_Int *min_coarse_size );
HYPRE_Int hypre_BoomerAMGSetSeqThreshold ( void *data , HYPRE_Int seq_threshold );
HYPRE_Int hypre_BoomerAMGGetSeqThreshold ( void *data , HYPRE_Int *seq_threshold );
HYPRE_Int hypre_BoomerAMGSetStrongThreshold ( void *data , double strong_threshold );

View File

@ -67,6 +67,7 @@ typedef struct
HYPRE_Int cycle_type;
HYPRE_Int relax_order;
HYPRE_Int max_coarse_size;
HYPRE_Int min_coarse_size;
HYPRE_Int seq_threshold;
HYPRE_Int *num_grid_sweeps;
HYPRE_Int *grid_relax_type;
@ -130,6 +131,7 @@ hypre_AMGHybridCreate( )
(AMGhybrid_data -> cycle_type) = 1;
(AMGhybrid_data -> relax_order) = 1;
(AMGhybrid_data -> max_coarse_size) = 9;
(AMGhybrid_data -> min_coarse_size) = 1;
(AMGhybrid_data -> seq_threshold) = 0;
(AMGhybrid_data -> num_grid_sweeps) = NULL;
(AMGhybrid_data -> grid_relax_type) = NULL;
@ -925,6 +927,31 @@ hypre_AMGHybridSetMaxCoarseSize( void *AMGhybrid_vdata,
return hypre_error_flag;
}
/*--------------------------------------------------------------------------
* hypre_AMGHybridSetMinCoarseSize
*--------------------------------------------------------------------------*/
HYPRE_Int
hypre_AMGHybridSetMinCoarseSize( void *AMGhybrid_vdata,
HYPRE_Int min_coarse_size )
{
hypre_AMGHybridData *AMGhybrid_data = AMGhybrid_vdata;
if (!AMGhybrid_data)
{
hypre_error_in_arg(1);
return hypre_error_flag;
}
if (min_coarse_size < 1)
{
hypre_error_in_arg(2);
return hypre_error_flag;
}
(AMGhybrid_data -> min_coarse_size) = min_coarse_size;
return hypre_error_flag;
}
/*--------------------------------------------------------------------------
* hypre_AMGHybridSetSeqThreshold
*--------------------------------------------------------------------------*/
@ -1522,6 +1549,7 @@ hypre_AMGHybridSolve( void *AMGhybrid_vdata,
HYPRE_Int sol_print_level; /* print_level for solver */
HYPRE_Int pre_print_level; /* print_level for preconditioner */
HYPRE_Int max_coarse_size, seq_threshold;
HYPRE_Int min_coarse_size;
if (!AMGhybrid_data)
{
@ -1569,6 +1597,7 @@ hypre_AMGHybridSolve( void *AMGhybrid_vdata,
relax_weight = (AMGhybrid_data -> relax_weight);
omega = (AMGhybrid_data -> omega);
max_coarse_size = (AMGhybrid_data -> max_coarse_size);
min_coarse_size = (AMGhybrid_data -> min_coarse_size);
seq_threshold = (AMGhybrid_data -> seq_threshold);
dof_func = (AMGhybrid_data -> dof_func);
pcg_default = (AMGhybrid_data -> pcg_default);
@ -1815,6 +1844,7 @@ hypre_AMGHybridSolve( void *AMGhybrid_vdata,
hypre_BoomerAMGSetMaxLevels(pcg_precond, max_levels);
hypre_BoomerAMGSetMaxRowSum(pcg_precond, max_row_sum);
hypre_BoomerAMGSetMaxCoarseSize(pcg_precond, max_coarse_size);
hypre_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
hypre_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
hypre_BoomerAMGSetAggNumLevels(pcg_precond, agg_num_levels);
hypre_BoomerAMGSetNumPaths(pcg_precond, num_paths);

View File

@ -36,6 +36,7 @@ hypre_BoomerAMGCreate()
/* setup params */
HYPRE_Int max_levels;
HYPRE_Int max_coarse_size;
HYPRE_Int min_coarse_size;
double strong_threshold;
double max_row_sum;
double trunc_factor;
@ -117,6 +118,7 @@ hypre_BoomerAMGCreate()
/* setup params */
max_levels = 25;
max_coarse_size = 9;
min_coarse_size = 1;
seq_threshold = 0;
strong_threshold = 0.25;
max_row_sum = 0.9;
@ -208,6 +210,7 @@ hypre_BoomerAMGCreate()
hypre_ParAMGDataUserRelaxWeight(amg_data) = 1.0;
hypre_BoomerAMGSetMaxLevels(amg_data, max_levels);
hypre_BoomerAMGSetMaxCoarseSize(amg_data, max_coarse_size);
hypre_BoomerAMGSetMinCoarseSize(amg_data, min_coarse_size);
hypre_BoomerAMGSetStrongThreshold(amg_data, strong_threshold);
hypre_BoomerAMGSetMaxRowSum(amg_data, max_row_sum);
hypre_BoomerAMGSetTruncFactor(amg_data, trunc_factor);
@ -671,6 +674,48 @@ hypre_BoomerAMGGetMaxCoarseSize( void *data,
return hypre_error_flag;
}
HYPRE_Int
hypre_BoomerAMGSetMinCoarseSize( void *data,
HYPRE_Int min_coarse_size )
{
hypre_ParAMGData *amg_data = data;
if (!amg_data)
{
hypre_printf("Warning! BoomerAMG object empty!\n");
hypre_error_in_arg(1);
return hypre_error_flag;
}
if (min_coarse_size < 1)
{
hypre_error_in_arg(2);
return hypre_error_flag;
}
hypre_ParAMGDataMinCoarseSize(amg_data) = min_coarse_size;
return hypre_error_flag;
}
HYPRE_Int
hypre_BoomerAMGGetMinCoarseSize( void *data,
HYPRE_Int * min_coarse_size )
{
hypre_ParAMGData *amg_data = data;
if (!amg_data)
{
hypre_printf("Warning! BoomerAMG object empty!\n");
hypre_error_in_arg(1);
return hypre_error_flag;
}
*min_coarse_size = hypre_ParAMGDataMinCoarseSize(amg_data);
return hypre_error_flag;
}
HYPRE_Int
hypre_BoomerAMGSetSeqThreshold( void *data,
HYPRE_Int seq_threshold )

View File

@ -58,6 +58,7 @@ typedef struct
HYPRE_Int CR_use_CG;
HYPRE_Int cgc_its;
HYPRE_Int max_coarse_size;
HYPRE_Int min_coarse_size;
HYPRE_Int seq_threshold;
/* solve params */
@ -229,6 +230,7 @@ typedef struct
#define hypre_ParAMGDataL1Norms(amg_data) ((amg_data)->l1_norms)
#define hypre_ParAMGDataCGCIts(amg_data) ((amg_data)->cgc_its)
#define hypre_ParAMGDataMaxCoarseSize(amg_data) ((amg_data)->max_coarse_size)
#define hypre_ParAMGDataMinCoarseSize(amg_data) ((amg_data)->min_coarse_size)
#define hypre_ParAMGDataSeqThreshold(amg_data) ((amg_data)->seq_threshold)
/* solve params */

View File

@ -114,6 +114,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
HYPRE_Int not_finished_coarsening = 1;
HYPRE_Int Setup_err_flag = 0;
HYPRE_Int coarse_threshold = hypre_ParAMGDataMaxCoarseSize(amg_data);
HYPRE_Int min_coarse_size = hypre_ParAMGDataMinCoarseSize(amg_data);
HYPRE_Int seq_threshold = hypre_ParAMGDataSeqThreshold(amg_data);
HYPRE_Int j, k;
HYPRE_Int num_procs,my_id,num_threads;
@ -927,7 +928,43 @@ hypre_BoomerAMGSetup( void *amg_vdata,
hypre_ParCSRMatrixDestroy(AN);
}
}
/*****xxxxxxxxxxxxx changes for min_coarse_size */
/* here we will determine the coarse grid size to be able to determine if it is not smaller
than requested minimal size */
if (level >= agg_num_levels)
{
if (block_mode )
{
hypre_BoomerAMGCoarseParms(comm,
hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(AN)),
1, NULL, CF_marker, NULL, &coarse_pnts_global);
}
else
{
hypre_BoomerAMGCoarseParms(comm, local_num_vars,
num_functions, dof_func_array[level], CF_marker,
&coarse_dof_func,&coarse_pnts_global);
}
#ifdef HYPRE_NO_GLOBAL_PARTITION
if (my_id == (num_procs -1)) coarse_size = coarse_pnts_global[1];
hypre_MPI_Bcast(&coarse_size, 1, HYPRE_MPI_INT, num_procs-1, comm);
#else
coarse_size = coarse_pnts_global[num_procs];
#endif
if (coarse_size < min_coarse_size)
{
if (S) hypre_ParCSRMatrixDestroy(S);
if (SN) hypre_ParCSRMatrixDestroy(SN);
if (AN) hypre_ParCSRMatrixDestroy(AN);
hypre_TFree(CF_marker);
hypre_TFree(coarse_pnts_global);
hypre_ParVectorDestroy(F_array[level]);
hypre_ParVectorDestroy(U_array[level]);
break;
}
}
/*****xxxxxxxxxxxxx changes for min_coarse_size end */
if (level < agg_num_levels)
{
if (nodal == 0)
@ -957,7 +994,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
hypre_TFree(CFN_marker);
hypre_BoomerAMGCoarseParms(comm, local_num_vars,
num_functions, dof_func_array[level], CF_marker,
&coarse_dof_func,&coarse_pnts_global);
&coarse_dof_func,&coarse_pnts_global);
hypre_BoomerAMGBuildMultipass(A_array[level],
CF_marker, S, coarse_pnts_global,
num_functions, dof_func_array[level], debug_flag,
@ -1129,9 +1166,9 @@ hypre_BoomerAMGSetup( void *amg_vdata,
else /* no aggressive coarsening */
{
/**** Get the coarse parameters ****/
/* xxxxxxxxxxxxxxxxxxxxxxxxx change for min_coarse_size
if (block_mode )
{
/* here we will determine interpolation using a nodal matrix */
hypre_BoomerAMGCoarseParms(comm,
hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(AN)),
1, NULL, CF_marker, NULL, &coarse_pnts_global);
@ -1148,6 +1185,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
#else
coarse_size = coarse_pnts_global[num_procs];
#endif
xxxxxxxxxxxxxxxxxxxxxxxxx change for min_coarse_size */
if (debug_flag==1) wall_time = time_getWallclockSeconds();
@ -1433,7 +1471,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
} /* end of no aggressive coarsening */
/*dof_func_array[level+1] = NULL;
if (num_functions > 1 && nodal > -1 && (!block_mode) )
if (num_functions > 1 && nodal > -1 && (!block_mode) )
dof_func_array[level+1] = coarse_dof_func;*/
@ -1452,6 +1490,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
dof_func_array[level+1] = NULL;
if (num_functions > 1 && nodal > -1 && (!block_mode) )
dof_func_array[level+1] = coarse_dof_func;
} /* end of if max_levels > 1 */
@ -1486,6 +1525,21 @@ hypre_BoomerAMGSetup( void *amg_vdata,
break;
}
if (level < agg_num_levels && coarse_size < min_coarse_size)
{
if (S)
hypre_ParCSRMatrixDestroy(S);
if (P)
hypre_ParCSRMatrixDestroy(P);
if (level > 0)
{
hypre_TFree(CF_marker_array[level]);
hypre_ParVectorDestroy(F_array[level]);
hypre_ParVectorDestroy(U_array[level]);
}
break;
}
/*-------------------------------------------------------------
* Build prolongation matrix, P, and place in P_array[level]

View File

@ -167,6 +167,7 @@ main( hypre_int argc,
HYPRE_Int smooth_num_levels = 0;
HYPRE_Int smooth_num_sweeps = 1;
HYPRE_Int coarse_threshold = 9;
HYPRE_Int min_coarse_size = 1;
HYPRE_Int seq_threshold = 0;
double relax_wt;
double relax_wt_level;
@ -739,6 +740,11 @@ main( hypre_int argc,
arg_index++;
coarse_threshold = atof(argv[arg_index++]);
}
else if ( strcmp(argv[arg_index], "-min_cs") == 0 )
{
arg_index++;
min_coarse_size = atof(argv[arg_index++]);
}
else if ( strcmp(argv[arg_index], "-seq_th") == 0 )
{
arg_index++;
@ -1956,6 +1962,7 @@ main( hypre_int argc,
HYPRE_ParCSRHybridSetCycleRelaxType(amg_solver, relax_coarse, 3);
HYPRE_ParCSRHybridSetRelaxOrder(amg_solver, relax_order);
HYPRE_ParCSRHybridSetMaxCoarseSize(amg_solver, coarse_threshold);
HYPRE_ParCSRHybridSetMinCoarseSize(amg_solver, min_coarse_size);
HYPRE_ParCSRHybridSetSeqThreshold(amg_solver, seq_threshold);
HYPRE_ParCSRHybridSetRelaxWt(amg_solver, relax_wt);
HYPRE_ParCSRHybridSetOuterWt(amg_solver, outer_wt);
@ -2021,6 +2028,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(amg_solver, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(amg_solver, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(amg_solver, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(amg_solver, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(amg_solver, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(amg_solver, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(amg_solver, jacobi_trunc_threshold);
@ -2145,6 +2153,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(amg_solver, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(amg_solver, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(amg_solver, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(amg_solver, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(amg_solver, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(amg_solver, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(amg_solver, jacobi_trunc_threshold);
@ -2285,6 +2294,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -2413,6 +2423,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -2611,6 +2622,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -2728,6 +2740,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -2929,6 +2942,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -3082,6 +3096,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -3241,6 +3256,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);
@ -3449,6 +3465,7 @@ main( hypre_int argc,
HYPRE_BoomerAMGSetStrongThreshold(pcg_precond, strong_threshold);
HYPRE_BoomerAMGSetSeqThreshold(pcg_precond, seq_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(pcg_precond, coarse_threshold);
HYPRE_BoomerAMGSetMinCoarseSize(pcg_precond, min_coarse_size);
HYPRE_BoomerAMGSetTruncFactor(pcg_precond, trunc_factor);
HYPRE_BoomerAMGSetPMaxElmts(pcg_precond, P_max_elmts);
HYPRE_BoomerAMGSetJacobiTruncThreshold(pcg_precond, jacobi_trunc_threshold);