| [6014] | 1 | /*!\file: PetscOptionsFromAnalysis.cpp
|
|---|
| 2 | * \brief: change petsc options using analysis type and parameters
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifdef HAVE_CONFIG_H
|
|---|
| 6 | #include "config.h"
|
|---|
| 7 | #else
|
|---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
|---|
| 9 | #endif
|
|---|
| 10 |
|
|---|
| 11 | #include "../../objects/objects.h"
|
|---|
| 12 | #include "../../Container/Parameters.h"
|
|---|
| 13 | #include "../../toolkits/toolkits.h"
|
|---|
| 14 |
|
|---|
| 15 | void PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type){
|
|---|
| 16 |
|
|---|
| 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;
|
|---|
| 24 |
|
|---|
| 25 | numanalyses=0;
|
|---|
| 26 | parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum);
|
|---|
| 27 | parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
|
|---|
| 28 |
|
|---|
| 29 | if(numanalyses==0)return; //we did not find petsc options, don't bother.
|
|---|
| 30 |
|
|---|
| 31 | /*ok, go through analyses and figure out if it corresponds to our analysis_type: */
|
|---|
| 32 | found=-1;
|
|---|
| 33 | for(i=0;i<numanalyses;i++){
|
|---|
| 34 | if (analyses[i]==analysis_type){
|
|---|
| 35 | /*found the analysis, get out of here: */
|
|---|
| 36 | found=i;
|
|---|
| 37 | break;
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | if(found==-1){
|
|---|
| 41 | /*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */
|
|---|
| 42 | for(i=0;i<numanalyses;i++){
|
|---|
| 43 | if (analyses[i]==NoneAnalysisEnum){
|
|---|
| 44 | /*found the default analysis, get out of here: */
|
|---|
| 45 | found=i;
|
|---|
| 46 | break;
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 | if (found==-1){
|
|---|
| 51 | /*ok, we did not find anything, this is not good! error out: */
|
|---|
| 52 | ISSMERROR("%s%s","could find neither a default analysis nor analysis ",EnumToString(analysis_type));
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | /*ok, grab the petsc option string: */
|
|---|
| 56 | string=strings[found];
|
|---|
| 57 |
|
|---|
| 58 | /*now, reset the options database with this string. Taken from petsc/install/src/sys/objects/pinit.c. This
|
|---|
| 59 | *capability is not covered by Petsc!: */
|
|---|
| 60 | PetscOptionsDestroy();
|
|---|
| 61 | PetscOptionsCreate();
|
|---|
| 62 | //PetscOptionsCheckInitial_Private();
|
|---|
| 63 | //PetscOptionsCheckInitial_Components();
|
|---|
| 64 | PetscOptionsSetFromOptions();
|
|---|
| 65 | PetscOptionsInsertMultipleString(string); //our patch
|
|---|
| 66 |
|
|---|
| 67 | /*Free ressources:{{{1*/
|
|---|
| 68 | xfree((void**)&analyses);
|
|---|
| 69 | for(i=0;i<numanalyses;i++){
|
|---|
| 70 | string=strings[i];
|
|---|
| 71 | xfree((void**)&string);
|
|---|
| 72 | }
|
|---|
| 73 | xfree((void**)&strings);
|
|---|
| 74 | /*}}}*/
|
|---|
| 75 |
|
|---|
| 76 | }
|
|---|