Changeset 6014


Ignore:
Timestamp:
09/24/10 10:04:01 (14 years ago)
Author:
Eric.Larour
Message:

Commit de la mort qui tue: new way of running petsc,
where options are specified using a @petscoptions class,
which acts in a different way for each analysis_type, with
of course some defaults. This allows to change the petsc
solver on a per analysis basis.

Location:
issm/trunk
Files:
7 added
4 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h

    r5992 r6014  
    367367        VerboseEnum,
    368368        WaitOnLockEnum,
     369        PetscOptionsStringsEnum,
     370        PetscOptionsAnalysesEnum,
    369371        GsetEnum,
    370372        FsetEnum,
  • TabularUnified issm/trunk/src/c/EnumDefinitions/EnumToString.cpp

    r5992 r6014  
    329329                case VerboseEnum : return "Verbose";
    330330                case WaitOnLockEnum : return "WaitOnLock";
     331                case PetscOptionsStringsEnum : return "PetscOptionsStrings";
     332                case PetscOptionsAnalysesEnum : return "PetscOptionsAnalyses";
    331333                case GsetEnum : return "Gset";
    332334                case FsetEnum : return "Fset";
  • TabularUnified issm/trunk/src/c/EnumDefinitions/StringToEnum.cpp

    r5992 r6014  
    327327        else if (strcmp(name,"Verbose")==0) return VerboseEnum;
    328328        else if (strcmp(name,"WaitOnLock")==0) return WaitOnLockEnum;
     329        else if (strcmp(name,"PetscOptionsStrings")==0) return PetscOptionsStringsEnum;
     330        else if (strcmp(name,"PetscOptionsAnalyses")==0) return PetscOptionsAnalysesEnum;
    329331        else if (strcmp(name,"Gset")==0) return GsetEnum;
    330332        else if (strcmp(name,"Fset")==0) return FsetEnum;
  • TabularUnified issm/trunk/src/c/Makefile.am

    r5997 r6014  
    251251                                        ./shared/Numerics/extrema.cpp\
    252252                                        ./shared/Numerics/UnitConversion.cpp\
     253                                        ./shared/Numerics/PetscOptionsFromAnalysis.cpp\
    253254                                        ./shared/Exceptions/exceptions.h\
    254255                                        ./shared/Exceptions/Exceptions.cpp\
     
    736737                                        ./objects/Numerics/ElementVector.h\
    737738                                        ./objects/Numerics/ElementVector.cpp\
     739                                        ./shared/Numerics/PetscOptionsFromAnalysis.cpp\
    738740                                        ./objects/Params/Param.h\
    739741                                        ./objects/Params/BoolParam.cpp\
     
    890892                                        ./io/pfopen.cpp\
    891893                                        ./io/pfclose.cpp\
     894                                        ./io/ParsePetscOptions.cpp\
    892895                                        ./EnumDefinitions/EnumDefinitions.h\
    893896                                        ./EnumDefinitions/EnumDefinitions.cpp\
  • TabularUnified issm/trunk/src/c/io/io.h

    r5172 r6014  
    1111
    1212class DataSet;
     13class Parameters;
    1314
    1415FILE* pfopen(char* filename,char* format);
     
    7273void WriteDataToDisk(void* data,int* pM,int* pN,char* datatype,FILE* fid);
    7374
     75/*petsc options: */
     76void ParsePetscOptions(Parameters* parameters, char* filename);
     77
    7478#endif
    7579
  • TabularUnified issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r6005 r6014  
    2424        mxArray* pfield2=NULL;
    2525        #endif
     26        int dummy;
     27        int numpetscoptions;
     28
     29        /*petsc options: */
     30        double*  analyses=NULL;
     31        char**   petscstrings=NULL;
    2632
    2733        if(*pparameters)return; //do not create parameters twice!
     
    96102        }
    97103
    98        
    99         /*Free data: */
     104        /*Deal with petsc options: */
     105        #ifdef _SERIAL_
     106                pfield=mxGetField(iomodel_handle,0,"petscoptions_analyses");
     107                FetchData(&analyses,&numpetscoptions,pfield);
     108                pfield=mxGetField(iomodel_handle,0,"petscoptions_strings");
     109                petscstrings=(char**)xmalloc(numpetscoptions*sizeof(char*)); //allocate
     110                for (i=0;i<numpetscoptions;i++){
     111                        pfield2=mxGetCell(pfield,i);
     112                        FetchData(&descriptor,pfield2);
     113                        petscstrings[i]=descriptor;
     114                }
     115                parameters->AddObject(new StringArrayParam(PetscOptionsStringsEnum,petscstrings,numpetscoptions));
     116                parameters->AddObject(new DoubleVecParam(PetscOptionsAnalysesEnum,analyses,numpetscoptions));
     117        #endif
     118
     119        /*Free data: {{{1*/
    100120        xfree((void**)&tag);
    101121        for(i=0;i<iomodel->numoutput;i++){
     
    104124        }
    105125        xfree((void**)&parameteroutput);
     126
     127        #ifdef _SERIAL_
     128        xfree((void**)&analyses);
     129        for(i=0;i<numpetscoptions;i++){
     130                char* descriptor=petscstrings[i];
     131                xfree((void**)&descriptor);
     132        }
     133        xfree((void**)&petscstrings);
     134        #endif
     135        /*}}}*/
    106136
    107137        /*Before returning, create parameters in case we are running Qmu or control types runs: */
  • TabularUnified issm/trunk/src/c/modules/Solverx/Solverx.cpp

    r5979 r6014  
    1616
    1717        /*output: */
    18         Vec uf=NULL;
     18        Vec        uf               = NULL;
    1919
    2020        /*intermediary: */
    21         int local_m,local_n;
    22        
    23         /*Solver*/
    24         KSP ksp=NULL;
    25         PC  pc=NULL;
    26         int iteration_number;
     21        int        local_m;
     22        int        local_n;
     23        int        analysis_type;
     24
     25        /*Solver */
     26        KSP        ksp              = NULL;
     27        PC         pc               = NULL;
     28        int        iteration_number;
    2729        PetscTruth flag;
    28         int solver_type;
    29         char* petscrc=NULL;
    30         bool  fromlocalsize=true;
     30        int        solver_type;
     31        bool       fromlocalsize    = true;
    3132
    3233
     
    5051
    5152
    52         /*Process petscrc to see if we are not using special types of external solvers: */
    53         PetscOptionsDetermineSolverType(&solver_type,parameters);
    54        
    55         /*In serial mode, we don't have a petsc.rc file to boot the Petsc options. Do it now
    56          * using the petscrc string recover in the parameters: */
     53        /*Process petsc options to see if we are not using special types of external solvers: */
     54        PetscOptionsDetermineSolverType(&solver_type);
     55
     56        /*In serial mode, matrices have been loaded at MPIAIJ or AIJ matrices.
     57         We need to convert them if we are going to run the solvers successfully: */
    5758        #ifdef _SERIAL_
    58                
    59                 parameters->FindParam(&petscrc,PetscRcEnum);
    60                 PetscOptionsInsertMultipleString(petscrc);
    61 
    62                 /*In serial mode, matrices have been loaded at MPIAIJ or AIJ matrices.
    63                  * We need to convert them if we are going to run the solvers successfully: */
    64                 #if _PETSC_VERSION_ == 2
    65                         if (solver_type==MUMPSPACKAGE_LU){
    66                                 /*Convert Kff to MATTAIJMUMPS: */
    67                                 MatConvert(Kff,MATAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
    68                         }
    69                         if (solver_type==MUMPSPACKAGE_CHOL){
    70                                 /*Convert Kff to MATTSBAIJMUMPS: */
    71                                 MatConvert(Kff,MATSBAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
    72                         }
    73                         if (solver_type==SPOOLESPACKAGE_LU){
    74                                 /*Convert Kff to MATTSBAIJMUMPS: */
    75                                 MatConvert(Kff,MATAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
    76                         }
    77                         if (solver_type==SPOOLESPACKAGE_CHOL){
    78                                 /*Convert Kff to MATTSBAIJMUMPS: */
    79                                 MatConvert(Kff,MATSBAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
    80                         }
    81                         if (solver_type==SUPERLUDISTPACKAGE){
    82                                 /*Convert Kff to MATTSBAIJMUMPS: */
    83                                 MatConvert(Kff,MATSUPERLU_DIST,MAT_REUSE_MATRIX,&Kff);
    84                         }
    85                 #endif
     59        #if _PETSC_VERSION_ == 2
     60        if (solver_type==MUMPSPACKAGE_LU){
     61                /*Convert Kff to MATTAIJMUMPS: */
     62                MatConvert(Kff,MATAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
     63        }
     64        if (solver_type==MUMPSPACKAGE_CHOL){
     65                /*Convert Kff to MATTSBAIJMUMPS: */
     66                MatConvert(Kff,MATSBAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
     67        }
     68        if (solver_type==SPOOLESPACKAGE_LU){
     69                /*Convert Kff to MATTSBAIJMUMPS: */
     70                MatConvert(Kff,MATAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
     71        }
     72        if (solver_type==SPOOLESPACKAGE_CHOL){
     73                /*Convert Kff to MATTSBAIJMUMPS: */
     74                MatConvert(Kff,MATSBAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
     75        }
     76        if (solver_type==SUPERLUDISTPACKAGE){
     77                /*Convert Kff to MATTSBAIJMUMPS: */
     78                MatConvert(Kff,MATSUPERLU_DIST,MAT_REUSE_MATRIX,&Kff);
     79        }
     80        #endif
    8681        #endif
    8782
     
    9287
    9388        #ifdef _SERIAL_
    94                 #if _PETSC_VERSION_ == 3
    95                 /*specific solver?: */
    96                 KSPGetPC(ksp,&pc);
    97                 if (solver_type==MUMPSPACKAGE_LU){
    98                         PCFactorSetMatSolverPackage(pc,MAT_SOLVER_MUMPS);
    99                 }
    100                 #endif
     89        #if _PETSC_VERSION_ == 3
     90        /*specific solver?: */
     91        KSPGetPC(ksp,&pc);
     92        if (solver_type==MUMPSPACKAGE_LU){
     93                PCFactorSetMatSolverPackage(pc,MAT_SOLVER_MUMPS);
     94        }
     95        #endif
    10196        #endif
    10297
     
    119114        /*Free ressources:*/
    120115        KSPFree(&ksp);
    121         xfree((void**)&petscrc);
    122116       
    123117        /*Assign output pointers:*/
  • TabularUnified issm/trunk/src/c/objects/FemModel.cpp

    r5772 r6014  
    127127void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
    128128
     129        int verbose=0;
     130
     131        /*retrieve parameters: */
     132        this->parameters->FindParam(&verbose,VerboseEnum);
     133       
    129134        /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
    130135         * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
     
    156161        this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
    157162
     163        /*take care of petsc options, that depend on this analysis type: */
     164        PetscOptionsFromAnalysis(this->parameters,analysis_type);
     165
     166        verbose=1;
     167        if(verbose){
     168                _printf_("Petsc Options set for analysis type: %s\n",EnumToString(analysis_type));
     169                PetscOptionsPrint(stdout);
     170        }
     171
     172
    158173}
    159174/*}}}1*/
  • TabularUnified issm/trunk/src/c/objects/IoModel.cpp

    r6005 r6014  
    4848                xfree((void**)&this->gridonpattyn);
    4949        }
    50         xfree((void**)&this->numpetscoptions);
    5150        xfree((void**)&this->elementonbed);
    5251        xfree((void**)&this->elementonsurface);
     
    182181        IoModelFetchData(&this->connectivity,iomodel_handle,"connectivity");
    183182        IoModelFetchData(&this->lowmem,iomodel_handle,"lowmem");
    184         IoModelFetchData(&this->numpetscoptions,iomodel_handle,"numpetscoptions");
    185183        IoModelFetchData(&this->viscosity_overshoot,iomodel_handle,"viscosity_overshoot");
    186184        IoModelFetchData(&this->artdiff,iomodel_handle,"artificial_diffusivity");
     
    227225        this->control_analysis=0;
    228226        this->control_parameter=NULL;
    229         this->numpetscoptions=NULL;
    230227        this->numberofvariables=0;
    231228        this->numvariabledescriptors=0;
  • TabularUnified issm/trunk/src/c/objects/IoModel.h

    r6005 r6014  
    2222                int     qmu_analysis;
    2323                int     control_analysis;
    24                 char*   numpetscoptions;
    2524
    2625                /*2d mesh: */
  • TabularUnified issm/trunk/src/c/objects/Params/DoubleVecParam.h

    r5103 r6014  
    4141                ~DoubleVecParam();
    4242                /*}}}*/
    43                 /*              /*Object virtual functions definitions:{{{1 */
     43                /*Object virtual functions definitions:{{{1 */
    4444                void  Echo();
    4545                void  DeepEcho();
  • TabularUnified issm/trunk/src/c/shared/Matlab/ModuleBoot.cpp

    r3328 r6014  
    1818       
    1919        /*Declare my_ rank and num_procs global variables!: */
    20         //int argc=2;
    21         //char* argv[]={"ISSM","-malloc no",NULL};
    2220        my_rank=0;
    2321        num_procs=1;
     
    2523        /*Initialize Petsc: */
    2624        PetscInitializeNoArguments();
    27         //PetscInitialize(&argc,(char***)&argv,PETSC_NULL,PETSC_NULL);
    28        
     25
    2926        return 1;
    3027}
  • TabularUnified issm/trunk/src/c/shared/Numerics/numerics.h

    r5595 r6014  
    88#include "./GaussPoints.h"
    99#include "./isnan.h"
     10
    1011class Input;
    1112class Parameters;
     
    2425void UnitConversion(double* values, int numvalues,int direction_enum, int type_enum, Parameters* parameters);
    2526double UnitConversion(double value, int direction_enum, int type_enum, Parameters* parameters);
     27void PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type);
    2628
    2729#endif //ifndef _NUMERICS_H_
  • TabularUnified issm/trunk/src/c/solutions/issm.cpp

    r5974 r6014  
    1515        FILE     *output_fid       = NULL;
    1616        char     *inputfilename    = NULL;
     17        char     *petscoptionsfilename = NULL;
    1718        char     *outputfilename   = NULL;
    1819        char     *lockname         = NULL;
     
    4243
    4344        /*Initialize Petsc and get start time*/
    44         int ierr=PetscInitialize(&argc,&argv,argv[4],""); 
     45        int ierr=PetscInitialize(&argc,&argv,(char*)0,""); 
    4546        if(ierr) ISSMERROR("Could not initialize Petsc");
    4647        MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
     
    5354        solution_type=StringToEnum(argv[1]);
    5455        inputfilename=argv[3];
     56        petscoptionsfilename=argv[4];
    5557        outputfilename=argv[5];
    5658        lockname=argv[6];
     
    7274        /*add output_fid to parameters: */
    7375        femmodel->parameters->SetParam(output_fid,OutputFilePointerEnum);
    74        
     76
     77        /*add petsc options to parameters: */
     78        ParsePetscOptions(femmodel->parameters,petscoptionsfilename);
     79
    7580        /*get parameters: */
    7681        femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
  • TabularUnified issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp

    r5977 r6014  
    1 /*!\file PetscOptionsDetermineSolverType.cpp
    2  * \brief:      Petsc comes with a wide array of solvers, some of them considered external (externally linked libraries).
    3         To activate these solvers, Petsc uses the Options database, which is set at the command line prompt
    4         when launching a Petsc executable (option -mat_type EXTERNALMATRIXTYPE).
    5        
    6         We do not use this feature, because once the jpl-package server is launched, we cannot go back and modify
    7         the command line arguments. We rely therefore on the use of the options_string sent from the Solver_client
    8         module to the server Solver/ module. On the server side, we receive this options_string and plug it into the
    9         options database using the routine PetscOptionsInsertMultipleSTring. Once this is done, the KSP (Petsc solver)
    10         object registers these options and selects the correct solution method. 
    11 
    12         Now, for external solvers, this does not work, because the choice of external solver needs to be done when launching
    13         the Petsc executable ( this way, every matrix created conforms to the external package, and the solver then
    14         knows what to do directly by looking at the type of input matrix ). To circumvent this problem, we
    15         still use the options_string sent by the Solver_client, and we look for the -mat_type option. If we find
    16         a -mat_type option with an argument relating to an external solver, we then convert the solver matrix 
    17         to the external type, and the KSP object then knows what to do.
    18 
    19         This routine parses the options_string and returns the type of external solver being used as an enum. If there is no
    20         external solver used, we return a default enum.
    21 
    22         Note: figure out if first and second should be xfreed.
     1/*!\file PetscOptionsDetermineSolverType.cpp: from the petsc options, determine what kind of solver
     2 * we are using.
    233 */
    244
     
    3919#include "../../../include/include.h"
    4020
    41 void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters){
     21void PetscOptionsDetermineSolverType(int* psolver_type){
    4222
    43         /*The list of options is going to be pairs of the type "-option option_value"*/
    44         #if _PETSC_VERSION_ == 2
    45         PetscToken *token=NULL;
    46         #else
    47         PetscToken token=NULL;
    48         #endif
    49         char* first=NULL;
    50         char* second=NULL;
    51         char* options_string=NULL;
    52         size_t len;
    53         int ignore_second;
    54         int first_token=1;
    55         char parallel_option[100];
     23        char option[100];
    5624        PetscTruth flag;
    5725
     
    5927        int solver_type=PETSCPACKAGE;
    6028
    61         /*In serial, pick up the options string from parameters, and analyze it.
    62          * In parallel, options are command line driven, so retrieve the mat_type
    63          * option and conclude: */
     29        /*retrieve mat_type option: */
     30        PetscOptionsGetString(PETSC_NULL,"-mat_type",&option[0],100,&flag);
    6431
    65         #ifdef _SERIAL_
    66                 parameters->FindParam(&options_string,PetscRcEnum);
     32        if (strcmp(option,"aijmumps")==0){
     33                solver_type=MUMPSPACKAGE_LU;
     34        }
     35        if (strcmp(option,"sbaijmumps")==0){
     36                solver_type=MUMPSPACKAGE_CHOL;
     37        }
     38        if (strcmp(option,"aijspooles")==0){
     39                solver_type=SPOOLESPACKAGE_LU;
     40        }
     41        if (strcmp(option,"sbaijspooles")==0){
     42                solver_type=SPOOLESPACKAGE_CHOL;
     43        }
     44        if (strcmp(option,"superlu_dist")==0){
     45                solver_type=SUPERLUDISTPACKAGE;
     46        }
    6747
    68                 PetscTokenCreate(options_string,' ',&token);
    69                 for (;;){
    70 
    71                         /*Read next tokens*/
    72                         if(first_token){
    73                                 PetscTokenFind(token,&first);
    74                         }
    75                         PetscTokenFind(token,&second);
    76                        
    77                         if (!first){
    78                                 /*We are at the end of options*/
    79                                 break;
    80                         }
    81                         if(!second){
    82                                 /*We have no second value, end the token analysis.*/
    83                                 if(first[0]!='-'){
    84                                         /*This is not good, the option does not have '-'! Get out*/
    85                                         ISSMERROR("%s%s%s","Option ",first," should be preceded by '-'!");
    86                                 }
    87                                 break;
    88                         }
    89                         else{
    90                                 /*Ok, we have a second token coming in. Is it another option, or 'first' option's value?*/
    91                                 if (second[0]=='-'){
    92                                         /*Second is another option, ignore it and prepare next loop step*/
    93                                         first=second;
    94                                         first_token=0;
    95                                 }
    96                                 else{
    97                                         /*Second is 'first' option's value*/
    98                                         PetscStrlen(second,&len);
    99                                         while (len > 0 && (second[len-1] == ' ' || second[len-1] == 'n')) {
    100                                                 len--; second[len] = 0;
    101                                         }
    102                                         /*We now have a pair first and second. Check whether first is equal to -mat_type. If so, check
    103                                          * the second argument for the name of the external package desired.*/
    104                                         if (strcmp(first,"-mat_type")==0){
    105                                                 if (strcmp(second,"aijmumps")==0){
    106                                                         solver_type=MUMPSPACKAGE_LU;
    107                                                 }
    108                                                 if (strcmp(second,"sbaijmumps")==0){
    109                                                         solver_type=MUMPSPACKAGE_CHOL;
    110                                                 }
    111                                                 if (strcmp(second,"aijspooles")==0){
    112                                                         solver_type=SPOOLESPACKAGE_LU;
    113                                                 }
    114                                                 if (strcmp(second,"sbaijspooles")==0){
    115                                                         solver_type=SPOOLESPACKAGE_CHOL;
    116                                                 }
    117                                                 if (strcmp(second,"superlu_dist")==0){
    118                                                         solver_type=SUPERLUDISTPACKAGE;
    119                                                 }
    120                                         }
    121                                        
    122                                         first_token=1;
    123                                 }
    124                         }
    125                 }
    126                 PetscTokenDestroy(token);
    127         #else
    128 
    129                 /*retrieve mat_type option: */
    130                 PetscOptionsGetString(PETSC_NULL,"-mat_type",&parallel_option[0],100,&flag);
    131 
    132                 if (strcmp(parallel_option,"aijmumps")==0){
    133                         solver_type=MUMPSPACKAGE_LU;
    134                 }
    135                 if (strcmp(parallel_option,"sbaijmumps")==0){
    136                         solver_type=MUMPSPACKAGE_CHOL;
    137                 }
    138                 if (strcmp(parallel_option,"aijspooles")==0){
    139                         solver_type=SPOOLESPACKAGE_LU;
    140                 }
    141                 if (strcmp(parallel_option,"sbaijspooles")==0){
    142                         solver_type=SPOOLESPACKAGE_CHOL;
    143                 }
    144                 if (strcmp(parallel_option,"superlu_dist")==0){
    145                         solver_type=SUPERLUDISTPACKAGE;
    146                 }
    147         #endif
    148 
    149         /*Clean-up and assign output*/
    150         xfree((void**)&options_string);
    15148        *psolver_type=solver_type;
    15249}
  • TabularUnified issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h

    r5975 r6014  
    99#include "petscvec.h"
    1010#include "petscksp.h"
     11#include "petscsys.h"
     12
    1113class Parameters;
    1214
     
    4042void MatInvert(Mat* pInv, Mat Matrix);
    4143void PetscOptionsInsertMultipleString(char* options_string);
    42 void PetscOptionsDetermineSolverType(int* psolver_type,Parameters* parameters);
     44void PetscOptionsDetermineSolverType(int* psolver_type);
    4345void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size);
    4446void MatMultPatch(Mat A,Vec X, Vec AX);
  • TabularUnified issm/trunk/src/c/toolkits/petsc/petscincludes.h

    r1 r6014  
    1010#include "petscvec.h"
    1111#include "petscksp.h"
     12#include "petscsys.h"
    1213
    1314/*our own patches: */
  • TabularUnified issm/trunk/src/m/classes/@model/model.m

    r6005 r6014  
    266266        %PETSc and MATLAB solver string
    267267        md.petscoptions=NaN;
    268         md.numpetscoptions=1;
     268        md.petscoptions_analyses=[];
     269        md.petscoptions_strings={};
    269270
    270271        %Analysis and sub_analysis
  • TabularUnified issm/trunk/src/m/classes/@model/setdefaultparameters.m

    r6005 r6014  
    239239md.petscoptions=addoptions(md.petscoptions,DiagnosticHorizAnalysisEnum,asmoptions);
    240240md.petscoptions=addoptions(md.petscoptions,DiagnosticVertAnalysisEnum,mumpsoptions);
    241 md.numpetscoptions=3; %don't forget the default analysis!
    242241
    243242%solution speed-up
  • TabularUnified issm/trunk/src/m/classes/petscoptions.m

    r6005 r6014  
    99                 options={NoneAnalysisEnum,asmoptions};
    1010                 %used when marshalling
    11                  analyses=[];
    12                  strings={};
    1311                 %}}}
    1412         end
     
    2119                                 analysis=o.options{i,1};
    2220                                 ioptions=o.options{i,2};
    23                                  string=PetscOptions2PetscRc(ioptions);
     21                                 string=petscoptiontostring(ioptions);
    2422                                 disp(sprintf('   %s -> ''%s''',EnumToString(analysis),string));
    2523                         end
     
    4543                 end
    4644                 %}}}
    47                  function o=marshall(o)%{{{1
     45                 function [analyses strings]=marshall(o)%{{{1
    4846                         %marshall options into analyses and strings
    49                          o.analyses=zeros(size(o.options,1),1);
    50                          o.strings=cell(size(o.options,1),1);
     47                         analyses=zeros(size(o.options,1),1);
     48                         strings=cell(size(o.options,1),1);
    5149                         for i=1:size(o.options,1),
    52                                  o.analyses(i)=o.options{i,1};
    53                                  o.strings{i}=petscoptiontostring(o.options{i,2});
     50                                 analyses(i)=o.options{i,1};
     51                                 strings{i}=petscoptiontostring(o.options{i,2});
    5452                         end
    5553                 end
  • TabularUnified issm/trunk/src/m/enum/EnumToString.m

    r5993 r6014  
    324324case VerboseEnum(), string='Verbose'; return
    325325case WaitOnLockEnum(), string='WaitOnLock'; return
     326case PetscOptionsStringsEnum(), string='PetscOptionsStrings'; return
     327case PetscOptionsAnalysesEnum(), string='PetscOptionsAnalyses'; return
    326328case GsetEnum(), string='Gset'; return
    327329case FsetEnum(), string='Fset'; return
  • TabularUnified issm/trunk/src/m/enum/FsetEnum.m

    r5993 r6014  
    99%      macro=FsetEnum()
    1010
    11 macro=314;
     11macro=316;
  • TabularUnified issm/trunk/src/m/enum/GsetEnum.m

    r5993 r6014  
    99%      macro=GsetEnum()
    1010
    11 macro=313;
     11macro=315;
  • TabularUnified issm/trunk/src/m/enum/SsetEnum.m

    r5993 r6014  
    99%      macro=SsetEnum()
    1010
    11 macro=315;
     11macro=317;
  • TabularUnified issm/trunk/src/m/enum/StringToEnum.m

    r5993 r6014  
    322322                        elseif (strcmpi(name,'Verbose')), enum=VerboseEnum(); return
    323323                        elseif (strcmpi(name,'WaitOnLock')), enum=WaitOnLockEnum(); return
     324                        elseif (strcmpi(name,'PetscOptionsStrings')), enum=PetscOptionsStringsEnum(); return
     325                        elseif (strcmpi(name,'PetscOptionsAnalyses')), enum=PetscOptionsAnalysesEnum(); return
    324326                        elseif (strcmpi(name,'Gset')), enum=GsetEnum(); return
    325327                        elseif (strcmpi(name,'Fset')), enum=FsetEnum(); return
  • TabularUnified issm/trunk/src/m/enum/YtsEnum.m

    r5993 r6014  
    99%      macro=YtsEnum()
    1010
    11 macro=316;
     11macro=318;
  • TabularUnified issm/trunk/src/m/model/marshall.m

    r6005 r6014  
    134134WriteData(fid,md.lowmem,'Integer','lowmem');
    135135WriteData(fid,md.optscal,'Mat','optscal');
    136 WriteData(fid,md.petscrc,'String','petscrc');
    137136WriteData(fid,md.viscosity_overshoot,'Scalar','viscosity_overshoot');
    138137WriteData(fid,md.stokesreconditioning,'Scalar','stokesreconditioning');
     
    180179WriteData(fid,md.outputfilename,'String','outputfilename');
    181180
    182 %petsc options:
    183 WriteData(fid,md.numpetscoptions,'Integer','numpetscoptions');
    184 WriteData(fid,md.petscoptions.analyses,'Mat','petscoptionsanalyses');
    185 for i=1:md.numpetscoptions,
    186         WriteData(fid,md.petscoptions.strings{i},'String',['petscoptionsstrings_' num2str(i-1)]);
    187 end
    188 
    189181%close file
    190182st=fclose(fid);
  • TabularUnified issm/trunk/src/m/model/presolve.m

    r6005 r6014  
    3434end
    3535
    36 %package together petscoptions:
    37 md.petscoptions=marshall(md.petscoptions);
    38 md.numpetscoptions=size(md.petscoptions.analyses,1);
     36%package together petscoptions for serial runs
     37[md.petscoptions_analyses md.petscoptions_strings]=marshall(md.petscoptions);
     38
     39%write a template file for issm to use, in parallel
     40if ~strcmpi(md.cluster.name,'none'),
     41        PetscOptions2PetscFile(md.petscoptions,[md.name '.petsc']);
     42end
  • TabularUnified issm/trunk/src/mex/Solver/Solver.cpp

    r5903 r6014  
    1212        Vec         uf0           = NULL;
    1313        Vec         uf            = NULL;
    14         char       *petscrc = NULL;
    1514        Parameters *parameters    = NULL;
    1615        int         verbose;
    17                
     16        int         analysis_type;
     17        char        option[100];
     18        PetscTruth  flag;
     19       
    1820        /*Matlab solver: */
    1921        mxArray* array[2];
     
    2426        /*checks on arguments on the matlab side: */
    2527        CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&SolverUsage);
     28       
     29        /*parameters: */
     30        FetchParams(&parameters,PARAMETERS);
     31        parameters->FindParam(&verbose,VerboseEnum);
    2632
    27         /*First, check solver string: */
    28         FetchParams(&parameters,PARAMETERS);
    29         parameters->FindParam(&petscrc,PetscRcEnum);
    30         int verbose; parameters->FindParam(&verbose,VerboseEnum);
     33        /*In serial mode, we have no set any petsc options, do it now: */
     34        #ifdef _SERIAL_
     35        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     36        PetscOptionsFromAnalysis(parameters,analysis_type);
     37        #endif
    3138       
     39        /*Retrieve solver type: */
     40        PetscOptionsGetString(PETSC_NULL,"-ksp_type",&option[0],100,&flag);
     41
    3242        /*Fetch rest of data only if not running the matlab solver: */
    33         if (strcmp(petscrc,matlabstring)!=0){
     43        if (strcmp(option,"matlab")!=0){
     44       
    3445                /*Input datasets: */
    3546                FetchData(&Kff,KFF);
    3647                FetchData(&pf,PF);
    3748                FetchData(&uf0,UF0);
    38                 /*Petsc solver: */
     49
     50                /*Core module: */
    3951                Solverx(&uf, Kff, pf, uf0, parameters);
     52
    4053                /*Write output*/
    4154                WriteData(UF,uf);
     
    5568        VecFree(&uf);
    5669        delete parameters;
    57         xfree((void**)&petscrc);
    5870
    5971        MODULEEND();
     72
    6073}
    6174
  • TabularUnified issm/trunk/src/mex/SystemMatrices/SystemMatrices.h

    r6005 r6014  
    3636#define PF   (mxArray**)&plhs[4]
    3737#define KMAX (mxArray**)&plhs[5]
    38 #define KMAX (mxArray**)&plhs[2]
    3938
    4039/* serial arg counts: */
  • TabularUnified issm/trunk/test/NightlyRun/test101.m

    r5955 r6014  
    44md=setelementstype(md,'macayeal','all');
    55md.cluster=none;
     6md.verbose=1;
    67md=solve(md,'analysis_type',DiagnosticSolutionEnum);
    78
  • TabularUnified issm/trunk/test/NightlyRun/test102.m

    r5976 r6014  
    1 md=mesh(model,'../Exp/Square.exp',150000);
     1md=mesh(model,'../Exp/Square.exp',100000);
    22md=geography(md,'all','');
    33md=parameterize(md,'../Par/SquareShelfConstrained.par');
    44md=setelementstype(md,'macayeal','all');
    55md=SetParallel(md,3);
     6md=extrude(md,3,1);
     7md.verbose=1;
     8
     9pos=find(md.x<600000 & md.x>400000 & md.y<600000 & md.y>400000);
     10npos=length(pos);
     11md.spcvelocity(pos,1:6)=[1*ones(npos,1) 1*ones(npos,1) 0*ones(npos,1) 0*ones(npos,1) 0*ones(npos,1) 0*ones(npos,1) ];
     12md.cluster.np=2;
    613md=solve(md,'analysis_type',DiagnosticSolutionEnum);
     14md=tres(md,'diagnostic');
    715
    816%Fields and tolerances to track changes
Note: See TracChangeset for help on using the changeset viewer.