Changeset 13461


Ignore:
Timestamp:
09/27/12 09:26:29 (13 years ago)
Author:
Eric.Larour
Message:

CHG: AutodiffDriversx now driven by the type of driver string supplied in autodiff.m
In addition, for fov_forward driver, we can now supply at the Matlab level (autodiff.m)
a list of indices on which we want the forward vector driver to be applied.

Location:
issm/trunk-jpl
Files:
1 added
10 edited

Legend:

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

    r13438 r13461  
    2727        AutodiffDriverEnum,
    2828        AutodiffFosForwardIndexEnum,
     29        AutodiffFovForwardIndicesEnum,
    2930        BalancethicknessSpcthicknessEnum,
    3031        BalancethicknessStabilizationEnum,
  • issm/trunk-jpl/src/c/modules/AutodiffDriversx/AutodiffDriversx.cpp

    r13458 r13461  
    1414
    1515
     16        /*diverse: */
    1617        int         i;
    1718        int         dummy;
     19
    1820        bool        isautodiff         = false;
    1921        int         num_dependents;
    2022        int         num_independents;
     23        char*       driver=NULL;
     24
     25        /*state variables: */
    2126        IssmDouble *axp                = NULL;
    2227        double     *xp                 = NULL;
    23         int         anIndepIndex;
    24         unsigned int * indepIndices    = NULL;
    25         int         tangentDirNum = 2;  // <----------- set this via config
    26 
    27        
     28
    2829        /*AD mode on?: */
    2930        parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);
     
    3334                #ifdef _HAVE_ADOLC_
    3435
     36                        if(VerboseAutodiff())_pprintLine_("   start AD driver");
     37
     38                        /*preliminary checks: */
    3539                        parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum);
    3640                        parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum);
    37 
    3841                        if(!(num_dependents*num_independents)) return;
    39 
    40                         if (tangentDirNum<1 || tangentDirNum>num_independents) {
    41                           _error_("tangentDirNum should be in [1,num_independents]"); // <------------ fix this error message to relate to config
    42                         }
    43 
     42                       
    4443                        /*retrieve state variable: */
    4544                        parameters->FindParam(&axp,&dummy,AutodiffXpEnum);
     
    5453                        ext_diff_fct *anEDF_for_solverx_p=dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p;
    5554
    56                         /*set the forward method function pointers: */
    57                         anEDF_for_solverx_p->zos_forward=EDF_for_solverx;
    58                         anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx;
    59                         anEDF_for_solverx_p->fov_forward=EDF_fov_forward_for_solverx;
    60                         anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx;
    61                         // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx;
     55                        /*Branch according to AD driver: */
     56                        parameters->FindParam(&driver,AutodiffDriverEnum);
     57
     58                        if (strcmp(driver,"fos_forward")==0){
     59                               
     60                                int     anIndepIndex;
     61                                double *tangentDir=NULL;
     62                                double *jacTimesTangentDir=NULL;
     63                                double *theOutput=NULL;
     64                               
     65                                /*retrieve direction index: */
     66                                parameters->FindParam(&anIndepIndex,AutodiffFosForwardIndexEnum);
     67                               
     68                                tangentDir=xNewZeroInit<double>(num_independents);
     69                                tangentDir[anIndepIndex]=1.0;
    6270                       
    63                         /*allocate the space for the parameters to invoke the forward methods:*/
    64                         anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n);
    65                         anEDF_for_solverx_p->dp_X=xNew<double>(anEDF_for_solverx_p->max_n);
    66                         anEDF_for_solverx_p->dpp_X=xNew<double>(anEDF_for_solverx_p->max_n, tangentDirNum);
    67                         anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m);
    68                         anEDF_for_solverx_p->dp_Y=xNew<double>(anEDF_for_solverx_p->max_m);
    69                         anEDF_for_solverx_p->dpp_Y=xNew<double>(anEDF_for_solverx_p->max_m, tangentDirNum);
    70                         /*allocate the space for the parameters to invoke the reverse methods:*/
    71                         anEDF_for_solverx_p->dp_U=xNew<double>(anEDF_for_solverx_p->max_m);
    72                         anEDF_for_solverx_p->dpp_U=xNew<double>(num_dependents,anEDF_for_solverx_p->max_m);
    73                         anEDF_for_solverx_p->dp_Z=xNew<double>(anEDF_for_solverx_p->max_n);
    74                         anEDF_for_solverx_p->dpp_Z=xNew<double>(num_dependents,anEDF_for_solverx_p->max_n);
    75 
    76                         /* Call AD driver:*/
    77                         if (tangentDirNum==1) {
    78                           // single direction:
    79                           double *tangentDir=xNewZeroInit<double>(num_independents);
    80                           parameters->FindParam(&anIndepIndex,AutodiffFosForwardIndexEnum);
    81                           tangentDir[anIndepIndex]=1.0;
    82                           double *jacTimesTangentDir=xNew<double>(num_dependents);
    83                           double *theOutput=xNew<double>(num_dependents);
    84                           if (fos_forward(1,num_dependents,num_independents, 0, xp, tangentDir, theOutput, jacTimesTangentDir ))
    85                             _error_("fos_forward returned non-zero error code");
    86                           results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,jacTimesTangentDir,num_dependents,1,1,0.0));
    87                           xDelete(theOutput);
    88                           xDelete(jacTimesTangentDir);
    89                           xDelete(tangentDir);
     71                                jacTimesTangentDir=xNew<double>(num_dependents);
     72                                theOutput=xNew<double>(num_dependents);
     73                               
     74                                /*set the forward method function pointers: */
     75                                anEDF_for_solverx_p->zos_forward=EDF_for_solverx;
     76                                anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx;
     77                                anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx;
     78
     79                                /*allocate the space for the parameters to invoke the forward methods:*/
     80                                anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n);
     81                                anEDF_for_solverx_p->dp_X=xNew<double>(anEDF_for_solverx_p->max_n);
     82                                anEDF_for_solverx_p->dpp_X=xNew<double>(anEDF_for_solverx_p->max_n, 1);
     83                                anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m);
     84                                anEDF_for_solverx_p->dp_Y=xNew<double>(anEDF_for_solverx_p->max_m);
     85                                anEDF_for_solverx_p->dpp_Y=xNew<double>(anEDF_for_solverx_p->max_m, 1);
     86
     87                                /*allocate the space for the parameters to invoke the reverse methods:*/
     88                                anEDF_for_solverx_p->dp_U=xNew<double>(anEDF_for_solverx_p->max_m);
     89                                anEDF_for_solverx_p->dpp_U=xNew<double>(num_dependents,anEDF_for_solverx_p->max_m);
     90                                anEDF_for_solverx_p->dp_Z=xNew<double>(anEDF_for_solverx_p->max_n);
     91                                anEDF_for_solverx_p->dpp_Z=xNew<double>(num_dependents,anEDF_for_solverx_p->max_n);
     92
     93                                /*call driver: */
     94                                if (fos_forward(1,num_dependents,num_independents, 0, xp, tangentDir, theOutput, jacTimesTangentDir )) _error_("fos_forward returned non-zero error code");
     95
     96                                /*add to results*/
     97                                results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,jacTimesTangentDir,num_dependents,1,1,0.0));
     98                               
     99                                /*free ressources :*/
     100                                xDelete(theOutput);
     101                                xDelete(jacTimesTangentDir);
     102                                xDelete(tangentDir);
    90103                        }
    91                         else {
    92                           // full Jacobian or Jacobian projection:
    93                           double **jacTimesSeed=xNew<double>(num_dependents,tangentDirNum);
    94                           if (tangentDirNum<num_independents) {
    95                             double **seed=xNewZeroInit<double>(num_independents,tangentDirNum);
    96 
    97                             // <<<<<<< from here <<<<<<<<<<<<
    98                             unsigned int * indepIndices=xNew<unsigned int>(tangentDirNum);
    99                             for(int i =0; i< tangentDirNum;++i) {
    100                               indepIndices[i]=i;
    101                             }
    102                             // <<<<<<<< to here << get this vector of independent indices from the config - should be 0 based and ideally also unsigned
    103 
    104                             // collect indices in a set to prevent accidental duplicates as long as we don't do compression:
    105                             std::set<unsigned int> anIndexSet;
    106                             for (int i=0; i<tangentDirNum; ++i) {
    107                               // make sure the index is in range
    108                               if (indepIndices[i]>num_independents) {
    109                                 _error_("indepIndices values must be in [0,num_independents-1]");
    110                               }
    111                               if (anIndexSet.find(indepIndices[i])!=anIndexSet.end()) {
    112                                 _error_("duplicate indepIndices values are not allowed until we implement Jacobian decompression");
    113                               }
    114                               anIndexSet.insert(indepIndices[i]);
    115                               // now populate the seed matrix from the set of independent indices;
    116                               // simple setup with a single 1.0 per column and at most a single 1.0 per row
    117                               seed[indepIndices[i]][i]=1.0;
    118                             }
    119                             double *theOutput=xNew<double>(num_dependents);
    120                             if (fov_forward(1,num_dependents,num_independents, tangentDirNum, xp, seed, theOutput, jacTimesSeed )) {
    121                               _error_("fov_forward returned non-zero error code");
    122                             }
    123                             xDelete(theOutput);
    124                             xDelete(indepIndices);
    125                             xDelete(seed);
    126                           }
    127                           else {
    128                             if (jacobian(1,num_dependents,num_independents,xp,jacTimesSeed)) {
    129                                 _error_("jacobian returned non-zero error code");
    130                             }
    131                           }
    132                           results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,*jacTimesSeed,num_dependents*tangentDirNum,1,1,0.0));
    133                           xDelete(jacTimesSeed);
     104                        else if ((strcmp(driver,"fov_forward")==0) || (strcmp(driver,"fov_forward")==0)){
     105                               
     106                                int* indepIndices=NULL;
     107                                int tangentDirNum;
     108                                int dummy;
     109                                double **jacTimesSeed=NULL;
     110                                double **seed=NULL;
     111                                double *theOutput=NULL;
     112                                std::set<unsigned int> anIndexSet;
     113
     114                                       
     115                                /*retrieve directions:*/
     116                                if (strcmp(driver,"jacobian")==0){
     117                                        tangentDirNum=num_independents;
     118                                        indepIndices=xNewZeroInit<int>(tangentDirNum);
     119                                        for(i=0;i<num_independents;i++)indepIndices[i]=1;
     120                                }
     121                                else{
     122                                        parameters->FindParam(&indepIndices,&tangentDirNum,&dummy,AutodiffFovForwardIndicesEnum);
     123                                }
     124
     125                                /*Some checks: */
     126                                if (tangentDirNum<1 || tangentDirNum>num_independents) _error_("tangentDirNum should be in [1,num_independents]");
     127
     128                                /* full Jacobian or Jacobian projection:*/
     129                                jacTimesSeed=xNew<double>(num_dependents,tangentDirNum);
     130                               
     131                                /*set the forward method function pointers: */
     132                                anEDF_for_solverx_p->zos_forward=EDF_for_solverx;
     133                                anEDF_for_solverx_p->fov_forward=EDF_fov_forward_for_solverx;
     134                                // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx;
     135
     136                                /*allocate the space for the parameters to invoke the forward methods:*/
     137                                anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n);
     138                                anEDF_for_solverx_p->dp_X=xNew<double>(anEDF_for_solverx_p->max_n);
     139                                anEDF_for_solverx_p->dpp_X=xNew<double>(anEDF_for_solverx_p->max_n, tangentDirNum);
     140                                anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m);
     141                                anEDF_for_solverx_p->dp_Y=xNew<double>(anEDF_for_solverx_p->max_m);
     142                                anEDF_for_solverx_p->dpp_Y=xNew<double>(anEDF_for_solverx_p->max_m, tangentDirNum);
     143
     144                                /*allocate the space for the parameters to invoke the reverse methods:*/
     145                                anEDF_for_solverx_p->dp_U=xNew<double>(anEDF_for_solverx_p->max_m);
     146                                anEDF_for_solverx_p->dpp_U=xNew<double>(num_dependents,anEDF_for_solverx_p->max_m);
     147                                anEDF_for_solverx_p->dp_Z=xNew<double>(anEDF_for_solverx_p->max_n);
     148                                anEDF_for_solverx_p->dpp_Z=xNew<double>(num_dependents,anEDF_for_solverx_p->max_n);
     149
     150                                /*seed matrix: */
     151                                seed=xNewZeroInit<double>(num_independents,tangentDirNum);
     152
     153                                /*collect indices in a set to prevent accidental duplicates as long as we don't do compression:*/
     154                                for (int i=0; i<tangentDirNum; ++i) {
     155                                        /* make sure the index is in range*/
     156                                        if (indepIndices[i]>num_independents) {
     157                                                _error_("indepIndices values must be in [0,num_independents-1]");
     158                                        }
     159                                        if (anIndexSet.find(indepIndices[i])!=anIndexSet.end()) {
     160                                                _error_("duplicate indepIndices values are not allowed until we implement Jacobian decompression");
     161                                        }
     162                                        anIndexSet.insert(indepIndices[i]);
     163                                        /* now populate the seed matrix from the set of independent indices;
     164                                         * simple setup with a single 1.0 per column and at most a single 1.0 per row*/
     165                                        seed[indepIndices[i]][i]=1.0;
     166                                }
     167
     168                                /*allocate output: */
     169                                theOutput=xNew<double>(num_dependents);
     170
     171                                /*call driver: */
     172                                if (strcmp(driver,"fov_forward")==0){
     173                                        if (fov_forward(1,num_dependents,num_independents, tangentDirNum, xp, seed, theOutput, jacTimesSeed )) _error_("fov_forward returned non-zero error code");
     174                                }
     175                                else{
     176                                        if (jacobian(1,num_dependents,num_independents,xp,jacTimesSeed))  _error_("jacobian returned non-zero error code");
     177                                }
     178
     179                                /*Free ressources: */
     180                                xDelete(theOutput);
     181                                xDelete(indepIndices);
     182                                xDelete(seed);
     183
     184                                /*add to results: */
     185                                results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,*jacTimesSeed,num_dependents*tangentDirNum,1,1,0.0));
     186
     187                                /*Free ressources: */
     188                                xDelete(jacTimesSeed);
     189                                xDelete<int>(indepIndices);
    134190                        }
     191                        else _error_("driver: " << driver << " not yet supported!");
    135192
    136193                        /* delete the allocated space for the parameters:*/
     
    149206                        xDelete(xp);
    150207                        xDelete(axp);
     208                       
     209                        if(VerboseAutodiff())_pprintLine_("   end AD driver");
    151210
    152211                #else
  • issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp

    r13438 r13461  
    3232                case AutodiffDriverEnum : return "AutodiffDriver";
    3333                case AutodiffFosForwardIndexEnum : return "AutodiffFosForwardIndex";
     34                case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices";
    3435                case BalancethicknessSpcthicknessEnum : return "BalancethicknessSpcthickness";
    3536                case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization";
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp

    r13432 r13461  
    2222        int*        types=NULL;
    2323        int         dummy;
     24        char*       autodiff_driver=NULL;
     25        int*        indices=NULL;
     26        int         num_indices;
    2427       
    2528        IssmDouble* xp=NULL;
     
    3740
    3841                /*retrieve driver: */
     42                iomodel->Constant(&autodiff_driver,AutodiffDriverEnum);
    3943                parameters->AddObject(iomodel->CopyConstantObject(AutodiffDriverEnum));
    40                 parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosForwardIndexEnum));
     44               
     45                if(strcmp(autodiff_driver,"fos_forward")==0){
     46                        parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosForwardIndexEnum));
     47                }
     48                else if(strcmp(autodiff_driver,"fov_forward")==0){
     49                        /*Retrieve list of indices: */
     50                        iomodel->FetchData(&indices,&num_indices,&dummy,AutodiffFovForwardIndicesEnum);
     51                        parameters->AddObject(new IntMatParam(AutodiffFovForwardIndicesEnum,indices,num_indices,1));
     52                        xDelete<int>(indices);
     53                }
    4154
    4255                /*Deal with dependents first: {{{*/
     
    92105                /*Assign output pointer: */
    93106                *pparameters=parameters;
     107
    94108        }
    95109}
  • issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp

    r13438 r13461  
    3333              else if (strcmp(name,"AutodiffDriver")==0) return AutodiffDriverEnum;
    3434              else if (strcmp(name,"AutodiffFosForwardIndex")==0) return AutodiffFosForwardIndexEnum;
     35              else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum;
    3536              else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum;
    3637              else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum;
     
    137138              else if (strcmp(name,"MeshElementonsurface")==0) return MeshElementonsurfaceEnum;
    138139              else if (strcmp(name,"MeshElements2d")==0) return MeshElements2dEnum;
    139               else if (strcmp(name,"MeshElements")==0) return MeshElementsEnum;
    140140         else stage=2;
    141141   }
    142142   if(stage==2){
    143               if (strcmp(name,"MeshLowerelements")==0) return MeshLowerelementsEnum;
     143              if (strcmp(name,"MeshElements")==0) return MeshElementsEnum;
     144              else if (strcmp(name,"MeshLowerelements")==0) return MeshLowerelementsEnum;
    144145              else if (strcmp(name,"MeshNumberofedges")==0) return MeshNumberofedgesEnum;
    145146              else if (strcmp(name,"MeshNumberofelements2d")==0) return MeshNumberofelements2dEnum;
     
    260261              else if (strcmp(name,"TransientSolution")==0) return TransientSolutionEnum;
    261262              else if (strcmp(name,"Approximation")==0) return ApproximationEnum;
    262               else if (strcmp(name,"NoneApproximation")==0) return NoneApproximationEnum;
    263263         else stage=3;
    264264   }
    265265   if(stage==3){
    266               if (strcmp(name,"HutterApproximation")==0) return HutterApproximationEnum;
     266              if (strcmp(name,"NoneApproximation")==0) return NoneApproximationEnum;
     267              else if (strcmp(name,"HutterApproximation")==0) return HutterApproximationEnum;
    267268              else if (strcmp(name,"MacAyealApproximation")==0) return MacAyealApproximationEnum;
    268269              else if (strcmp(name,"MacAyealPattynApproximation")==0) return MacAyealPattynApproximationEnum;
     
    383384              else if (strcmp(name,"TemperatureOld")==0) return TemperatureOldEnum;
    384385              else if (strcmp(name,"TemperaturePicard")==0) return TemperaturePicardEnum;
    385               else if (strcmp(name,"TemperatureSurface")==0) return TemperatureSurfaceEnum;
    386386         else stage=4;
    387387   }
    388388   if(stage==4){
    389               if (strcmp(name,"TemperatureBasal")==0) return TemperatureBasalEnum;
     389              if (strcmp(name,"TemperatureSurface")==0) return TemperatureSurfaceEnum;
     390              else if (strcmp(name,"TemperatureBasal")==0) return TemperatureBasalEnum;
    390391              else if (strcmp(name,"ThicknessAbsMisfit")==0) return ThicknessAbsMisfitEnum;
    391392              else if (strcmp(name,"Type")==0) return TypeEnum;
     
    506507              else if (strcmp(name,"Option")==0) return OptionEnum;
    507508              else if (strcmp(name,"GenericOption")==0) return GenericOptionEnum;
    508               else if (strcmp(name,"OptionCell")==0) return OptionCellEnum;
    509509         else stage=5;
    510510   }
    511511   if(stage==5){
    512               if (strcmp(name,"OptionChar")==0) return OptionCharEnum;
     512              if (strcmp(name,"OptionCell")==0) return OptionCellEnum;
     513              else if (strcmp(name,"OptionChar")==0) return OptionCharEnum;
    513514              else if (strcmp(name,"OptionStruct")==0) return OptionStructEnum;
    514515              else if (strcmp(name,"OptionDouble")==0) return OptionDoubleEnum;
  • issm/trunk-jpl/src/m/classes/autodiff.m

    r13429 r13461  
    2929
    3030                        %Driver value:
    31                         md = checkfield(md,'autodiff.driver','values',{'fos_forward'});
     31                        md = checkfield(md,'autodiff.driver','values',{'fos_forward','fov_forward'});
     32
     33                        %go through our dependents and independents and check consistency:
     34                        for i=1:numel(obj.dependents),
     35                                dep=obj.dependents{i};
     36                                md=checkconsistency(dep,md,solution,analyses);
     37                        end
     38                        for i=1:numel(obj.independents),
     39                                indep=obj.independents{i};
     40                                md=checkconsistency(indep,md,i,solution,analyses,obj.driver);
     41                        end
     42
    3243
    3344                end % }}}
     
    3748                        fielddisplay(obj,'dependents','list of dependent variables');
    3849                        fielddisplay(obj,'independents','list of independent variables');
    39                         fielddisplay(obj,'driver','ADOLC driver');
     50                        fielddisplay(obj,'driver','ADOLC driver (''fos_forward'' or ''fov_forward''');
    4051                end % }}}
    4152                function marshall(obj,fid) % {{{
     
    101112                                        end
    102113                                end
    103                                 WriteData(fid,'data',index-1,'enum',AutodiffFosForwardIndexEnum(),'format','Integer'); %c-index numbering.
     114                                index=index-1; %get c-index numbering going
     115                                WriteData(fid,'data',index,'enum',AutodiffFosForwardIndexEnum(),'format','Integer');
    104116                        end
     117                        %if driver is fov_forward, build indices:
     118                        if strcmpi(obj.driver,'fov_forward'),
     119                                indices=0;
     120                               
     121                                for i=1:num_independent_objects,
     122                                        indep=obj.independents{i};
     123                                        if ~isempty(indep.fos_forward_index),
     124                                                indices=indices+indep.fov_forward_indices;
     125                                                break;
     126                                        else
     127                                                if strcmpi(indep.type,'scalar'),
     128                                                        indices=indices+1;
     129                                                else
     130                                                        indices=indices+indep.nods;
     131                                                end
     132                                        end
     133                                end
     134                                indices=indices-1; %get c-indices numbering going
     135
     136                                WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum,'format','IntMat','mattype',3);
     137                        end
     138
    105139                end % }}}
    106140        end
  • issm/trunk-jpl/src/m/classes/independent.m

    r13429 r13461  
    99                type                 = '';
    1010                fos_forward_index    = NaN;
     11                fov_forward_indices  = [];
    1112                nods                 = 0;
    1213        end
     
    2627
    2728                end % }}}
    28                 function md = checkconsistency(obj,md,solution,analyses) % {{{
     29                function md = checkconsistency(obj,md,i,solution,analyses,driver) % {{{
    2930                        %do nothing for now
    3031                        if ~isnan(obj.fos_forward_index),
     32                                if ~strcmpi(driver,'fos_forward'),
     33                                        error('cannot declare an independent with a fos_forward_index when the driver is not fos_forward!');
     34                                end
    3135                                if obj.nods==0,
    3236                                        error('independent checkconsistency error: nods should be set to the size of the independent variable');
    3337                                end
    3438                        end
     39
     40                        if ~isempty(obj.fov_forward_indices),
     41                                if ~strcmpi(driver,'fov_forward'),
     42                                        error('cannot declare an independent with fov_forward_indices when the driver is not fov_forward!');
     43                                end
     44
     45                                if obj.nods==0,
     46                                        error('independent checkconsistency error: nods should be set to the size of the independent variable');
     47                                end
     48                                md = checkfield(md,['autodiff.independents{' num2str(i) '}.fov_forward_indices'],'>=',1,'<=',obj.nods,'size',[NaN 1]);
     49                        end
     50
    3551
    3652                end % }}}
     
    4359                                fielddisplay(obj,'fos_forward_index','index for fos_foward driver of ADOLC');
    4460                        end
    45 
     61                        if ~isnan(obj.fov_forward_indices),
     62                                fielddisplay(obj,'fov_forward_indices','indices for fov_foward driver of ADOLC');
     63                        end
    4664                end % }}}
    4765                function scalar=typetoscalar(obj) % {{{
  • issm/trunk-jpl/src/m/enum/EnumDefinitions.py

    r13438 r13461  
    159159        return StringToEnum('AutodiffFosForwardIndex')[0]
    160160
     161def AutodiffFovForwardIndicesEnum():
     162        """
     163        AUTODIFFFOVFORWARDINDICESENUM - Enum of AutodiffFovForwardIndices
     164
     165           Usage:
     166              macro=AutodiffFovForwardIndicesEnum()
     167        """
     168
     169        return StringToEnum('AutodiffFovForwardIndices')[0]
     170
    161171def BalancethicknessSpcthicknessEnum():
    162172        """
     
    48774887        """
    48784888
    4879         return 486
    4880 
     4889        return 487
     4890
  • issm/trunk-jpl/src/m/enum/MaximumNumberOfEnums.m

    r13438 r13461  
    99%      macro=MaximumNumberOfEnums()
    1010
    11 macro=486;
     11macro=487;
  • issm/trunk-jpl/test/NightlyRun/ad.m

    r13438 r13461  
    66
    77md.autodiff.isautodiff=true;
     8md.verbose.autodiff=true;
    89index=1;
    910md.autodiff.independents={...
    10         independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index)
     11        independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fov_forward_indices',(1:md.mesh.numberofvertices)')
     12        %independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index)
    1113        };
    1214
    1315md.autodiff.dependents={...
    1416        dependent('name','IceVolume','type','scalar')...
     17        dependent('name','MaxVel','type','scalar')...
    1518        };
    16 md.autodiff.driver='fos_forward';
     19%md.autodiff.driver='fos_forward';
     20md.autodiff.driver='fov_forward';
    1721
    1822md=solve(md,TransientSolutionEnum);
Note: See TracChangeset for help on using the changeset viewer.