Changeset 4052
- Timestamp:
- 06/17/10 11:10:12 (15 years ago)
- Location:
- issm/trunk/src/c/solutions
- Files:
-
- 2 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk/src/c/solutions/control_core.cpp ¶
r4048 r4052 41 41 double* J=NULL; 42 42 43 /* Process models*/44 ControlInitialization(femmodel);43 /*some preliminary work to be done if running full-Stokes analysis: */ 44 stokescontrolinit(femmodel); 45 45 46 /*Recover parameters used throughout the solution: */46 /*Recover parameters used throughout the solution:{{{1*/ 47 47 femmodel->parameters->FindParam(&nsteps,NStepsEnum); 48 48 femmodel->parameters->FindParam(&control_type,ControlTypeEnum); … … 57 57 femmodel->parameters->FindParam(&cm_gradient,CmGradientEnum); 58 58 femmodel->parameters->FindParam(&control_steady,ControlSteadyEnum); 59 /*}}}*/ 59 60 60 61 /*Initialize misfit: */ … … 69 70 70 71 _printf_("\n%s%i%s%i\n"," control method step ",n+1,"/",nsteps); 71 femmodel->UpdateInputsFromConstant(fit[n],FitEnum);72 UpdateInputsFromConstantx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,fit[n],FitEnum); 72 73 73 74 /*In case we are running a steady state control method, compute new temperature field using new parameter * distribution: */ 74 if (control_steady) steadystate_core( model);75 if (control_steady) steadystate_core(femmodel); 75 76 76 if(verbose)_printf_("%s\n"," computing gradJ...");77 _printf_("%s\n"," computing gradJ..."); 77 78 gradient_core(femmodel); 78 79 79 80 /*Return gradient if asked: */ 80 81 if (cm_gradient){ 81 InputToResultx(fem odel->elements,femodel->nodes,femodel->vertices,femodel->loads,femodel->materials,femodel->parameters,GradientEnum);82 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,GradientEnum); 82 83 goto cleanup_and_return; 83 84 } … … 91 92 92 93 _printf_("%s"," constraining the new distribution..."); 93 ControlConstrain x(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type,cm_min,cm_max);94 ControlConstrainInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type,cm_min,cm_max); 94 95 95 96 _printf_("%s"," save new parameter..."); … … 98 99 _printf_("%s%i%s%g\n"," value of misfit J after optimization #",n+1,": ",J[n]); 99 100 100 if(controlconvergence )goto cleanup_and_return;101 if(controlconvergence(J,fit,eps_cm,n))goto convergence_point; 101 102 102 103 /*Temporary saving every 5 control steps: */ 103 104 if (((n+1)%5)==0){ 104 105 _printf_("%s"," saving temporary results..."); 105 ControlRestart(femmodel);106 controlrestart(femmodel); 106 107 } 107 108 } 108 109 110 111 convergence_point: 109 112 _printf_("%s"," preparing final velocity solution"); 110 113 if (control_steady) steadystate_core(femmodel); … … 113 116 /*some results not computed by steadystate_core or diagnostic_core: */ 114 117 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type); //the parameter itself! 115 femmodel-> otherresults->AddObject(new DoubleResult(femmodel->otherresults->Size()+1,0,1,"J",J,nsteps));116 femmodel-> otherresults->AddObject(new StringResult(results->Size()+1,ControlTypeEnum,0,1,EnumAsString(control_type)));118 femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0)); 119 femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumAsString(control_type),1,0)); 117 120 118 121 cleanup_and_return: 119 120 122 /*Free ressources: */ 121 123 xfree((void**)&control_type); -
TabularUnified issm/trunk/src/c/solutions/diagnostic_core.cpp ¶
r4047 r4052 23 23 double stokesreconditioning; 24 24 25 /* recover parameters: */25 /* recover parameters: {{{1*/ 26 26 femmodel->parameters->FindParam(&verbose,VerboseEnum); 27 27 femmodel->parameters->FindParam(&dim,DimEnum); … … 31 31 femmodel->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 32 32 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); 33 /*}}}*/ 33 34 34 35 /*for qmu analysis, reinitialize velocity so that fake sensitivities do not show up as a result of a different restart of the convergence at each trial.*/ -
TabularUnified issm/trunk/src/c/solutions/objectivefunctionC.cpp ¶
r4048 r4052 54 54 55 55 /*Constrain:*/ 56 ControlConstrain x(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type,cm_min,cm_max);56 ControlConstrainInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type,cm_min,cm_max); 57 57 58 58 /*Run diagnostic with updated inputs: */ -
TabularUnified issm/trunk/src/c/solutions/solutions.h ¶
r4048 r4052 13 13 14 14 /*cores: */ 15 Results* prognostic_core(FemModel* model);16 Results* prognostic2_core(FemModel* model);17 Results* balancedthickness_core(FemModel* model);18 Results* balancedthickness2_core(FemModel* model);19 Results* balancedvelocities_core(FemModel* model);20 Results* slopecompute_core(FemModel* model);21 Results* control_core(FemModel*model);22 Results* steadystate_core(FemModel*model);23 Results* transient_core (FemModel*model);24 Results* transient_core_ 2d(FemModel*model);25 Results* transient_core_3d(FemModel*model);26 void adjoint_core(FemModel* model);27 void gradient_core(FemModel* model,int step=0, double search_scalar=0);28 void diagnostic_core(FemModel*model);29 void thermal_core(FemModel*model);30 void surfaceslope_core(FemModel*femmodel);31 void bedslope_core(FemModel* femmodel);15 Results* prognostic_core(FemModel* femmodel); 16 Results* prognostic2_core(FemModel* femmodel); 17 Results* balancedthickness_core(FemModel* femmodel); 18 Results* balancedthickness2_core(FemModel* femmodel); 19 Results* balancedvelocities_core(FemModel* femmodel); 20 Results* slopecompute_core(FemModel* femmodel); 21 Results* steadystate_core(FemModel* femmodel); 22 Results* transient_core(FemModel* femmodel); 23 Results* transient_core_2d(FemModel* femmodel); 24 Results* transient_core_3d(FemModel* femmodel); 25 void adjoint_core(FemModel* femmodel); 26 void gradient_core(FemModel* femmodel,int step=0, double search_scalar=0); 27 void diagnostic_core(FemModel* femmodel); 28 void thermal_core(FemModel* femmodel); 29 void surfaceslope_core(FemModel* femfemmodel); 30 void bedslope_core(FemModel* femfemmodel); 31 void control_core(FemModel* femmodel); 32 32 33 33 //int GradJOrth(WorkspaceParams* workspaceparams); … … 35 35 int controlconvergence(double* J, double* fit, double eps_cm, int n); 36 36 37 int GoldenSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* fem model);37 int GoldenSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femfemmodel); 38 38 39 int BrentSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* fem model);39 int BrentSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femfemmodel); 40 40 41 41 double objectivefunctionC(double search_scalar,OptArgs* optargs); 42 42 43 int GradJSearch(double* search_vector,FemModel* fem model,int step);43 int GradJSearch(double* search_vector,FemModel* femfemmodel,int step); 44 44 //int GradJCheck(WorkspaceParams* workspaceparams,int step,int status); 45 45 … … 47 47 void WriteLockFile(char* filename); 48 48 49 void ControlInitialization(FemModel*model);50 void ControlRestart(FemModel*femmodel);49 void stokescontrolinit(FemModel* femfemmodel); 50 void controlrestart(FemModel* femfemmodel); 51 51 52 void CreateFemModel(FemModel* fem model,ConstDataHandle MODEL,int analysis_type,int sub_analysis_type);53 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* fem model,char* filename);54 void ResetBoundaryConditions(FemModel* fem model, int analysis_type, int sub_analysis_type);52 void CreateFemModel(FemModel* femfemmodel,ConstDataHandle MODEL,int analysis_type,int sub_analysis_type); 53 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femfemmodel,char* filename); 54 void ResetBoundaryConditions(FemModel* femfemmodel, int analysis_type, int sub_analysis_type); 55 55 56 56 #endif
Note:
See TracChangeset
for help on using the changeset viewer.