Changeset 2892


Ignore:
Timestamp:
01/22/10 07:26:54 (15 years ago)
Author:
Eric.Larour
Message:

Added new solution type: control gradient. Can now retrieve control method gradient
and return, without computing whole control method solution.

Location:
issm/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Makefile.am

    r2865 r2892  
    308308                                        ./ProcessParamsx/ProcessParamsx.cpp\
    309309                                        ./ProcessParamsx/ProcessParamsx.h\
     310                                        ./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp\
     311                                        ./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h\
    310312                                        ./Qmux/Qmux.h\
    311313                                        ./Qmux/Qmux.cpp\
  • issm/trunk/src/c/ModelProcessorx/Control/CreateParametersControl.cpp

    r2383 r2892  
    2020        Param*   param = NULL;
    2121        int      count;
    22         int      analysis_type;
    23         int      numberofdofspernode;
    2422
    2523        double* fit=NULL;
     
    140138                param= new Param(count,"cm_max",DOUBLE);
    141139                param->SetDouble(iomodel->cm_max);
     140                parameters->AddObject(param);
     141
     142                /*cm_gradient: */
     143                count++;
     144                param= new Param(count,"cm_gradient",DOUBLE);
     145                param->SetDouble(iomodel->cm_gradient);
    142146                parameters->AddObject(param);
    143147
  • issm/trunk/src/c/ModelProcessorx/IoModel.cpp

    r2383 r2892  
    125125        iomodel->cm_min=0;
    126126        iomodel->cm_max=0;
     127        iomodel->cm_gradient=0;
    127128        iomodel->verbose=0;
    128129        iomodel->plot=0;
     
    353354        IoModelFetchData(&iomodel->cm_min,iomodel_handle,"cm_min");
    354355        IoModelFetchData(&iomodel->cm_max,iomodel_handle,"cm_max");
     356        IoModelFetchData(&iomodel->cm_gradient,iomodel_handle,"cm_gradient");
    355357        IoModelFetchData(&iomodel->eps_res,iomodel_handle,"eps_res");
    356358        IoModelFetchData(&iomodel->eps_rel,iomodel_handle,"eps_rel");
  • issm/trunk/src/c/ModelProcessorx/IoModel.h

    r2722 r2892  
    117117        double  cm_min;
    118118        double  cm_max;
     119        int     cm_gradient;;
    119120
    120121        double  cm_noisedampening;
  • issm/trunk/src/c/issm.h

    r2776 r2892  
    4949#include "./PenaltyConstraintsx/PenaltyConstraintsx.h"
    5050#include "./ProcessParamsx/ProcessParamsx.h"
     51#include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h"
    5152#include "./Gradjx/Gradjx.h"
    5253#include "./Orthx/Orthx.h"
  • issm/trunk/src/c/parallel/ProcessResults.cpp

    r2722 r2892  
    9090        double* m_g_serial=NULL;
    9191        double* melting=NULL;
     92
     93        Vec     grad_g=NULL;
     94        double* grad_g_serial=NULL;
     95        double* gradient=NULL;
    9296
    9397        Vec     v_g=NULL;
     
    286290                        VecFree(&t_g);
    287291                }
     292                else if(strcmp(result->GetFieldName(),"grad_g")==0){
     293                       
     294                        /*easy, grad_g is of size numberofnodes, on 1 dof, just repartition: */
     295                        result->GetField(&grad_g);
     296                        VecToMPISerial(&grad_g_serial,grad_g);
     297                        fem_c->parameters->FindParam(&numberofnodes,"numberofnodes");
     298                        VecToMPISerial(&partition,fem_c->partition->vector);
     299
     300                        gradient=(double*)xmalloc(numberofnodes*sizeof(double));
     301
     302                        for(i=0;i<numberofnodes;i++){
     303                                gradient[i]=grad_g_serial[(int)partition[i]];
     304                        }
     305
     306                        /*Ok, add gradient to newresults: */
     307                        newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"gradient",gradient,numberofnodes);
     308                        newresults->AddObject(newresult);
     309
     310                        /*do some cleanup: */
     311                        xfree((void**)&grad_g_serial);
     312                        xfree((void**)&partition);
     313                        xfree((void**)&gradient);
     314                        VecFree(&grad_g);
     315                }
    288316                else if(strcmp(result->GetFieldName(),"m_g")==0){
    289317                        /*easy, m_g is of size numberofnodes, on 1 dof, just repartition: */
  • issm/trunk/src/c/parallel/control_core.cpp

    r2773 r2892  
    4242        double  cm_min;
    4343        double  cm_max;
     44        int     cm_gradient;
    4445        int     nsteps,n,i;
    4546        double* J=NULL;
     
    7172        model->FindParam(&cm_min,"cm_min");
    7273        model->FindParam(&cm_max,"cm_max");
     74        model->FindParam(&cm_gradient,"cm_gradient");
    7375        model->FindParam(&param_g,NULL,NULL,"param_g");
    7476        model->FindParam(&analysis_type,"analysis_type");
     
    113115                gradjcompute_results->FindResult(&grad_g,"grad_g");
    114116                delete gradjcompute_results;
     117
     118                /*Return gradient if asked: */
     119                if (cm_gradient){
     120                       
     121                        /*Plug results into output dataset: */
     122                        result=new Result(results->Size()+1,0,1,"grad_g",grad_g);
     123                        results->AddObject(result);
     124               
     125                        /*Free ressources: */
     126                        xfree((void**)&control_type);
     127                        xfree((void**)&fit);
     128                        xfree((void**)&optscal);
     129                        xfree((void**)&maxiter);
     130                        xfree((void**)&cm_jump);
     131                        xfree((void**)&grad_g_double);
     132                        xfree((void**)&param_g);
     133                        VecFree(&u_g);
     134                        VecFree(&t_g);
     135                        VecFree(&m_g);
     136                        xfree((void**)&J);
     137                        return;
     138                }
    115139
    116140                /*Normalize if last gradient not satisfying (search_scalar==0)*/
  • issm/trunk/src/m/classes/@model/model.m

    r2547 r2892  
    198198        md.fit=[];
    199199        md.cm_jump=[];
     200        md.cm_gradient=0;
    200201        md.epsvel=0;
    201202        md.meanvel=0;
  • issm/trunk/src/m/classes/@model/setdefaultparameters.m

    r2547 r2892  
    204204md.cm_max=200;
    205205
     206%stop control solution at the gradient computation and return it?
     207md.cm_gradient=0;
     208
    206209%eps_cm is a criteria to stop the control methods.
    207210%if J[n]-J[n-1]/J[n] < criteria, the control run stops
  • issm/trunk/src/mex/Makefile.am

    r2775 r2892  
    3737                                PenaltySystemMatrices\
    3838                                ProcessParams\
     39                                PropagateFlagsFromConnectivity\
    3940                                Qmu\
    4041                                Reduceloadfromgtof\
     
    178179                          ProcessParams/ProcessParams.h
    179180
     181PropagateFlagsFromConnectivity_SOURCES = PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\
     182                          PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
     183
    180184Qmu_SOURCES = Qmu/Qmu.cpp\
    181185                          Qmu/Qmu.h
Note: See TracChangeset for help on using the changeset viewer.