1//this file contains all the default settings 2 3//returns an object containing default pc_type, ksp_type, etc. enter an empty string for solver if working on the root solver 4//IMPORTANT: USE SOLVER == "" TO GENERATE DEFAULT OPTIONS FOR A GIVEN SET OF PROPERTIES 5function getDefaults(solver,symm,posdef,logstruc,child_symm,child_posdef,child_logstruc) { 6 7 var ret = new Object(); 8 9 if(solver == "") { //case 1: user did not override default solver. we simply return the default pc_type and ksp_type for the given options. this should really only be used on the root solver since other solvers have parents and should call this method on the parent instead to generate a better default option (in that case, we would take the sub_pc_type instead of just pc_type) 10 if(logstruc) { 11 ret.pc_type = "fieldsplit"; 12 } 13 if(symm) { 14 if(!logstruc) 15 ret.pc_type = "icc"; 16 17 if(!posdef) { //symm && !posdef 18 ret.ksp_type = "minres"; 19 } 20 else { //symm && posdef 21 ret.ksp_type = "cg"; 22 } 23 } 24 else { //!symm 25 if(!logstruc) 26 ret.pc_type = "bjacobi"; 27 ret.ksp_type = "gmres"; 28 } 29 } 30 31 //case 2: user did indeed override default solver. generate the default options for the solver they selected (for example, pc_mg_blocks for pc_type=mg) and also the default sub_pc_type and sub_ksp_type for that solver (if any) 32 33 else if(solver == "mg") { 34 ret = { 35 sub_pc_type: "sor", 36 sub_ksp_type: "chebyshev", 37 pc_mg_levels: 2, 38 pc_mg_type: "multiplicative" 39 }; 40 if(child_logstruc) 41 ret.sub_pc_type = "fieldsplit"; 42 } 43 44 else if(solver == "gamg") { 45 ret = { 46 sub_pc_type: "sor", 47 sub_ksp_type: "chebyshev", 48 pc_gamg_levels: 2, 49 pc_gamg_type: "multiplicative" 50 } 51 if(child_logstruc) 52 ret.sub_pc_type = "fieldsplit"; 53 } 54 55 else if(solver == "fieldsplit") { 56 ret = { 57 sub_pc_type: "sor", 58 sub_ksp_type: "chebyshev", 59 pc_fieldsplit_blocks: 2, 60 pc_fieldsplit_type: "multiplicative" 61 }; 62 if(child_logstruc) 63 ret.sub_pc_type = "fieldsplit"; 64 } 65 66 else if(solver == "bjacobi") { 67 ret = { 68 pc_bjacobi_blocks: 2, 69 sub_ksp_type: "preonly" 70 }; 71 if(symm) 72 ret.sub_pc_type = "icc"; 73 else 74 ret.sub_pc_type = "ilu"; 75 76 if(child_logstruc) 77 ret.sub_pc_type = "fieldsplit"; 78 } 79 80 else if(solver == "asm") { 81 ret = { 82 pc_asm_blocks: 2, 83 pc_asm_overlap: 2, 84 sub_ksp_type: "preonly" 85 }; 86 if(symm) 87 ret.sub_pc_type = "icc"; 88 else 89 ret.sub_pc_type = "ilu"; 90 91 if(child_logstruc) 92 ret.sub_pc_type = "fieldsplit"; 93 } 94 95 else if(solver == "redundant") { 96 ret = { 97 pc_redundant_number: 2, 98 sub_ksp_type: "preonly" 99 }; 100 if(symm) 101 ret.sub_pc_type = "cholesky"; 102 else 103 ret.sub_pc_type = "lu"; 104 105 if(child_logstruc) 106 ret.sub_pc_type = "fieldsplit"; 107 } 108 109 else if(solver == "ksp") { //note: this is for pc_type = ksp 110 ret = { 111 sub_pc_type: "bjacobi", 112 sub_ksp_type: "gmres" 113 }; 114 if(child_logstruc) 115 ret.sub_pc_type = "fieldsplit"; 116 } 117 118 return ret; 119} 120