1998-01-07 03:57:39 +08:00
|
|
|
/*BHEADER**********************************************************************
|
|
|
|
|
* (c) 1997 The Regents of the University of California
|
|
|
|
|
*
|
|
|
|
|
* See the file COPYRIGHT_and_DISCLAIMER for a complete copyright
|
|
|
|
|
* notice, contact person, and disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* $Revision$
|
|
|
|
|
*********************************************************************EHEADER*/
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
1998-02-18 01:56:00 +08:00
|
|
|
* HYPRE_StructMatrix interface
|
1998-01-07 03:57:39 +08:00
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "headers.h"
|
2000-04-20 05:31:17 +08:00
|
|
|
|
1998-01-07 03:57:39 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixCreate
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
1998-12-19 08:46:37 +08:00
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixCreate( MPI_Comm comm,
|
1999-09-01 07:31:24 +08:00
|
|
|
HYPRE_StructGrid grid,
|
|
|
|
|
HYPRE_StructStencil stencil,
|
|
|
|
|
HYPRE_StructMatrix *matrix )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
*matrix = hypre_StructMatrixCreate(comm, grid, stencil);
|
1998-12-19 08:46:37 +08:00
|
|
|
|
|
|
|
|
return 0;
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixDestroy
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixDestroy( HYPRE_StructMatrix matrix )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
return( hypre_StructMatrixDestroy(matrix) );
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixInitialize
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixInitialize( HYPRE_StructMatrix matrix )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
return ( hypre_StructMatrixInitialize(matrix) );
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixSetValues
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixSetValues( HYPRE_StructMatrix matrix,
|
1998-02-19 07:45:29 +08:00
|
|
|
int *grid_index,
|
|
|
|
|
int num_stencil_indices,
|
|
|
|
|
int *stencil_indices,
|
2000-04-20 05:31:17 +08:00
|
|
|
double *values )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
hypre_Index new_grid_index;
|
|
|
|
|
|
|
|
|
|
int d;
|
|
|
|
|
int ierr = 0;
|
1998-01-07 03:57:39 +08:00
|
|
|
|
1998-03-14 00:56:50 +08:00
|
|
|
hypre_ClearIndex(new_grid_index);
|
2000-04-20 05:31:17 +08:00
|
|
|
for (d = 0; d < hypre_StructGridDim(hypre_StructMatrixGrid(matrix)); d++)
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_IndexD(new_grid_index, d) = grid_index[d];
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
ierr = hypre_StructMatrixSetValues(matrix, new_grid_index,
|
|
|
|
|
num_stencil_indices, stencil_indices,
|
|
|
|
|
values, 0);
|
1998-01-07 03:57:39 +08:00
|
|
|
|
|
|
|
|
return (ierr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixSetBoxValues
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixSetBoxValues( HYPRE_StructMatrix matrix,
|
1998-02-19 07:45:29 +08:00
|
|
|
int *ilower,
|
|
|
|
|
int *iupper,
|
|
|
|
|
int num_stencil_indices,
|
|
|
|
|
int *stencil_indices,
|
2000-04-20 05:31:17 +08:00
|
|
|
double *values )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_Index new_ilower;
|
|
|
|
|
hypre_Index new_iupper;
|
|
|
|
|
hypre_Box *new_value_box;
|
1998-01-07 03:57:39 +08:00
|
|
|
|
1998-02-19 07:45:29 +08:00
|
|
|
int d;
|
1998-05-27 22:13:16 +08:00
|
|
|
int ierr = 0;
|
1998-01-07 03:57:39 +08:00
|
|
|
|
1998-03-14 00:56:50 +08:00
|
|
|
hypre_ClearIndex(new_ilower);
|
|
|
|
|
hypre_ClearIndex(new_iupper);
|
2000-04-20 05:31:17 +08:00
|
|
|
for (d = 0; d < hypre_StructGridDim(hypre_StructMatrixGrid(matrix)); d++)
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_IndexD(new_ilower, d) = ilower[d];
|
|
|
|
|
hypre_IndexD(new_iupper, d) = iupper[d];
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
1999-09-07 15:03:59 +08:00
|
|
|
new_value_box = hypre_BoxCreate();
|
|
|
|
|
hypre_BoxSetExtents(new_value_box, new_ilower, new_iupper);
|
1998-01-07 03:57:39 +08:00
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
ierr = hypre_StructMatrixSetBoxValues(matrix, new_value_box,
|
|
|
|
|
num_stencil_indices, stencil_indices,
|
|
|
|
|
values, 0);
|
2000-03-16 08:03:20 +08:00
|
|
|
|
|
|
|
|
hypre_BoxDestroy(new_value_box);
|
|
|
|
|
|
|
|
|
|
return (ierr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE_StructMatrixAddToValues
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
HYPRE_StructMatrixAddToValues( HYPRE_StructMatrix matrix,
|
|
|
|
|
int *grid_index,
|
|
|
|
|
int num_stencil_indices,
|
|
|
|
|
int *stencil_indices,
|
2000-04-20 05:31:17 +08:00
|
|
|
double *values )
|
2000-03-16 08:03:20 +08:00
|
|
|
{
|
|
|
|
|
hypre_Index new_grid_index;
|
|
|
|
|
|
|
|
|
|
int d;
|
|
|
|
|
int ierr = 0;
|
|
|
|
|
|
|
|
|
|
hypre_ClearIndex(new_grid_index);
|
2000-04-20 05:31:17 +08:00
|
|
|
for (d = 0; d < hypre_StructGridDim(hypre_StructMatrixGrid(matrix)); d++)
|
2000-03-16 08:03:20 +08:00
|
|
|
{
|
|
|
|
|
hypre_IndexD(new_grid_index, d) = grid_index[d];
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
ierr = hypre_StructMatrixSetValues(matrix, new_grid_index,
|
|
|
|
|
num_stencil_indices, stencil_indices,
|
|
|
|
|
values, 1);
|
2000-03-16 08:03:20 +08:00
|
|
|
|
|
|
|
|
return (ierr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE_StructMatrixAddToBoxValues
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
HYPRE_StructMatrixAddToBoxValues( HYPRE_StructMatrix matrix,
|
|
|
|
|
int *ilower,
|
|
|
|
|
int *iupper,
|
|
|
|
|
int num_stencil_indices,
|
|
|
|
|
int *stencil_indices,
|
2000-04-20 05:31:17 +08:00
|
|
|
double *values )
|
2000-03-16 08:03:20 +08:00
|
|
|
{
|
|
|
|
|
hypre_Index new_ilower;
|
|
|
|
|
hypre_Index new_iupper;
|
|
|
|
|
hypre_Box *new_value_box;
|
|
|
|
|
|
|
|
|
|
int d;
|
|
|
|
|
int ierr = 0;
|
|
|
|
|
|
|
|
|
|
hypre_ClearIndex(new_ilower);
|
|
|
|
|
hypre_ClearIndex(new_iupper);
|
2000-04-20 05:31:17 +08:00
|
|
|
for (d = 0; d < hypre_StructGridDim(hypre_StructMatrixGrid(matrix)); d++)
|
2000-03-16 08:03:20 +08:00
|
|
|
{
|
|
|
|
|
hypre_IndexD(new_ilower, d) = ilower[d];
|
|
|
|
|
hypre_IndexD(new_iupper, d) = iupper[d];
|
|
|
|
|
}
|
|
|
|
|
new_value_box = hypre_BoxCreate();
|
|
|
|
|
hypre_BoxSetExtents(new_value_box, new_ilower, new_iupper);
|
|
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
ierr = hypre_StructMatrixSetBoxValues(matrix, new_value_box,
|
|
|
|
|
num_stencil_indices, stencil_indices,
|
|
|
|
|
values, 1);
|
1998-01-07 03:57:39 +08:00
|
|
|
|
1999-09-07 15:03:59 +08:00
|
|
|
hypre_BoxDestroy(new_value_box);
|
1998-01-07 03:57:39 +08:00
|
|
|
|
|
|
|
|
return (ierr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixAssemble
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixAssemble( HYPRE_StructMatrix matrix )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
return( hypre_StructMatrixAssemble(matrix) );
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixSetNumGhost
|
1998-01-07 03:57:39 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
1998-12-22 04:00:10 +08:00
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixSetNumGhost( HYPRE_StructMatrix matrix,
|
1998-02-19 07:45:29 +08:00
|
|
|
int *num_ghost )
|
1998-01-07 03:57:39 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
return ( hypre_StructMatrixSetNumGhost(matrix, num_ghost) );
|
1998-01-07 03:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
1998-01-13 04:27:31 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixGetGrid
|
1998-01-13 04:27:31 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
1998-12-23 02:26:25 +08:00
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixGetGrid( HYPRE_StructMatrix matrix, HYPRE_StructGrid *grid )
|
1998-01-13 04:27:31 +08:00
|
|
|
{
|
1998-12-23 02:26:25 +08:00
|
|
|
int ierr = 0;
|
|
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
*grid = hypre_StructMatrixGrid(matrix);
|
1998-12-23 02:26:25 +08:00
|
|
|
|
|
|
|
|
return ierr;
|
1998-01-13 04:27:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixSetSymmetric
|
1998-01-13 04:27:31 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
1998-12-22 04:00:10 +08:00
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixSetSymmetric( HYPRE_StructMatrix matrix,
|
1998-02-19 07:45:29 +08:00
|
|
|
int symmetric )
|
1998-01-13 04:27:31 +08:00
|
|
|
{
|
1998-12-22 04:00:10 +08:00
|
|
|
int ierr = 0;
|
|
|
|
|
|
2000-04-20 05:31:17 +08:00
|
|
|
hypre_StructMatrixSymmetric(matrix) = symmetric;
|
1998-12-22 04:00:10 +08:00
|
|
|
|
|
|
|
|
return ierr;
|
1998-01-13 04:27:31 +08:00
|
|
|
}
|
|
|
|
|
|
1998-01-13 06:17:12 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
1999-09-07 15:03:59 +08:00
|
|
|
* HYPRE_StructMatrixPrint
|
1998-01-13 06:17:12 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
1998-12-22 04:00:10 +08:00
|
|
|
int
|
1999-09-07 15:03:59 +08:00
|
|
|
HYPRE_StructMatrixPrint( char *filename,
|
1998-02-19 07:45:29 +08:00
|
|
|
HYPRE_StructMatrix matrix,
|
|
|
|
|
int all )
|
1998-01-13 06:17:12 +08:00
|
|
|
{
|
2000-04-20 05:31:17 +08:00
|
|
|
return ( hypre_StructMatrixPrint(filename, matrix, all) );
|
1998-01-13 06:17:12 +08:00
|
|
|
}
|
1998-11-10 03:22:08 +08:00
|
|
|
|