Changeset 4454


Ignore:
Timestamp:
07/07/10 18:33:24 (15 years ago)
Author:
Eric.Larour
Message:

Finished Qmu capability redesign. Now some testing is in order

Location:
issm/trunk/src
Files:
6 edited

Legend:

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

    r4453 r4454  
    88#include "../../toolkits/toolkits.h"
    99#include "../../EnumDefinitions/EnumDefinitions.h"
     10#include "../modules.h"
    1011
    11 void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables){
     12void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,Vec vec_partition,double* variables,char* *variables_descriptors,int numvariables){
    1213
     14        int     i,j,k;
     15        int     dummy;
     16       
    1317        int     verbose;
     18        int     numberofvertices;
    1419        int     qmu_npart;
    15         double* qmu_part=NULL;
    16         int     dummy;
     20        double *qmu_part_serial = NULL;
     21        double *qmu_part  = NULL;
     22
     23        double* distributed_values=NULL;
     24        double* parameter=NULL;
     25        double* parameter_serial=NULL;
     26        char*   descriptor=NULL;
     27        char*   root=NULL; //root name of distributed variable, ex: thickness, drag, etc ...
     28        double* partition=NULL; //serial version of vec_partition
    1729
    1830        /*retrieve parameters: */
    1931        parameters->FindParam(&verbose,VerboseEnum);
    2032        parameters->FindParam(&qmu_npart,QmuNPartEnum);
    21         parameters->FindParam(&qmu_part,&dummy,QmuPartEnum);
     33        parameters->FindParam(&qmu_part_serial,&dummy,QmuPartEnum);
     34        numberofvertices=vertices->NumberOfVertices();
    2235
    23         ISSMERROR(" not supported yet!");
     36        /*serialize partition vector: */
     37        VecToMPISerial(&partition,vec_partition);
     38
     39        /*Use partition vector to repartition qmu_part, which is ordered in a serial way: */
     40        qmu_part=(double*)xmalloc(numberofvertices*sizeof(double));
     41        for(k=0;k<numberofvertices;k++) qmu_part[(int)(partition[k])]=qmu_part_serial[k];
     42       
     43        /*Go through all dakota descriptors, ex: "rho_ice","thermal_conductivity","thickness1","thickness2", etc ..., and
     44         * for each descriptor, take the variable value and plug it into the inputs: */
     45
     46        for(i=0;i<numvariables;i++){
     47       
     48                descriptor=variables_descriptors[i];
     49
     50                /*From descriptor, figure out if the variable is distributed (distributed implies there is a numeric value at the
     51                 * end of the descriptor, for ex: thickness1, thickness10, etc .... If it is distributed, the next qmu_npart (number
     52                 * of partitions in the distributed variable) variable are the values for each partition of the distributed variable: */
     53                if (!isdistributed(&root,descriptor)){
     54                       
     55                        /*Ok, variable is not distributed, just update inputs using the variable: */
     56                        InputUpdateFromConstantx( elements,nodes, vertices,loads, materials,  parameters, variables[i],StringAsEnum(descriptor));
     57
     58                }
     59                else{
     60                       
     61                        /*Ok, variable is distributed. Root name of variable is also known. Now, allocate distributed_values and fill the
     62                         * distributed_values with the next qmu_npart variables: */
     63
     64                        distributed_values=(double*)xmalloc(qmu_npart*sizeof(double));
     65                        for(j=0;j<qmu_npart;j++){
     66                                distributed_values[j]=variables[i+j];
     67                        }
     68
     69                        /*Now, pick up the parameter corresponding to root: */
     70                        parameters->FindParam(&parameter_serial,NULL,NULL,StringAsEnum(root));
     71
     72                        /*repartition parameter: */
     73                        parameter=(double*)xmalloc(numberofvertices*sizeof(double));
     74                        for(k=0;k<numberofvertices;k++) parameter[(int)(partition[k])]=parameter_serial[k];
     75
     76                        /*We've got the parameter, we need to update it using qmu_part (a partitioning vector), and the distributed_values: */
     77                        for(k=0;k<numberofvertices;k++){
     78                                parameter[k]=parameter[k]*distributed_values[(int)qmu_part[k]];
     79                        }
     80
     81                        #ifdef _ISSM_DEBUG_
     82                                PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter vetor:");
     83                                PetscSynchronizedFlush(MPI_COMM_WORLD);
     84                                for(k=0;k<numberofvertices;k++){
     85                                        PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,parameter[k]);
     86                                        PetscSynchronizedFlush(MPI_COMM_WORLD);
     87                                }
     88                        #endif
     89                         
     90
     91                        /*Update inputs using the parameter vector: */
     92                        InputUpdateFromVectorx( elements,nodes, vertices,loads, materials,  parameters, parameter, StringAsEnum(root), VertexEnum);
     93
     94                        /*increment i to skip the distributed values just collected: */
     95                        i+=qmu_npart-1; //careful, the for loop will add 1.
     96
     97                        /*Free allocations: */
     98                        xfree((void**)&parameter);
     99                        xfree((void**)&parameter_serial);
     100                        xfree((void**)&distributed_values);
     101
     102                }
     103                xfree((void**)&root);
     104        }
     105
     106        /*Free ressources:*/
     107        xfree((void**)&partition);
     108        xfree((void**)&qmu_part);
     109        xfree((void**)&qmu_part_serial);
     110
    24111}
  • issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h

    r4453 r4454  
    99#include "../../Container/Container.h"
    1010
    11 void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables);
     11void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,Vec partition,double* variables,char* *variables_descriptors,int numvariables);
    1212
    1313#endif  /* _INPUTUPDATEFROMDAKOTAXX_H */
  • issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp

    r4453 r4454  
    6161
    6262        /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
    63         InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,variables,variables_descriptors,numvariables);
     63        InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,femmodel->partition,variables,variables_descriptors,numvariables);
    6464
    6565        /*Run the core solution sequence: */
  • issm/trunk/src/m/solutions/SpawnCore.m

    r4439 r4454  
    1414
    1515%first update the inputs to the femmodel using the variables provided to us by dakota.
    16 [femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,variables,variabledescriptors);
     16[femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,femmodel.partition,variables,variabledescriptors);
    1717
    1818%now run the core solution
  • issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp

    r4453 r4454  
    2222        int         numvariables;
    2323        mxArray*    pfield=NULL;
     24        Vec         partition=NULL;
    2425
    2526        /*Boot module: */
     
    3637        FetchData((DataSet**)&materials,MATERIALSIN);
    3738        FetchParams(&parameters,PARAMETERSIN);
     39        FetchData(&partition,PARTITION);
    3840       
    3941        /*dakota input: */
     
    5153       
    5254        /*!Generate internal degree of freedom numbers: */
    53         InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters,variables,variables_descriptors,numvariables);
     55        InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters,partition,variables,variables_descriptors,numvariables);
    5456
    5557        /*write output datasets: */
     
    6466        delete materials;
    6567        delete parameters;
     68        VecFree(&partition);
    6669       
    6770        xfree((void**)&variables);
  • issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h

    r4439 r4454  
    2424#define MATERIALSIN (mxArray*)prhs[4]
    2525#define PARAMETERSIN (mxArray*)prhs[5]
    26 #define VARIABLES (mxArray*)prhs[6]
    27 #define VARIABLESDESCRIPTORS (mxArray*)prhs[7]
     26#define PARTITION (mxArray*)prhs[6]
     27#define VARIABLES (mxArray*)prhs[7]
     28#define VARIABLESDESCRIPTORS (mxArray*)prhs[8]
    2829
    2930/* serial output macros: */
     
    3536#define NLHS  2
    3637#undef NRHS
    37 #define NRHS  8
     38#define NRHS  9
    3839
    3940#endif  /* _UPDATEINPUTSFROMDAKOTA_H */
Note: See TracChangeset for help on using the changeset viewer.