Changeset 10571


Ignore:
Timestamp:
11/10/11 09:32:40 (13 years ago)
Author:
Eric.Larour
Message:

New transient update capability for dakota

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

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp

    r9650 r10571  
    1212void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables){
    1313
    14         int     i,j,k;
     14        int     i,j,k,l;
    1515        int     dummy;
    1616       
    1717        int     numberofvertices;
     18        int     nrows;
     19        int     ncols;
    1820        int     npart;
    1921        double *qmu_part  = NULL;
     
    5355
    5456                        /*Now, pick up the parameter corresponding to root: */
    55                         parameters->FindParam(&parameter,NULL,StringToEnumx(root));
     57                        parameters->FindParam(&parameter,&nrows,&ncols,StringToEnumx(root));
    5658
    57                         /*We've got the parameter, we need to update it using qmu_part (a partitioning vector), and the distributed_values: */
     59                        /*We've got the parameter, we need to update it using qmu_part (a partitioning vector),
     60                         * and the distributed_values. Two cases: we either have a nrows=numberofvertices, in
     61                         * which case our parameter is a vector, or nrows=numberofvertices+1, in which case,
     62                         * our parameter is a transient vector. Deal with both cases accordingly: */
    5863                        for(k=0;k<numberofvertices;k++){
    59                                 parameter[k]=parameter[k]*distributed_values[(int)qmu_part[k]];
     64                                for(l=0;l<ncols;l++){
     65                                        *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)qmu_part[k]];
     66                                }
    6067                        }
    6168
    6269                        #ifdef _DEBUG_
    63                                 PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter vector:");
     70                                PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter matrix:");
    6471                                PetscSynchronizedFlush(MPI_COMM_WORLD);
    65                                 for(k=0;k<numberofvertices;k++){
    66                                         PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,parameter[k]);
     72                                for(l=0;l<ncols;l++){
     73                                        PetscSynchronizedPrintf(MPI_COMM_WORLD," time %i\n",l);
    6774                                        PetscSynchronizedFlush(MPI_COMM_WORLD);
     75
     76                                        for(k=0;k<numberofvertices;k++){
     77                                                PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,*(parameter+k*ncols+l));
     78                                                PetscSynchronizedFlush(MPI_COMM_WORLD);
     79                                        }
    6880                                }
    6981                                PetscSynchronizedPrintf(MPI_COMM_WORLD," descriptor: %s root %s enum: %i\n",descriptor,root,StringToEnumx(root));
     
    7284                         
    7385
    74                         /*Update inputs using the parameter vector: */
    75                         InputUpdateFromVectorDakotax( elements,nodes, vertices,loads, materials,  parameters, parameter, StringToEnumx(root), VertexEnum);
     86                        /*Update inputs using the parameter matrix: */
     87                        InputUpdateFromMatrixDakotax( elements,nodes, vertices,loads, materials,  parameters, parameter, nrows,ncols,StringToEnumx(root), VertexEnum);
    7688
    7789                        /*increment i to skip the distributed values just collected: */
  • TabularUnified issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp

    r10566 r10571  
    5656        int      numberofresponses;
    5757        int      numberofvertices;
     58        int      nrows;
     59        int      ncols;
    5860
    5961        /*}}}*/
     
    123125                               
    124126                                /*Recover data: */
    125                                 iomodel->FetchData(&dakota_parameter,NULL,NULL,StringToEnumx(tag));
     127                                iomodel->FetchData(&dakota_parameter,&nrows,&ncols,StringToEnumx(tag));
    126128
    127129                                /*Convert units: */
    128                                 UnitConversion(dakota_parameter,numberofvertices,ExtToIuEnum,StringToEnumx(tag));
     130                                UnitConversion(dakota_parameter,nrows*ncols,ExtToIuEnum,StringToEnumx(tag));
    129131
    130132                                /*Add to parameters: */
    131                                 parameters->AddObject(new DoubleVecParam(StringToEnumx(tag),dakota_parameter,numberofvertices));
     133                                parameters->AddObject(new DoubleMatParam(StringToEnumx(tag),dakota_parameter,nrows,ncols));
    132134                               
    133135                                /*Free ressources:*/
  • TabularUnified issm/trunk/src/c/objects/Elements/Penta.h

    r10514 r10571  
    7474                void  InputUpdateFromVectorDakota(double* vector, int name, int type);
    7575                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
     76                void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
    7677                #endif
    7778                void  InputUpdateFromIoModel(int index, IoModel* iomodel);
  • TabularUnified issm/trunk/src/c/objects/Elements/Tria.cpp

    r10565 r10571  
    49804980}
    49814981/*}}}*/
     4982/*FUNCTION Tria::InputUpdateFromVectorMatrix(double* matrix, int nrows, int ncols, int name, int type);{{{1*/
     4983void  Tria::InputUpdateFromVectorMatrix(double* matrix, int nrows, int ncols, int name, int type){
     4984       
     4985        int i,j,t;
     4986
     4987        /*Check that name is an element input*/
     4988        if (!IsInput(name)) return;
     4989
     4990        switch(type){
     4991
     4992                case VertexEnum:
     4993                       
     4994                        double values[3];
     4995                        double time;
     4996
     4997                        /*Ok, create transient input: */
     4998                        for(t=0;t<ncols;t++){ //ncols is the number of times
     4999
     5000                                /*create input values: */
     5001                                for(i=0;i<3;i++){
     5002                                        row=this->nodes[i]->GetSidList();
     5003                                        values[i]=(double)matrix[ncols*row+t];
     5004                                }
     5005
     5006                                /*time? :*/
     5007                                time=(double)matrix[(nrows-1)*ncols+t]*yts;
     5008
     5009                                if(t==0) transientinput=new TransientInput(vector_enum);
     5010                                transientinput->AddTimeInput(new TriaVertexInput(vector_enum,nodeinputs),time);
     5011                        }
     5012                        this->inputs->AddInput(transientinput);
     5013                        break;
     5014
     5015                default:
     5016                        _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
     5017        }
     5018
     5019}
     5020/*}}}*/
    49825021#endif
    49835022
  • TabularUnified issm/trunk/src/c/objects/Elements/Tria.h

    r10440 r10571  
    6666                #ifdef _HAVE_DAKOTA_
    6767                void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     68                void  InputUpdateFromVectorDakota(double* vector, int name, int type);
    6869                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    6970                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
     71                void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
    7072                #endif
    7173                void  InputUpdateFromConstant(double constant, int name);
Note: See TracChangeset for help on using the changeset viewer.