Changeset 4193


Ignore:
Timestamp:
06/24/10 13:46:42 (15 years ago)
Author:
Eric.Larour
Message:

Some updates on Qmu module: simplifications

Location:
issm/trunk/src
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Makefile.am

    r4168 r4193  
    10301030                                        ./modules/Qmux/Qmux.cpp\
    10311031                                        ./modules/Qmux/DakotaResponses.cpp\
     1032                                        ./modules/Qmux/DakotaMPI_Bcast.cpp\
    10321033                                        ./modules/Qmux/SpawnCore.cpp\
    10331034                                        ./modules/Qmux/SpawnCoreParallel.cpp\
  • issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp

    r4082 r4193  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void InputUpdateFromDakotax(double* variables,char** variables_descriptors,int numvariables,FemModel* femmodel,double* qmu_part,int qmu_npart){
     11void InputUpdateFromDakotax(FemModel* femmodel, double* variables,char** variables_descriptors,int numvariables){
     12       
     13        /*retrieve parameters: */
     14        femmodel->parameters->FindParam(&verbose,VerboseEnum);
     15        femmodel->parameters->FindParam(&qmu_npart,QmuNPartEnum);
     16        femmodel->parameters->FindParam(&qmu_part,&dummy,QmuPartEnum);
     17
     18
    1219
    1320        ISSMERROR(" not supported yet!");
  • issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h

    r4082 r4193  
    99#include "../../DataSet/DataSet.h"
    1010
    11 
    12 void InputUpdateFromDakotax(double* variables,char** variables_descriptors,int numvariables,FemModel* femmodel,double* qmu_part,int qmu_npart);
     11void InputUpdateFromDakotax(FemModel* femmodel,double* variables,char** variables_descriptors,int numvariables);
    1312
    1413#endif  /* _INPUTUPDATEFROMDAKOTAXX_H */
  • issm/trunk/src/c/modules/Qmux/Qmux.cpp

    r4042 r4193  
    5050#endif
    5151
    52 #ifdef _SERIAL_
    53 void Qmux(mxArray* femmodel,char* dakota_input_file,char* dakota_output_file,char* dakota_error_file){
    54 #else
    55 void Qmux(FemModel* femmodel){
    56 #endif
     52void Qmux(void* femmodel,Parameters* parameters){ //void* for femmodel, because we do not use it, just pass it along
    5753
    5854
    5955        #ifdef _HAVE_DAKOTA_ //only works if dakota library has been compiled in.
    60 
    61         #ifdef _PARALLEL_
    62         char* dakota_input_file=NULL;
    63         char* dakota_output_file=NULL;
    64         char* dakota_error_file=NULL;
    65         extern int my_rank;
    66         #endif
    67         int status=0;
     56       
     57        extern int         my_rank;
     58        char*              dakota_input_file  = NULL;
     59        char*              dakota_output_file = NULL;
     60        char*              dakota_error_file  = NULL;
     61        int                status=0;
    6862        Dakota::ModelLIter ml_iter;
    6963
    70         #ifdef _PARALLEL_
    7164        /*Recover dakota_input_file, dakota_output_file and dakota_error_file, in the parameters dataset in parallel */
    72         model->FindParam(&dakota_input_file,QmuInNameEnum);
    73         model->FindParam(&dakota_output_file,QmuOutNameEnum);
    74         model->FindParam(&dakota_error_file,QmuErrNameEnum);
    75         #endif
     65        parameters->FindParam(&dakota_input_file,QmuInNameEnum);
     66        parameters->FindParam(&dakota_output_file,QmuOutNameEnum);
     67        parameters->FindParam(&dakota_error_file,QmuErrNameEnum);
    7668
    7769        #ifdef _PARALLEL_
     
    131123                }
    132124        }
    133         #endif
     125        #endif //#ifdef _PARALLEL_
    134126
    135127        /*Free ressources:*/
    136         #ifdef _PARALLEL_
    137128        xfree((void**)&dakota_input_file);
    138129        xfree((void**)&dakota_error_file);
    139130        xfree((void**)&dakota_output_file);
    140         #endif
    141131
    142 
    143         #endif
    144 
     132        #endif //#ifdef _HAVE_DAKOTA_
    145133}
  • issm/trunk/src/c/modules/Qmux/Qmux.h

    r4043 r4193  
    99#include "../../objects/objects.h"
    1010
     11void Qmux(void* femmodel,Parameters* parameters);
     12
    1113/* local prototypes: */
    1214int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
     15
    1316#ifdef _SERIAL_
    14 void Qmux(mxArray* femmodel,char* dakota_input_file,char* dakota_output_file,char* dakota_error_file);
    1517void SpawnCoreSerial(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, mxArray* femmodel,int counter);
    1618#else
    17 void Qmux(FemModel* femmodel);
    1819void SpawnCoreParallel(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodel,int counter);
    1920void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel);
     21void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses);
    2022#endif
    2123
    22 
    2324#endif  /* _QMUX_H */
    24 
  • issm/trunk/src/c/modules/Qmux/SpawnCore.cpp

    r4043 r4193  
    2020
    2121        /*Branch into a serial SpawnCore and a parallel SpawnCore: */
     22
    2223        #ifdef _SERIAL_
    23         SpawnCoreSerial(responses, numresponses, variables, variables_descriptors,numvariables, (mxArray*)femmodel, counter);
     24                SpawnCoreSerial(responses, numresponses, variables, variables_descriptors,numvariables, (mxArray*)femmodel, counter);
    2425        #else
    25         /*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */
    26         MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); if(counter==-1)return 0;
    27        
    28         SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter);
     26
     27                /*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */
     28                MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD);
     29                if(counter==-1)return 0;
     30
     31                SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter);
    2932        #endif
    3033
  • issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp

    r4082 r4193  
    4141       
    4242        char   **responses_descriptors     = NULL;
    43         int      num_responses_descriptors;
    4443        char    *string                    = NULL;
    4544        int      string_length;
     
    5049        int      solution_type;
    5150
    52        
    53        
    5451        /*synchronize all cpus, as CPU 0 is probably late (it is starting the entire dakota strategy!) : */
    5552        MPI_Barrier(MPI_COMM_WORLD);
     53        _printf_("qmu iteration: %i\n",counter);
    5654       
    57         /*some parameters needed: */
     55        /*retrieve parameters: */
    5856        femmodel->parameters->FindParam(&verbose,VerboseEnum);
     57        femmodel->parameters->FindParam(&responses_descriptors,&dummy,ResponseDescriptorsEnum);
     58        if(dummy!=numresponses)ISSMERROR(" parameter numresponses not equal to Dakota provided numresponses: %i vs %i\n",dummy,numresponses);
     59
     60        /* only cpu 0, running dakota is providing us with variables, variables_descriptors and responses.
     61         * broadcast onto other cpus: */
     62        DakotaMPI_Bcast(&variables,&variables_descriptors,&numvariables,&numresponses);
     63
     64        /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
     65        InputUpdateFromDakotax(femmodel,variables,variables_descriptors,numvariables);
     66
     67        /*Run the analysis core solution sequence: */
    5968        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    60                
    61         /*Recover partitioning for dakota: */
    62         femmodel->parameters->FindParam(&qmu_npart,QmuNPartEnum);
    63         femmodel->parameters->FindParam(&qmu_part,&dummy,QmuPartEnum);
    64 
    65         /*broadcast variables: only cpu 0 has correct values*/
    66         MPI_Bcast(&numvariables,1,MPI_INT,0,MPI_COMM_WORLD);
    67         if(my_rank!=0)variables=(double*)xmalloc(numvariables*sizeof(double));
    68         MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,MPI_COMM_WORLD);
    69 
    70         /*broadcast variables_descriptors: */
    71         if(my_rank!=0){
    72                 variables_descriptors=(char**)xmalloc(numvariables*sizeof(char*));
    73         }
    74         for(i=0;i<numvariables;i++){
    75                 if(my_rank==0){
    76                         string=variables_descriptors[i];
    77                         string_length=(strlen(string)+1)*sizeof(char);
    78                 }
    79                 MPI_Bcast(&string_length,1,MPI_INT,0,MPI_COMM_WORLD);
    80                 if(my_rank!=0)string=(char*)xmalloc(string_length);
    81                 MPI_Bcast(string,string_length,MPI_CHAR,0,MPI_COMM_WORLD);
    82                 if(my_rank!=0)variables_descriptors[i]=string;
     69        if(verbose)_printf_("%s%s%s\n","Starting ",EnumAsString(solution_type)," core:");
     70        switch(solution_type){
     71                case DiagnosticAnalysisEnum:
     72                        diagnostic_core(femmodel);
     73                        break;
     74                case ThermalAnalysisEnum:
     75                        thermal_core(femmodel);
     76                        break;
     77                case PrognosticAnalysisEnum:
     78                        prognostic_core(femmodel);
     79                        break;
     80                case Transient2DAnalysisEnum:
     81                        transient2d_core(femmodel);
     82                        break;
     83                case Transient3DAnalysisEnum:
     84                        transient3d_core(femmodel);
     85                default:
     86                        ISSMERROR("%s%s%s"," solution_type: ",EnumAsString(solution_type),", not supported yet!");
     87                        break;
    8388        }
    8489
    85         /*broadcast numresponses: */
    86         MPI_Bcast(&numresponses,1,MPI_INT,0,MPI_COMM_WORLD);
    87 
    88         _printf_("qmu iteration: %i\n",counter);
    89 
    90         /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
    91         InputUpdateFromDakotax(variables,variables_descriptors,numvariables,femmodel,qmu_part,qmu_npart);
    92 
    93         /*Run the analysis core solution sequence: */
    94         if(solution_type==DiagnosticAnalysisEnum){
    95                        
    96                 if(verbose)_printf_("Starting diagnostic core\n");
    97 
    98                 diagnostic_core(femmodel);
    99 
    100         }
    101         else if(solution_type==ThermalAnalysisEnum){
    102                
    103                 if(verbose)_printf_("Starting thermal core\n");
    104                 thermal_core(femmodel);
    105 
    106         }
    107         else if(solution_type==PrognosticAnalysisEnum){
    108 
    109                 if(verbose)_printf_("Starting prognostic core\n");
    110                 prognostic_core(femmodel);
    111 
    112         }
    113         else if(solution_type==Transient2DAnalysisEnum){
    114 
    115                 if(verbose)_printf_("Starting transient core\n");
    116                 transient2d_core(femmodel);
    117 
    118         }
    119         else if(solution_type==Transient3DAnalysisEnum){
    120 
    121                 if(verbose)_printf_("Starting transient core\n");
    122                 transient3d_core(femmodel);
    123 
    124         }
    125         else ISSMERROR("%s%s%s"," solution_type: ",EnumAsString(solution_type),", not supported yet!");
    126        
    12790        /*compute responses on cpu 0: dummy for now! */
    12891        if(verbose)_printf_("compute dakota responses:\n");
    12992        DakotaResponses(responses,responses_descriptors,numresponses,femmodel);
    13093
    131         /*Free ressources:*/
     94        /*Free ressources:{{{1*/
    13295        //variables only on cpu != 0
    13396        if(my_rank!=0){
     
    147110        xfree((void**)&responses_descriptors);
    148111        xfree((void**)&qmu_part);
    149 
    150 
     112        /*}}}*/
    151113}
    152114
  • issm/trunk/src/m/solutions/NewFemModel.m

    r4188 r4193  
    1818   displaystring(md.verbose,'\n   reading data from model %s...',md.name);
    1919   [femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.constraints,femmodel.loads,femmodel.materials,femmodel.parameters]=ModelProcessor(md,solution_type,femmodel.analysis_type_list);
    20 
     20   
    2121        %Initialize some fiels with empty celils
    2222        femmodel.m_yg=cell(nummodels,1);
  • issm/trunk/src/m/solutions/SpawnCore.m

    r4131 r4193  
    1 function responses=SpawnCore(models,variables,variabledescriptors,counter);
     1function responses=SpawnCore(femmodel,variables,variabledescriptors,counter);
    22%SPAWNCORE - for Qmu analysis, using Dakota. Spawn the core solution.
    33%
    44%   Usage:
    5 %      responses=SpawnCore(models,variables,variabledescriptors)
     5%      responses=SpawnCore(femmodel,variables,variabledescriptors)
    66%
    77
    88%recover parameters
    9 verbose=models.dh.parameters.Verbose;
    10 parameters=models.dh.parameters;
    11 responsedescriptors=models.dh.parameters.responsedescriptors;
    12 npart=models.dh.parameters.qmu_npart;
    13 part=models.dh.parameters.qmu_part+1; %C indexing
    14 numberofnodes=models.dh.parameters.NumberOfNodes;
     9verbose=femmodel.parameters.Verbose;
     10responsedescriptors=femmodel.parameters.responsedescriptors;
     11npart=femmodel.parameters.qmu_npart;
     12part=femmodel.parameters.qmu_part+1; %C indexing
     13numberofnodes=femmodel.parameters.NumberOfNodes;
    1514
    16 disp(['   qmu iteration: ',num2str(counter)]);
     15displaystring(verbose,'%s%i',['   qmu iteration:'],counter);
    1716
    18 %first update the inputs to the models using the variables provided to us by dakota.
     17%first update the inputs to the femmodel using the variables provided to us by dakota.
    1918count=1;
    2019while count<=numel(variables)
     
    2726        else
    2827                root=qmuroot(descriptor);
    29                 param=parameters.(root);
     28                param=femmodel.parameters.(root);
    3029
    3130                %next npart values in variables are partition values for this param, collect them.
     
    4746if analysis_type==DiagnosticAnalysisEnum(),
    4847
    49         results=diagnostic_core(models);
     48        results=diagnostic_core(femmodel);
    5049
    5150else
     
    5453
    5554%process results
    56 processedresults=processresults(models,results);
     55processedresults=processresults(femmodel,results);
    5756
    5857%now process the results to get response function values
     
    6059for i=1:numel(responsedescriptors),
    6160        descriptor=responsedescriptors{i};
    62         responses(i)=qmuresponse(models,results,processedresults,descriptor);
     61        responses(i)=qmuresponse(femmodel,results,processedresults,descriptor);
    6362end
  • issm/trunk/src/m/solutions/bedslope.m

    r4184 r4193  
    2828        else
    2929                %launch dakota driver for diagnostic core solution
    30                 Qmu(femmodel);
     30                Qmu(femmodel,femmodel.parameters);
    3131        end
    3232
  • issm/trunk/src/m/solutions/diagnostic.m

    r4184 r4193  
    3737        else
    3838                %launch dakota driver for diagnostic core solution
    39                 Qmu(femmodel);
     39                Qmu(femmodel,femmodel.parameters);
    4040        end
    4141
  • issm/trunk/src/m/solutions/prognostic.m

    r4184 r4193  
    2828        else
    2929                %launch dakota driver for diagnostic core solution
    30                 Qmu(femmodel);
     30                Qmu(femmodel,femmodel.parameters);
    3131        end
    3232
  • issm/trunk/src/m/solutions/prognostic2.m

    r4184 r4193  
    2727        else
    2828                %launch dakota driver for diagnostic core solution
    29                 Qmu(femmodel);
     29                Qmu(femmodel,femmodel.parameters);
    3030        end
    3131
  • issm/trunk/src/m/solutions/surfaceslope.m

    r4184 r4193  
    2828        else
    2929                %launch dakota driver for diagnostic core solution
    30                 Qmu(femmodel);
     30                Qmu(femmodel,femmodel.parameters);
    3131        end
    3232
  • issm/trunk/src/m/solutions/transient2d.m

    r4184 r4193  
    2727        else
    2828                %launch dakota driver for diagnostic core solution
    29                 Qmu(femmodel);
     29                Qmu(femmodel,femmodel.parameters);
    3030        end
    3131
  • issm/trunk/src/m/solutions/transient3d.m

    r4184 r4193  
    2626        else
    2727                %launch dakota driver for diagnostic core solution
    28                 Qmu(femmodel);
     28                Qmu(femmodel,femmodel.parameters);
    2929        end
    3030
  • issm/trunk/src/mex/Qmu/Qmu.cpp

    r4103 r4193  
    1414
    1515        /*diverse: */
    16         int   noerr=1;
     16        int         noerr      = 1;
    1717
    1818        /*input datasets: */
    19         mxArray* femmodel=NULL;
    20         mxArray* parameters=NULL;
    21         char*    dakota_input_file=NULL;
    22         char*    dakota_output_file=NULL;
    23         char*    dakota_error_file=NULL;
     19        mxArray    *femmodel   = NULL;
     20        Parameters *parameters = NULL;
    2421
    2522        /* output datasets: none*/
     
    3835        femmodel=FEMMODEL;
    3936
    40         /*get parameters from femmodel structure: */
    41         parameters=mxGetField(FEMMODEL,0,"parameters");
    42 
    43         FetchData(&dakota_input_file,mxGetField(parameters,0,"qmuinname"));
    44         FetchData(&dakota_output_file,mxGetField(parameters,0,"qmuoutname"));
    45         FetchData(&dakota_error_file,mxGetField(parameters,0,"qmuerrname"));
     37        /*Fetch parameters from femmodel structure: */
     38        FetchData(&parameters,PARAMETERS);
    4639
    4740        /*!Generate internal degree of freedom numbers: */
    48         Qmux(femmodel,dakota_input_file,dakota_output_file,dakota_error_file);
    49 
    50         /*Free ressources:*/
    51         xfree((void**)&dakota_input_file);
    52         xfree((void**)&dakota_output_file);
    53         xfree((void**)&dakota_error_file);
     41        Qmux(femmodel,parameters);
    5442
    5543        /*end module: */
Note: See TracChangeset for help on using the changeset viewer.