Automated coefficient-dependent determination of Jacobi weights. Determine
levelwise.
This commit is contained in:
parent
956fcf613c
commit
9bb64418bd
@ -41,7 +41,6 @@ typedef struct
|
||||
{
|
||||
void *relax_data;
|
||||
int relax_type;
|
||||
int usr_jacobi_weight;
|
||||
double jacobi_weight;
|
||||
|
||||
} hypre_SysPFMGRelaxData;
|
||||
@ -112,42 +111,15 @@ hypre_SysPFMGRelaxSetup( void *sys_pfmg_relax_vdata,
|
||||
hypre_SysPFMGRelaxData *sys_pfmg_relax_data = sys_pfmg_relax_vdata;
|
||||
void *relax_data = (sys_pfmg_relax_data -> relax_data);
|
||||
int relax_type = (sys_pfmg_relax_data -> relax_type);
|
||||
int usr_jacobi_weight= (sys_pfmg_relax_data -> usr_jacobi_weight);
|
||||
double jacobi_weight = (sys_pfmg_relax_data -> jacobi_weight);
|
||||
int ndim = hypre_SStructPGridNDim(
|
||||
hypre_SStructPVectorPGrid(x));
|
||||
|
||||
int ierr = 0;
|
||||
|
||||
if (relax_type == 1)
|
||||
{
|
||||
if (usr_jacobi_weight)
|
||||
{
|
||||
hypre_NodeRelaxSetWeight(relax_data, jacobi_weight);
|
||||
}
|
||||
|
||||
else /* weights dimensionally dependent */
|
||||
{
|
||||
switch(ndim)
|
||||
{
|
||||
case 1: /* Weighted Jacobi (weight = 2/3)- already set */
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 2: /* Weighted Jacobi (weight = 0.80) */
|
||||
{
|
||||
hypre_NodeRelaxSetWeight(relax_data, 0.80);
|
||||
break;
|
||||
}
|
||||
case 3: /* Weighted Jacobi (weight = 6/7) */
|
||||
{
|
||||
hypre_NodeRelaxSetWeight(relax_data, 0.857142857);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
hypre_NodeRelaxSetWeight(relax_data, jacobi_weight);
|
||||
}
|
||||
|
||||
|
||||
ierr = hypre_NodeRelaxSetup((sys_pfmg_relax_data -> relax_data), A, b, x);
|
||||
|
||||
return ierr;
|
||||
@ -167,17 +139,14 @@ hypre_SysPFMGRelaxSetType( void *sys_pfmg_relax_vdata,
|
||||
|
||||
(sys_pfmg_relax_data -> relax_type) = relax_type;
|
||||
|
||||
hypre_NodeRelaxSetWeight(relax_data, 1.0);
|
||||
switch(relax_type)
|
||||
{
|
||||
case 1: /* Weighted Jacobi (weight = 2/3) */
|
||||
hypre_NodeRelaxSetWeight(relax_data, 0.666666);
|
||||
|
||||
case 0: /* Jacobi */
|
||||
{
|
||||
hypre_Index stride;
|
||||
hypre_Index indices[1];
|
||||
|
||||
hypre_NodeRelaxSetWeight(relax_data, 1.0);
|
||||
hypre_NodeRelaxSetNumNodesets(relax_data, 1);
|
||||
|
||||
hypre_SetIndex(stride, 1, 1, 1);
|
||||
@ -225,8 +194,7 @@ hypre_SysPFMGRelaxSetJacobiWeight(void *sys_pfmg_relax_vdata,
|
||||
hypre_SysPFMGRelaxData *sys_pfmg_relax_data = sys_pfmg_relax_vdata;
|
||||
|
||||
(sys_pfmg_relax_data -> jacobi_weight) = weight;
|
||||
(sys_pfmg_relax_data -> usr_jacobi_weight)= 1;
|
||||
|
||||
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
|
||||
@ -117,6 +117,9 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
|
||||
hypre_Box *cbox;
|
||||
|
||||
double *relax_weights;
|
||||
double alpha;
|
||||
|
||||
double min_dxyz;
|
||||
int cdir;
|
||||
int d, l;
|
||||
@ -188,12 +191,14 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
P_grid_l[0] = NULL;
|
||||
cdir_l = hypre_TAlloc(int, max_levels);
|
||||
active_l = hypre_TAlloc(int, max_levels);
|
||||
relax_weights= hypre_CTAlloc(double, max_levels);
|
||||
hypre_SetIndex(coarsen, 1, 1, 1); /* forces relaxation on finest grid */
|
||||
for (l = 0; ; l++)
|
||||
{
|
||||
/* determine cdir */
|
||||
min_dxyz = dxyz[0] + dxyz[1] + dxyz[2] + 1;
|
||||
cdir = -1;
|
||||
alpha= 0.0;
|
||||
for (d = 0; d < dim; d++)
|
||||
{
|
||||
if ((hypre_BoxIMaxD(cbox, d) > hypre_BoxIMinD(cbox, d)) &&
|
||||
@ -202,6 +207,29 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
min_dxyz = dxyz[d];
|
||||
cdir = d;
|
||||
}
|
||||
alpha+= 1.0/(dxyz[d]*dxyz[d]);
|
||||
}
|
||||
|
||||
if (cdir != -1)
|
||||
{
|
||||
for (d = 0; d < dim; d++)
|
||||
{
|
||||
if (d != cdir)
|
||||
{
|
||||
relax_weights[l]+= 1.0/(dxyz[d]*dxyz[d]);
|
||||
}
|
||||
}
|
||||
alpha= relax_weights[l]/alpha;
|
||||
|
||||
/* determine level Jacobi weights */
|
||||
if (dim > 1)
|
||||
{
|
||||
relax_weights[l]= 2.0/(3.0 - alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
relax_weights[l]= 2.0/3.0; /* always 2/3 for 1-d */
|
||||
}
|
||||
}
|
||||
|
||||
/* if cannot coarsen in any direction, stop */
|
||||
@ -395,6 +423,10 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[0], jacobi_weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[0], relax_weights[0]);
|
||||
}
|
||||
hypre_SysPFMGRelaxSetTempVec(relax_data_l[0], tx_l[0]);
|
||||
hypre_SysPFMGRelaxSetup(relax_data_l[0], A_l[0], b_l[0], x_l[0]);
|
||||
if (num_levels > 1)
|
||||
@ -409,6 +441,10 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[l], jacobi_weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[l], relax_weights[l]);
|
||||
}
|
||||
hypre_SysPFMGRelaxSetTempVec(relax_data_l[l], tx_l[l]);
|
||||
hypre_SysPFMGRelaxSetup(relax_data_l[l], A_l[l], b_l[l], x_l[l]);
|
||||
}
|
||||
@ -421,9 +457,14 @@ hypre_SysPFMGSetup( void *sys_pfmg_vdata,
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[l], jacobi_weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
hypre_SysPFMGRelaxSetJacobiWeight(relax_data_l[l], relax_weights[l]);
|
||||
}
|
||||
hypre_SysPFMGRelaxSetTempVec(relax_data_l[l], tx_l[l]);
|
||||
hypre_SysPFMGRelaxSetup(relax_data_l[l], A_l[l], b_l[l], x_l[l]);
|
||||
}
|
||||
hypre_TFree(relax_weights);
|
||||
|
||||
for (l = 0; l < num_levels; l++)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user