Changeset 5975


Ignore:
Timestamp:
09/22/10 21:02:59 (14 years ago)
Author:
Eric.Larour
Message:

Fixed bug that was preventing name.petsc to be considered in the solver -> it was getting clobbered by the initial
solver_string!
Also started some ecco3 routines.

Location:
issm/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/Solverx/Solverx.cpp

    r5903 r5975  
    5151
    5252        /*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);
    5554       
    5655        /*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  
    3939#include "../../../include/include.h"
    4040
    41 void PetscOptionsDetermineSolverType(int* psolver_type,char* options_string){
     41void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters){
    4242
     43       
     44       
    4345
    4446        /*The list of options is going to be pairs of the type "-option option_value"*/
     
    5355        int ignore_second;
    5456        int first_token=1;
     57        char parallel_option[100];
     58        PetscTruth flag;
    5559
    5660        /*output: */
    5761        int solver_type=PETSCPACKAGE;
    5862
     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: */
    5966
    60         PetscTokenCreate(options_string,' ',&token);
    61         for (;;){
    62                
     67        #ifdef _SERIAL_
     68                parameters->FindParam(&options_string,PetscRcEnum);
    6369
    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);
    7978                        }
    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;
    8892                        }
    8993                        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;
    9499                                }
    95                                 /*We now have a pair first and second. Check whether first is equal to -mat_type. If so, check
    96                                  * 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;
    100105                                        }
    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                                                }
    103124                                        }
    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;
    113127                                }
    114                                
    115                                 first_token=1;
    116128                        }
    117129                }
    118         }
     130                PetscTokenDestroy(token);
     131        #else
    119132
    120         PetscTokenDestroy(token);
     133                /*retrieve mat_type option: */
     134                PetscOptionsGetString(PETSC_NULL,"-mat_type",&parallel_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
    121154
    122155        /*Assign output: */
  • issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h

    r5895 r5975  
    99#include "petscvec.h"
    1010#include "petscksp.h"
     11class Parameters;
    1112
    1213
     
    3940void MatInvert(Mat* pInv, Mat Matrix);
    4041void PetscOptionsInsertMultipleString(char* options_string);
    41 void PetscOptionsDetermineSolverType(int* psolver_type,char* options_string);
     42void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters);
    4243void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size);
    4344void MatMultPatch(Mat A,Vec X, Vec AX);
  • issm/trunk/test/NightlyRun/test102.m

    r5964 r5975  
    44md=setelementstype(md,'macayeal','all');
    55md=SetParallel(md,3);
     6md=solversettomumps(md);
    67md=solve(md,'analysis_type',DiagnosticSolutionEnum);
    78
Note: See TracChangeset for help on using the changeset viewer.