Changeset 3869


Ignore:
Timestamp:
05/20/10 16:22:15 (15 years ago)
Author:
Mathieu Morlighem
Message:

prepared InputToResultx/InputToResultx.cpp, to be completed

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

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/DataSet/DataSet.cpp

    r3847 r3869  
    945945        }
    946946
     947}
     948/*}}}*/
     949/*FUNCTION DataSet::DepthAverageInputAtBase(int enum_type) {{{1*/
     950void  DataSet::DepthAverageInputAtBase(int enum_type){
     951
     952        vector<Object*>::iterator object;
     953        Element* element=NULL;
     954
     955        for ( object=objects.begin() ; object < objects.end(); object++ ){
     956
     957                if(EnumIsElement((*object)->Enum())){
     958
     959                        element=(Element*)(*object);
     960                        element->DepthAverageInputAtBase(enum_type);
     961                }
     962        }
     963       
     964}
     965/*}}}*/
     966/*FUNCTION DataSet::InputExtrude(int enum_type) {{{1*/
     967void  DataSet::InputExtrude(int enum_type){
     968       
     969        vector<Object*>::iterator object;
     970        Penta* penta=NULL;
     971
     972        for ( object=objects.begin() ; object < objects.end(); object++ ){
     973
     974                if((*object)->Enum()==PentaEnum){
     975                        penta=(Penta*)(*object);
     976                        penta->InputExtrude(enum_type);
     977                }
     978        }
     979}
     980/*}}}*/
     981/*FUNCTION DataSet::InputToResult{{{1*/
     982void  DataSet::InputToResult(Mat* psolution,int enum_type){
     983
     984        /*Output*/
     985        Mat solution=NULL;
     986
     987        /*Intermediary*/
     988        int i;
     989        vector<Object*>::iterator object;
     990        extern int num_procs;
     991        extern int my_rank;
     992        Element* element=NULL;
     993        int  elemcols;
     994        int  cols=0,lines=0;
     995        int  local_cols=0;
     996        int*   all_cols=NULL;
     997        int  local_lines=0;
     998        int*   all_lines=NULL;
     999
     1000        ISSMERROR("not implemented yet");
     1001        /*First: Get number of columns to be allocated*/
     1002        for ( object=objects.begin() ; object < objects.end(); object++ ){
     1003
     1004                if(EnumIsElement((*object)->Enum())){
     1005
     1006                        /*increase number of lines by 1*/
     1007                        local_lines++;
     1008
     1009                        /*Get number of columns required for this element*/
     1010                        element=(Element*)(*object);
     1011                        //elemcols=element->InputToResultAllocation(enum_type);
     1012
     1013                        /*Increase number of columns if higher than previous value*/
     1014                        //if(elemcols>local_cols) local_cols=elemcols;
     1015                }
     1016        }
     1017
     1018        /*OK, sum contributions of all cpus*/
     1019        all_lines=(int*)xmalloc(num_procs*sizeof(int));
     1020        MPI_Gather(&local_lines,1,MPI_INT,all_lines,1,MPI_INT,0,MPI_COMM_WORLD);
     1021        MPI_Bcast(all_lines,num_procs,MPI_INT,0,MPI_COMM_WORLD);
     1022        all_cols=(int*)xmalloc(num_procs*sizeof(int));
     1023        MPI_Gather(&local_cols,1,MPI_INT,all_cols,1,MPI_INT,0,MPI_COMM_WORLD);
     1024        MPI_Bcast(all_cols,num_procs,MPI_INT,0,MPI_COMM_WORLD);
     1025
     1026        for(i=0;i<num_procs;i++) if(all_cols[i]>cols) cols=all_cols[i];
     1027        for(i=0;i<num_procs;i++) lines+=all_lines[i];
     1028
     1029        /*Second: Create Dense matrix that has the right size*/
     1030        MatCreateMPIDense(PETSC_COMM_WORLD, PETSC_DECIDE, PETSC_DECIDE,lines,cols,PETSC_NULL,&solution);
     1031
     1032        /*Finally, enter solution for every element*/
     1033        for ( object=objects.begin() ; object < objects.end(); object++ ){
     1034
     1035                if(EnumIsElement((*object)->Enum())){
     1036                        element=(Element*)(*object);
     1037                        //elemcols=element->InputToResult(&solution,enum_type);
     1038                }
     1039        }
     1040
     1041        /*Allocate output pointer*/
     1042        *psolution=solution;
     1043
     1044        /* Free ressources: */
     1045        xfree((void**)&all_cols);
     1046        xfree((void**)&all_lines);
    9471047}
    9481048/*}}}*/
  • issm/trunk/src/c/DataSet/DataSet.h

    r3855 r3869  
    9393                void  FieldAverageOntoVertices(Vec fieldsum,Vec connectivity,double* field);
    9494                void  FieldDepthAverageAtBase(Vec field,double* field_serial,char* fieldname);
     95                void  DepthAverageInputAtBase(int enum_type);
     96                void  InputExtrude(int enum_type);
    9597                int   DeleteObject(Object* object);
    9698                void  ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type);
     
    99101                int   FindResult(void* pvalue, char* name);
    100102                void  FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse);
     103                void  InputToResult(Mat* psolution,int enum_type);
    101104                void  UpdateVertexPositions(double* thickness,double* bed);
    102105                void  OutputRifts(Vec riftproperties);
     
    128131                /*numerics: {{{1*/
    129132                int  AddInput(Input* in_input);
     133                Input* GetInput(int enum_name);
    130134                Inputs* SpawnTriaInputs(int* indices);
    131135               
  • issm/trunk/src/c/DataSet/Inputs.cpp

    r3861 r3869  
    529529}
    530530/*}}}*/
     531/*FUNCTION Inputs::GetInput{{{1*/
     532Input* Inputs::GetInput(int enum_name){
     533
     534        vector<Object*>::iterator object;
     535        Input* input=NULL;
     536
     537        for ( object=objects.begin() ; object < objects.end(); object++ ){
     538
     539                input=(Input*)(*object);
     540
     541                if (input->EnumType()==enum_name){
     542                        return input;
     543                }
     544        }
     545        ISSMERROR("input with enum %i (%s) not found",enum_name,EnumAsString(enum_name));
     546}
     547/*}}}*/
    531548/*FUNCTION Inputs::ChangeEnum{{{1*/
    532549void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){
  • issm/trunk/src/c/DepthAverageInputx/DepthAverageInputx.cpp

    r3823 r3869  
    1111
    1212void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type){
     13       
     14        /*First, get elements*/
     15        elements->Configure(elements,loads, nodes,vertices, materials,parameters);
    1316
    14        
    15         /*First, get elements and loads configured: */
    16         elements->Configure(elements,loads, nodes,vertices, materials,parameters);
    17         nodes->Configure(elements,loads, nodes,vertices, materials,parameters);
    18         loads->Configure(elements, loads, nodes,vertices, materials,parameters);
    19         parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
     17        /*First depth-average inputs at base of the glacier*/
     18        elements->DepthAverageInputAtBase(enum_type);
    2019
    21 
     20        /*Then extrude vertically the new inputs*/
     21        elements->InputExtrude(enum_type);
    2222
    2323}
  • issm/trunk/src/c/ExtrudeInputx/ExtrudeInputx.cpp

    r3791 r3869  
    1212void ExtrudeInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type){
    1313
    14         ISSMERROR(" not supported yet!");
     14        /*First, get elements*/
     15        elements->Configure(elements,loads, nodes,vertices, materials,parameters);
     16
     17        /*Then extrude vertically the new inputs*/
     18        elements->InputExtrude(enum_type);
    1519
    1620}
  • issm/trunk/src/c/FieldAverageOntoVerticesx/FieldAverageOntoVerticesx.cpp

    r3775 r3869  
    2323        Vec field=NULL;
    2424
    25         /*Initioalize intermediary*/
     25        /*Initialize intermediary*/
    2626        found=parameters->FindParam(&numberofvertices,NumberOfVerticesEnum);
    2727        connectivity=NewVec(numberofvertices);
  • issm/trunk/src/c/InputToResultx/InputToResultx.cpp

    r3807 r3869  
    1313void InputToResultx(Result** presult,DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials,Parameters* parameters,int enum_type,int id, double time, int step){
    1414
    15         ISSMERROR(" not supported yet!");
     15        /*Intermediary output vector*/
     16        Mat     solution=NULL;
     17        Result* result=NULL;
     18
     19        /*First, get elements*/
     20        elements->Configure(elements,loads, nodes,vertices, materials,parameters);
     21
     22        /*Then extrude vertically the new inputs*/
     23        elements->InputToResult(&solution,enum_type);
     24
     25        /*Create Result and clean up*/
     26        /*Mat support in result to be added!!!!!!*/
     27        //result=new Result(id,time,step,enum_type,solution);
     28        MatFree(&solution);
     29
     30        /*Assign output pointer*/
     31        *presult=result;
    1632
    1733}
  • issm/trunk/src/c/objects/Elements/Beam.h

    r3821 r3869  
    5252                Object* copy();
    5353                void  SetClone(int* minranks);
    54                 void    UpdateInputsFromVector(double* vector, int name, int type);
    55                 void    UpdateInputsFromVector(int* vector, int name, int type);
    56                 void    UpdateInputsFromVector(bool* vector, int name, int type);
    57                 void    UpdateInputsFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");}
    58                 void    UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
    59                 void    UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
     54                void  UpdateInputsFromVector(double* vector, int name, int type);
     55                void  UpdateInputsFromVector(int* vector, int name, int type);
     56                void  UpdateInputsFromVector(bool* vector, int name, int type);
     57                void  UpdateInputsFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");}
     58                void  UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
     59                void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
    6060
    61                 void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
     61                void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
    6262
    63 
     63                void   DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
    6464                /*}}}*/
    6565                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Elements/Element.h

    r3821 r3869  
    4242                virtual double CostFunction(int analysis_type,int sub_analysis_type)=0;
    4343                virtual double SurfaceArea(int analysis_type,int sub_analysis_type)=0;
     44                virtual void   DepthAverageInputAtBase(int enum_type)=0;
    4445                virtual void   ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type)=0;
    4546                virtual void   ComputePressure(Vec p_g,       int analysis_type,int sub_analysis_type)=0;
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r3864 r3869  
    337337        }
    338338        else return false;
     339}
     340/*}}}*/
     341/*FUNCTION Penta::IsOnSurface{{{1*/
     342bool Penta::IsOnSurface(void){
     343
     344        bool onsurface;
     345        inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum);
     346        return onsurface;
     347
     348}
     349/*}}}*/
     350/*FUNCTION Penta::GetUpperElement{{{1*/
     351Penta* Penta::GetUpperElement(void){
     352
     353        Penta* upper_penta=NULL;
     354        upper_penta=(Penta*)neighbors[1]; //first one under, second one above
     355        return upper_penta;
     356
    339357}
    340358/*}}}*/
     
    29622980
    29632981        } //if (extrude)
     2982}
     2983/*}}}*/
     2984/*FUNCTION Penta::InputExtrude {{{1*/
     2985void  Penta::InputExtrude(int enum_type){
     2986
     2987        bool onbed;
     2988        bool onsurface;
     2989
     2990        Penta* penta=NULL;
     2991
     2992        /*recover parameters: */
     2993        inputs->GetParameterValue(&onbed,ElementOnBedEnum);
     2994        inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum);
     2995
     2996        /*Are we on the base, not on the surface?:*/
     2997        if(onbed==1 & onsurface==0){
     2998
     2999                /*this element is on the bed. We are going to, follow the upper element until we reach the surface. At each upper element,
     3000                 * we'll add the input of the lower element*/
     3001
     3002                penta=this;
     3003
     3004                for(;;){
     3005
     3006                        /* get upper Penta*/
     3007                        penta=penta->GetUpperElement();
     3008
     3009                        /*Add input of the basal element*/
     3010                        penta->inputs->AddInput(this->inputs->GetInput(enum_type));
     3011
     3012                        /*Stop if we have reached the surface*/
     3013                        if (penta->IsOnSurface()) break;
     3014
     3015                }
     3016        }
     3017
     3018        return;
     3019}
     3020/*}}}*/
     3021/*FUNCTION Penta::DepthAverageInputAtBase{{{1*/
     3022void  Penta::DepthAverageInputAtBase(int enum_type){
     3023        ISSMERROR("Not implemented yet (see Penta::InputExtrude and Node::FieldDepthAverageAtBase)");
    29643024}
    29653025/*}}}*/
  • issm/trunk/src/c/objects/Elements/Penta.h

    r3858 r3869  
    5050                int   Enum();
    5151                int   Id();
    52                 bool IsInput(int name);
     52                bool  IsInput(int name);
     53                bool  IsOnSurface(void);
     54                Penta* GetUpperElement(void);
    5355                void  Marshall(char** pmarshalled_dataset);
    5456                int   MarshallSize();
     
    98100                void  GetNodalFunctions(double* l1l6, double* gauss_coord);
    99101                void  FieldExtrude(Vec field,double* field_serial,char* field_name, int iscollapsed);
     102                void  InputExtrude(int enum_type);
     103                void  DepthAverageInputAtBase(int enum_type);
    100104                void  ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type);
    101105                void  ComputePressure(Vec p_g,int analysis_type,int sub_analysis_type);
  • issm/trunk/src/c/objects/Elements/Sing.h

    r3821 r3869  
    6161                void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
    6262
     63                void   DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
    6364                /*}}}*/
    6465                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r3864 r3869  
    470470/*FUNCTION Tria::UpdateInputsFromSolutionPrognostic {{{1*/
    471471void  Tria::UpdateInputsFromSolutionPrognostic(double* solution, int analysis_type, int sub_analysis_type){
    472         ISSMERROR(" not supported yet!");
     472
     473        int i;
     474
     475        const int    numvertices=3;
     476        const int    numdofpervertex=1;
     477        const int    numdof=numdofpervertex*numvertices;
     478
     479        int          doflist[numdof];
     480        double       values[numdof];
     481        double       thickness[numvertices];
     482
     483        int          dummy;
     484
     485        /*Get dof list: */
     486        GetDofList(&doflist[0],&dummy);
     487
     488        /*Use the dof list to index into the solution vector: */
     489        for(i=0;i<numdof;i++){
     490                values[i]=solution[doflist[i]];
     491        }
     492
     493        /*Add thickness as inputs to the tria element: */
     494        this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,values));
    473495}
    474496/*}}}*/
     
    46634685}
    46644686/*}}}*/
     4687/*FUNCTION Tria::DepthAverageInputAtBase {{{1*/
     4688void  Tria::DepthAverageInputAtBase(int enum_type){
     4689
     4690        /*New input*/
     4691        Input* oldinput=NULL;
     4692        Input* newinput=NULL;
     4693
     4694        /*copy input of enum_type*/
     4695        oldinput=this->inputs->GetInput(enum_type);
     4696        newinput=(Input*)oldinput->copy();
     4697
     4698        /*Assign new name (average)*/
     4699        switch(enum_type){
     4700
     4701                case VxEnum:
     4702                        newinput->ChangeEnum(VxAverageEnum);
     4703                        break;
     4704
     4705                case VyEnum:
     4706                        newinput->ChangeEnum(VyAverageEnum);
     4707                        break;
     4708
     4709                default:
     4710                        ISSMERROR("enum_type: %i (%s) not suppoerted yet",enum_type,EnumAsString(enum_type));
     4711        }
     4712
     4713        /*Add new input to current element*/
     4714        this->inputs->AddInput(newinput);
     4715
     4716}
     4717/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.h

    r3834 r3869  
    5252                int   MyRank();
    5353                void  SetClone(int* minranks);
    54                
     54                void  DepthAverageInputAtBase(int enum_type);
    5555                /*}}}*/
    5656                /*FUNCTION element numerical routines {{{1*/
Note: See TracChangeset for help on using the changeset viewer.