Changeset 4052


Ignore:
Timestamp:
06/17/10 11:10:12 (15 years ago)
Author:
Eric.Larour
Message:

Some renaming of routines.
extensive changes to control_core.

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  
    4141        double* J=NULL;
    4242
    43         /*Process models*/
    44         ControlInitialization(femmodel);
     43        /*some preliminary work to be done if running full-Stokes analysis: */
     44        stokescontrolinit(femmodel);
    4545
    46         /*Recover parameters used throughout the solution:*/
     46        /*Recover parameters used throughout the solution:{{{1*/
    4747        femmodel->parameters->FindParam(&nsteps,NStepsEnum);
    4848        femmodel->parameters->FindParam(&control_type,ControlTypeEnum);
     
    5757        femmodel->parameters->FindParam(&cm_gradient,CmGradientEnum);
    5858        femmodel->parameters->FindParam(&control_steady,ControlSteadyEnum);
     59        /*}}}*/
    5960
    6061        /*Initialize misfit: */
     
    6970
    7071                _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);
    7273               
    7374                /*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);
    7576       
    76                 if(verbose)_printf_("%s\n","      computing gradJ...");
     77                _printf_("%s\n","      computing gradJ...");
    7778                gradient_core(femmodel);
    7879
    7980                /*Return gradient if asked: */
    8081                if (cm_gradient){
    81                         InputToResultx(femodel->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);
    8283                        goto cleanup_and_return;
    8384                }
     
    9192
    9293                _printf_("%s","      constraining the new distribution...");   
    93                 ControlConstrainx(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);
    9495               
    9596                _printf_("%s","      save new parameter...");
     
    9899                _printf_("%s%i%s%g\n","      value of misfit J after optimization #",n+1,": ",J[n]);
    99100               
    100                 if(controlconvergence)goto cleanup_and_return;
     101                if(controlconvergence(J,fit,eps_cm,n))goto convergence_point;
    101102
    102103                /*Temporary saving every 5 control steps: */
    103104                if (((n+1)%5)==0){
    104105                        _printf_("%s","      saving temporary results...");
    105                         ControlRestart(femmodel);
     106                        controlrestart(femmodel);
    106107                }
    107108        }
    108109
     110
     111        convergence_point:
    109112        _printf_("%s","      preparing final velocity solution");
    110113        if (control_steady) steadystate_core(femmodel);
     
    113116        /*some results not computed by steadystate_core or diagnostic_core: */
    114117        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));
    117120
    118121        cleanup_and_return:
    119        
    120122        /*Free ressources: */
    121123        xfree((void**)&control_type);
  • TabularUnified issm/trunk/src/c/solutions/diagnostic_core.cpp

    r4047 r4052  
    2323        double stokesreconditioning;
    2424
    25         /* recover parameters: */
     25        /* recover parameters: {{{1*/
    2626        femmodel->parameters->FindParam(&verbose,VerboseEnum);
    2727        femmodel->parameters->FindParam(&dim,DimEnum);
     
    3131        femmodel->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum);
    3232        femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
     33        /*}}}*/
    3334
    3435        /*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  
    5454
    5555        /*Constrain:*/
    56         ControlConstrainx(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);
    5757
    5858        /*Run diagnostic with updated inputs: */
  • TabularUnified issm/trunk/src/c/solutions/solutions.h

    r4048 r4052  
    1313
    1414/*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);
     15Results* prognostic_core(FemModel* femmodel);
     16Results* prognostic2_core(FemModel* femmodel);
     17Results* balancedthickness_core(FemModel* femmodel);
     18Results* balancedthickness2_core(FemModel* femmodel);
     19Results* balancedvelocities_core(FemModel* femmodel);
     20Results* slopecompute_core(FemModel* femmodel);
     21Results* steadystate_core(FemModel* femmodel);
     22Results* transient_core(FemModel* femmodel);
     23Results* transient_core_2d(FemModel* femmodel);
     24Results* transient_core_3d(FemModel* femmodel);
     25void adjoint_core(FemModel* femmodel);
     26void gradient_core(FemModel* femmodel,int step=0, double search_scalar=0);
     27void diagnostic_core(FemModel* femmodel);
     28void thermal_core(FemModel* femmodel);
     29void surfaceslope_core(FemModel* femfemmodel);
     30void bedslope_core(FemModel* femfemmodel);
     31void control_core(FemModel* femmodel);
    3232
    3333//int GradJOrth(WorkspaceParams* workspaceparams);
     
    3535int controlconvergence(double* J, double* fit, double eps_cm, int n);
    3636
    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* femmodel);
     37int 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);
    3838
    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* femmodel);
     39int 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);
    4040       
    4141double objectivefunctionC(double search_scalar,OptArgs* optargs);
    4242
    43 int GradJSearch(double* search_vector,FemModel* femmodel,int step);
     43int GradJSearch(double* search_vector,FemModel* femfemmodel,int step);
    4444//int GradJCheck(WorkspaceParams* workspaceparams,int step,int status);
    4545
     
    4747void WriteLockFile(char* filename);
    4848
    49 void ControlInitialization(FemModel* model);
    50 void ControlRestart(FemModel* femmodel);
     49void stokescontrolinit(FemModel* femfemmodel);
     50void controlrestart(FemModel* femfemmodel);
    5151
    52 void CreateFemModel(FemModel* femmodel,ConstDataHandle MODEL,int analysis_type,int sub_analysis_type);
    53 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femmodel,char* filename);
    54 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type, int sub_analysis_type);
     52void CreateFemModel(FemModel* femfemmodel,ConstDataHandle MODEL,int analysis_type,int sub_analysis_type);
     53//int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femfemmodel,char* filename);
     54void ResetBoundaryConditions(FemModel* femfemmodel, int analysis_type, int sub_analysis_type);
    5555
    5656#endif
Note: See TracChangeset for help on using the changeset viewer.