PaStiX Handbook  6.4.0
symbol_expand.c
Go to the documentation of this file.
1 /**
2  *
3  * @file symbol_expand.c
4  *
5  * @copyright 2012-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
6  * Univ. Bordeaux. All rights reserved.
7  *
8  * @version 6.4.0
9  * @author Vincent Bridonneau
10  * @author Mathieu Faverge
11  * @date 2024-07-05
12  *
13  * @precisions normal z -> s d c p
14  *
15  **/
16 #include "common.h"
17 #include "symbol/symbol.h"
18 #include "symbol_reorder.h"
19 
20 /**
21  *******************************************************************************
22  *
23  * @ingroup symbol_dev
24  *
25  * @brief Compute the index of the first cblk belonging to the Schur complement
26  *
27  *******************************************************************************
28  *
29  * @param[inout] symbptr
30  * The symbol structure pointer in which to find the schur.
31  *
32  *******************************************************************************
33  *
34  * @return The index of the first cblk belonging to the Schur complement.
35  *
36  *******************************************************************************/
37 static inline pastix_int_t
39 {
40  const symbol_cblk_t *cblk;
41 
42  cblk = symbptr->cblktab + symbptr->cblknbr;
43 
44  for (; cblk >= symbptr->cblktab; cblk--)
45  {
46  if ( cblk->fcolnum == symbptr->schurfcol ) {
47  return cblk - symbptr->cblktab;
48  }
49 
50  assert( cblk->fcolnum > symbptr->schurfcol );
51  }
52 
53  return 0;
54 }
55 
56 /**
57  *******************************************************************************
58  *
59  * @ingroup symbol_dev
60  *
61  * @brief Expand the symbol matrix structure when the dof are variadic
62  *
63  *******************************************************************************
64  *
65  * @param[inout] symbptr
66  * The symbol structure to expand. On entry, the information is based
67  * on the compressed graph. On exit, the information are expanded to
68  * the size of the expanded matrix.
69  *
70  *******************************************************************************/
71 static inline void
73 {
74  pastix_int_t i, baseval, cblknbr, bloknbr;
75  symbol_cblk_t *cblk;
76  symbol_blok_t *blok;
77  const pastix_int_t *dofs;
78  pastix_int_t schuridx;
79 
80  dofs = symbptr->dofs;
81  baseval = symbptr->baseval;
82  cblknbr = symbptr->cblknbr;
83  bloknbr = symbptr->bloknbr;
84 
85  /*
86  * Get the cblk index corresponding to schurfcol
87  */
88  schuridx = symbol_expand_find_schurcblk( symbptr );
89 
90  /*
91  * Update cblks
92  */
93  cblk = symbptr->cblktab;
94  for (i=0; i<cblknbr; i++, cblk++) {
95  cblk->fcolnum = dofs[ cblk->fcolnum - baseval ];
96  cblk->lcolnum = dofs[ cblk->lcolnum + 1 - baseval ] - 1;
97  }
98  cblk->fcolnum = cblk[-1].lcolnum + 1;
99  cblk->lcolnum = cblk[-1].lcolnum + 1;
100 
101  /*
102  * Update bloks
103  */
104  blok = symbptr->bloktab;
105  for (i=0; i<bloknbr; i++, blok++) {
106  blok->frownum = dofs[ blok->frownum - baseval ];
107  blok->lrownum = dofs[ blok->lrownum + 1 - baseval ] - 1;
108  }
109 
110  symbptr->nodenbr = symbptr->cblktab[cblknbr ].lcolnum - baseval;
111  symbptr->schurfcol = symbptr->cblktab[schuridx].fcolnum;
112 }
113 
114 /**
115  *******************************************************************************
116  *
117  * @ingroup symbol_dev
118  *
119  * @brief Expand the symbol matrix structure when the dof are constant
120  *
121  *******************************************************************************
122  *
123  * @param[inout] symbptr
124  * The symbol structure to expand. On entry, the information is based
125  * on the compressed graph. On exit, the information are expanded to
126  * the size of the expanded matrix.
127  *
128  *******************************************************************************/
129 static inline void
131 {
132  pastix_int_t col, cblknbr, bloknbr, row, dof;
133  symbol_cblk_t *cblk;
134  symbol_blok_t *blok;
135 
136  dof = symbptr->dof;
137 
138  /* Update cblks first */
139  cblk = symbptr->cblktab;
140  cblknbr = symbptr->cblknbr;
141 
142  for (col = 0; col < cblknbr; col++, cblk++)
143  {
144  cblk->fcolnum = cblk->fcolnum * dof;
145  cblk->lcolnum = (cblk->lcolnum+1) * dof - 1;
146  }
147  cblk->fcolnum = cblk[-1].lcolnum + 1;
148  cblk->lcolnum = cblk[-1].lcolnum + 1;
149 
150  /* Update block row and column indexes */
151  bloknbr = symbptr->bloknbr;
152  blok = symbptr->bloktab;
153 
154  for (row = 0; row < bloknbr; row++, blok++)
155  {
156  blok->frownum = blok->frownum * dof;
157  blok->lrownum = (blok->lrownum+1) * dof - 1;
158  }
159 
160  symbptr->nodenbr *= dof;
161  symbptr->schurfcol *= dof;
162 }
163 
164 /**
165  *******************************************************************************
166  *
167  * @ingroup pastix_symbol
168  *
169  * @brief Expand the symbol matrix structure based on the dof information
170  * (compressed -> expanded)
171  *
172  *******************************************************************************
173  *
174  * @param[inout] symbptr
175  * The symbol structure to expand. On entry, the information is based
176  * on the compressed graph. On exit, the information are expanded to
177  * the size of the expanded matrix.
178  *
179  *******************************************************************************/
180 void
182 {
183  if ( symbptr == NULL ) {
184  pastix_print_error( "pastixSymbolExpand: The symbol matrix is not initialized\n" );
185  return;
186  }
187 
188  pastixSymbolBase( symbptr, 0 );
189 
190  if ( symbptr->dof > 1 ) {
191  symbol_expand_fix( symbptr );
192  }
193  else if ( symbptr->dof < 1 ) {
194  symbol_expand_var( symbptr );
195  }
196 
197  symbptr->dof = 1;
198  memFree_null( symbptr->dofs );
199 
200  pastixSymbolCheck( symbptr );
201 }
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
pastix_int_t frownum
Definition: symbol.h:60
pastix_int_t lrownum
Definition: symbol.h:61
pastix_int_t bloknbr
Definition: symbol.h:80
pastix_int_t baseval
Definition: symbol.h:78
symbol_cblk_t * cblktab
Definition: symbol.h:83
pastix_int_t schurfcol
Definition: symbol.h:82
pastix_int_t fcolnum
Definition: symbol.h:46
pastix_int_t lcolnum
Definition: symbol.h:47
pastix_int_t dof
Definition: symbol.h:87
symbol_blok_t * bloktab
Definition: symbol.h:84
pastix_int_t * dofs
Definition: symbol.h:89
pastix_int_t nodenbr
Definition: symbol.h:81
pastix_int_t cblknbr
Definition: symbol.h:79
void pastixSymbolBase(symbol_matrix_t *symbptr, const pastix_int_t baseval)
Sets the base of the given symbol matrix structure to the given base value.
Definition: symbol_base.c:37
void pastixSymbolExpand(symbol_matrix_t *symbptr)
Expand the symbol matrix structure based on the dof information (compressed -> expanded)
int pastixSymbolCheck(const symbol_matrix_t *symbptr)
Checks the consistency of the given symbolic block matrix.
Definition: symbol_check.c:47
Symbol block structure.
Definition: symbol.h:59
Symbol column block structure.
Definition: symbol.h:45
Symbol matrix structure.
Definition: symbol.h:77
static pastix_int_t symbol_expand_find_schurcblk(const symbol_matrix_t *symbptr)
Compute the index of the first cblk belonging to the Schur complement.
Definition: symbol_expand.c:38
static void symbol_expand_var(symbol_matrix_t *symbptr)
Expand the symbol matrix structure when the dof are variadic.
Definition: symbol_expand.c:72
static void symbol_expand_fix(symbol_matrix_t *symbptr)
Expand the symbol matrix structure when the dof are constant.