Actual source code: bddcstructs.h

petsc-3.9.4 2018-09-11
Report Typos and Errors

  4:  #include <petscksp.h>
  5:  #include <petscbt.h>

  7: /* special marks for interface graph: they cannot be enums, since special marks should in principle range from -4 to -max_int */
  8: #define PCBDDCGRAPH_NEUMANN_MARK -1
  9: #define PCBDDCGRAPH_DIRICHLET_MARK -2
 10: #define PCBDDCGRAPH_LOCAL_PERIODIC_MARK -3
 11: #define PCBDDCGRAPH_SPECIAL_MARK -4

 13: /* Structure for local graph partitioning */
 14: struct _PCBDDCGraph {
 15:   PetscBool              setupcalled;
 16:   /* graph information */
 17:   ISLocalToGlobalMapping l2gmap;
 18:   PetscInt               nvtxs;
 19:   PetscInt               nvtxs_global;
 20:   PetscBT                touched;
 21:   PetscInt               *count;
 22:   PetscInt               **neighbours_set;
 23:   PetscInt               *subset;
 24:   PetscInt               *which_dof;
 25:   PetscInt               *special_dof;
 26:   PetscInt               custom_minimal_size;
 27:   PetscBool              twodim;
 28:   PetscBool              twodimset;
 29:   PetscBool              has_dirichlet;
 30:   IS                     dirdofs;
 31:   IS                     dirdofsB;
 32:   PetscInt               commsizelimit;
 33:   PetscInt               maxcount;
 34:   /* data for connected components */
 35:   PetscInt               ncc;
 36:   PetscInt               *cptr;
 37:   PetscInt               *queue;
 38:   PetscBool              queue_sorted;
 39:   /* data for interface subsets */
 40:   PetscInt               n_subsets;
 41:   PetscInt               *subset_size;
 42:   PetscInt               **subset_idxs;
 43:   PetscInt               *subset_ncc;
 44:   PetscInt               *subset_ref_node;
 45:   /* data for periodic dofs */
 46:   PetscInt               *mirrors;
 47:   PetscInt               **mirrors_set;
 48:   /* placeholders for connectivity relation between dofs */
 49:   PetscInt               nvtxs_csr;
 50:   PetscInt               *xadj;
 51:   PetscInt               *adjncy;
 52:   PetscBool              freecsr;
 53:   /* data for local subdomains (if any have been detected)
 54:      these are not intended to be exposed */
 55:   PetscInt               n_local_subs;
 56:   PetscInt               *local_subs;
 57:   /* coordinates (for corner detection) */
 58:   PetscBool              active_coords;
 59:   PetscBool              cloc;
 60:   PetscInt               cdim,cnloc;
 61:   PetscReal*             coords;

 63: };
 64: typedef struct _PCBDDCGraph *PCBDDCGraph;

 66: /* Wrap to MatFactor solver in Schur complement mode. Provides
 67:    - standalone solver for interior variables
 68:    - forward and backward substitutions for correction solver
 69: */
 70: /* It assumes that interior variables are a contiguous set starting from 0 */
 71: struct _PCBDDCReuseSolvers {
 72:   /* the factored matrix obtained from MatGetFactor(...,solver_package,...) */
 73:   Mat        F;
 74:   /* placeholders for the solution and rhs on the whole set of dofs of A (size local_dofs - local_vertices)*/
 75:   Vec        sol;
 76:   Vec        rhs;
 77:   /* */
 78:   PetscBool  has_vertices;
 79:   /* shell PCs to handle interior/correction solvers */
 80:   PC         interior_solver;
 81:   PC         correction_solver;
 82:   IS         is_R;
 83:   /* objects to handle Schur complement solution */
 84:   Vec        rhs_B;
 85:   Vec        sol_B;
 86:   IS         is_B;
 87:   VecScatter correction_scatter_B;
 88:   /* handle benign trick without change of basis on pressures */
 89:   PetscInt    benign_n;
 90:   IS          *benign_zerodiag_subs;
 91:   PetscScalar *benign_save_vals;
 92:   Mat         benign_csAIB;
 93:   Mat         benign_AIIm1ones;
 94:   Vec         benign_corr_work;
 95:   Vec         benign_dummy_schur_vec;
 96: };
 97: typedef struct _PCBDDCReuseSolvers *PCBDDCReuseSolvers;

 99: /* structure to handle Schur complements on subsets */
100: struct _PCBDDCSubSchurs {
101:   /* local Neumann matrix */
102:   Mat A;
103:   /* local Schur complement */
104:   Mat S;
105:   /* index sets */
106:   IS  is_I;
107:   IS  is_B;
108:   /* whether Schur complements are explicitly computed with or not */
109:   char      mat_solver_type[64];
110:   PetscBool schur_explicit;
111:   /* matrices cointained explicit schur complements cat together */
112:   /* note that AIJ format is used but the values are inserted as in column major ordering */
113:   Mat S_Ej_all;
114:   Mat sum_S_Ej_all;
115:   Mat sum_S_Ej_inv_all;
116:   Mat sum_S_Ej_tilda_all;
117:   IS  is_Ej_all;
118:   IS  is_vertices;
119:   IS  is_dir;
120:   /* l2g maps */
121:   ISLocalToGlobalMapping l2gmap;
122:   ISLocalToGlobalMapping BtoNmap;
123:   /* number of local subproblems */
124:   PetscInt n_subs;
125:   /* connected components */
126:   IS*      is_subs;
127:   PetscBT  is_edge;
128:   /* mat flags */
129:   PetscBool is_symmetric;
130:   PetscBool is_hermitian;
131:   PetscBool is_posdef;
132:   /* data structure to reuse MatFactor with Schur solver */
133:   PCBDDCReuseSolvers reuse_solver;
134:   /* change of variables */
135:   KSP       *change;
136:   IS        *change_primal_sub;
137:   PetscBool change_with_qr;
138:   /* prefix */
139:   char      *prefix;
140: };
141: typedef struct _PCBDDCSubSchurs *PCBDDCSubSchurs;

143: /* Structure for deluxe scaling */
144: struct _PCBDDCDeluxeScaling {
145:   /* simple scaling on selected dofs (i.e. primal vertices and nodes on interface dirichlet boundaries) */
146:   PetscInt        n_simple;
147:   PetscInt*       idx_simple_B;
148:   /* handle deluxe problems  */
149:   PetscInt        seq_n;
150:   PetscScalar     *workspace;
151:   VecScatter      *seq_scctx;
152:   Vec             *seq_work1;
153:   Vec             *seq_work2;
154:   Mat             *seq_mat;
155:   Mat             *seq_mat_inv_sum;
156:   KSP             *change;
157:   PetscBool       change_with_qr;
158: };
159: typedef struct _PCBDDCDeluxeScaling *PCBDDCDeluxeScaling;

161: /* inexact solvers with nullspace correction */
162: struct _NullSpaceCorrection_ctx {
163:   Mat         basis_mat;
164:   Mat         Kbasis_mat;
165:   Mat         Lbasis_mat;
166:   PC          local_pc;
167:   Vec         work_small_1;
168:   Vec         work_small_2;
169:   Vec         work_full_1;
170:   Vec         work_full_2;
171:   PetscBool   apply_scaling;
172:   PetscScalar scale;
173: };
174: typedef struct _NullSpaceCorrection_ctx *NullSpaceCorrection_ctx;

176: /* MatShell context for benign mat mults */
177: struct _PCBDDCBenignMatMult_ctx {
178:   Mat         A;
179:   PetscInt    benign_n;
180:   IS          *benign_zerodiag_subs;
181:   PetscScalar *work;
182:   PetscBool   apply_left;
183:   PetscBool   apply_right;
184:   PetscBool   apply_p0;
185:   PetscBool   free;
186: };
187: typedef struct _PCBDDCBenignMatMult_ctx *PCBDDCBenignMatMult_ctx;

189: /* feti-dp mat */
190: struct _FETIDPMat_ctx {
191:   PetscInt   n;               /* local number of rows */
192:   PetscInt   N;               /* global number of rows */
193:   PetscInt   n_lambda;        /* global number of multipliers */
194:   Vec        lambda_local;
195:   Vec        temp_solution_B;
196:   Vec        temp_solution_D;
197:   Mat        B_delta;
198:   Mat        B_Ddelta;
199:   PetscBool  deluxe_nonred;
200:   VecScatter l2g_lambda;
201:   PC         pc;
202:   PetscBool  fully_redundant;
203:   /* saddle point */
204:   VecScatter l2g_lambda_only;
205:   Mat        B_BB;
206:   Mat        B_BI;
207:   Mat        Bt_BB;
208:   Mat        Bt_BI;
209:   Mat        C;
210:   VecScatter l2g_p;
211:   VecScatter g2g_p;
212:   Vec        vP;
213:   Vec        xPg;
214:   Vec        yPg;
215:   Vec        rhs_flip;
216:   IS         pressure;
217:   IS         lagrange;
218: };
219: typedef struct _FETIDPMat_ctx *FETIDPMat_ctx;

221: /* feti-dp preconditioner */
222: struct _FETIDPPC_ctx {
223:   Mat        S_j;
224:   Vec        lambda_local;
225:   Mat        B_Ddelta;
226:   VecScatter l2g_lambda;
227:   PC         pc;
228:   /* saddle point */
229:   Vec        xPg;
230:   Vec        yPg;
231: };
232: typedef struct _FETIDPPC_ctx *FETIDPPC_ctx;

234: struct _BDdelta_DN {
235:   Mat BD;
236:   KSP kBD;
237:   Vec work;
238: };
239: typedef struct _BDdelta_DN *BDdelta_DN;

241: #endif