1 /******************************************************************************
2  * Copyright 1998-2019 Lawrence Livermore National Security, LLC and other
3  * HYPRE Project Developers. See the top-level COPYRIGHT file for details.
4  *
5  * SPDX-License-Identifier: (Apache-2.0 OR MIT)
6  ******************************************************************************/
7 
8 /******************************************************************************
9  *
10  * Header info for the hypre_SStructMatrix structures
11  *
12  *****************************************************************************/
13 
14 #ifndef hypre_SSTRUCT_MATRIX_HEADER
15 #define hypre_SSTRUCT_MATRIX_HEADER
16 
17 /*--------------------------------------------------------------------------
18  * hypre_SStructMatrix:
19  *--------------------------------------------------------------------------*/
20 
21 typedef struct
22 {
23    MPI_Comm                comm;
24    hypre_SStructPGrid     *pgrid;
25    hypre_SStructStencil  **stencils;     /* nvar array of stencils */
26 
27    HYPRE_Int               nvars;
28    HYPRE_Int             **smaps;
29    hypre_StructStencil  ***sstencils;    /* nvar x nvar array of sstencils */
30    hypre_StructMatrix   ***smatrices;    /* nvar x nvar array of smatrices */
31    HYPRE_Int             **symmetric;    /* Stencil entries symmetric?
32                                           * (nvar x nvar array) */
33 
34    /* temporary storage for SetValues routines */
35    HYPRE_Int               sentries_size;
36    HYPRE_Int              *sentries;
37 
38    HYPRE_Int               accumulated;  /* AddTo values accumulated? */
39 
40    HYPRE_Int               ref_count;
41 
42 } hypre_SStructPMatrix;
43 
44 typedef struct hypre_SStructMatrix_struct
45 {
46    MPI_Comm                comm;
47    HYPRE_Int               ndim;
48    hypre_SStructGraph     *graph;
49    HYPRE_Int            ***splits;   /* S/U-matrix split for each stencil */
50 
51    /* S-matrix info */
52    HYPRE_Int               nparts;
53    hypre_SStructPMatrix  **pmatrices;
54    HYPRE_Int            ***symmetric;    /* Stencil entries symmetric?
55                                           * (nparts x nvar x nvar array) */
56 
57    /* U-matrix info */
58    HYPRE_IJMatrix          ijmatrix;
59    hypre_ParCSRMatrix     *parcsrmatrix;
60 
61    /* temporary storage for SetValues routines */
62    HYPRE_Int               entries_size;
63    HYPRE_Int              *Sentries;
64    HYPRE_Int              *Uentries;
65 
66    HYPRE_Int               tmp_size;     /* size of the following 3 */
67    HYPRE_BigInt           *tmp_row_coords;
68    HYPRE_BigInt           *tmp_col_coords;
69    HYPRE_Complex          *tmp_coeffs;
70    HYPRE_BigInt           *d_tmp_row_coords;
71    HYPRE_BigInt           *d_tmp_col_coords;
72    HYPRE_Complex          *d_tmp_coeffs;
73 
74    HYPRE_Int               ns_symmetric; /* Non-stencil entries symmetric? */
75    HYPRE_Int               global_size;  /* Total number of nonzero coeffs */
76 
77    HYPRE_Int               ref_count;
78 
79   /* GEC0902   adding an object type to the matrix  */
80    HYPRE_Int               object_type;
81 
82 } hypre_SStructMatrix;
83 
84 /*--------------------------------------------------------------------------
85  * Accessor macros: hypre_SStructMatrix
86  *--------------------------------------------------------------------------*/
87 
88 #define hypre_SStructMatrixComm(mat)                 ((mat) -> comm)
89 #define hypre_SStructMatrixNDim(mat)                 ((mat) -> ndim)
90 #define hypre_SStructMatrixGraph(mat)                ((mat) -> graph)
91 #define hypre_SStructMatrixSplits(mat)               ((mat) -> splits)
92 #define hypre_SStructMatrixSplit(mat, p, v)          ((mat) -> splits[p][v])
93 #define hypre_SStructMatrixNParts(mat)               ((mat) -> nparts)
94 #define hypre_SStructMatrixPMatrices(mat)            ((mat) -> pmatrices)
95 #define hypre_SStructMatrixPMatrix(mat, part)        ((mat) -> pmatrices[part])
96 #define hypre_SStructMatrixSymmetric(mat)            ((mat) -> symmetric)
97 #define hypre_SStructMatrixIJMatrix(mat)             ((mat) -> ijmatrix)
98 #define hypre_SStructMatrixParCSRMatrix(mat)         ((mat) -> parcsrmatrix)
99 #define hypre_SStructMatrixEntriesSize(mat)          ((mat) -> entries_size)
100 #define hypre_SStructMatrixSEntries(mat)             ((mat) -> Sentries)
101 #define hypre_SStructMatrixUEntries(mat)             ((mat) -> Uentries)
102 #define hypre_SStructMatrixTmpSize(mat)              ((mat) -> tmp_size)
103 #define hypre_SStructMatrixTmpRowCoords(mat)         ((mat) -> tmp_row_coords)
104 #define hypre_SStructMatrixTmpColCoords(mat)         ((mat) -> tmp_col_coords)
105 #define hypre_SStructMatrixTmpCoeffs(mat)            ((mat) -> tmp_coeffs)
106 #define hypre_SStructMatrixTmpRowCoordsDevice(mat)   ((mat) -> d_tmp_row_coords)
107 #define hypre_SStructMatrixTmpColCoordsDevice(mat)   ((mat) -> d_tmp_col_coords)
108 #define hypre_SStructMatrixTmpCoeffsDevice(mat)      ((mat) -> d_tmp_coeffs)
109 #define hypre_SStructMatrixNSSymmetric(mat)          ((mat) -> ns_symmetric)
110 #define hypre_SStructMatrixGlobalSize(mat)           ((mat) -> global_size)
111 #define hypre_SStructMatrixRefCount(mat)             ((mat) -> ref_count)
112 #define hypre_SStructMatrixObjectType(mat)           ((mat) -> object_type)
113 
114 /*--------------------------------------------------------------------------
115  * Accessor macros: hypre_SStructPMatrix
116  *--------------------------------------------------------------------------*/
117 
118 #define hypre_SStructPMatrixComm(pmat)              ((pmat) -> comm)
119 #define hypre_SStructPMatrixPGrid(pmat)             ((pmat) -> pgrid)
120 #define hypre_SStructPMatrixNDim(pmat) \
121 hypre_SStructPGridNDim(hypre_SStructPMatrixPGrid(pmat))
122 #define hypre_SStructPMatrixStencils(pmat)          ((pmat) -> stencils)
123 #define hypre_SStructPMatrixNVars(pmat)             ((pmat) -> nvars)
124 #define hypre_SStructPMatrixStencil(pmat, var)      ((pmat) -> stencils[var])
125 #define hypre_SStructPMatrixSMaps(pmat)             ((pmat) -> smaps)
126 #define hypre_SStructPMatrixSMap(pmat, var)         ((pmat) -> smaps[var])
127 #define hypre_SStructPMatrixSStencils(pmat)         ((pmat) -> sstencils)
128 #define hypre_SStructPMatrixSStencil(pmat, vi, vj) \
129 ((pmat) -> sstencils[vi][vj])
130 #define hypre_SStructPMatrixSMatrices(pmat)         ((pmat) -> smatrices)
131 #define hypre_SStructPMatrixSMatrix(pmat, vi, vj)  \
132 ((pmat) -> smatrices[vi][vj])
133 #define hypre_SStructPMatrixSymmetric(pmat)         ((pmat) -> symmetric)
134 #define hypre_SStructPMatrixSEntriesSize(pmat)      ((pmat) -> sentries_size)
135 #define hypre_SStructPMatrixSEntries(pmat)          ((pmat) -> sentries)
136 #define hypre_SStructPMatrixAccumulated(pmat)       ((pmat) -> accumulated)
137 #define hypre_SStructPMatrixRefCount(pmat)          ((pmat) -> ref_count)
138 
139 #endif
140