xref: /petsc/src/dm/impls/da/hypre/mhyp.h (revision f4bdf6c41fcda3d82613625104db08c3659d212a)
1*f4bdf6c4SBarry Smith 
2*f4bdf6c4SBarry Smith #if !defined(_MHYP_H)
3*f4bdf6c4SBarry Smith #define _MHYP_H
4*f4bdf6c4SBarry Smith 
5*f4bdf6c4SBarry Smith #include "petscdm.h"   /*I "petscdm.h" I*/
6*f4bdf6c4SBarry Smith #include "HYPRE_struct_mv.h"
7*f4bdf6c4SBarry Smith #include "HYPRE_struct_ls.h"
8*f4bdf6c4SBarry Smith #include "_hypre_struct_mv.h"
9*f4bdf6c4SBarry Smith #include "HYPRE_sstruct_mv.h"
10*f4bdf6c4SBarry Smith #include "HYPRE_sstruct_ls.h"
11*f4bdf6c4SBarry Smith #include "_hypre_sstruct_mv.h"
12*f4bdf6c4SBarry Smith 
13*f4bdf6c4SBarry Smith typedef struct {
14*f4bdf6c4SBarry Smith   MPI_Comm            hcomm;
15*f4bdf6c4SBarry Smith   DM                  da;
16*f4bdf6c4SBarry Smith   HYPRE_StructGrid    hgrid;
17*f4bdf6c4SBarry Smith   HYPRE_StructStencil hstencil;
18*f4bdf6c4SBarry Smith   HYPRE_StructMatrix  hmat;
19*f4bdf6c4SBarry Smith   HYPRE_StructVector  hb,hx;
20*f4bdf6c4SBarry Smith   hypre_Box           hbox;
21*f4bdf6c4SBarry Smith 
22*f4bdf6c4SBarry Smith   PetscBool           needsinitialization;
23*f4bdf6c4SBarry Smith 
24*f4bdf6c4SBarry Smith   /* variables that are stored here so they need not be reloaded for each MatSetValuesLocal() or MatZeroRowsLocal() call */
25*f4bdf6c4SBarry Smith   PetscInt            *gindices,rstart,gnx,gnxgny,xs,ys,zs,nx,ny,nxny;
26*f4bdf6c4SBarry Smith } Mat_HYPREStruct;
27*f4bdf6c4SBarry Smith 
28*f4bdf6c4SBarry Smith typedef struct {
29*f4bdf6c4SBarry Smith   MPI_Comm               hcomm;
30*f4bdf6c4SBarry Smith   DM                     da;
31*f4bdf6c4SBarry Smith   HYPRE_SStructGrid      ss_grid;
32*f4bdf6c4SBarry Smith   HYPRE_SStructGraph     ss_graph;
33*f4bdf6c4SBarry Smith   HYPRE_SStructStencil   ss_stencil;
34*f4bdf6c4SBarry Smith   HYPRE_SStructMatrix    ss_mat;
35*f4bdf6c4SBarry Smith   HYPRE_SStructVector    ss_b, ss_x;
36*f4bdf6c4SBarry Smith   hypre_Box              hbox;
37*f4bdf6c4SBarry Smith 
38*f4bdf6c4SBarry Smith   int                    ss_object_type;
39*f4bdf6c4SBarry Smith   int                    nvars;
40*f4bdf6c4SBarry Smith   int                    dofs_order;
41*f4bdf6c4SBarry Smith 
42*f4bdf6c4SBarry Smith   PetscBool              needsinitialization;
43*f4bdf6c4SBarry Smith 
44*f4bdf6c4SBarry Smith   /* variables that are stored here so they need not be reloaded for each MatSetValuesLocal() or MatZeroRowsLocal() call */
45*f4bdf6c4SBarry Smith   PetscInt              *gindices,rstart,gnx,gnxgny,gnxgnygnz,xs,ys,zs,nx,ny,nz,nxny,nxnynz;
46*f4bdf6c4SBarry Smith } Mat_HYPRESStruct;
47*f4bdf6c4SBarry Smith 
48*f4bdf6c4SBarry Smith 
49*f4bdf6c4SBarry Smith extern PetscErrorCode MatHYPRE_IJMatrixCreate(Mat,HYPRE_IJMatrix*);
50*f4bdf6c4SBarry Smith extern PetscErrorCode MatHYPRE_IJMatrixCopy(Mat,HYPRE_IJMatrix);
51*f4bdf6c4SBarry Smith extern PetscErrorCode MatHYPRE_IJMatrixFastCopy(Mat,HYPRE_IJMatrix);
52*f4bdf6c4SBarry Smith extern PetscErrorCode VecHYPRE_IJVectorCreate(Vec,HYPRE_IJVector*);
53*f4bdf6c4SBarry Smith 
54*f4bdf6c4SBarry Smith /*
55*f4bdf6c4SBarry Smith     PetscStackCallHypre - Calls a hypre library routine after pushing the name of the routine on the stack.
56*f4bdf6c4SBarry Smith 
57*f4bdf6c4SBarry Smith    Input Parameters:
58*f4bdf6c4SBarry Smith +   name - string that gives the name of the function being called
59*f4bdf6c4SBarry Smith -   routine - actual call to the routine
60*f4bdf6c4SBarry Smith 
61*f4bdf6c4SBarry Smith    Developer Note: this is so that when a hypre routine results in a crash or corrupts memory, they get blamed instead of PETSc.
62*f4bdf6c4SBarry Smith 
63*f4bdf6c4SBarry Smith */
64*f4bdf6c4SBarry Smith #define PetscStackCallHypre(name,func,args) do {                        \
65*f4bdf6c4SBarry Smith     const char *_fname = name ? name : #func;                           \
66*f4bdf6c4SBarry Smith     PetscStackPush(_fname);ierr = func args;if (ierr) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in %s()",_fname);PetscStackPop; \
67*f4bdf6c4SBarry Smith   } while (0)
68*f4bdf6c4SBarry Smith 
69*f4bdf6c4SBarry Smith #endif
70