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