changed SetValues so that one cannot set values on another processor any longer.Added a new function HYPRE_IJMatrixSetPrintLevel to allow disabling printing of errors

This commit is contained in:
ulrikey 2010-01-05 16:43:21 +00:00
parent f08fce2123
commit 90747b6802
6 changed files with 351 additions and 110 deletions

View File

@ -56,6 +56,7 @@ int HYPRE_IJMatrixCreate( MPI_Comm comm, int ilower, int iupper,
hypre_IJMatrixTranslator(ijmatrix) = NULL;
hypre_IJMatrixObjectType(ijmatrix) = HYPRE_UNITIALIZED;
hypre_IJMatrixAssembleFlag(ijmatrix) = 0;
hypre_IJMatrixPrintLevel(ijmatrix) = 0;
MPI_Comm_size(comm,&num_procs);
MPI_Comm_rank(comm, &myid);
@ -157,7 +158,7 @@ int HYPRE_IJMatrixCreate( MPI_Comm comm, int ilower, int iupper,
i4 = 4*i;
if ( recv_buf[i4+1] != (recv_buf[i4+4]-1) )
{
printf("Warning -- row partitioning does not line up! Partitioning incomplete!\n");
/*printf("Warning -- row partitioning does not line up! Partitioning incomplete!\n");*/
hypre_error(HYPRE_ERROR_GENERIC);
return hypre_error_flag;
}
@ -187,7 +188,7 @@ int HYPRE_IJMatrixCreate( MPI_Comm comm, int ilower, int iupper,
i4 = 4*i;
if (recv_buf[i4+3] != recv_buf[i4+6]-1)
{
printf("Warning -- col partitioning does not line up! Partitioning incomplete!\n");
/*printf("Warning -- col partitioning does not line up! Partitioning incomplete!\n");*/
hypre_error(HYPRE_ERROR_GENERIC);
return hypre_error_flag;
}
@ -235,7 +236,7 @@ HYPRE_IJMatrixDestroy( HYPRE_IJMatrix matrix )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixDestroy\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixDestroy\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -262,7 +263,7 @@ HYPRE_IJMatrixDestroy( HYPRE_IJMatrix matrix )
ierr = hypre_IJMatrixDestroyParCSR( ijmatrix );
else if ( hypre_IJMatrixObjectType(ijmatrix) != -1 )
{
printf("Unrecognized object type -- HYPRE_IJMatrixDestroy\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixDestroy\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -286,7 +287,7 @@ HYPRE_IJMatrixInitialize( HYPRE_IJMatrix matrix )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixInitialize\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixInitialize\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
@ -302,7 +303,7 @@ HYPRE_IJMatrixInitialize( HYPRE_IJMatrix matrix )
ierr = hypre_IJMatrixInitializeParCSR( ijmatrix ) ;
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixInitialize\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixInitialize\n");*/
hypre_error_in_arg(1);
}
@ -311,6 +312,26 @@ HYPRE_IJMatrixInitialize( HYPRE_IJMatrix matrix )
}
/*--------------------------------------------------------------------------
* HYPRE_IJMatrixSetPrintLevel
*--------------------------------------------------------------------------*/
int
HYPRE_IJMatrixSetPrintLevel( HYPRE_IJMatrix matrix, int print_level)
{
hypre_IJMatrix *ijmatrix = (hypre_IJMatrix *) matrix;
if (!ijmatrix)
{
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetPrintLevel\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
hypre_IJMatrixPrintLevel(ijmatrix) = 1;
return hypre_error_flag;
}
/*--------------------------------------------------------------------------
* HYPRE_IJMatrixSetValues
@ -328,7 +349,7 @@ HYPRE_IJMatrixSetValues( HYPRE_IJMatrix matrix, int nrows,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetValues\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetValues\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -376,7 +397,7 @@ HYPRE_IJMatrixSetValues( HYPRE_IJMatrix matrix, int nrows,
rows, cols, values ) );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixSetValues\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixSetValues\n");*/
hypre_error_in_arg(1);
}
@ -401,7 +422,7 @@ HYPRE_IJMatrixAddToValues( HYPRE_IJMatrix matrix, int nrows,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixAddToValues\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixAddToValues\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -449,7 +470,7 @@ HYPRE_IJMatrixAddToValues( HYPRE_IJMatrix matrix, int nrows,
rows, cols, values ) );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixAddToValues\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixAddToValues\n");*/
hypre_error_in_arg(1);
}
@ -468,7 +489,7 @@ HYPRE_IJMatrixAssemble( HYPRE_IJMatrix matrix )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixAssemble\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixAssemble\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -483,7 +504,7 @@ HYPRE_IJMatrixAssemble( HYPRE_IJMatrix matrix )
return( hypre_IJMatrixAssembleParCSR( ijmatrix ) );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixAssemble\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixAssemble\n");*/
hypre_error_in_arg(1);
}
@ -504,7 +525,7 @@ HYPRE_IJMatrixGetRowCounts( HYPRE_IJMatrix matrix, int nrows,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetRowCounts\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetRowCounts\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -537,7 +558,7 @@ HYPRE_IJMatrixGetRowCounts( HYPRE_IJMatrix matrix, int nrows,
hypre_IJMatrixGetRowCountsParCSR( ijmatrix, nrows, rows, ncols );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixGetRowCounts\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixGetRowCounts\n");*/
hypre_error_in_arg(1);
}
@ -559,7 +580,7 @@ HYPRE_IJMatrixGetValues( HYPRE_IJMatrix matrix, int nrows, int *ncols,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetValues\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetValues\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -607,7 +628,7 @@ HYPRE_IJMatrixGetValues( HYPRE_IJMatrix matrix, int nrows, int *ncols,
rows, cols, values );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixGetValues\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixGetValues\n");*/
hypre_error_in_arg(1);
}
@ -626,7 +647,7 @@ HYPRE_IJMatrixSetObjectType( HYPRE_IJMatrix matrix, int type )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetObjectType\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetObjectType\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -647,7 +668,7 @@ HYPRE_IJMatrixGetObjectType( HYPRE_IJMatrix matrix, int *type )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObjectType\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObjectType\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -673,7 +694,7 @@ HYPRE_IJMatrixGetLocalRange( HYPRE_IJMatrix matrix, int *ilower, int *iupper,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObjectType\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObjectType\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -721,7 +742,7 @@ HYPRE_IJMatrixGetObject( HYPRE_IJMatrix matrix, void **object )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObject\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixGetObject\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -744,7 +765,7 @@ HYPRE_IJMatrixSetRowSizes( HYPRE_IJMatrix matrix, const int *sizes )
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetRowSizes\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetRowSizes\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -759,7 +780,7 @@ HYPRE_IJMatrixSetRowSizes( HYPRE_IJMatrix matrix, const int *sizes )
return( hypre_IJMatrixSetRowSizesParCSR( ijmatrix , sizes ) );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixSetRowSizes\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixSetRowSizes\n");*/
hypre_error_in_arg(1);
}
@ -780,7 +801,7 @@ HYPRE_IJMatrixSetDiagOffdSizes( HYPRE_IJMatrix matrix,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetDiagOffdSizes\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetDiagOffdSizes\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -798,7 +819,7 @@ HYPRE_IJMatrixSetDiagOffdSizes( HYPRE_IJMatrix matrix,
offdiag_sizes );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixSetDiagOffdSizes\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixSetDiagOffdSizes\n");*/
hypre_error_in_arg(1);
}
return hypre_error_flag;
@ -817,7 +838,7 @@ HYPRE_IJMatrixSetMaxOffProcElmts( HYPRE_IJMatrix matrix,
if (!ijmatrix)
{
printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetMaxOffProcElmts\n");
/*printf("Variable ijmatrix is NULL -- HYPRE_IJMatrixSetMaxOffProcElmts\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -835,7 +856,7 @@ HYPRE_IJMatrixSetMaxOffProcElmts( HYPRE_IJMatrix matrix,
max_off_proc_elmts) );
else
{
printf("Unrecognized object type -- HYPRE_IJMatrixSetMaxOffProcElmts\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixSetMaxOffProcElmts\n");*/
hypre_error_in_arg(1);
}
return hypre_error_flag;
@ -865,7 +886,7 @@ HYPRE_IJMatrixRead( const char *filename,
if ((file = fopen(new_filename, "r")) == NULL)
{
printf("Error: can't open input file %s\n", new_filename);
/*printf("Error: can't open input file %s\n", new_filename);*/
hypre_error_in_arg(1);
return hypre_error_flag;
@ -915,14 +936,14 @@ HYPRE_IJMatrixPrint( HYPRE_IJMatrix matrix,
if (!matrix)
{
printf("Variable matrix is NULL -- HYPRE_IJMatrixPrint\n");
/*printf("Variable matrix is NULL -- HYPRE_IJMatrixPrint\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
if ( (hypre_IJMatrixObjectType(matrix) != HYPRE_PARCSR) )
{
printf("Unrecognized object type -- HYPRE_IJMatrixPrint\n");
/*printf("Unrecognized object type -- HYPRE_IJMatrixPrint\n");*/
hypre_error_in_arg(1);
return hypre_error_flag;
}
@ -933,7 +954,7 @@ HYPRE_IJMatrixPrint( HYPRE_IJMatrix matrix,
if ((file = fopen(new_filename, "w")) == NULL)
{
printf("Error: can't open output file %s\n", new_filename);
/*printf("Error: can't open output file %s\n", new_filename);*/
hypre_error_in_arg(2);
return hypre_error_flag;
}

View File

@ -330,6 +330,7 @@ int hypre_IJMatrixGetRowCountsParCSR( hypre_IJMatrix *matrix,
int *offd_i = hypre_CSRMatrixI(offd);
int i, my_id;
int print_level = hypre_IJMatrixPrintLevel(matrix);
MPI_Comm_rank(comm,&my_id);
@ -355,7 +356,8 @@ int hypre_IJMatrixGetRowCountsParCSR( hypre_IJMatrix *matrix,
else
{
ncols[i] = 0;
printf ("Warning! Row %d is not on Proc. %d!\n", row_index, my_id);
if (print_level)
printf ("Warning! Row %d is not on Proc. %d!\n", row_index, my_id);
}
}
@ -405,6 +407,7 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
int col_0, col_n, row, row_local, row_size;
int warning = 0;
int *counter;
int print_level = hypre_IJMatrixPrintLevel(matrix);
MPI_Comm_size(comm,&num_procs);
MPI_Comm_rank(comm,&my_id);
@ -412,7 +415,8 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
if (assemble_flag == 0)
{
hypre_error_in_arg(1);
printf("Error! Matrix not assembled yet! HYPRE_IJMatrixGetValues\n");
if (print_level)
printf("Error! Matrix not assembled yet! HYPRE_IJMatrixGetValues\n");
}
#ifdef HYPRE_NO_GLOBAL_PARTITION
@ -464,7 +468,8 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
if (counter[i]+row_size > counter[nrows])
{
hypre_error_in_arg(1);
printf ("Error! Not enough memory! HYPRE_IJMatrixGetValues\n");
if (print_level)
printf ("Error! Not enough memory! HYPRE_IJMatrixGetValues\n");
}
if (ncols[i] < row_size)
warning = 1;
@ -481,13 +486,15 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
counter[i+1] = indx;
}
else
printf ("Warning! Row %d is not on Proc. %d!\n", row, my_id);
if (print_level)
printf ("Warning! Row %d is not on Proc. %d!\n", row, my_id);
}
if (warning)
{
for (i=0; i < nrows; i++)
ncols[i] = counter[i+1] - counter[i];
printf ("Warning! ncols has been changed!\n");
if (print_level)
printf ("Warning! ncols has been changed!\n");
}
hypre_TFree(counter);
}
@ -548,7 +555,8 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
}
}
else
printf ("Warning! Row %d is not on Proc. %d!\n", row, my_id);
if (print_level)
printf ("Warning! Row %d is not on Proc. %d!\n", row, my_id);
}
}
@ -559,7 +567,7 @@ hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix,
*
* hypre_IJMatrixSetValuesParCSR
*
* sets or adds row values to an IJMatrix before assembly,
* sets values in an IJMatrix before assembly,
*
*****************************************************************************/
int
@ -578,8 +586,10 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
MPI_Comm comm = hypre_IJMatrixComm(matrix);
int num_procs, my_id;
int row_local, row;
int row_len;
int col_0, col_n;
int i, ii, j, n, not_found;
int i, ii, j, k, n, not_found;
int col_indx, cancel_indx, cnt1;
int **aux_j;
int *local_j;
int *tmp_j;
@ -603,11 +613,12 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
double *offd_data;
int first;
int current_num_elmts;
int max_off_proc_elmts;
/*int max_off_proc_elmts;*/
int off_proc_i_indx;
int *off_proc_i;
int *off_proc_j;
double *off_proc_data;
int print_level = hypre_IJMatrixPrintLevel(matrix);
/*double *off_proc_data;*/
MPI_Comm_size(comm, &num_procs);
MPI_Comm_rank(comm, &my_id);
par_matrix = hypre_IJMatrixObject( matrix );
@ -626,10 +637,11 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (nrows < 0)
{
hypre_error_in_arg(2);
printf("Error! nrows negative! HYPRE_IJMatrixSetValues\n");
if (print_level)
printf("Error! nrows negative! HYPRE_IJMatrixSetValues\n");
}
if (hypre_IJMatrixAssembleFlag(matrix))
if (hypre_IJMatrixAssembleFlag(matrix)) /* matrix already assembled*/
{
int *col_map_offd;
int num_cols_offd;
@ -672,7 +684,7 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (n > size)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" row %d too long! \n", row);
if (print_level) printf (" row %d too long! \n", row);
return hypre_error_flag;
}
@ -692,7 +704,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (j_offd == -1)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
return hypre_error_flag;
}
@ -708,7 +721,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (not_found)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
return hypre_error_flag;
}
@ -720,7 +734,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (diag_j[pos_diag] != row_local)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
/* return -1;*/
return hypre_error_flag;
@ -741,7 +756,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
if (not_found)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
/* return -1; */
return hypre_error_flag;
@ -753,10 +769,53 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
/* processor does not own the row */
else
else /*search for previous occurrences and cancel them */
{
aux_matrix = hypre_IJMatrixTranslator(matrix);
if (!aux_matrix)
if (aux_matrix)
{
current_num_elmts
= hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix);
off_proc_i_indx = hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix);
off_proc_i = hypre_AuxParCSRMatrixOffProcI(aux_matrix);
off_proc_j = hypre_AuxParCSRMatrixOffProcJ(aux_matrix);
col_indx = 0;
cancel_indx = hypre_AuxParCSRMatrixCancelIndx(aux_matrix);
for (i=0; i < off_proc_i_indx; i=i+2)
{
row_len = off_proc_i[i+1];
if (off_proc_i[i] == row)
{
for (j=0; j < n; j++)
{
cnt1 = col_indx;
for (k=0; k < row_len; k++)
{
if (off_proc_j[cnt1] == cols[j])
{
off_proc_j[cnt1++] = -1;
cancel_indx++;
/* if no repetition allowed */
/* off_proc_j[col_indx] = -1;
col_indx -= k;
break; */
}
else
{
cnt1++;
}
}
}
col_indx += row_len;
}
else
{
col_indx += row_len;
}
}
hypre_AuxParCSRMatrixCancelIndx(aux_matrix) = cancel_indx;
/* if (!aux_matrix)
{
#ifdef HYPRE_NO_GLOBAL_PARTITION
size = row_partitioning[1]-row_partitioning[0];
@ -813,9 +872,10 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
}
hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix) = off_proc_i_indx;
hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix)
= current_num_elmts;
}
} /* end of for loop */
= current_num_elmts; */
}
}
}
}
else
{
@ -961,7 +1021,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
else
{
hypre_error(HYPRE_ERROR_GENERIC);
printf("Error in row %d ! Too many elements!\n",
if (print_level)
printf("Error in row %d ! Too many elements!\n",
row);
/* return 1; */
return hypre_error_flag;
@ -990,7 +1051,8 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
else
{
hypre_error(HYPRE_ERROR_GENERIC);
printf("Error in row %d ! Too many elements !\n",
if (print_level)
printf("Error in row %d ! Too many elements !\n",
row);
/* return 1; */
return hypre_error_flag;
@ -1010,8 +1072,52 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
/* processor does not own the row */
else
{
aux_matrix = hypre_IJMatrixTranslator(matrix);
if (aux_matrix)
{
current_num_elmts
= hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix);
off_proc_i_indx = hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix);
off_proc_i = hypre_AuxParCSRMatrixOffProcI(aux_matrix);
off_proc_j = hypre_AuxParCSRMatrixOffProcJ(aux_matrix);
col_indx = 0;
cancel_indx = hypre_AuxParCSRMatrixCancelIndx(aux_matrix);
for (i=0; i < off_proc_i_indx; i=i+2)
{
row_len = off_proc_i[i+1];
if (off_proc_i[i] == row)
{
for (j=0; j < n; j++)
{
cnt1 = col_indx;
for (k=0; k < row_len; k++)
{
if (off_proc_j[cnt1] == cols[j])
{
off_proc_j[cnt1++] = -1;
cancel_indx++;
/* if no repetition allowed */
/* off_proc_j[col_indx] = -1;
col_indx -= k;
break; */
}
else
{
cnt1++;
}
}
}
col_indx += row_len;
}
else
{
col_indx += row_len;
}
}
hypre_AuxParCSRMatrixCancelIndx(aux_matrix) = cancel_indx;
}
current_num_elmts
/*current_num_elmts
= hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix);
max_off_proc_elmts
= hypre_AuxParCSRMatrixMaxOffProcElmts(aux_matrix);
@ -1057,7 +1163,7 @@ hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix,
}
hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix) = off_proc_i_indx;
hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix)
= current_num_elmts;
= current_num_elmts; */
}
}
}
@ -1118,6 +1224,7 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
int *off_proc_i;
int *off_proc_j;
double *off_proc_data;
int print_level = hypre_IJMatrixPrintLevel(matrix);
MPI_Comm_size(comm, &num_procs);
MPI_Comm_rank(comm, &my_id);
@ -1179,7 +1286,7 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
if (n > size)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" row %d too long! \n", row);
if (print_level) printf (" row %d too long! \n", row);
/* return -1; */
return hypre_error_flag;
}
@ -1200,7 +1307,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
if (j_offd == -1)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
return hypre_error_flag;
/* return -1; */
@ -1217,7 +1325,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
if (not_found)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
/* return -1;*/
return hypre_error_flag;
@ -1230,7 +1339,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
if (diag_j[pos_diag] != row_local)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
/* return -1; */
return hypre_error_flag;
@ -1251,7 +1361,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
if (not_found)
{
hypre_error(HYPRE_ERROR_GENERIC);
printf (" Error, element %d %d does not exist\n",
if (print_level)
printf (" Error, element %d %d does not exist\n",
row, cols[indx]);
/* return -1;*/
return hypre_error_flag;
@ -1313,8 +1424,10 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
}
/* AB - 4/6 - the row should be negative to indicate an add */
/* UMY - 12/28/09 - now positive since we eliminated the feature of
setting on other processors */
/* off_proc_i[off_proc_i_indx++] = row; */
off_proc_i[off_proc_i_indx++] = -row-1;
off_proc_i[off_proc_i_indx++] = row;
off_proc_i[off_proc_i_indx++] = n;
for (i=0; i < n; i++)
@ -1472,7 +1585,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
else
{
hypre_error(HYPRE_ERROR_GENERIC);
printf("Error in row %d ! Too many elements!\n",
if (print_level)
printf("Error in row %d ! Too many elements!\n",
row);
/* return 1;*/
return hypre_error_flag;
@ -1501,7 +1615,8 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
else
{
hypre_error(HYPRE_ERROR_GENERIC);
printf("Error in row %d ! Too many elements !\n",
if (print_level)
printf("Error in row %d ! Too many elements !\n",
row);
/* return 1; */
return hypre_error_flag;
@ -1557,7 +1672,7 @@ hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix,
hypre_AuxParCSRMatrixOffProcJ(aux_matrix) = off_proc_j;
hypre_AuxParCSRMatrixOffProcData(aux_matrix) = off_proc_data;
}
off_proc_i[off_proc_i_indx++] = -row-1;
off_proc_i[off_proc_i_indx++] = row;
off_proc_i[off_proc_i_indx++] = n;
for (i=0; i < n; i++)
{
@ -1625,9 +1740,60 @@ hypre_IJMatrixAssembleParCSR(hypre_IJMatrix *matrix)
int *off_proc_j;
double *off_proc_data;
int offd_proc_elmts;
int new_off_proc_i_indx;
int cancel_indx;
int col_indx;
int current_indx;
int current_i;
int row_len;
if (aux_matrix)
{
/* first delete all cancelled elements */
cancel_indx = hypre_AuxParCSRMatrixCancelIndx(aux_matrix);
if (cancel_indx)
{
current_num_elmts=hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix);
off_proc_i=hypre_AuxParCSRMatrixOffProcI(aux_matrix);
off_proc_j=hypre_AuxParCSRMatrixOffProcJ(aux_matrix);
off_proc_data=hypre_AuxParCSRMatrixOffProcData(aux_matrix);
off_proc_i_indx = hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix);
col_indx = 0;
current_i = 0;
current_indx = 0;
new_off_proc_i_indx = off_proc_i_indx;
for (i=0; i < off_proc_i_indx; i= i+2)
{
row_len = off_proc_i[i+1];
for (j=0; j < off_proc_i[i+1]; j++)
{
if (off_proc_j[col_indx] == -1)
{
col_indx++;
row_len--;
current_num_elmts--;
}
else
{
off_proc_j[current_indx] = off_proc_j[col_indx];
off_proc_data[current_indx++] = off_proc_data[col_indx++];
}
}
if (row_len)
{
off_proc_i[current_i] = off_proc_i[i];
off_proc_i[current_i+1] = row_len;
current_i += 2;
}
else
{
new_off_proc_i_indx -= 2;
}
}
hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix) = new_off_proc_i_indx;
hypre_AuxParCSRMatrixCurrentNumElmts(aux_matrix) = current_num_elmts;
}
off_proc_i_indx = hypre_AuxParCSRMatrixOffProcIIndx(aux_matrix);
MPI_Allreduce(&off_proc_i_indx,&offd_proc_elmts,1,MPI_INT, MPI_SUM,comm);
if (offd_proc_elmts)
@ -2094,21 +2260,21 @@ hypre_IJMatrixAssembleOffProcValsParCSR( hypre_IJMatrix *matrix,
for (ii=0; ii < recv_chunks[i]; ii++)
{
row = recv_i[j];
if (row < 0)
/*if (row < 0)
{
row = -row-1;
hypre_IJMatrixAddToValuesParCSR(matrix,1,&recv_i[j+1],&row,
row = -row-1;*/
hypre_IJMatrixAddToValuesParCSR(matrix,1,&recv_i[j+1],&row,
&recv_i[j+2],&recv_data[j2]);
j2 += recv_i[j+1];
j += recv_i[j+1]+2;
}
j2 += recv_i[j+1];
j += recv_i[j+1]+2;
/*}
else
{
hypre_IJMatrixSetValuesParCSR(matrix,1,&recv_i[j+1],&row,
&recv_i[j+2],&recv_data[j2]);
j2 += recv_i[j+1];
j += recv_i[j+1]+2;
}
}*/
}
}
hypre_TFree(recv_chunks);
@ -2629,17 +2795,17 @@ hypre_IJMatrixAssembleOffProcValsParCSR( hypre_IJMatrix *matrix,
}
if (row < 0) /* Add */
/*if (row < 0)
{
row = -row-1;
hypre_IJMatrixAddToValuesParCSR(matrix,1,&num_elements,&row,
row = -row-1;*/
hypre_IJMatrixAddToValuesParCSR(matrix,1,&num_elements,&row,
col_ptr,col_data_ptr);
}
else /* Set */
/*}
else
{
hypre_IJMatrixSetValuesParCSR(matrix,1,&num_elements,&row,
col_ptr,col_data_ptr);
}
}*/
indx += (num_elements*2);
}

View File

@ -44,6 +44,7 @@ typedef struct hypre_IJMatrix_struct
int global_first_col; /* to be able to avoind using the global */
int global_num_rows; /* global partition */
int global_num_cols;
int print_level;
@ -69,6 +70,7 @@ typedef struct hypre_IJMatrix_struct
#define hypre_IJMatrixGlobalFirstCol(matrix) ((matrix) -> global_first_col)
#define hypre_IJMatrixGlobalNumRows(matrix) ((matrix) -> global_num_rows)
#define hypre_IJMatrixGlobalNumCols(matrix) ((matrix) -> global_num_cols)
#define hypre_IJMatrixPrintLevel(matrix) ((matrix) -> print_level)
/*--------------------------------------------------------------------------
* prototypes for operations on local objects

View File

@ -1,18 +1,3 @@
/*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
#include <HYPRE_config.h>
@ -28,6 +13,21 @@
extern "C" {
#endif
/*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
@ -77,6 +77,8 @@ typedef struct
if AddToValues*/
int *off_proc_j; /* contains column indices */
double *off_proc_data; /* contains corresponding data */
int cancel_indx; /* number of elements that have to be deleted due
to setting values from another processor */
} hypre_AuxParCSRMatrix;
/*--------------------------------------------------------------------------
@ -101,8 +103,24 @@ typedef struct
#define hypre_AuxParCSRMatrixOffProcI(matrix) ((matrix) -> off_proc_i)
#define hypre_AuxParCSRMatrixOffProcJ(matrix) ((matrix) -> off_proc_j)
#define hypre_AuxParCSRMatrixOffProcData(matrix) ((matrix) -> off_proc_data)
#define hypre_AuxParCSRMatrixCancelIndx(matrix) ((matrix) -> cancel_indx)
#endif
/*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
@ -138,6 +156,21 @@ typedef struct
#define hypre_AuxParVectorOffProcData(matrix) ((matrix) -> off_proc_data)
#endif
/*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
* Header info for the hypre_IJMatrix structures
@ -169,6 +202,7 @@ typedef struct hypre_IJMatrix_struct
int global_first_col; /* to be able to avoind using the global */
int global_num_rows; /* global partition */
int global_num_cols;
int print_level;
@ -194,6 +228,7 @@ typedef struct hypre_IJMatrix_struct
#define hypre_IJMatrixGlobalFirstCol(matrix) ((matrix) -> global_first_col)
#define hypre_IJMatrixGlobalNumRows(matrix) ((matrix) -> global_num_rows)
#define hypre_IJMatrixGlobalNumCols(matrix) ((matrix) -> global_num_cols)
#define hypre_IJMatrixPrintLevel(matrix) ((matrix) -> print_level)
/*--------------------------------------------------------------------------
* prototypes for operations on local objects
@ -212,6 +247,21 @@ hypre_GetIJMatrixISISMatrix( HYPRE_IJMatrix IJmatrix, RowMatrix *reference )
#endif
#endif
/*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
* Header info for the hypre_IJMatrix structures
@ -307,22 +357,20 @@ int hypre_IJMatrixDestroyISIS ( hypre_IJMatrix *matrix );
int hypre_IJMatrixSetTotalSizeISIS ( hypre_IJMatrix *matrix , int size );
/* IJMatrix_parcsr.c */
int hypre_IJMatrixCreateParCSR( hypre_IJMatrix *matrix );
int hypre_IJMatrixSetRowSizesParCSR( hypre_IJMatrix *matrix , const int *sizes );
int hypre_IJMatrixSetDiagOffdSizesParCSR( hypre_IJMatrix *matrix , const int *diag_sizes , const int *offdiag_sizes );
int hypre_IJMatrixSetMaxOffProcElmtsParCSR( hypre_IJMatrix *matrix , int max_off_proc_elmts );
int hypre_IJMatrixInitializeParCSR( hypre_IJMatrix *matrix );
int hypre_IJMatrixGetRowCountsParCSR( hypre_IJMatrix *matrix , int nrows , int *rows , int *ncols );
int hypre_IJMatrixGetValuesParCSR( hypre_IJMatrix *matrix , int nrows , int *ncols , int *rows , int *cols , double *values );
int hypre_IJMatrixSetValuesParCSR( hypre_IJMatrix *matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int hypre_IJMatrixAddToValuesParCSR( hypre_IJMatrix *matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int hypre_IJMatrixAssembleParCSR( hypre_IJMatrix *matrix );
int hypre_IJMatrixDestroyParCSR( hypre_IJMatrix *matrix );
int hypre_IJMatrixAssembleOffProcValsParCSR( hypre_IJMatrix *matrix , int off_proc_i_indx , int max_off_proc_elmts , int current_num_elmts , int *off_proc_i , int *off_proc_j , double *off_proc_data );
int hypre_FillResponseIJOffProcVals(void *p_recv_contact_buf, int contact_size, int contact_proc, void *ro, MPI_Comm comm, void **p_send_response_buf, int *response_message_size );
int hypre_FillResponseIJOffProcValsDouble(void *p_recv_contact_buf, int contact_size, int contact_proc, void *ro, MPI_Comm comm, void **p_send_response_buf, int *response_message_size );
int hypre_FindProc( int *list , int value , int list_length );
int hypre_IJMatrixCreateParCSR ( hypre_IJMatrix *matrix );
int hypre_IJMatrixSetRowSizesParCSR ( hypre_IJMatrix *matrix , const int *sizes );
int hypre_IJMatrixSetDiagOffdSizesParCSR ( hypre_IJMatrix *matrix , const int *diag_sizes , const int *offdiag_sizes );
int hypre_IJMatrixSetMaxOffProcElmtsParCSR ( hypre_IJMatrix *matrix , int max_off_proc_elmts );
int hypre_IJMatrixInitializeParCSR ( hypre_IJMatrix *matrix );
int hypre_IJMatrixGetRowCountsParCSR ( hypre_IJMatrix *matrix , int nrows , int *rows , int *ncols );
int hypre_IJMatrixGetValuesParCSR ( hypre_IJMatrix *matrix , int nrows , int *ncols , int *rows , int *cols , double *values );
int hypre_IJMatrixSetValuesParCSR ( hypre_IJMatrix *matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int hypre_IJMatrixAddToValuesParCSR ( hypre_IJMatrix *matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int hypre_IJMatrixAssembleParCSR ( hypre_IJMatrix *matrix );
int hypre_IJMatrixDestroyParCSR ( hypre_IJMatrix *matrix );
int hypre_IJMatrixAssembleOffProcValsParCSR ( hypre_IJMatrix *matrix , int off_proc_i_indx , int max_off_proc_elmts , int current_num_elmts , int *off_proc_i , int *off_proc_j , double *off_proc_data );
int hypre_FillResponseIJOffProcVals ( void *p_recv_contact_buf , int contact_size , int contact_proc , void *ro , MPI_Comm comm , void **p_send_response_buf , int *response_message_size );
int hypre_FindProc ( int *list , int value , int list_length );
/* IJMatrix_petsc.c */
int hypre_IJMatrixSetLocalSizePETSc ( hypre_IJMatrix *matrix , int local_m , int local_n );
@ -362,6 +410,7 @@ int hypre_IJVectorAssembleOffProcValsPar ( hypre_IJVector *vector , int max_off_
int HYPRE_IJMatrixCreate ( MPI_Comm comm , int ilower , int iupper , int jlower , int jupper , HYPRE_IJMatrix *matrix );
int HYPRE_IJMatrixDestroy ( HYPRE_IJMatrix matrix );
int HYPRE_IJMatrixInitialize ( HYPRE_IJMatrix matrix );
int HYPRE_IJMatrixSetPrintLevel ( HYPRE_IJMatrix matrix , int print_level );
int HYPRE_IJMatrixSetValues ( HYPRE_IJMatrix matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int HYPRE_IJMatrixAddToValues ( HYPRE_IJMatrix matrix , int nrows , int *ncols , const int *rows , const int *cols , const double *values );
int HYPRE_IJMatrixAssemble ( HYPRE_IJMatrix matrix );

View File

@ -62,6 +62,8 @@ typedef struct
if AddToValues*/
int *off_proc_j; /* contains column indices */
double *off_proc_data; /* contains corresponding data */
int cancel_indx; /* number of elements that have to be deleted due
to setting values from another processor */
} hypre_AuxParCSRMatrix;
/*--------------------------------------------------------------------------
@ -86,5 +88,6 @@ typedef struct
#define hypre_AuxParCSRMatrixOffProcI(matrix) ((matrix) -> off_proc_i)
#define hypre_AuxParCSRMatrixOffProcJ(matrix) ((matrix) -> off_proc_j)
#define hypre_AuxParCSRMatrixOffProcData(matrix) ((matrix) -> off_proc_data)
#define hypre_AuxParCSRMatrixCancelIndx(matrix) ((matrix) -> cancel_indx)
#endif

View File

@ -17,7 +17,7 @@
INTERNAL_HEADER=IJ_mv.h
INTERNAL_HEADER=_hypre_IJ_mv.h
#===========================================================================
# Include guards and other includes