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