Changeset 5975
- Timestamp:
- 09/22/10 21:02:59 (14 years ago)
- Location:
- issm/trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/Solverx/Solverx.cpp
r5903 r5975 51 51 52 52 /*Process petscrc to see if we are not using special types of external solvers: */ 53 parameters->FindParam(&petscrc,PetscRcEnum); 54 PetscOptionsDetermineSolverType(&solver_type,petscrc); 53 PetscOptionsDetermineSolverType(&solver_type,parameters); 55 54 56 55 /*In serial mode, we don't have a petsc.rc file to boot the Petsc options. Do it now -
issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
r3775 r5975 39 39 #include "../../../include/include.h" 40 40 41 void PetscOptionsDetermineSolverType(int* psolver_type, char* options_string){41 void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters){ 42 42 43 44 43 45 44 46 /*The list of options is going to be pairs of the type "-option option_value"*/ … … 53 55 int ignore_second; 54 56 int first_token=1; 57 char parallel_option[100]; 58 PetscTruth flag; 55 59 56 60 /*output: */ 57 61 int solver_type=PETSCPACKAGE; 58 62 63 /*In serial, pick up the options string from parameters, and analyze it. 64 * In parallel, options are command line driven, so retrieve the mat_type 65 * option and conclude: */ 59 66 60 PetscTokenCreate(options_string,' ',&token); 61 for (;;){ 62 67 #ifdef _SERIAL_ 68 parameters->FindParam(&options_string,PetscRcEnum); 63 69 64 /*Read next tokens*/ 65 if(first_token){ 66 PetscTokenFind(token,&first); 67 } 68 PetscTokenFind(token,&second); 69 70 if (!first){ 71 /*We are at the end of options*/ 72 break; 73 } 74 if(!second){ 75 /*We have no second value, end the token analysis.*/ 76 if(first[0]!='-'){ 77 /*This is not good, the option does not have '-'! Get out*/ 78 ISSMERROR("%s%s%s","Option ",first," should be preceded by '-'!"); 70 71 PetscTokenCreate(options_string,' ',&token); 72 for (;;){ 73 74 75 /*Read next tokens*/ 76 if(first_token){ 77 PetscTokenFind(token,&first); 79 78 } 80 break; 81 } 82 else{ 83 /*Ok, we have a second token coming in. Is it another option, or 'first' option's value?*/ 84 if (second[0]=='-'){ 85 /*Second is another option, ignore it and prepare next loop step*/ 86 first=second; 87 first_token=0; 79 PetscTokenFind(token,&second); 80 81 if (!first){ 82 /*We are at the end of options*/ 83 break; 84 } 85 if(!second){ 86 /*We have no second value, end the token analysis.*/ 87 if(first[0]!='-'){ 88 /*This is not good, the option does not have '-'! Get out*/ 89 ISSMERROR("%s%s%s","Option ",first," should be preceded by '-'!"); 90 } 91 break; 88 92 } 89 93 else{ 90 /*Second is 'first' option's value*/ 91 PetscStrlen(second,&len); 92 while (len > 0 && (second[len-1] == ' ' || second[len-1] == 'n')) { 93 len--; second[len] = 0; 94 /*Ok, we have a second token coming in. Is it another option, or 'first' option's value?*/ 95 if (second[0]=='-'){ 96 /*Second is another option, ignore it and prepare next loop step*/ 97 first=second; 98 first_token=0; 94 99 } 95 /*We now have a pair first and second. Check whether first is equal to -mat_type. If so, check96 * the second argument for the name of the external package desired.*/97 if (strcmp(first,"-mat_type")==0){98 if (strcmp(second,"aijmumps")==0){99 solver_type=MUMPSPACKAGE_LU;100 else{ 101 /*Second is 'first' option's value*/ 102 PetscStrlen(second,&len); 103 while (len > 0 && (second[len-1] == ' ' || second[len-1] == 'n')) { 104 len--; second[len] = 0; 100 105 } 101 if (strcmp(second,"sbaijmumps")==0){ 102 solver_type=MUMPSPACKAGE_CHOL; 106 /*We now have a pair first and second. Check whether first is equal to -mat_type. If so, check 107 * the second argument for the name of the external package desired.*/ 108 if (strcmp(first,"-mat_type")==0){ 109 if (strcmp(second,"aijmumps")==0){ 110 solver_type=MUMPSPACKAGE_LU; 111 } 112 if (strcmp(second,"sbaijmumps")==0){ 113 solver_type=MUMPSPACKAGE_CHOL; 114 } 115 if (strcmp(second,"aijspooles")==0){ 116 solver_type=SPOOLESPACKAGE_LU; 117 } 118 if (strcmp(second,"sbaijspooles")==0){ 119 solver_type=SPOOLESPACKAGE_CHOL; 120 } 121 if (strcmp(second,"superlu_dist")==0){ 122 solver_type=SUPERLUDISTPACKAGE; 123 } 103 124 } 104 if (strcmp(second,"aijspooles")==0){ 105 solver_type=SPOOLESPACKAGE_LU; 106 } 107 if (strcmp(second,"sbaijspooles")==0){ 108 solver_type=SPOOLESPACKAGE_CHOL; 109 } 110 if (strcmp(second,"superlu_dist")==0){ 111 solver_type=SUPERLUDISTPACKAGE; 112 } 125 126 first_token=1; 113 127 } 114 115 first_token=1;116 128 } 117 129 } 118 } 130 PetscTokenDestroy(token); 131 #else 119 132 120 PetscTokenDestroy(token); 133 /*retrieve mat_type option: */ 134 PetscOptionsGetString(PETSC_NULL,"-mat_type",¶llel_option[0],100,&flag); 135 136 if (strcmp(parallel_option,"aijmumps")==0){ 137 solver_type=MUMPSPACKAGE_LU; 138 } 139 if (strcmp(parallel_option,"sbaijmumps")==0){ 140 solver_type=MUMPSPACKAGE_CHOL; 141 } 142 if (strcmp(parallel_option,"aijspooles")==0){ 143 solver_type=SPOOLESPACKAGE_LU; 144 } 145 if (strcmp(parallel_option,"sbaijspooles")==0){ 146 solver_type=SPOOLESPACKAGE_CHOL; 147 } 148 if (strcmp(parallel_option,"superlu_dist")==0){ 149 solver_type=SUPERLUDISTPACKAGE; 150 } 151 #endif 152 153 121 154 122 155 /*Assign output: */ -
issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
r5895 r5975 9 9 #include "petscvec.h" 10 10 #include "petscksp.h" 11 class Parameters; 11 12 12 13 … … 39 40 void MatInvert(Mat* pInv, Mat Matrix); 40 41 void PetscOptionsInsertMultipleString(char* options_string); 41 void PetscOptionsDetermineSolverType(int* psolver_type, char* options_string);42 void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters); 42 43 void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size); 43 44 void MatMultPatch(Mat A,Vec X, Vec AX); -
issm/trunk/test/NightlyRun/test102.m
r5964 r5975 4 4 md=setelementstype(md,'macayeal','all'); 5 5 md=SetParallel(md,3); 6 md=solversettomumps(md); 6 7 md=solve(md,'analysis_type',DiagnosticSolutionEnum); 7 8
Note:
See TracChangeset
for help on using the changeset viewer.