Ignore:
Timestamp:
03/13/12 19:59:59 (13 years ago)
Author:
Eric.Larour
Message:

Completed separation of Petsc from ISSM. Matrix and Vector
are now the vehicles for Mat and Vec objects when running with
Petsc, or double* when running with a custom made type of matrix (still
to be finished).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp

    r9826 r11695  
    1515void PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type){
    1616
    17         int     dummy;
    18         double* analyses=NULL;
    19         char**  strings=NULL;
    20         int     numanalyses;
    21         char*   string=NULL;
    22         int     found=-1;
    23         int     i;
     17        /*intermediary: */
     18        char* options=NULL;
    2419
    25         numanalyses=0;
    26         parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum);
    27 
    28         #ifdef _SERIAL_ //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param  when running with only 1 analysis
    29         if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum);
    30         }
    31         else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
    32         #else
    33         parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
    34         #endif
    35 
    36         if(numanalyses==0)return; //we did not find petsc options, don't bother.
    37 
    38         /*ok, go through analyses and figure out if it corresponds to our analysis_type: */
    39         found=-1;
    40         for(i=0;i<numanalyses;i++){
    41                 if (analyses[i]==analysis_type){
    42                         /*found the analysis, get out of here: */
    43                         found=i;
    44                         break;
    45                 }
    46         }
    47         if(found==-1){
    48                 /*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */
    49                 for(i=0;i<numanalyses;i++){
    50                         if (analyses[i]==NoneAnalysisEnum){
    51                                 /*found the default analysis, get out of here: */
    52                                 found=i;
    53                                 break;
    54                         }
    55                 }
    56         }
    57         if (found==-1){
    58                 /*ok, we did not find anything, this is not good! error out: */
    59                 _error_("%s%s","could find neither a default analysis  nor analysis ",EnumToStringx(analysis_type));
    60         }
    61 
    62         /*ok, grab the petsc option string: */
    63         string=strings[found];
     20        /*Recover first the options string for this analysis: */
     21        options=OptionsFromAnalysis(parameters,analysis_type);
    6422
    6523        /*now, reset the options database with this string. Taken from petsc/install/src/sys/objects/pinit.c. This
     
    7230        //PetscOptionsCheckInitial_Components();
    7331        PetscOptionsSetFromOptions();
    74         PetscOptionsInsertMultipleString(string); //our patch
     32        PetscOptionsInsertMultipleString(options); //our patch
    7533        #else
    7634        PetscOptionsSetFromOptions();
    7735        PetscOptionsClear();
    7836        //PetscOptionsSetFromOptions();
    79         PetscOptionsInsertMultipleString(string); //our patch
     37        PetscOptionsInsertMultipleString(options); //our patch
    8038        #endif
    8139
    82 
    83         /*Free ressources*/
    84         xfree((void**)&analyses);
    85         for(i=0;i<numanalyses;i++){
    86                 string=strings[i];
    87                 xfree((void**)&string);
    88         }
    89         xfree((void**)&strings);
    90 
     40        /*Free ressources:*/
     41        xfree((void**)&options);
    9142}
Note: See TracChangeset for help on using the changeset viewer.