source:
issm/oecreview/Archive/13393-13976/ISSM-13539-13540.diff@
14312
Last change on this file since 14312 was 13980, checked in by , 12 years ago | |
---|---|
File size: 40.9 KB |
-
../trunk-jpl/externalpackages/python/install-2.7.3-macosx-lion.sh
7 7 mkdir install src 8 8 9 9 #Download from ISSM server 10 $ISSM_DIR/scripts/DownloadExternalPackage.py http://issm.jpl.nasa.gov/files/externalpackages/Python-2.7.3.tgz Python-2.7.3.tgz10 #$ISSM_DIR/scripts/DownloadExternalPackage.py http://issm.jpl.nasa.gov/files/externalpackages/Python-2.7.3.tgz Python-2.7.3.tgz 11 11 12 12 #Untar and move python into install directory 13 13 tar -zxvf Python-2.7.3.tgz … … 16 16 17 17 #Configure and compile 18 18 cd src 19 ./configure \ 20 --enable-framework="$ISSM_DIR/externalpackages/python/install/Library/Frameworks" 19 ./configure --enable-framework="$ISSM_DIR/externalpackages/python/install/Library/Frameworks" 21 20 if [ $# -eq 0 ]; then 22 21 make 23 22 else -
../trunk-jpl/src/c/solutions/CorePointerFromSolutionEnum.cpp
17 17 #include "../include/include.h" 18 18 #include "../solvers/solvers.h" 19 19 20 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype ){20 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore){ 21 21 22 22 /*output: */ 23 23 void (*solutioncore)(FemModel*)=NULL; 24 24 25 switch(solutiontype){ 25 /*parameters: */ 26 bool control_analysis=false; 27 bool tao_analysis=false; 28 bool dakota_analysis=false; 26 29 27 case DiagnosticSolutionEnum: 28 #ifdef _HAVE_DIAGNOSTIC_ 29 solutioncore=&diagnostic_core; 30 #else 31 _error_("ISSM was not compiled with diagnostic capabilities. Exiting"); 32 #endif 33 break; 34 case SteadystateSolutionEnum: 35 #ifdef _HAVE_STEADYSTATE_ 36 solutioncore=&steadystate_core; 37 #else 38 _error_("ISSM was not compiled with steady state capabilities. Exiting"); 39 #endif 40 break; 41 case ThermalSolutionEnum: 42 #ifdef _HAVE_THERMAL_ 43 solutioncore=&thermal_core; 44 #else 45 _error_("ISSM was not compiled with thermal capabilities. Exiting"); 46 #endif 47 break; 48 case EnthalpySolutionEnum: 49 #ifdef _HAVE_THERMAL_ 50 solutioncore=&enthalpy_core; 51 #else 52 _error_("ISSM was not compiled with thermal capabilities. Exiting"); 53 #endif 54 break; 55 case BalancethicknessSolutionEnum: 56 #ifdef _HAVE_BALANCED_ 57 solutioncore=&balancethickness_core; 58 #else 59 _error_("ISSM was not compiled with balanced capabilities. Exiting"); 60 #endif 61 break; 62 case HydrologySolutionEnum: 63 #ifdef _HAVE_HYDROLOGY_ 64 solutioncore=&hydrology_core; 65 #else 66 _error_("ISSM was not compiled with hydrology capabilities. Exiting"); 67 #endif 68 break; 69 case SurfaceSlopeSolutionEnum: 70 #ifdef _HAVE_SLOPE_ 71 solutioncore=&surfaceslope_core; 72 #else 73 _error_("ISSM was not compiled with slope capabilities. Exiting"); 74 #endif 75 break; 76 case BedSlopeSolutionEnum: 77 #ifdef _HAVE_SLOPE_ 78 solutioncore=&bedslope_core; 79 #else 80 _error_("ISSM was not compiled with slope capabilities. Exiting"); 81 #endif 82 break; 83 case TransientSolutionEnum: 84 #ifdef _HAVE_TRANSIENT_ 85 solutioncore=&transient_core; 86 #else 87 _error_("ISSM was not compiled with transient capabilities. Exiting"); 88 #endif 89 break; 90 case PrognosticSolutionEnum: 91 #ifdef _HAVE_PROGNOSTIC_ 92 solutioncore=&prognostic_core; 93 #else 94 _error_("ISSM was not compiled with prognostic capabilities. Exiting"); 95 #endif 96 break; 97 default: 98 _error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!"); 99 break; 30 /* retrieve some parameters that tell us whether wrappers are allowed, or whether we return 31 * a pure core. Wrappers can be dakota_core (which samples many solution_cores) or control_core (which 32 * carries out adjoint based inversion on a certain core: */ 33 parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); 34 parameters->FindParam(&control_analysis,InversionIscontrolEnum); 35 parameters->FindParam(&tao_analysis,InversionTaoEnum); 36 37 if(nodakotacore)dakota_analysis=false; 38 39 if(dakota_analysis){ 40 #ifdef _HAVE_DAKOTA_ 41 solutioncore=dakota_core; 42 #else 43 _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!"); 44 #endif 100 45 } 101 46 else if(control_analysis){ 47 #ifdef _HAVE_CONTROL_ 48 if(tao_analysis) solutioncore=controltao_core; 49 else solutioncore=control_core; 50 #else 51 _error_("ISSM was not compiled with control support, cannot carry out control analysis!"); 52 #endif 53 } 54 else PureCorePointerFromSolutionEnum(&solutioncore,parameters,solutiontype); /*This means we retrieve a core solution that is not a wrapper*/ 55 102 56 /*Assign output pointer:*/ 103 57 _assert_(psolutioncore); 104 58 *psolutioncore=solutioncore; -
../trunk-jpl/src/c/solutions/PureCorePointerFromSolutionEnum.cpp
1 /*!\file: PureCorePointerFromSolutionEnum.cpp 2 * \brief: return type of analyses, number of analyses and core solution function. 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 "../toolkits/toolkits.h" 12 #include "../classes/objects/objects.h" 13 #include "../shared/shared.h" 14 #include "../EnumDefinitions/EnumDefinitions.h" 15 #include "./solutions.h" 16 #include "../modules/modules.h" 17 #include "../include/include.h" 18 #include "../solvers/solvers.h" 19 20 void PureCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype){ 21 22 /*output: */ 23 void (*solutioncore)(FemModel*)=NULL; 24 25 switch(solutiontype){ 26 27 case DiagnosticSolutionEnum: 28 #ifdef _HAVE_DIAGNOSTIC_ 29 solutioncore=&diagnostic_core; 30 #else 31 _error_("ISSM was not compiled with diagnostic capabilities. Exiting"); 32 #endif 33 break; 34 case SteadystateSolutionEnum: 35 #ifdef _HAVE_STEADYSTATE_ 36 solutioncore=&steadystate_core; 37 #else 38 _error_("ISSM was not compiled with steady state capabilities. Exiting"); 39 #endif 40 break; 41 case ThermalSolutionEnum: 42 #ifdef _HAVE_THERMAL_ 43 solutioncore=&thermal_core; 44 #else 45 _error_("ISSM was not compiled with thermal capabilities. Exiting"); 46 #endif 47 break; 48 case EnthalpySolutionEnum: 49 #ifdef _HAVE_THERMAL_ 50 solutioncore=&enthalpy_core; 51 #else 52 _error_("ISSM was not compiled with thermal capabilities. Exiting"); 53 #endif 54 break; 55 case BalancethicknessSolutionEnum: 56 #ifdef _HAVE_BALANCED_ 57 solutioncore=&balancethickness_core; 58 #else 59 _error_("ISSM was not compiled with balanced capabilities. Exiting"); 60 #endif 61 break; 62 case HydrologySolutionEnum: 63 #ifdef _HAVE_HYDROLOGY_ 64 solutioncore=&hydrology_core; 65 #else 66 _error_("ISSM was not compiled with hydrology capabilities. Exiting"); 67 #endif 68 break; 69 case SurfaceSlopeSolutionEnum: 70 #ifdef _HAVE_SLOPE_ 71 solutioncore=&surfaceslope_core; 72 #else 73 _error_("ISSM was not compiled with slope capabilities. Exiting"); 74 #endif 75 break; 76 case BedSlopeSolutionEnum: 77 #ifdef _HAVE_SLOPE_ 78 solutioncore=&bedslope_core; 79 #else 80 _error_("ISSM was not compiled with slope capabilities. Exiting"); 81 #endif 82 break; 83 case TransientSolutionEnum: 84 #ifdef _HAVE_TRANSIENT_ 85 solutioncore=&transient_core; 86 #else 87 _error_("ISSM was not compiled with transient capabilities. Exiting"); 88 #endif 89 break; 90 case PrognosticSolutionEnum: 91 #ifdef _HAVE_PROGNOSTIC_ 92 solutioncore=&prognostic_core; 93 #else 94 _error_("ISSM was not compiled with prognostic capabilities. Exiting"); 95 #endif 96 break; 97 default: 98 _error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!"); 99 break; 100 } 101 102 /*Assign output pointer:*/ 103 _assert_(psolutioncore); 104 *psolutioncore=solutioncore; 105 106 } -
../trunk-jpl/src/c/solutions/ad_core.cpp
1 /*!\file ad_core 2 * \brief: compute outputs from the AD mode, using our dependents and independents, and drivers available in Adolc. 3 */ 4 5 /*Includes: {{{*/ 6 #ifdef HAVE_CONFIG_H 7 #include <config.h> 8 #else 9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 10 #endif 11 12 13 #include <set> 14 #include "../toolkits/toolkits.h" 15 #include "../classes/objects/objects.h" 16 #include "../shared/shared.h" 17 #include "../io/io.h" 18 #include "../EnumDefinitions/EnumDefinitions.h" 19 #include "./solutions.h" 20 #include "../modules/modules.h" 21 #include "../include/include.h" 22 #include "../solvers/solvers.h" 23 /*}}}*/ 24 25 void ad_core(FemModel* femmodel){ 26 27 /*diverse: */ 28 int i; 29 int dummy; 30 31 bool isautodiff = false; 32 int num_dependents; 33 int num_independents; 34 char* driver=NULL; 35 36 /*state variables: */ 37 IssmDouble *axp = NULL; 38 double *xp = NULL; 39 40 /*AD mode on?: */ 41 femmodel->parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 42 43 if(isautodiff){ 44 45 #ifdef _HAVE_ADOLC_ 46 47 if(VerboseAutodiff())_pprintLine_(" start ad core"); 48 49 /*First, stop tracing: */ 50 trace_off(); 51 52 /*preliminary checks: */ 53 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 54 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 55 if(!(num_dependents*num_independents)) return; 56 57 /*retrieve state variable: */ 58 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); 59 60 /* driver argument */ 61 xp=xNew<double>(num_independents); 62 for(i=0;i<num_independents;i++){ 63 xp[i]=reCast<double,IssmDouble>(axp[i]); 64 } 65 66 /*get the EDF pointer:*/ 67 ext_diff_fct *anEDF_for_solverx_p=dynamic_cast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p; 68 69 /*Branch according to AD driver: */ 70 femmodel->parameters->FindParam(&driver,AutodiffDriverEnum); 71 72 /* these are always needed regardless of the interpreter */ 73 anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n); 74 anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m); 75 76 if (strcmp(driver,"fos_forward")==0){ 77 78 int anIndepIndex; 79 double *tangentDir=NULL; 80 double *jacTimesTangentDir=NULL; 81 double *theOutput=NULL; 82 83 /*retrieve direction index: */ 84 femmodel->parameters->FindParam(&anIndepIndex,AutodiffFosForwardIndexEnum); 85 86 if (anIndepIndex<0 || anIndepIndex>=num_independents) _error_("index value for AutodiffFosForwardIndexEnum should be in [0,num_independents-1]"); 87 88 tangentDir=xNewZeroInit<double>(num_independents); 89 tangentDir[anIndepIndex]=1.0; 90 91 jacTimesTangentDir=xNew<double>(num_dependents); 92 theOutput=xNew<double>(num_dependents); 93 94 /*set the forward method function pointer: */ 95 anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx; 96 97 /*allocate the space for the parameters to invoke the EDF fos_forward:*/ 98 anEDF_for_solverx_p->dp_X=xNew<double>(anEDF_for_solverx_p->max_n); 99 anEDF_for_solverx_p->dp_Y=xNew<double>(anEDF_for_solverx_p->max_m); 100 101 /*call driver: */ 102 fos_forward(1,num_dependents,num_independents, 0, xp, tangentDir, theOutput, jacTimesTangentDir ); 103 104 /*add to results*/ 105 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,jacTimesTangentDir,num_dependents,1,1,0.0)); 106 107 /*free resources :*/ 108 xDelete(theOutput); 109 xDelete(jacTimesTangentDir); 110 xDelete(tangentDir); 111 } 112 else if ((strcmp(driver,"fov_forward")==0) || (strcmp(driver,"fov_forward_all")==0)){ 113 114 int* indepIndices=NULL; 115 int tangentDirNum; 116 int dummy; 117 double **jacTimesSeed=NULL; 118 double **seed=NULL; 119 double *theOutput=NULL; 120 std::set<unsigned int> anIndexSet; 121 122 123 /*retrieve directions:*/ 124 if (strcmp(driver,"fov_forward_all")==0){ 125 tangentDirNum=num_independents; 126 indepIndices=xNewZeroInit<int>(tangentDirNum); 127 for(i=0;i<num_independents;i++)indepIndices[i]=1; 128 } 129 else{ 130 femmodel->parameters->FindParam(&indepIndices,&tangentDirNum,&dummy,AutodiffFovForwardIndicesEnum); 131 } 132 133 /*Some checks: */ 134 if (tangentDirNum<1 || tangentDirNum>num_independents) _error_("tangentDirNum should be in [1,num_independents]"); 135 136 /* full Jacobian or Jacobian projection:*/ 137 jacTimesSeed=xNew<double>(num_dependents,tangentDirNum); 138 139 /*set the forward method function pointers: */ 140 anEDF_for_solverx_p->fov_forward=EDF_fov_forward_for_solverx; 141 // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 142 143 /*allocate the space for the parameters to invoke EDF fov_forward:*/ 144 anEDF_for_solverx_p->dpp_X=xNew<double>(anEDF_for_solverx_p->max_n, tangentDirNum); 145 anEDF_for_solverx_p->dpp_Y=xNew<double>(anEDF_for_solverx_p->max_m, tangentDirNum); 146 147 /*seed matrix: */ 148 seed=xNewZeroInit<double>(num_independents,tangentDirNum); 149 150 /*collect indices in a set to prevent accidental duplicates as long as we don't do compression:*/ 151 for (int i=0; i<tangentDirNum; ++i) { 152 /* make sure the index is in range*/ 153 if (indepIndices[i]>num_independents) { 154 _error_("indepIndices values must be in [0,num_independents-1]"); 155 } 156 if (anIndexSet.find(indepIndices[i])!=anIndexSet.end()) { 157 _error_("duplicate indepIndices values are not allowed until we implement Jacobian decompression"); 158 } 159 anIndexSet.insert(indepIndices[i]); 160 /* now populate the seed matrix from the set of independent indices; 161 * simple setup with a single 1.0 per column and at most a single 1.0 per row*/ 162 seed[indepIndices[i]][i]=1.0; 163 } 164 165 /*allocate output: */ 166 theOutput=xNew<double>(num_dependents); 167 168 /*call driver: */ 169 fov_forward(1,num_dependents,num_independents, tangentDirNum, xp, seed, theOutput, jacTimesSeed ); 170 /*Free resources: */ 171 xDelete(theOutput); 172 xDelete(indepIndices); 173 xDelete(seed); 174 175 /*add to results: */ 176 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,*jacTimesSeed,num_dependents*tangentDirNum,1,1,0.0)); 177 178 /*Free resources: */ 179 xDelete(jacTimesSeed); 180 xDelete(indepIndices); 181 } 182 else if (strcmp(driver,"fos_reverse")==0) { 183 184 int aDepIndex=0; 185 double *aWeightVector=NULL; 186 double *weightVectorTimesJac=NULL; 187 188 /*retrieve direction index: */ 189 femmodel->parameters->FindParam(&aDepIndex,AutodiffFosReverseIndexEnum); 190 191 if (aDepIndex<0 || aDepIndex>=num_dependents) _error_("index value for AutodiffFosReverseIndexEnum should be in [0,num_dependents-1]"); 192 193 aWeightVector=xNewZeroInit<double>(num_dependents); 194 aWeightVector[aDepIndex]=1.0; 195 196 weightVectorTimesJac=xNew<double>(num_independents); 197 198 /*set the forward method function pointer: */ 199 anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx; 200 201 /*allocate the space for the parameters to invoke the EDF fos_reverse :*/ 202 anEDF_for_solverx_p->dp_U=xNew<double>(anEDF_for_solverx_p->max_m); 203 anEDF_for_solverx_p->dp_Z=xNew<double>(anEDF_for_solverx_p->max_n); 204 205 /*call driver: */ 206 fos_reverse(1,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); 207 208 /*add to results*/ 209 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,weightVectorTimesJac,num_independents,1,1,0.0)); 210 211 /*free resources :*/ 212 xDelete(weightVectorTimesJac); 213 xDelete(aWeightVector); 214 } 215 else if ((strcmp(driver,"fov_reverse")==0) || (strcmp(driver,"fov_reverse_all")==0)){ 216 217 int* depIndices=NULL; 218 int weightNum; 219 int dummy; 220 double **weightsTimesJac=NULL; 221 double **weights=NULL; 222 std::set<unsigned int> anIndexSet; 223 224 225 /*retrieve directions:*/ 226 if (strcmp(driver,"fov_reverse_all")==0){ 227 weightNum=num_dependents; 228 depIndices=xNewZeroInit<int>(weightNum); 229 for(i=0;i<num_dependents;i++)depIndices[i]=1; 230 } 231 else{ 232 femmodel->parameters->FindParam(&depIndices,&weightNum,&dummy,AutodiffFovForwardIndicesEnum); 233 } 234 235 /*Some checks: */ 236 if (weightNum<1 || weightNum>num_dependents) _error_("tangentDirNum should be in [1,num_dependents]"); 237 238 /* full Jacobian or Jacobian projection:*/ 239 weightsTimesJac=xNew<double>(weightNum,num_independents); 240 241 /*set the forward method function pointers: */ 242 anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 243 244 /*allocate the space for the parameters to invoke the EDF fos_reverse :*/ 245 anEDF_for_solverx_p->dpp_U=xNew<double>(weightNum,anEDF_for_solverx_p->max_m); 246 anEDF_for_solverx_p->dpp_Z=xNew<double>(weightNum,anEDF_for_solverx_p->max_n); 247 248 /*seed matrix: */ 249 weights=xNewZeroInit<double>(weightNum,num_dependents); 250 251 /*collect indices in a set to prevent accidental duplicates as long as we don't do compression:*/ 252 for (int i=0; i<weightNum; ++i) { 253 /* make sure the index is in range*/ 254 if (depIndices[i]>num_dependents) { 255 _error_("depIndices values must be in [0,num_dependents-1]"); 256 } 257 if (anIndexSet.find(depIndices[i])!=anIndexSet.end()) { 258 _error_("duplicate depIndices values are not allowed until we implement Jacobian decompression"); 259 } 260 anIndexSet.insert(depIndices[i]); 261 /* now populate the seed matrix from the set of independent indices; 262 * simple setup with a single 1.0 per column and at most a single 1.0 per row*/ 263 weights[depIndices[i]][i]=1.0; 264 } 265 266 /*call driver: */ 267 fov_reverse(1,num_dependents,num_independents, weightNum, weights, weightsTimesJac ); 268 269 /*add to results: */ 270 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,*weightsTimesJac,weightNum*num_independents,1,1,0.0)); 271 272 /*Free resources: */ 273 xDelete(weights); 274 xDelete(weightsTimesJac); 275 xDelete(depIndices); 276 } 277 else _error_("driver: " << driver << " not yet supported!"); 278 279 /* delete the allocated space for the parameters:*/ 280 xDelete(anEDF_for_solverx_p->dp_x); 281 xDelete(anEDF_for_solverx_p->dp_X); 282 xDelete(anEDF_for_solverx_p->dpp_X); 283 xDelete(anEDF_for_solverx_p->dp_y); 284 xDelete(anEDF_for_solverx_p->dp_Y); 285 xDelete(anEDF_for_solverx_p->dpp_Y); 286 xDelete(anEDF_for_solverx_p->dp_U); 287 xDelete(anEDF_for_solverx_p->dpp_U); 288 xDelete(anEDF_for_solverx_p->dp_Z); 289 xDelete(anEDF_for_solverx_p->dpp_Z); 290 291 /*Free resources: */ 292 xDelete(xp); 293 xDelete(axp); 294 295 if(VerboseAutodiff())_pprintLine_(" end AD core"); 296 297 #else 298 _error_("Should not be requesting AD drivers when an AD library is not available!"); 299 #endif 300 } 301 } -
../trunk-jpl/src/c/solutions/solutions.h
30 30 void steadystate_core(FemModel* femmodel); 31 31 void transient_core(FemModel* femmodel); 32 32 void dakota_core(FemModel* femmodel); 33 void ad_core(FemModel* femmodel); 33 34 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs); 34 35 35 36 //convergence: … … 51 52 52 53 //solution configuration 53 54 void AnalysisConfiguration(int** panalyses,int* pnumanalyses, int solutiontype); 54 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype); 55 void PureCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype); 56 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false); 55 57 void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype); 56 58 57 59 -
../trunk-jpl/src/c/solutions/dakota_core.cpp
64 64 Dakota::ModelLIter ml_iter; 65 65 Parameters* parameters = NULL; 66 66 67 /*Retrieve parameters: */68 parameters=femmodel->parameters;69 70 67 /*Recover dakota_input_file, dakota_output_file and dakota_error_file, in the parameters dataset in parallel */ 71 parameters->FindParam(&dakota_input_file,QmuInNameEnum);72 parameters->FindParam(&dakota_output_file,QmuOutNameEnum);73 parameters->FindParam(&dakota_error_file,QmuErrNameEnum);68 femmodel->parameters->FindParam(&dakota_input_file,QmuInNameEnum); 69 femmodel->parameters->FindParam(&dakota_output_file,QmuOutNameEnum); 70 femmodel->parameters->FindParam(&dakota_error_file,QmuErrNameEnum); 74 71 75 72 if(my_rank==0){ 76 73 -
../trunk-jpl/src/c/solutions/issm.cpp
14 14 FILE *output_fid = NULL; 15 15 FILE *petscoptionsfid = NULL; 16 16 bool waitonlock = false; 17 bool dakota_analysis,control_analysis,tao_analysis;18 17 19 18 /*AD: */ 20 19 bool autodiff=false; … … 78 77 79 78 /*get parameters: */ 80 79 femmodel->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum); 81 femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);82 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);83 femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);84 80 femmodel->parameters->FindParam(&autodiff,AutodiffIsautodiffEnum); 85 81 86 82 /*Profiling: */ … … 103 99 #endif 104 100 105 101 _pprintLine_("call computational core:"); 106 107 108 profiler->Tag(StartCore); 109 if(dakota_analysis){ 110 #ifdef _HAVE_DAKOTA_ 111 dakota_core(femmodel); 112 #else 113 _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!"); 114 #endif 115 } 116 else if(control_analysis){ 117 #ifdef _HAVE_CONTROL_ 118 if(tao_analysis) controltao_core(femmodel); 119 else control_core(femmodel); 120 #else 121 _error_("ISSM was not compiled with control support, cannot carry out control analysis!"); 122 #endif 123 } 124 else{ 125 solutioncore(femmodel); 126 } 127 128 #ifdef _HAVE_ADOLC_ 129 if(autodiff){ 130 trace_off(); 131 AutodiffDriversx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); 132 } 133 #endif 134 profiler->Tag(FinishCore); 135 102 profiler->Tag(StartCore); solutioncore(femmodel); profiler->Tag(FinishCore); 103 profiler->Tag(StartAdCore); ad_core(femmodel); profiler->Tag(FinishAdCore); 104 136 105 ProfilerEnd(profiler,femmodel->results,femmodel->parameters); 137 106 138 107 _pprintLine_("write results to disk:"); … … 219 188 _pprintLine_("Solution memory used : " << solution_memory << " Bytes"); 220 189 221 190 /*Add to results: */ 222 results->AddObject(new GenericExternalResult< double>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0));223 results->AddObject(new GenericExternalResult< double>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0));224 results->AddObject(new GenericExternalResult< double>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0));191 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0)); 192 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0)); 193 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0)); 225 194 } 226 195 227 196 } /*}}}*/ -
../trunk-jpl/src/c/solutions/DakotaSpawnCore.cpp
54 54 bool control_analysis = false; 55 55 void (*solutioncore)(FemModel*) = NULL; 56 56 FemModel* femmodel = NULL; 57 bool nodakotacore = true; 57 58 58 59 59 60 /*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */ … … 80 81 81 82 /*Determine solution sequence: */ 82 83 if(VerboseQmu()) _pprintLine_("Starting " << EnumToStringx(solution_type) << " core:"); 83 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 84 #ifdef _HAVE_CONTROL_ 85 if(control_analysis)solutioncore=&control_core; 86 #else 87 _error_("ISSM was not compiled with control capabilities, exiting!"); 88 #endif 84 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type,nodakotacore); 89 85 90 86 /*Run the core solution sequence: */ 91 87 solutioncore(femmodel); … … 96 92 97 93 /*Free ressources:*/ 98 94 DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors); 95 96 return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running! 99 97 } 100 98 101 99 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses){ /*{{{*/ -
../trunk-jpl/src/c/solutions/control_core.cpp
61 61 femmodel->parameters->SetParam(false,SaveResultsEnum); 62 62 63 63 /*out of solution_type, figure out solution core and adjoint function pointer*/ 64 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);64 PureCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 65 65 AdjointCorePointerFromSolutionEnum(&adjointcore,solution_type); 66 66 67 67 /*Launch once a complete solution to set up all inputs*/ -
../trunk-jpl/src/c/solutions/controltao_core.cpp
93 93 if(VerboseControl()) _pprintLine_(" preparing final solution"); 94 94 femmodel->parameters->SetParam(true,SaveResultsEnum); 95 95 void (*solutioncore)(FemModel*)=NULL; 96 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);96 PureCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 97 97 solutioncore(femmodel); 98 98 99 99 /*Clean up and return*/ -
../trunk-jpl/src/c/modules/AutodiffDriversx/AutodiffDriversx.cpp
1 /*!\file AutodiffDriversx2 * \brief: compute outputs from the AD mode, using our dependents and independents, and drivers available in Adolc.3 */4 #include <set>5 #include "../../modules/modules.h"6 #include "../../shared/shared.h"7 #include "../../include/include.h"8 #include "../../toolkits/toolkits.h"9 #include "../../EnumDefinitions/EnumDefinitions.h"10 11 12 void AutodiffDriversx(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,Results* results){13 14 15 /*diverse: */16 int i;17 int dummy;18 19 bool isautodiff = false;20 int num_dependents;21 int num_independents;22 char* driver=NULL;23 24 /*state variables: */25 IssmDouble *axp = NULL;26 double *xp = NULL;27 28 /*AD mode on?: */29 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);30 31 if(isautodiff){32 33 #ifdef _HAVE_ADOLC_34 35 if(VerboseAutodiff())_pprintLine_(" start AD driver");36 37 /*preliminary checks: */38 parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum);39 parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum);40 if(!(num_dependents*num_independents)) return;41 42 /*retrieve state variable: */43 parameters->FindParam(&axp,&dummy,AutodiffXpEnum);44 45 /* driver argument */46 xp=xNew<double>(num_independents);47 for(i=0;i<num_independents;i++){48 xp[i]=reCast<double,IssmDouble>(axp[i]);49 }50 51 /*get the EDF pointer:*/52 ext_diff_fct *anEDF_for_solverx_p=dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p;53 54 /*Branch according to AD driver: */55 parameters->FindParam(&driver,AutodiffDriverEnum);56 57 /* these are always needed regardless of the interpreter */58 anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n);59 anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m);60 61 if (strcmp(driver,"fos_forward")==0){62 63 int anIndepIndex;64 double *tangentDir=NULL;65 double *jacTimesTangentDir=NULL;66 double *theOutput=NULL;67 68 /*retrieve direction index: */69 parameters->FindParam(&anIndepIndex,AutodiffFosForwardIndexEnum);70 71 if (anIndepIndex<0 || anIndepIndex>=num_independents) _error_("index value for AutodiffFosForwardIndexEnum should be in [0,num_independents-1]");72 73 tangentDir=xNewZeroInit<double>(num_independents);74 tangentDir[anIndepIndex]=1.0;75 76 jacTimesTangentDir=xNew<double>(num_dependents);77 theOutput=xNew<double>(num_dependents);78 79 /*set the forward method function pointer: */80 anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx;81 82 /*allocate the space for the parameters to invoke the EDF fos_forward:*/83 anEDF_for_solverx_p->dp_X=xNew<double>(anEDF_for_solverx_p->max_n);84 anEDF_for_solverx_p->dp_Y=xNew<double>(anEDF_for_solverx_p->max_m);85 86 /*call driver: */87 fos_forward(1,num_dependents,num_independents, 0, xp, tangentDir, theOutput, jacTimesTangentDir );88 89 /*add to results*/90 results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,jacTimesTangentDir,num_dependents,1,1,0.0));91 92 /*free resources :*/93 xDelete(theOutput);94 xDelete(jacTimesTangentDir);95 xDelete(tangentDir);96 }97 else if ((strcmp(driver,"fov_forward")==0) || (strcmp(driver,"fov_forward_all")==0)){98 99 int* indepIndices=NULL;100 int tangentDirNum;101 int dummy;102 double **jacTimesSeed=NULL;103 double **seed=NULL;104 double *theOutput=NULL;105 std::set<unsigned int> anIndexSet;106 107 108 /*retrieve directions:*/109 if (strcmp(driver,"fov_forward_all")==0){110 tangentDirNum=num_independents;111 indepIndices=xNewZeroInit<int>(tangentDirNum);112 for(i=0;i<num_independents;i++)indepIndices[i]=1;113 }114 else{115 parameters->FindParam(&indepIndices,&tangentDirNum,&dummy,AutodiffFovForwardIndicesEnum);116 }117 118 /*Some checks: */119 if (tangentDirNum<1 || tangentDirNum>num_independents) _error_("tangentDirNum should be in [1,num_independents]");120 121 /* full Jacobian or Jacobian projection:*/122 jacTimesSeed=xNew<double>(num_dependents,tangentDirNum);123 124 /*set the forward method function pointers: */125 anEDF_for_solverx_p->fov_forward=EDF_fov_forward_for_solverx;126 // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx;127 128 /*allocate the space for the parameters to invoke EDF fov_forward:*/129 anEDF_for_solverx_p->dpp_X=xNew<double>(anEDF_for_solverx_p->max_n, tangentDirNum);130 anEDF_for_solverx_p->dpp_Y=xNew<double>(anEDF_for_solverx_p->max_m, tangentDirNum);131 132 /*seed matrix: */133 seed=xNewZeroInit<double>(num_independents,tangentDirNum);134 135 /*collect indices in a set to prevent accidental duplicates as long as we don't do compression:*/136 for (int i=0; i<tangentDirNum; ++i) {137 /* make sure the index is in range*/138 if (indepIndices[i]>num_independents) {139 _error_("indepIndices values must be in [0,num_independents-1]");140 }141 if (anIndexSet.find(indepIndices[i])!=anIndexSet.end()) {142 _error_("duplicate indepIndices values are not allowed until we implement Jacobian decompression");143 }144 anIndexSet.insert(indepIndices[i]);145 /* now populate the seed matrix from the set of independent indices;146 * simple setup with a single 1.0 per column and at most a single 1.0 per row*/147 seed[indepIndices[i]][i]=1.0;148 }149 150 /*allocate output: */151 theOutput=xNew<double>(num_dependents);152 153 /*call driver: */154 fov_forward(1,num_dependents,num_independents, tangentDirNum, xp, seed, theOutput, jacTimesSeed );155 /*Free resources: */156 xDelete(theOutput);157 xDelete(indepIndices);158 xDelete(seed);159 160 /*add to results: */161 results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,*jacTimesSeed,num_dependents*tangentDirNum,1,1,0.0));162 163 /*Free resources: */164 xDelete(jacTimesSeed);165 xDelete(indepIndices);166 }167 else if (strcmp(driver,"fos_reverse")==0) {168 169 int aDepIndex=0;170 double *aWeightVector=NULL;171 double *weightVectorTimesJac=NULL;172 173 /*retrieve direction index: */174 parameters->FindParam(&aDepIndex,AutodiffFosReverseIndexEnum);175 176 if (aDepIndex<0 || aDepIndex>=num_dependents) _error_("index value for AutodiffFosReverseIndexEnum should be in [0,num_dependents-1]");177 178 aWeightVector=xNewZeroInit<double>(num_dependents);179 aWeightVector[aDepIndex]=1.0;180 181 weightVectorTimesJac=xNew<double>(num_independents);182 183 /*set the forward method function pointer: */184 anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx;185 186 /*allocate the space for the parameters to invoke the EDF fos_reverse :*/187 anEDF_for_solverx_p->dp_U=xNew<double>(anEDF_for_solverx_p->max_m);188 anEDF_for_solverx_p->dp_Z=xNew<double>(anEDF_for_solverx_p->max_n);189 190 /*call driver: */191 fos_reverse(1,num_dependents,num_independents, aWeightVector, weightVectorTimesJac );192 193 /*add to results*/194 results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,weightVectorTimesJac,num_independents,1,1,0.0));195 196 /*free resources :*/197 xDelete(weightVectorTimesJac);198 xDelete(aWeightVector);199 }200 else if ((strcmp(driver,"fov_reverse")==0) || (strcmp(driver,"fov_reverse_all")==0)){201 202 int* depIndices=NULL;203 int weightNum;204 int dummy;205 double **weightsTimesJac=NULL;206 double **weights=NULL;207 std::set<unsigned int> anIndexSet;208 209 210 /*retrieve directions:*/211 if (strcmp(driver,"fov_reverse_all")==0){212 weightNum=num_dependents;213 depIndices=xNewZeroInit<int>(weightNum);214 for(i=0;i<num_dependents;i++)depIndices[i]=1;215 }216 else{217 parameters->FindParam(&depIndices,&weightNum,&dummy,AutodiffFovForwardIndicesEnum);218 }219 220 /*Some checks: */221 if (weightNum<1 || weightNum>num_dependents) _error_("tangentDirNum should be in [1,num_dependents]");222 223 /* full Jacobian or Jacobian projection:*/224 weightsTimesJac=xNew<double>(weightNum,num_independents);225 226 /*set the forward method function pointers: */227 anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx;228 229 /*allocate the space for the parameters to invoke the EDF fos_reverse :*/230 anEDF_for_solverx_p->dpp_U=xNew<double>(weightNum,anEDF_for_solverx_p->max_m);231 anEDF_for_solverx_p->dpp_Z=xNew<double>(weightNum,anEDF_for_solverx_p->max_n);232 233 /*seed matrix: */234 weights=xNewZeroInit<double>(weightNum,num_dependents);235 236 /*collect indices in a set to prevent accidental duplicates as long as we don't do compression:*/237 for (int i=0; i<weightNum; ++i) {238 /* make sure the index is in range*/239 if (depIndices[i]>num_dependents) {240 _error_("depIndices values must be in [0,num_dependents-1]");241 }242 if (anIndexSet.find(depIndices[i])!=anIndexSet.end()) {243 _error_("duplicate depIndices values are not allowed until we implement Jacobian decompression");244 }245 anIndexSet.insert(depIndices[i]);246 /* now populate the seed matrix from the set of independent indices;247 * simple setup with a single 1.0 per column and at most a single 1.0 per row*/248 weights[depIndices[i]][i]=1.0;249 }250 251 /*call driver: */252 fov_reverse(1,num_dependents,num_independents, weightNum, weights, weightsTimesJac );253 254 /*add to results: */255 results->AddObject(new GenericExternalResult<IssmPDouble*>(results->Size()+1,AutodiffJacobianEnum,*weightsTimesJac,weightNum*num_independents,1,1,0.0));256 257 /*Free resources: */258 xDelete(weights);259 xDelete(weightsTimesJac);260 xDelete(depIndices);261 }262 else _error_("driver: " << driver << " not yet supported!");263 264 /* delete the allocated space for the parameters:*/265 xDelete(anEDF_for_solverx_p->dp_x);266 xDelete(anEDF_for_solverx_p->dp_X);267 xDelete(anEDF_for_solverx_p->dpp_X);268 xDelete(anEDF_for_solverx_p->dp_y);269 xDelete(anEDF_for_solverx_p->dp_Y);270 xDelete(anEDF_for_solverx_p->dpp_Y);271 xDelete(anEDF_for_solverx_p->dp_U);272 xDelete(anEDF_for_solverx_p->dpp_U);273 xDelete(anEDF_for_solverx_p->dp_Z);274 xDelete(anEDF_for_solverx_p->dpp_Z);275 276 /*Free resources: */277 xDelete(xp);278 xDelete(axp);279 280 if(VerboseAutodiff())_pprintLine_(" end AD driver");281 282 #else283 _error_("Should not be requesting AD drivers when an AD library is not available!");284 #endif285 }286 } -
../trunk-jpl/src/c/modules/AutodiffDriversx/AutodiffDriversx.h
1 /*!\file: AutodiffDriversx.h2 * \brief header file for requesting AD results (gradient, jacobian, etc ...)3 */4 5 #ifndef _AUTODIFF_DRIVERSX_H_6 #define _AUTODIFF_DRIVERSX_H_7 8 #include "../../Container/Container.h"9 10 /* local prototypes: */11 void AutodiffDriversx(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,Results* results);12 13 #endif /* _AUTODIFF_DRIVERSX_H_*/ -
../trunk-jpl/src/c/modules/modules.h
7 7 8 8 /*Modules: */ 9 9 #include "./AddExternalResultx/AddExternalResultx.h" 10 #include "./AutodiffDriversx/AutodiffDriversx.h"11 10 #include "./AverageFilterx/AverageFilterx.h" 12 11 #include "./AverageOntoPartitionx/AverageOntoPartitionx.h" 13 12 #include "./Bamgx/Bamgx.h" -
../trunk-jpl/src/c/Makefile.am
326 326 ./modules/RequestedOutputsx/RequestedOutputsx.cpp\ 327 327 ./modules/RequestedDependentsx/RequestedDependentsx.h\ 328 328 ./modules/RequestedDependentsx/RequestedDependentsx.cpp\ 329 ./modules/AutodiffDriversx/AutodiffDriversx.h\330 ./modules/AutodiffDriversx/AutodiffDriversx.cpp\331 329 ./modules/ResetConstraintsx/ResetConstraintsx.h\ 332 330 ./modules/ResetConstraintsx/ResetConstraintsx.cpp\ 333 331 ./modules/ResetCoordinateSystemx/ResetCoordinateSystemx.h\ … … 349 347 ./solutions/ResetBoundaryConditions.cpp\ 350 348 ./solutions/AnalysisConfiguration.cpp\ 351 349 ./solutions/CorePointerFromSolutionEnum.cpp\ 350 ./solutions/PureCorePointerFromSolutionEnum.cpp\ 352 351 ./solutions/EnvironmentInit.cpp\ 353 352 ./solutions/EnvironmentFinalize.cpp\ 353 ./solutions/ad_core.cpp\ 354 354 ./solvers/solver_linear.cpp\ 355 355 ./solvers/solver_nonlinear.cpp\ 356 356 ./solvers/solver_newton.cpp\ -
../trunk-jpl/src/c/classes/objects/Profiler.cpp
16 16 /*FUNCTION Profiler::Profiler() default constructor {{{*/ 17 17 Profiler::Profiler(){ 18 18 this->time=new Parameters(); 19 this->flops=new Parameters(); 20 this->memory=new Parameters(); 19 21 } 20 22 /*}}}*/ 21 23 /*FUNCTION Profiler::~Profiler(){{{*/ -
../trunk-jpl/src/c/classes/objects/Profiler.h
20 20 FinishInit, 21 21 StartCore, 22 22 FinishCore, 23 StartAdCore, 24 FinishAdCore, 23 25 Finish 24 26 }; 25 27
Note:
See TracBrowser
for help on using the repository browser.