Changeset 4353


Ignore:
Timestamp:
06/30/10 14:17:09 (15 years ago)
Author:
Mathieu Morlighem
Message:

fixing control methods

Location:
issm/trunk/src/c
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk/src/c/objects/Elements/Penta.cpp

    r4350 r4353  
    290290/*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{1*/
    291291void  Penta::InputUpdateFromConstant(bool constant, int name){
    292         /*Nothing updated for now*/
     292
     293        /*Check that name is an element input*/
     294        if (!IsInput(name)) return;
     295
     296        /*update input*/
     297        this->inputs->AddInput(new BoolInput(name,constant));
    293298}
    294299/*}}}*/
    295300/*FUNCTION Penta::InputUpdateFromConstant(double value, int name);{{{1*/
    296301void  Penta::InputUpdateFromConstant(double constant, int name){
    297         /*Nothing updated for now*/
     302        /*Check that name is an element input*/
     303        if (!IsInput(name)) return;
     304
     305        /*update input*/
     306        this->inputs->AddInput(new DoubleInput(name,constant));
    298307}
    299308/*}}}*/
    300309/*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{1*/
    301310void  Penta::InputUpdateFromConstant(int constant, int name){
    302         /*Nothing updated for now*/
     311        /*Check that name is an element input*/
     312        if (!IsInput(name)) return;
     313
     314        /*update input*/
     315        this->inputs->AddInput(new IntInput(name,constant));
    303316}
    304317/*}}}*/
     
    22472260/*FUNCTION Penta::IsInput{{{1*/
    22482261bool Penta::IsInput(int name){
    2249         if (name==ThicknessEnum ||
     2262        if (
     2263                                name==ThicknessEnum ||
    22502264                                name==SurfaceEnum ||
    22512265                                name==BedEnum ||
     
    22622276                                name==TemperatureAverageEnum ||
    22632277                                name==RheologyBEnum ||
    2264                                 name==RheologyNEnum) {
     2278                                name==RheologyNEnum ||
     2279                                name==FitEnum
     2280                                ) {
    22652281                return true;
    22662282        }
  • TabularUnified issm/trunk/src/c/objects/Elements/Tria.cpp

    r4350 r4353  
    302302/*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{1*/
    303303void  Tria::InputUpdateFromConstant(int constant, int name){
    304         /*Nothing updated for now*/
     304        /*Check that name is an element input*/
     305        if (!IsInput(name)) return;
     306
     307        /*update input*/
     308        this->inputs->AddInput(new IntInput(name,constant));
    305309}
    306310/*}}}*/
    307311/*FUNCTION Tria::InputUpdateFromConstant(double value, int name);{{{1*/
    308312void  Tria::InputUpdateFromConstant(double constant, int name){
    309         /*Nothing updated for now*/
     313        /*Check that name is an element input*/
     314        if (!IsInput(name)) return;
     315
     316        /*update input*/
     317        this->inputs->AddInput(new DoubleInput(name,constant));
    310318}
    311319/*}}}*/
    312320/*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{1*/
    313321void  Tria::InputUpdateFromConstant(bool constant, int name){
    314         /*Nothing updated for now*/
     322        /*Check that name is an element input*/
     323        if (!IsInput(name)) return;
     324
     325        /*update input*/
     326        this->inputs->AddInput(new BoolInput(name,constant));
    315327}
    316328/*}}}*/
     
    329341        else if (analysis_type==DiagnosticHorizAnalysisEnum){
    330342                InputUpdateFromSolutionDiagnosticHoriz( solution);
     343        }
     344        else if (analysis_type==AdjointAnalysisEnum){
     345                InputUpdateFromSolutionAdjoint( solution);
    331346        }
    332347        else if (analysis_type==BedSlopeAnalysisEnum || analysis_type==SurfaceSlopeAnalysisEnum){
     
    721736        double scale=0;
    722737        double S=0;
    723         double fit=-1;
     738        int    fit=-1;
    724739
    725740        /*retrieve some parameters: */
     
    18871902        double scaley=1;
    18881903        double S=0;
    1889         double fit=-1;
     1904        int    fit=-1;
    18901905
    18911906        /*inputs: */
     
    21202135        /*inputs: */
    21212136        bool onwater;
    2122         int  fit;
     2137        int fit;
    21232138
    21242139        /*retrieve inputs :*/
     
    53195334}
    53205335/*}}}*/
     5336/*FUNCTION Tria::InputUpdateFromSolutionAdjoint {{{1*/
     5337void  Tria::InputUpdateFromSolutionAdjoint(double* solution){
     5338
     5339        int i;
     5340
     5341        const int    numvertices=3;
     5342        const int    numdofpervertex=2;
     5343        const int    numdof=numdofpervertex*numvertices;
     5344
     5345        int          doflist[numdof];
     5346        double       values[numdof];
     5347        double       lambdax[numvertices];
     5348        double       lambday[numvertices];
     5349
     5350        int          dummy;
     5351
     5352        /*Get dof list: */
     5353        GetDofList(&doflist[0],&dummy);
     5354
     5355        /*Use the dof list to index into the solution vector: */
     5356        for(i=0;i<numdof;i++){
     5357                values[i]=solution[doflist[i]];
     5358        }
     5359
     5360        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     5361        for(i=0;i<numvertices;i++){
     5362                lambdax[i]=values[i*numdofpervertex+0];
     5363                lambday[i]=values[i*numdofpervertex+1];
     5364        }
     5365
     5366        /*Add vx and vy as inputs to the tria element: */
     5367        this->inputs->AddInput(new TriaVertexInput(AdjointxEnum,lambdax));
     5368        this->inputs->AddInput(new TriaVertexInput(AdjointyEnum,lambday));
     5369
     5370}
     5371/*}}}*/
    53215372/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{1*/
    53225373void  Tria::InputUpdateFromSolutionDiagnosticHoriz(double* solution){
     
    54735524/*FUNCTION Tria::IsInput{{{1*/
    54745525bool Tria::IsInput(int name){
    5475         if (name==SurfaceSlopeXEnum ||
    5476                                 name==SurfaceSlopeYEnum){
     5526        if (
     5527                                name==SurfaceSlopeXEnum ||
     5528                                name==SurfaceSlopeYEnum ||
     5529                                name==FitEnum
     5530                ){
    54775531                return true;
    54785532        }
  • TabularUnified issm/trunk/src/c/objects/Elements/Tria.h

    r4285 r4353  
    152152                void      GetSolutionFromInputsDiagnosticHoriz(Vec solution);
    153153                void      GradjDragStokes(Vec gradient);
     154                void      InputUpdateFromSolutionAdjoint( double* solution);
    154155                void      InputUpdateFromSolutionDiagnosticHoriz( double* solution);
    155156                void      InputUpdateFromSolutionSlopeCompute( double* solution);
  • TabularUnified issm/trunk/src/c/objects/Inputs/IntInput.cpp

    r4248 r4353  
    191191/*}}}*/
    192192/*FUNCTION IntInput::GetParameterValue(double* pvalue){{{1*/
    193 void IntInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");}
     193void IntInput::GetParameterValue(double* pvalue){
     194        ISSMERROR("IntInput cannot return a double in parallel");
     195}
    194196/*}}}*/
    195197/*FUNCTION IntInput::GetParameterValue(double* pvalue,Node* node){{{1*/
  • TabularUnified issm/trunk/src/c/shared/Exceptions/Exceptions.cpp

    r3787 r4353  
    4242        else{
    4343                #ifdef _PARALLEL_
    44                         printf("\n[%i] %s%s%s%i\n",my_rank,"??? Error using ==> ",file_name.c_str()," at ",file_line);
    45                         printf("[%i] %s%s%s\n\n",my_rank,function_name.c_str()," error message: ",what());
     44                        printf("\n[%i] ??? Error using ==> %s:%i\n",my_rank,file_name.c_str(),file_line);
     45                        printf("[%i] %s error message: %s\n\n",my_rank,function_name.c_str(),what());
    4646                #else
    47                         printf("\n%s%s%s%i\n","??? Error using ==> ",file_name.c_str()," at ",file_line);
    48                         printf("%s%s%s\n\n",function_name.c_str()," error message: ",what());
     47                        printf("\n??? Error using ==> %s at %i\n",file_name.c_str(),file_line);
     48                        printf("%s error message: %s\n\n",function_name.c_str(),what());
    4949                #endif
    5050        }
  • TabularUnified issm/trunk/src/c/solutions/adjoint_core.cpp

    r4331 r4353  
    1111#include "../include/include.h"
    1212#include "../solvers/solvers.h"
    13 
    1413
    1514void adjoint_core(FemModel* femmodel){
  • TabularUnified issm/trunk/src/c/solutions/control_core.cpp

    r4285 r4353  
    1919        int     verbose=0;
    2020        int     control_type;
    21         int     control_steady;
     21        bool    control_steady;
    2222        int     nsteps;
    2323        double  eps_cm;
     
    2525        double  cm_min;
    2626        double  cm_max;
    27         int     cm_gradient;
     27        bool    cm_gradient;
    2828        int     dim;
    2929
     
    4848        femmodel->parameters->FindParam(&nsteps,NStepsEnum);
    4949        femmodel->parameters->FindParam(&control_type,ControlTypeEnum);
    50         femmodel->parameters->FindParam(&fit,NULL,NULL,FitEnum);
    51         femmodel->parameters->FindParam(&optscal,NULL,NULL,OptScalEnum);
    52         femmodel->parameters->FindParam(&maxiter,NULL,NULL,MaxIterEnum);
    53         femmodel->parameters->FindParam(&cm_jump,NULL,NULL,CmJumpEnum);
     50        femmodel->parameters->FindParam(&fit,NULL,FitEnum);
     51        femmodel->parameters->FindParam(&optscal,NULL,OptScalEnum);
     52        femmodel->parameters->FindParam(&maxiter,NULL,MaxIterEnum);
     53        femmodel->parameters->FindParam(&cm_jump,NULL,CmJumpEnum);
    5454        femmodel->parameters->FindParam(&eps_cm,EpsCmEnum);
    5555        femmodel->parameters->FindParam(&tolx,TolXEnum);
     
    7272
    7373                _printf_("\n%s%i%s%i\n","   control method step ",n+1,"/",nsteps);
    74                 InputUpdateFromConstantx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,fit[n],FitEnum);
     74                InputUpdateFromConstantx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,(int)fit[n],FitEnum);
    7575               
    7676                /*In case we are running a steady state control method, compute new temperature field using new parameter * distribution: */
  • TabularUnified issm/trunk/src/c/solutions/gradient_core.cpp

    r4091 r4353  
    1616       
    1717        /*parameters: */
    18         int control_steady;
     18        bool control_steady;
    1919        int control_type;
    2020        int verbose;
  • TabularUnified issm/trunk/src/c/solutions/objectivefunctionC.cpp

    r4079 r4353  
    3636        int     control_type;
    3737        int     analysis_type;
    38         int     control_steady;
     38        bool    control_steady;
    3939        bool    conserve_loads=true;
    4040       
     
    4545        n=optargs->n;
    4646
    47         femmodel->parameters->FindParam(&optscal,NULL,NULL,OptScalEnum);
    48         femmodel->parameters->FindParam(&fit,NULL,NULL,FitEnum);
     47        femmodel->parameters->FindParam(&optscal,NULL,OptScalEnum);
     48        femmodel->parameters->FindParam(&fit,NULL,FitEnum);
    4949        femmodel->parameters->FindParam(&cm_min,CmMinEnum);
    5050        femmodel->parameters->FindParam(&cm_max,CmMaxEnum);
Note: See TracChangeset for help on using the changeset viewer.