Changeset 4855


Ignore:
Timestamp:
07/28/10 19:02:43 (15 years ago)
Author:
Eric.Larour
Message:

Finished ModelProcessor update for loading several segments for MassFlux computation.

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

Legend:

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

    r4059 r4855  
    229229}
    230230/*}}}*/
     231/*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/
     232int   Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){
     233       
     234        /*Go through a dataset, and find a Param* object
     235         *which parameter name is "name" : */
     236       
     237        vector<Object*>::iterator object;
     238        Param* param=NULL;
     239
     240        int found=0;
     241
     242        for ( object=objects.begin() ; object < objects.end(); object++ ){
     243
     244                /*Ok, this object is a parameter, recover it and ask which name it has: */
     245                param=(Param*)(*object);
     246
     247                if(param->EnumType()==enum_type){
     248                        /*Ok, this is the one! Recover the value of this parameter: */
     249                        param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
     250                        found=1;
     251                        break;
     252                }
     253        }
     254        return found;
     255}
     256/*}}}*/
    231257/*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/
    232258int   Parameters::FindParam(Vec* pvec,int enum_type){
  • issm/trunk/src/c/Container/Parameters.h

    r4236 r4855  
    3333                int   FindParam(double** pdoublearray,int* pM,int enum_type);
    3434                int   FindParam(double** pdoublearray,int* pM,int* pN,int enum_type);
     35                int   FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
    3536                int   FindParam(Vec* pvec,int enum_type);
    3637                int   FindParam(Mat* pmat,int enum_type);
  • issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h

    r4852 r4855  
    334334        QmuErrNameEnum,
    335335        QmuInNameEnum,
    336         QmuMassFluxNumSegmentsEnum,
    337336        QmuMassFluxSegmentsEnum,
    338337        QmuNPartEnum,
  • issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp

    r4773 r4855  
    2020void DakotaResponsesx(double* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char** responses_descriptors,int numresponses){
    2121
    22         int        i;
     22        int        i,j;
    2323        int        dummy;
     24        int        counter;
    2425        extern int my_rank;
    2526
     
    7172                }
    7273                else if(strlen(response_descriptor)>=8){
    73 
    7474                        if(strncmp(response_descriptor,"MassFlux",8)==0){
    7575
    76                                 double*   segments=NULL;
    77                                 int       num_segments;
     76                                /*Deal with several mass flux computations: {{{1*/
     77                                double** array=NULL;
     78                                int      M;
     79                                int*     mdims_array=NULL;
     80                                int*     ndims_array=NULL;
     81
     82                                double*  segments=NULL;
     83                                int      num_segments;
    7884
    7985                                /*retrieve qmu_mass_flux_segments: */
    80                                 parameters->FindParam(&segments,&num_segments,&dummy,QmuMassFluxSegmentsEnum);
     86                                parameters->FindParam(&array,&M,&mdims_array,&ndims_array,QmuMassFluxSegmentsEnum);
     87
     88                                /*figure out counter after MassFlux: */
     89                                sscanf(response_descriptor,"MassFlux%i",&counter);
     90
     91                                /*retrieve segments from array: */
     92                                segments=array[counter-1]; //matlab to "C" indexing
     93                                num_segments=mdims_array[counter-1];
    8194
    8295                                /*call mass flux module: */
     
    8497
    8598                                /*Free ressources:*/
    86                                 xfree((void**)&segments);
     99                                for(j=0;j<M;j++){
     100                                        double* matrix=array[i];
     101                                        xfree((void**)&matrix);
     102                                }
     103                                xfree((void**)&mdims_array);
     104                                xfree((void**)&ndims_array);
     105                                xfree((void**)&array);
     106                                /*}}}*/
    87107                        }
    88 
    89108                }
    90109                else{
  • issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp

    r4854 r4855  
    4444        double** array=NULL;
    4545        double*  matrix=NULL;
     46        double*  temp_matrix=NULL;
    4647        int*     mdims_array=NULL;
    4748        int*     ndims_array=NULL;
    4849        int      M;
     50        int      temp_m,temp_n;
    4951
    5052        #ifdef _SERIAL_
     
    190192                        #ifdef _SERIAL_
    191193                        pfield=mxGetField(iomodel_handle,0,"qmu_mass_flux_segments");
    192                         for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){
     194                        for(i=0;i<M;i++){
    193195                                pfield2=mxGetCell(pfield,i);
    194196                                FetchData(&matrix,mdims_array+i,ndims_array+i,pfield2);
     
    196198                        }
    197199                        #else
    198                         for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){
    199                                 sprintf(massflux_tag,"%s%i","qmu_mass_flux_segmentsi",i);
    200                                 IoModelFetchData(&tot_matrix,tot_mdims_array+i,NULL,iomodel_handle,"qmu_mass_flux_segments");
    201                                 variabledescriptors[i]=descriptor;
    202                         }
    203                         #endif
    204 
    205                         #ifdef _PARALLEL_
    206                         IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments");
    207                         IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments");
    208 
    209 
    210                         /*Only if partitioning exist do we care about the segments: */
    211                         if(iomodel->my_elements){
    212 
    213                                 /*Use the element partitioning vector from the iomodel to down select qmu_mass_flux_segments to only segments that are relevant
    214                                  * to this cpu: */
    215                                 my_tot_qmu_mass_flux_segments=0;
    216                                 for(j=0;j<tot_qmu_mass_flux_segments;j++){
    217                                         if (  iomodel->my_elements[(int)(*(qmu_mass_flux_segments+5*j+4))-1])my_tot_qmu_mass_flux_segments++;
     200                        for(i=0;i<M;i++){
     201                                sprintf(massflux_tag,"%s%i","qmu_mass_flux_segments",i);
     202                                IoModelFetchData(&temp_matrix,&temp_m,&temp_n,iomodel_handle,massflux_tag);
     203
     204                                /*This temp_matrix represents all the segments, for all elements. On this cpu, we only have a subset of these
     205                                 * elements. Extract matrix, out of temp_matrix, corresponding to only our elements: */
     206                                m=0;
     207                                for(j=0;j<temp_m;j++){
     208                                        if (  iomodel->my_elements[(int)(*(temp_matrix+5*j+4))-1])m++;
    218209                                }
    219 
    220 
    221                                 if(my_tot_qmu_mass_flux_segments){
    222                                         my_qmu_mass_flux_segments=(double*)xcalloc(5*my_tot_qmu_mass_flux_segments,sizeof(double));
    223                                         second_count=0;
    224                                         for(j=0;j<tot_qmu_mass_flux_segments;j++){
    225                                                 if (iomodel->my_elements[(int)*(qmu_mass_flux_segments+5*j+4)-1]){
    226                                                         for(k=0;k<5;k++)*(my_qmu_mass_flux_segments+5*second_count+k)=*(qmu_mass_flux_segments+5*j+k);
    227                                                         second_count++;
     210                                if(m){
     211                                        matrix=(double*)xcalloc(5*m,sizeof(double));
     212                                        count=0;
     213                                        for(j=0;j<temp_m;j++){
     214                                                if (iomodel->my_elements[(int)*(temp_matrix+5*j+4)-1]){
     215                                                        for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
     216                                                        count++;
    228217                                                }
    229218                                        }
    230219                                }
    231220
    232                                 parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,my_qmu_mass_flux_segments,my_tot_qmu_mass_flux_segments,5));
    233 
    234                         }
    235                                        
    236                         #else
    237                         IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments");
    238                         IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments");
    239 
    240                         parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,qmu_mass_flux_segments,tot_qmu_mass_flux_segments,5));
    241                         parameters->AddObject(new DoubleVecParam(QmuMassFluxNumSegmentsEnum,qmu_mass_flux_num_segments,tot_qmu_mass_flux_num_segments));
    242 
     221                                /*Assign: */
     222                                array[i]=matrix;
     223                                mdims_array[i]=m;
     224                                ndims_array[i]=5;
     225
     226                                /*Free data: */
     227                                xfree((void**)&temp_matrix);
     228                        }
    243229                        #endif
    244230
    245                         xfree((void**)&qmu_mass_flux_segments);
    246                         xfree((void**)&my_qmu_mass_flux_segments);
    247                         xfree((void**)&qmu_mass_flux_num_segments);
    248                         xfree((void**)&my_qmu_mass_flux_num_segments);
     231                        /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
     232                        parameters->AddObject(new DoubleMatArrayParam(QmuMassFluxSegmentsEnum,array,M,mdims_array,ndims_array));
     233
     234                        /*Free data: */
     235                        for(i=0;i<M;i++){
     236                                double* matrix=array[i];
     237                                xfree((void**)&matrix);
     238                        }
     239                        xfree((void**)&mdims_array);
     240                        xfree((void**)&ndims_array);
     241                        xfree((void**)&array);
    249242                }
    250243                /*}}}*/
Note: See TracChangeset for help on using the changeset viewer.