source: issm/oecreview/Archive/24684-25833/ISSM-25255-25256.diff@ 25834

Last change on this file since 25834 was 25834, checked in by Mathieu Morlighem, 4 years ago

CHG: added 24684-25833

File size: 13.3 KB
  • ../trunk-jpl/src/c/classes/Elements/Tria.h

     
    4545                #ifdef _HAVE_DAKOTA_
    4646                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
    4747                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
     48                void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name);
    4849                #endif
    4950                void  InputUpdateFromIoModel(int index, IoModel* iomodel);
    5051                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
  • ../trunk-jpl/src/c/classes/Elements/Penta.cpp

     
    47064706#endif
    47074707
    47084708#ifdef _HAVE_DAKOTA_
     4709void       Penta::InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){/*{{{*/
     4710
     4711        int interp;
     4712        int type;
     4713       
     4714        /*Branch according to whether we have a transient or not input: */
     4715        type=this->inputs2->GetInputObjectEnum(name);
     4716        if(type==PentaInput2Enum){
     4717                /*Figure out if we are P0 or P1 interpolation: */
     4718                PentaInput2* pentainput = this->inputs2->GetPentaInput(name);
     4719                PentaInput2* pentainput2 = this->inputs2->GetPentaInput(DummyEnum);
     4720                interp=pentainput->GetInterpolation();
     4721               
     4722                if (interp==P0Enum){
     4723                        /*Update the value if this element belongs to the partition: */
     4724                        if(partition[this->Sid()]!=-1){
     4725                                int lid=this->lid; pentainput->Serve(1,&lid);
     4726                                /*scale P0 value  for this element, corresponding to the partition:*/
     4727                                IssmDouble value = pentainput->element_values[0];
     4728                                value*=distributed_values[(int)partition[this->Sid()]];
     4729                                pentainput2->SetInput(P0Enum,this->lid,value);
     4730                        }
     4731                }
     4732                else if (interp==P1Enum){
     4733                        IssmDouble values[NUMVERTICES];
     4734                        int lidlist[NUMVERTICES];
     4735                        this->GetVerticesLidList(&lidlist[0]);
     4736                        pentainput->Serve(NUMVERTICES,&lidlist[0]);
     4737                        for (int i=0;i<NUMVERTICES;i++){
     4738                                values[i]=pentainput->element_values[i];
     4739                                if(partition[this->vertices[i]->Sid()]!=-1) values[i]*=distributed_values[(int)partition[this->vertices[i]->Sid()]];
     4740                        }
     4741                        pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
     4742                }
     4743                else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
     4744        }
     4745        else if(type==TransientInput2Enum){
     4746
     4747
     4748                IssmDouble* steps=NULL;
     4749                int nsteps;
     4750                TransientInput2* transientinput = NULL;
     4751                TransientInput2* transientinput2 = NULL;
     4752
     4753                /*retrieve transient input:*/
     4754                transientinput= this->inputs2->GetTransientInput(name);
     4755                transientinput2= this->inputs2->GetTransientInput(DummyEnum);
     4756
     4757                /*retrieve time steps: */
     4758                transientinput->GetAllTimes(&steps,&nsteps);
     4759
     4760                /*double check:*/
     4761                if (nsteps!=nt && nt!=1) _error_("Penta:InputScaleFromDakota error message: transient input " << EnumToStringx(name) << 
     4762                                " should have the same number of time steps as the number of time values distributed by Dakota: " << nt << "\n");
     4763
     4764                /*needed to update inputs:*/
     4765                int lidlist[NUMVERTICES];
     4766                this->GetVerticesLidList(&lidlist[0]);
     4767
     4768                /*go through the transient inputs, and update:*/
     4769                for (int i=0;i<nsteps;i++){
     4770                        PentaInput2* pentainput=transientinput->GetPentaInput(i);
     4771                        PentaInput2* pentainput2=transientinput2->GetPentaInput(i);
     4772                        interp=pentainput->GetInterpolation();
     4773
     4774                        if (interp==P0Enum){
     4775                                /*Update the value if this element belongs to the partition: */
     4776                                if(partition[this->Sid()]!=-1){
     4777                                        int lid=this->lid; pentainput->Serve(1,&lid);
     4778                                        /*scale P0 value  for this element, corresponding to the partition:*/
     4779                                        IssmDouble value = pentainput->element_values[0];
     4780                                        if(nt==1) value*=distributed_values[(int)partition[this->Sid()]]; //we scale all the time steps  with the same distributed_value
     4781                                        else value*=distributed_values[(int)partition[this->Sid()]*nsteps+i]; //we scale all the time steps with distributed value for each step
     4782
     4783                                        pentainput2->SetInput(P0Enum,this->lid,value);
     4784                                }
     4785                        }
     4786                        else if (interp==P1Enum){
     4787                                IssmDouble values[NUMVERTICES];
     4788                                pentainput->Serve(NUMVERTICES,&lidlist[0]);
     4789                                for (int j=0;j<NUMVERTICES;j++){
     4790                                        values[j]=pentainput->element_values[j];
     4791                                        if(partition[this->vertices[i]->Sid()]!=-1){
     4792                                                if(nt==1) values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]];//we scale all the time steps  with the same distributed_value
     4793                                                else values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]*nsteps+i];//we scale all the time steps with distributed value for each step
     4794                                        }
     4795                                }
     4796                                pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
     4797                        }
     4798                        else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
     4799                }
     4800        }
     4801        else _error_("Penta::InputScaleFromDakota error message: input type " << EnumToStringx(name) << " not supported yet!");
     4802}
     4803/*}}}*/
    47094804void       Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/
    47104805
    47114806        /*Check that name is an element input*/
  • ../trunk-jpl/src/c/classes/Elements/Penta.h

     
    199199                void           ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input,Input2* vz_input);
    200200
    201201                #ifdef _HAVE_DAKOTA_
    202                 void           InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
    203                 void           InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
     202                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
     203                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
     204                void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name);
     205
    204206                #endif
    205207
    206208                #ifdef _HAVE_GIA_
  • ../trunk-jpl/src/c/classes/Elements/Seg.h

     
    181181#endif
    182182
    183183#ifdef _HAVE_DAKOTA_
    184                 void        InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
    185                 void        InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
     184                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
     185                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
     186                void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){_error_("not implemented yet!");}
     187;
    186188#endif
    187189                /*}}}*/
    188190};
  • ../trunk-jpl/src/c/classes/Elements/Tetra.h

     
    187187#endif
    188188
    189189#ifdef _HAVE_DAKOTA_
    190                 void        InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
    191                 void        InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
     190                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
     191                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
     192                void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){_error_("not implemented yet!");}
    192193#endif
    193194                /*}}}*/
    194195};
  • ../trunk-jpl/src/c/classes/Elements/Element.h

     
    279279                #ifdef _HAVE_DAKOTA_
    280280                virtual void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int rows, int ncols, int name, int type)=0;
    281281                virtual void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type)=0;
     282                virtual void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name)=0;
    282283                #endif
    283284                virtual void  InputUpdateFromIoModel(int index, IoModel* iomodel)=0;
    284285                virtual void  InputUpdateFromVector(IssmDouble* vector, int name, int type)=0;
  • ../trunk-jpl/src/c/classes/Elements/Tria.cpp

     
    60206020#endif
    60216021
    60226022#ifdef _HAVE_DAKOTA_
     6023void       Tria::InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){/*{{{*/
     6024
     6025        int interp;
     6026        int type;
     6027       
     6028        /*Branch according to whether we have a transient or not input: */
     6029        type=this->inputs2->GetInputObjectEnum(name);
     6030        if(type==TriaInput2Enum){
     6031                /*Figure out if we are P0 or P1 interpolation: */
     6032                TriaInput2* triainput = this->inputs2->GetTriaInput(name);
     6033                TriaInput2* triainput2 = this->inputs2->GetTriaInput(DummyEnum);
     6034                this->InputServe(triainput);
     6035                interp=triainput->GetInterpolation();
     6036               
     6037                if (interp==P0Enum){
     6038                        /*Update the value if this element belongs to the partition: */
     6039                        if(partition[this->Sid()]!=-1){
     6040                                /*scale P0 value  for this element, corresponding to the partition:*/
     6041                                IssmDouble value = triainput->element_values[0];
     6042                                value*=distributed_values[(int)partition[this->Sid()]];
     6043                                triainput2->SetInput(P0Enum,this->lid,value);
     6044                        }
     6045                }
     6046                else if (interp==P1Enum){
     6047                        IssmDouble values[NUMVERTICES];
     6048                        int lidlist[NUMVERTICES];
     6049                        this->GetVerticesLidList(&lidlist[0]);
     6050                        for (int i=0;i<NUMVERTICES;i++){
     6051                                values[i]=triainput->element_values[i];
     6052                                if(partition[this->vertices[i]->Sid()]!=-1) values[i]*=distributed_values[(int)partition[this->vertices[i]->Sid()]];
     6053                        }
     6054                        triainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
     6055                }
     6056                else _error_("Tria::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
     6057        }
     6058        else if(type==TransientInput2Enum){
     6059
     6060
     6061                IssmDouble* steps=NULL;
     6062                int nsteps;
     6063                TransientInput2* transientinput = NULL;
     6064                TransientInput2* transientinput2 = NULL;
     6065
     6066                /*retrieve transient input:*/
     6067                transientinput= this->inputs2->GetTransientInput(name);
     6068                transientinput2= this->inputs2->GetTransientInput(DummyEnum);
     6069
     6070                /*retrieve time steps: */
     6071                transientinput->GetAllTimes(&steps,&nsteps);
     6072
     6073                /*double check:*/
     6074                if (nsteps!=nt && nt!=1) _error_("Tria:InputScaleFromDakota error message: transient input " << EnumToStringx(name) << 
     6075                                " should have the same number of time steps as the number of time values distributed by Dakota: " << nt << "\n");
     6076
     6077                /*needed to update inputs:*/
     6078                int lidlist[NUMVERTICES];
     6079                this->GetVerticesLidList(&lidlist[0]);
     6080
     6081                /*go through the transient inputs, and update:*/
     6082                for (int i=0;i<nsteps;i++){
     6083                        TriaInput2* triainput=transientinput->GetTriaInput(i);
     6084                        TriaInput2* triainput2=transientinput2->GetTriaInput(i);
     6085                        this->InputServe(triainput);
     6086                        interp=triainput->GetInterpolation();
     6087
     6088                        if (interp==P0Enum){
     6089                                /*Update the value if this element belongs to the partition: */
     6090                                if(partition[this->Sid()]!=-1){
     6091                                        /*scale P0 value  for this element, corresponding to the partition:*/
     6092                                        IssmDouble value = triainput->element_values[0];
     6093                                        if(nt==1) value*=distributed_values[(int)partition[this->Sid()]]; //we scale all the time steps  with the same distributed_value
     6094                                        else value*=distributed_values[(int)partition[this->Sid()]*nsteps+i]; //we scale all the time steps with distributed value for each step
     6095
     6096                                        triainput2->SetInput(P0Enum,this->lid,value);
     6097                                }
     6098                        }
     6099                        else if (interp==P1Enum){
     6100                                IssmDouble values[NUMVERTICES];
     6101                                for (int j=0;j<NUMVERTICES;j++){
     6102                                        values[j]=triainput->element_values[j];
     6103                                        if(partition[this->vertices[i]->Sid()]!=-1){
     6104                                                if(nt==1) values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]];//we scale all the time steps  with the same distributed_value
     6105                                                else values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]*nsteps+i];//we scale all the time steps with distributed value for each step
     6106                                        }
     6107                                }
     6108                                triainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
     6109                        }
     6110                        else _error_("Tria::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
     6111                }
     6112        }
     6113        else _error_("Tria::InputScaleFromDakota error message: input type " << EnumToStringx(name) << " not supported yet!");
     6114}
     6115/*}}}*/
    60236116void       Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/
    60246117
    60256118        /*Check that name is an element input*/
Note: See TracBrowser for help on using the repository browser.