Changeset 8129


Ignore:
Timestamp:
05/04/11 11:28:47 (14 years ago)
Author:
Mathieu Morlighem
Message:

Now cm_min and cm_max are of size md.numberofgrids x 1 -> very useful for BalanceThickness

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

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Container/DataSet.cpp

    r7692 r8129  
    123123         * because this is a nasty error: */
    124124        if (marshalled_dataset!=old_marshalled_dataset){
    125                 _error_("final marshalled dataset is different from initial one!");
     125                _error_("final marshalled dataset \"%s\" is different from initial one!",EnumToString(enum_type));
    126126                abort();
    127127        }
  • issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp

    r6226 r8129  
    4949                IoModelFetchData(&iomodel->cm_responses,NULL,NULL,iomodel_handle,"cm_responses");
    5050                IoModelFetchData(&iomodel->cm_jump,NULL,NULL,iomodel_handle,"cm_jump");
    51                 IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min");
    52                 IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max");
    5351                IoModelFetchData(&iomodel->optscal,NULL,NULL,iomodel_handle,"optscal");
    5452                IoModelFetchData(&iomodel->maxiter,NULL,NULL,iomodel_handle,"maxiter");
     
    5755                parameters->AddObject(new DoubleVecParam(CmJumpEnum,iomodel->cm_jump,iomodel->nsteps));
    5856                parameters->AddObject(new DoubleMatParam(OptScalEnum,iomodel->optscal,iomodel->nsteps,iomodel->num_control_type));
    59                 parameters->AddObject(new DoubleVecParam(CmMinEnum,iomodel->cm_min,iomodel->num_control_type));
    60                 parameters->AddObject(new DoubleVecParam(CmMaxEnum,iomodel->cm_max,iomodel->num_control_type));
    6157                parameters->AddObject(new DoubleVecParam(MaxIterEnum,iomodel->maxiter,iomodel->nsteps));
    6258
    6359                xfree((void**)&iomodel->cm_responses);
    6460                xfree((void**)&iomodel->cm_jump);
    65                 xfree((void**)&iomodel->cm_min);
    66                 xfree((void**)&iomodel->cm_max);
    6761                xfree((void**)&iomodel->optscal);
    6862                xfree((void**)&iomodel->maxiter);
  • issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp

    r6412 r8129  
    2828        IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type");
    2929        IoModelFetchData(&iomodel->weights,NULL,NULL,iomodel_handle,"weights");
     30        IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min");
     31        IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max");
    3032        IoModelFetchData(&iomodel->vx_obs,NULL,NULL,iomodel_handle,"vx_obs");
    3133        IoModelFetchData(&iomodel->vy_obs,NULL,NULL,iomodel_handle,"vy_obs");
     
    6971        xfree((void**)&iomodel->elements);
    7072        xfree((void**)&iomodel->weights);
     73        xfree((void**)&iomodel->cm_min);
     74        xfree((void**)&iomodel->cm_max);
    7175        xfree((void**)&iomodel->control_type);
    7276        xfree((void**)&iomodel->vx_obs);
  • issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp

    r7089 r8129  
    4242        IoModelFetchData(&iomodel->rheology_n,NULL,NULL,iomodel_handle,"rheology_n");
    4343        IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type");
     44        IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min");
     45        IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max");
    4446       
    4547        /*Create elements and materials: */
     
    6567        xfree((void**)&iomodel->rheology_n);
    6668        xfree((void**)&iomodel->control_type);
     69        xfree((void**)&iomodel->cm_min);
     70        xfree((void**)&iomodel->cm_max);
    6771
    6872        /*Add new constrant material property tgo materials, at the end: */
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r8120 r8129  
    37103710        int*   control_type=NULL;
    37113711        Input* input=NULL;
    3712         double *cm_min=NULL;
    3713         double *cm_max=NULL;
    37143712
    37153713        /*retrieve some parameters: */
    3716         this->parameters->FindParam(&cm_min,NULL,CmMinEnum);
    3717         this->parameters->FindParam(&cm_max,NULL,CmMaxEnum);
    37183714        this->parameters->FindParam(&num_controls,NumControlsEnum);
    37193715        this->parameters->FindParam(&control_type,NULL,ControlTypeEnum);
     
    37323728
    37333729                ((ControlInput*)input)->UpdateValue(scalar);
    3734                 input->Constrain(cm_min[i],cm_max[i]);
     3730                ((ControlInput*)input)->Constrain();
    37353731                if (save_parameter) ((ControlInput*)input)->SaveValue();
    37363732
     
    37423738        /*Clean up and return*/
    37433739        xfree((void**)&control_type);
    3744         xfree((void**)&cm_min);
    3745         xfree((void**)&cm_max);
    37463740}
    37473741/*}}}*/
     
    39703964        int     penta_vertex_ids[6];
    39713965        double  nodeinputs[6];
     3966        double  cmmininputs[6];
     3967        double  cmmaxinputs[6];
    39723968
    39733969        /*Checks if debuging*/
     
    40744070                                        if (iomodel->dhdt){
    40754071                                                for(j=0;j<6;j++)nodeinputs[j]=iomodel->dhdt[penta_vertex_ids[j]-1]/iomodel->yts;
    4076                                                 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs,i+1));
     4072                                                for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4073                                                for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4074                                                this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    40774075                                        }
    40784076                                        break;
     
    40804078                                        if (iomodel->vx){
    40814079                                                for(j=0;j<6;j++)nodeinputs[j]=iomodel->vx[penta_vertex_ids[j]-1]/iomodel->yts;
    4082                                                 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,i+1));
     4080                                                for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4081                                                for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4082                                                this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    40834083                                        }
    40844084                                        break;
     
    40864086                                        if (iomodel->vy){
    40874087                                                for(j=0;j<6;j++)nodeinputs[j]=iomodel->vy[penta_vertex_ids[j]-1]/iomodel->yts;
    4088                                                 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,i+1));
     4088                                                for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4089                                                for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     4090                                                this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    40894091                                        }
    40904092                                        break;
     
    40924094                                        if (iomodel->drag_coefficient){
    40934095                                                for(j=0;j<6;j++)nodeinputs[j]=iomodel->drag_coefficient[penta_vertex_ids[j]-1];
    4094                                                 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs,i+1));
     4096                                                for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i];
     4097                                                for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i];
     4098                                                this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    40954099                                        }
    40964100                                        break;
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r8073 r8129  
    36623662        int*   control_type=NULL;
    36633663        Input* input=NULL;
    3664         double *cm_min=NULL;
    3665         double *cm_max=NULL;
    36663664
    36673665        /*retrieve some parameters: */
    3668         this->parameters->FindParam(&cm_min,NULL,CmMinEnum);
    3669         this->parameters->FindParam(&cm_max,NULL,CmMaxEnum);
    36703666        this->parameters->FindParam(&num_controls,NumControlsEnum);
    36713667        this->parameters->FindParam(&control_type,NULL,ControlTypeEnum);
     
    36853681
    36863682                ((ControlInput*)input)->UpdateValue(scalar);
    3687                 input->Constrain(cm_min[i],cm_max[i]);
     3683                ((ControlInput*)input)->Constrain();
    36883684                if (save_parameter) ((ControlInput*)input)->SaveValue();
    36893685
     
    36923688        /*Clean up and return*/
    36933689        xfree((void**)&control_type);
    3694         xfree((void**)&cm_min);
    3695         xfree((void**)&cm_max);
    36963690}
    36973691/*}}}*/
     
    38273821        int    tria_vertex_ids[3];
    38283822        double nodeinputs[3];
     3823        double cmmininputs[3];
     3824        double cmmaxinputs[3];
    38293825
    38303826        /*Checks if debuging*/
     
    39523948                                        if (iomodel->dhdt){
    39533949                                                for(j=0;j<3;j++)nodeinputs[j]=iomodel->dhdt[tria_vertex_ids[j]-1]/iomodel->yts;
    3954                                                 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs,i+1));
     3950                                                for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3951                                                for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3952                                                this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    39553953                                        }
    39563954                                        break;
     
    39583956                                        if (iomodel->vx){
    39593957                                                for(j=0;j<3;j++)nodeinputs[j]=iomodel->vx[tria_vertex_ids[j]-1]/iomodel->yts;
    3960                                                 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,i+1));
     3958                                                for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3959                                                for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3960                                                this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    39613961                                        }
    39623962                                        break;
     
    39643964                                        if (iomodel->vy){
    39653965                                                for(j=0;j<3;j++)nodeinputs[j]=iomodel->vy[tria_vertex_ids[j]-1]/iomodel->yts;
    3966                                                 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,i+1));
     3966                                                for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3967                                                for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts;
     3968                                                this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    39673969                                        }
    39683970                                        break;
     
    39703972                                        if (iomodel->drag_coefficient){
    39713973                                                for(j=0;j<3;j++)nodeinputs[j]=iomodel->drag_coefficient[tria_vertex_ids[j]-1];
    3972                                                 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs,i+1));
     3974                                                for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i];
     3975                                                for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i];
     3976                                                this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    39733977                                        }
    39743978                                        break;
  • issm/trunk/src/c/objects/Inputs/BoolInput.h

    r6412 r8129  
    4141                Input* SpawnTriaInput(int* indices);
    4242                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
     43                Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
     44                Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4345                ElementResult* SpawnResult(int step, double time);
    4446                /*}}}*/
  • issm/trunk/src/c/objects/Inputs/ControlInput.cpp

    r6412 r8129  
    2323        values      = NULL;
    2424        savedvalues = NULL;
     25        minvalues   = NULL;
     26        maxvalues   = NULL;
    2527        gradient    = NULL;
    2628}
    2729/*}}}*/
    28 /*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues,int id){{{1*/
    29 ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues,int id){
     30/*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){{{1*/
     31ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){
    3032
    3133        control_id=id;
     
    3638                        values     =new TriaVertexInput(enum_type,pvalues);
    3739                        savedvalues=new TriaVertexInput(enum_type,pvalues);
     40                        minvalues  =new TriaVertexInput(enum_type,pmin);
     41                        maxvalues  =new TriaVertexInput(enum_type,pmax);
    3842                        break;
    3943                case PentaVertexInputEnum:
    4044                        values     =new PentaVertexInput(enum_type,pvalues);
    4145                        savedvalues=new PentaVertexInput(enum_type,pvalues);
     46                        minvalues  =new PentaVertexInput(enum_type,pmin);
     47                        maxvalues  =new PentaVertexInput(enum_type,pmax);
    4248                        break;
    4349                default:
     
    5157        delete values;
    5258        delete savedvalues;
     59        delete minvalues;
     60        delete maxvalues;
    5361        delete gradient;
    5462}
     
    6674        printf("ControlInput:\n");
    6775        printf("   enum: %i (%s)\n",this->enum_type,EnumToString(this->enum_type));
    68         printf("---values: \n");      if (values)      values->Echo();
    69         printf("---savedvalues: \n"); if (savedvalues) savedvalues->Echo();
    70         printf("---gradient: \n");    if (gradient)    gradient->Echo();
     76        printf("---values: \n");     if (values)      values->Echo();
     77        printf("---savedvalues: \n");if (savedvalues) savedvalues->Echo();
     78        printf("---minvalues: \n");  if (minvalues)   minvalues->Echo();
     79        printf("---maxvalues: \n");  if (maxvalues)   maxvalues->Echo();
     80        printf("---gradient: \n");   if (gradient)    gradient->Echo();
    7181}
    7282/*}}}*/
     
    122132        }
    123133
     134        /*marshal minvalues*/
     135        if(!minvalues){
     136                flag=0;
     137                memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);
     138        }
     139        else{
     140                flag=1;
     141                memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);
     142                this->minvalues->Marshall(&marshalled_dataset);
     143        }
     144
     145        /*marshal maxvalues*/
     146        if(!maxvalues){
     147                flag=0;
     148                memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);
     149        }
     150        else{
     151                flag=1;
     152                memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);
     153                this->maxvalues->Marshall(&marshalled_dataset);
     154        }
     155
    124156        /*marshal gradient*/
    125157        if(!gradient){
     
    144176        size=sizeof(enum_type)+
    145177          +sizeof(control_id)
    146           +3*sizeof(int) //3 flags
     178          +5*sizeof(int) //5 flags
    147179          +sizeof(int); //sizeof(int) for enum value
    148180
    149181        if(values)     size+=values->MarshallSize();
    150182        if(savedvalues)size+=savedvalues->MarshallSize();
     183        if(minvalues)size+=minvalues->MarshallSize();
     184        if(maxvalues)size+=maxvalues->MarshallSize();
    151185        if(gradient)   size+=gradient->MarshallSize();
    152186        return size;
     
    203237        }
    204238
     239        /*Demarshal minvalues*/
     240        memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
     241        if(flag){
     242                memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
     243                if(input_enum_type==PentaVertexInputEnum){
     244                        minvalues=new PentaVertexInput();
     245                        minvalues->Demarshall(&marshalled_dataset);
     246                }
     247                else if(input_enum_type==TriaVertexInputEnum){
     248                        minvalues=new TriaVertexInput();
     249                        minvalues->Demarshall(&marshalled_dataset);
     250                }
     251                else _error_("Not supported yet");
     252        }
     253        else{
     254                minvalues=NULL;
     255        }
     256
     257        /*Demarshal maxvalues*/
     258        memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
     259        if(flag){
     260                memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
     261                if(input_enum_type==PentaVertexInputEnum){
     262                        maxvalues=new PentaVertexInput();
     263                        maxvalues->Demarshall(&marshalled_dataset);
     264                }
     265                else if(input_enum_type==TriaVertexInputEnum){
     266                        maxvalues=new TriaVertexInput();
     267                        maxvalues->Demarshall(&marshalled_dataset);
     268                }
     269                else _error_("Not supported yet");
     270        }
     271        else{
     272                maxvalues=NULL;
     273        }
     274
    205275        /*Demarshal gradient*/
    206276        memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
     
    244314        if(values)      output->values=(Input*)this->values->copy();
    245315        if(savedvalues) output->savedvalues=(Input*)this->savedvalues->copy();
     316        if(minvalues)   output->minvalues=(Input*)this->minvalues->copy();
     317        if(maxvalues)   output->maxvalues=(Input*)this->maxvalues->copy();
    246318        if(gradient)    output->gradient=(Input*)this->gradient->copy();
    247319
     
    260332
    261333/*Object functions*/
    262 /*FUNCTION ControlInput::Constrain{{{1*/
    263 void ControlInput::Constrain(double cm_min, double cm_max){
    264         values->Constrain(cm_min,cm_max);
     334/*FUNCTION ControlInput::Constrain(){{{1*/
     335void ControlInput::Constrain(void){
     336
     337        Input* newvalues=NULL;
     338
     339        newvalues=this->values->PointwiseMin(maxvalues);
     340        delete values; this->values=newvalues;
     341        newvalues=this->values->PointwiseMax(minvalues);
     342        delete values; this->values=newvalues;
     343}/*}}}*/
     344/*FUNCTION ControlInput::Constrain(double min, double max){{{1*/
     345void ControlInput::Constrain(double min, double max){
     346           values->Constrain(min,max);
    265347}/*}}}*/
    266348/*FUNCTION ControlInput::Extrude{{{1*/
  • issm/trunk/src/c/objects/Inputs/ControlInput.h

    r6412 r8129  
    2121                Input* values;
    2222                Input* savedvalues;
     23                Input* minvalues;
     24                Input* maxvalues;
    2325                Input* gradient;
    2426
    2527                /*ControlInput constructors, destructors: {{{1*/
    2628                ControlInput();
    27                 ControlInput(int enum_type,int enum_input,double* pvalues,int id);
     29                ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id);
    2830                ~ControlInput();
    2931                /*}}}*/
     
    4345                Input* SpawnTriaInput(int* indices);
    4446                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
     47                Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
     48                Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4549                ElementResult* SpawnResult(int step, double time);
    4650                /*}}}*/
     
    6771                void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    6872                void AXPY(Input* xinput,double scalar){_error_("not implemented yet");};
    69                 void Constrain(double cm_min, double cm_max);
     73                void Constrain(void);
     74                void Constrain(double min,double max);
    7075                double InfinityNorm(void){_error_("not implemented yet");};
    7176                double Max(void){_error_("not implemented yet");};
  • issm/trunk/src/c/objects/Inputs/DoubleInput.cpp

    r6412 r8129  
    313313
    314314        /*Intermediaries*/
    315         double       AdotBvalue;
    316315        double       Bvalue;
    317316
     
    327326}
    328327/*}}}*/
     328/*FUNCTION DoubleInput::PointwiseMin{{{1*/
     329Input* DoubleInput::PointwiseMin(Input* input){
     330
     331        /*Ouput*/
     332        DoubleInput* outinput=NULL;
     333
     334        /*Intermediaries*/
     335        double       min;
     336
     337        /*Check that inputB is of the same type*/
     338        if (input->Min() < this->Min()) min=input->Min();
     339        else min=this->Min();
     340
     341        /*Create new DoubleInput*/
     342        outinput=new DoubleInput(this->enum_type,min);
     343
     344        /*Return output pointer*/
     345        return outinput;
     346
     347}
     348/*}}}*/
     349/*FUNCTION DoubleInput::PointwiseMax{{{1*/
     350Input* DoubleInput::PointwiseMax(Input* input){
     351
     352        /*Ouput*/
     353        DoubleInput* outinput=NULL;
     354
     355        /*Intermediaries*/
     356        double       max;
     357
     358        /*Check that inputB is of the same type*/
     359        if (input->Max() > this->Max()) max=input->Max();
     360        else max=this->Max();
     361
     362        /*Create new DoubleInput*/
     363        outinput=new DoubleInput(this->enum_type,max);
     364
     365        /*Return output pointer*/
     366        return outinput;
     367
     368}
     369/*}}}*/
  • issm/trunk/src/c/objects/Inputs/DoubleInput.h

    r6412 r8129  
    4040                Input* SpawnTriaInput(int* indices);
    4141                Input* PointwiseDivide(Input* inputB);
     42                Input* PointwiseMin(Input* inputB);
     43                Input* PointwiseMax(Input* inputB);
    4244                ElementResult* SpawnResult(int step, double time);
    4345                /*}}}*/
  • issm/trunk/src/c/objects/Inputs/Input.h

    r5743 r8129  
    5757                virtual Input* SpawnTriaInput(int* indices)=0;
    5858                virtual Input* PointwiseDivide(Input* inputB)=0;
     59                virtual Input* PointwiseMax(Input* inputmax)=0;
     60                virtual Input* PointwiseMin(Input* inputmin)=0;
    5961                virtual ElementResult* SpawnResult(int step, double time)=0;
    6062
  • issm/trunk/src/c/objects/Inputs/IntInput.h

    r6412 r8129  
    4141                Input* SpawnTriaInput(int* indices);
    4242                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
     43                Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
     44                Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4345                ElementResult* SpawnResult(int step, double time);
    4446                /*}}}*/
  • issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp

    r6413 r8129  
    575575        PentaVertexInput *xinputB     = NULL;
    576576        int               B_numvalues;
    577         double           *B_values    = NULL;
    578577        const int         numgrids    = 6;
    579578        double            AdotBvalues[numgrids];
     
    597596}
    598597/*}}}*/
     598/*FUNCTION PentaVertexInput::PointwiseMin{{{1*/
     599Input* PentaVertexInput::PointwiseMin(Input* inputB){
     600
     601        /*Ouput*/
     602        PentaVertexInput* outinput=NULL;
     603
     604        /*Intermediaries*/
     605        int               i;
     606        PentaVertexInput *xinputB     = NULL;
     607        int               B_numvalues;
     608        const int         numgrids    = 6;
     609        double            minvalues[numgrids];
     610
     611        /*Check that inputB is of the same type*/
     612        if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum()));
     613        xinputB=(PentaVertexInput*)inputB;
     614
     615        /*Create point wise min*/
     616        for(i=0;i<numgrids;i++){
     617                if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
     618                else minvalues[i]=this->values[i];
     619        }
     620
     621        /*Create new Penta vertex input (copy of current input)*/
     622        outinput=new PentaVertexInput(this->enum_type,&minvalues[0]);
     623
     624        /*Return output pointer*/
     625        return outinput;
     626
     627}
     628/*}}}*/
     629/*FUNCTION PentaVertexInput::PointwiseMax{{{1*/
     630Input* PentaVertexInput::PointwiseMax(Input* inputB){
     631
     632        /*Ouput*/
     633        PentaVertexInput* outinput=NULL;
     634
     635        /*Intermediaries*/
     636        int               i;
     637        PentaVertexInput *xinputB     = NULL;
     638        int               B_numvalues;
     639        const int         numgrids    = 6;
     640        double            maxvalues[numgrids];
     641
     642        /*Check that inputB is of the same type*/
     643        if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum()));
     644        xinputB=(PentaVertexInput*)inputB;
     645
     646        /*Create point wise max*/
     647        for(i=0;i<numgrids;i++){
     648                if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
     649                else maxvalues[i]=this->values[i];
     650        }
     651
     652        /*Create new Penta vertex input (copy of current input)*/
     653        outinput=new PentaVertexInput(this->enum_type,&maxvalues[0]);
     654
     655        /*Return output pointer*/
     656        return outinput;
     657
     658}
     659/*}}}*/
    599660/*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
    600661void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
  • issm/trunk/src/c/objects/Inputs/PentaVertexInput.h

    r6412 r8129  
    4141                Input* SpawnTriaInput(int* indices);
    4242                Input* PointwiseDivide(Input* inputB);
     43                Input* PointwiseMin(Input* inputB);
     44                Input* PointwiseMax(Input* inputB);
    4345                ElementResult* SpawnResult(int step, double time);
    4446                /*}}}*/
  • issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp

    r7089 r8129  
    403403}
    404404/*}}}*/
     405/*FUNCTION TriaVertexInput::PointwiseMin{{{1*/
     406Input* TriaVertexInput::PointwiseMin(Input* inputB){
     407
     408        /*Ouput*/
     409        TriaVertexInput* outinput=NULL;
     410
     411        /*Intermediaries*/
     412        int               i;
     413        TriaVertexInput *xinputB     = NULL;
     414        int               B_numvalues;
     415        const int         numgrids    = 3;
     416        double            minvalues[numgrids];
     417
     418        /*Check that inputB is of the same type*/
     419        if (inputB->Enum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum()));
     420        xinputB=(TriaVertexInput*)inputB;
     421
     422        /*Create point wise min*/
     423        for(i=0;i<numgrids;i++){
     424                if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
     425                else minvalues[i]=this->values[i];
     426        }
     427
     428        /*Create new Tria vertex input (copy of current input)*/
     429        outinput=new TriaVertexInput(this->enum_type,&minvalues[0]);
     430
     431        /*Return output pointer*/
     432        return outinput;
     433
     434}
     435/*}}}*/
     436/*FUNCTION TriaVertexInput::PointwiseMax{{{1*/
     437Input* TriaVertexInput::PointwiseMax(Input* inputB){
     438
     439        /*Ouput*/
     440        TriaVertexInput* outinput=NULL;
     441
     442        /*Intermediaries*/
     443        int               i;
     444        TriaVertexInput *xinputB     = NULL;
     445        int               B_numvalues;
     446        const int         numgrids    = 3;
     447        double            maxvalues[numgrids];
     448
     449        /*Check that inputB is of the same type*/
     450        if (inputB->Enum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum()));
     451        xinputB=(TriaVertexInput*)inputB;
     452
     453        /*Create point wise max*/
     454        for(i=0;i<numgrids;i++){
     455                if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
     456                else maxvalues[i]=this->values[i];
     457        }
     458
     459        /*Create new Tria vertex input (copy of current input)*/
     460        outinput=new TriaVertexInput(this->enum_type,&maxvalues[0]);
     461
     462        /*Return output pointer*/
     463        return outinput;
     464
     465}
     466/*}}}*/
  • issm/trunk/src/c/objects/Inputs/TriaVertexInput.h

    r6412 r8129  
    4141                Input* SpawnTriaInput(int* indices);
    4242                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
     43                Input* PointwiseMin(Input* inputB);
     44                Input* PointwiseMax(Input* inputB);
    4345                ElementResult* SpawnResult(int step, double time);
    4446                /*}}}*/
  • issm/trunk/src/c/objects/Materials/Matice.cpp

    r7834 r8129  
    608608                const int num_vertices = 3; //Tria has 3 vertices
    609609                double    nodeinputs[num_vertices];
     610                double    cmmininputs[num_vertices];
     611                double    cmmaxinputs[num_vertices];
    610612
    611613                /*Get B*/
     
    627629                                        case RheologyBbarEnum:
    628630                                                if (iomodel->rheology_B){
     631                                                        _assert_(iomodel->rheology_B);_assert_(iomodel->cm_min); _assert_(iomodel->cm_max);
    629632                                                        for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)];
    630                                                         this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs,i+1));
     633                                                        for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->cm_min[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i];
     634                                                        for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->cm_max[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i];
     635                                                        this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    631636                                                }
    632637                                                break;
     
    642647                const int num_vertices = 6; //Penta has 6 vertices
    643648                double    nodeinputs[num_vertices];
     649                double    cmmininputs[num_vertices];
     650                double    cmmaxinputs[num_vertices];
    644651
    645652                /*Get B*/
     
    661668                                        case RheologyBbarEnum:
    662669                                                if (iomodel->rheology_B){
     670                                                        _assert_(iomodel->rheology_B);_assert_(iomodel->cm_min); _assert_(iomodel->cm_max);
    663671                                                        for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)];
    664                                                         this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs,i+1));
     672                                                        for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->cm_min[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i];
     673                                                        for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->cm_max[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i];
     674                                                        this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
    665675                                                }
    666676                                                break;
Note: See TracChangeset for help on using the changeset viewer.