1 #define PETSCKSP_DLL 2 3 #include "../src/ksp/pc/impls/factor/factor.h" /*I "petscpc.h" I*/ 4 5 /* ------------------------------------------------------------------------------------------*/ 6 7 EXTERN_C_BEGIN 8 #undef __FUNCT__ 9 #define __FUNCT__ "PCFactorSetZeroPivot_Factor" 10 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetZeroPivot_Factor(PC pc,PetscReal z) 11 { 12 PC_Factor *ilu = (PC_Factor*)pc->data; 13 14 PetscFunctionBegin; 15 ilu->info.zeropivot = z; 16 PetscFunctionReturn(0); 17 } 18 EXTERN_C_END 19 20 EXTERN_C_BEGIN 21 #undef __FUNCT__ 22 #define __FUNCT__ "PCFactorSetShiftNonzero_Factor" 23 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftNonzero_Factor(PC pc,PetscReal shift) 24 { 25 PC_Factor *dir = (PC_Factor*)pc->data; 26 27 PetscFunctionBegin; 28 if (shift == (PetscReal) PETSC_DECIDE) { 29 dir->info.shiftnz = 1.e-12; 30 } else { 31 dir->info.shiftnz = shift; 32 } 33 PetscFunctionReturn(0); 34 } 35 EXTERN_C_END 36 37 EXTERN_C_BEGIN 38 #undef __FUNCT__ 39 #define __FUNCT__ "PCFactorSetShiftPd_Factor" 40 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftPd_Factor(PC pc,PetscTruth shift) 41 { 42 PC_Factor *dir = (PC_Factor*)pc->data; 43 44 PetscFunctionBegin; 45 if (shift) { 46 dir->info.shiftpd = 1.0; 47 } else { 48 dir->info.shiftpd = 0.0; 49 } 50 PetscFunctionReturn(0); 51 } 52 EXTERN_C_END 53 54 EXTERN_C_BEGIN 55 #undef __FUNCT__ 56 #define __FUNCT__ "PCFactorSetUseDropTolerance_Factor" 57 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetUseDropTolerance_Factor(PC pc,PetscReal dt,PetscReal dtcol,PetscInt dtcount) 58 { 59 PC_Factor *ilu = (PC_Factor*)pc->data; 60 61 PetscFunctionBegin; 62 if (pc->setupcalled && (!ilu->info.usedt || ((PC_Factor*)ilu)->info.dt != dt || ((PC_Factor*)ilu)->info.dtcol != dtcol || ((PC_Factor*)ilu)->info.dtcount != dtcount)) { 63 SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Cannot change tolerance after use"); 64 } 65 ilu->info.usedt = PETSC_TRUE; 66 ilu->info.dt = dt; 67 ilu->info.dtcol = dtcol; 68 ilu->info.dtcount = dtcount; 69 ilu->info.fill = PETSC_DEFAULT; 70 PetscFunctionReturn(0); 71 } 72 EXTERN_C_END 73 74 EXTERN_C_BEGIN 75 #undef __FUNCT__ 76 #define __FUNCT__ "PCFactorSetFill_Factor" 77 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetFill_Factor(PC pc,PetscReal fill) 78 { 79 PC_Factor *dir = (PC_Factor*)pc->data; 80 81 PetscFunctionBegin; 82 dir->info.fill = fill; 83 PetscFunctionReturn(0); 84 } 85 EXTERN_C_END 86 87 EXTERN_C_BEGIN 88 #undef __FUNCT__ 89 #define __FUNCT__ "PCFactorSetMatOrderingType_Factor" 90 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetMatOrderingType_Factor(PC pc,const MatOrderingType ordering) 91 { 92 PC_Factor *dir = (PC_Factor*)pc->data; 93 PetscErrorCode ierr; 94 PetscTruth flg; 95 96 PetscFunctionBegin; 97 if (!pc->setupcalled) { 98 ierr = PetscStrfree(dir->ordering);CHKERRQ(ierr); 99 ierr = PetscStrallocpy(ordering,&dir->ordering);CHKERRQ(ierr); 100 } else { 101 ierr = PetscStrcmp(dir->ordering,ordering,&flg);CHKERRQ(ierr); 102 if (!flg) { 103 SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Cannot change ordering after use"); 104 } 105 } 106 PetscFunctionReturn(0); 107 } 108 EXTERN_C_END 109 110 EXTERN_C_BEGIN 111 #undef __FUNCT__ 112 #define __FUNCT__ "PCFactorSetLevels_Factor" 113 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetLevels_Factor(PC pc,PetscInt levels) 114 { 115 PC_Factor *ilu = (PC_Factor*)pc->data; 116 117 PetscFunctionBegin; 118 if (!pc->setupcalled) { 119 ilu->info.levels = levels; 120 } else if (ilu->info.usedt || ilu->info.levels != levels) { 121 SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Cannot change levels after use"); 122 } 123 PetscFunctionReturn(0); 124 } 125 EXTERN_C_END 126 127 EXTERN_C_BEGIN 128 #undef __FUNCT__ 129 #define __FUNCT__ "PCFactorSetAllowDiagonalFill_Factor" 130 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetAllowDiagonalFill_Factor(PC pc) 131 { 132 PC_Factor *dir = (PC_Factor*)pc->data; 133 134 PetscFunctionBegin; 135 dir->info.diagonal_fill = 1; 136 PetscFunctionReturn(0); 137 } 138 EXTERN_C_END 139 140 141 /* ------------------------------------------------------------------------------------------*/ 142 143 EXTERN_C_BEGIN 144 #undef __FUNCT__ 145 #define __FUNCT__ "PCFactorSetPivotInBlocks_Factor" 146 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetPivotInBlocks_Factor(PC pc,PetscTruth pivot) 147 { 148 PC_Factor *dir = (PC_Factor*)pc->data; 149 150 PetscFunctionBegin; 151 dir->info.pivotinblocks = pivot ? 1.0 : 0.0; 152 PetscFunctionReturn(0); 153 } 154 EXTERN_C_END 155 156 EXTERN_C_BEGIN 157 #undef __FUNCT__ 158 #define __FUNCT__ "PCFactorSetShiftInBlocks_Factor" 159 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftInBlocks_Factor(PC pc,PetscReal shift) 160 { 161 PC_Factor *dir = (PC_Factor*)pc->data; 162 163 PetscFunctionBegin; 164 if (shift == PETSC_DEFAULT) { 165 dir->info.shiftinblocks = 1.e-12; 166 } else { 167 dir->info.shiftinblocks = shift; 168 } 169 PetscFunctionReturn(0); 170 } 171 EXTERN_C_END 172 173 174 EXTERN_C_BEGIN 175 #undef __FUNCT__ 176 #define __FUNCT__ "PCFactorGetMatrix_Factor" 177 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorGetMatrix_Factor(PC pc,Mat *mat) 178 { 179 PC_Factor *ilu = (PC_Factor*)pc->data; 180 181 PetscFunctionBegin; 182 if (!ilu->fact) SETERRQ(PETSC_ERR_ORDER,"Matrix not yet factored; call after KSPSetUp() or PCSetUp()"); 183 *mat = ilu->fact; 184 PetscFunctionReturn(0); 185 } 186 EXTERN_C_END 187 188 EXTERN_C_BEGIN 189 #undef __FUNCT__ 190 #define __FUNCT__ "PCFactorSetMatSolverPackage_Factor" 191 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetMatSolverPackage_Factor(PC pc,const MatSolverPackage stype) 192 { 193 PetscErrorCode ierr; 194 PC_Factor *lu = (PC_Factor*)pc->data; 195 196 PetscFunctionBegin; 197 if (lu->fact) { 198 const MatSolverPackage ltype; 199 PetscTruth flg; 200 ierr = MatFactorGetSolverPackage(lu->fact,<ype);CHKERRQ(ierr); 201 ierr = PetscStrcmp(stype,ltype,&flg);CHKERRQ(ierr); 202 if (!flg) { 203 SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Cannot change solver matrix package after PC has been setup or used"); 204 } 205 } 206 ierr = PetscStrfree(lu->solvertype);CHKERRQ(ierr); 207 ierr = PetscStrallocpy(stype,&lu->solvertype);CHKERRQ(ierr); 208 PetscFunctionReturn(0); 209 } 210 EXTERN_C_END 211 212 EXTERN_C_BEGIN 213 #undef __FUNCT__ 214 #define __FUNCT__ "PCFactorGetMatSolverPackage_Factor" 215 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorGetMatSolverPackage_Factor(PC pc,const MatSolverPackage *stype) 216 { 217 PC_Factor *lu = (PC_Factor*)pc->data; 218 219 PetscFunctionBegin; 220 *stype = lu->solvertype; 221 PetscFunctionReturn(0); 222 } 223 EXTERN_C_END 224 225 EXTERN_C_BEGIN 226 #undef __FUNCT__ 227 #define __FUNCT__ "PCFactorSetPivoting_Factor" 228 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetPivoting_Factor(PC pc,PetscReal dtcol) 229 { 230 PC_Factor *dir = (PC_Factor*)pc->data; 231 232 PetscFunctionBegin; 233 if (dtcol < 0.0 || dtcol > 1.0) SETERRQ1(PETSC_ERR_ARG_OUTOFRANGE,"Column pivot tolerance is %G must be between 0 and 1",dtcol); 234 dir->info.dtcol = dtcol; 235 PetscFunctionReturn(0); 236 } 237 EXTERN_C_END 238