Changeset 4887


Ignore:
Timestamp:
07/29/10 14:58:36 (15 years ago)
Author:
seroussi
Message:

added penpair for DiagnosticHoriz models

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

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp

    r4611 r4887  
    6565        count=0;
    6666
    67         if(iomodel->numpenalties){
    68 
    69                 for (i=0;i<iomodel->numpenalties;i++){
    70 
    71                         for(j=1;j<iomodel->numlayers;j++){
    72        
    73                                 /*We are pairing nodes along a vertical profile.*/
    74                                 node1=(int)*(iomodel->penalties+iomodel->numlayers*i)+iomodel->nodecounter;
    75                                 node2=(int)*(iomodel->penalties+iomodel->numlayers*i+j)+iomodel->nodecounter;
    76 
    77                                 constraints->AddObject(new Rgb(iomodel->constraintcounter+count+1,node1,node2,1,DiagnosticHorizAnalysisEnum));  //add count'th Rgb on dof 1 between node1 and node2
    78                                
    79                                 count++;
    80                                
    81                                 constraints->AddObject(new Rgb(iomodel->constraintcounter+count+1,node1,node2,2,DiagnosticHorizAnalysisEnum));  //add count'th Rgb on dof 1 between node1 and node2
    82 
    83                         }
    84                 }
    85         }
     67//      if(iomodel->numpenalties){
     68//
     69//              for (i=0;i<iomodel->numpenalties;i++){
     70//
     71//                      for(j=1;j<iomodel->numlayers;j++){
     72//     
     73//                              /*We are pairing nodes along a vertical profile.*/
     74//                              node1=(int)*(iomodel->penalties+iomodel->numlayers*i)+iomodel->nodecounter;
     75//                              node2=(int)*(iomodel->penalties+iomodel->numlayers*i+j)+iomodel->nodecounter;
     76//
     77//                              constraints->AddObject(new Rgb(iomodel->constraintcounter+count+1,node1,node2,1,DiagnosticHorizAnalysisEnum));  //add count'th Rgb on dof 1 between node1 and node2
     78//                             
     79//                              count++;
     80//                             
     81//                              constraints->AddObject(new Rgb(iomodel->constraintcounter+count+1,node1,node2,2,DiagnosticHorizAnalysisEnum));  //add count'th Rgb on dof 1 between node1 and node2
     82//
     83//                      }
     84//              }
     85//      }
    8686
    8787        /*Free data: */
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp

    r4236 r4887  
    2323        int i;
    2424        int count=0;
     25        int penpair_ids[2];
    2526
    2627        /*Recover pointer: */
     
    6970        xfree((void**)&iomodel->bed);
    7071
     72        /*Create Penpair for penalties: */
     73        IoModelFetchData(&iomodel->penalties,&iomodel->numpenalties,NULL,iomodel_handle,"penalties");
     74       
     75        if(iomodel->numpenalties){
     76                for(i=0;i<iomodel->numpenalties;i++){
     77                               
     78                        //if((iomodel->my_vertices[iomodel->penalties[2*i+0]]==1)){
     79                                penpair_ids[0]=(int)iomodel->penalties[2*i+0];
     80                                penpair_ids[1]=(int)iomodel->penalties[2*i+1];
     81
     82                                loads->AddObject(new Penpair(iomodel->loadcounter+count+1,&penpair_ids[0],DiagnosticHorizAnalysisEnum));
     83                                count++;
     84                        //}
     85                }
     86        }
     87
     88        /*free ressources: */
     89        xfree((void**)&iomodel->penalties);
     90
    7191        /*Create Riffront loads for rifts: */
    7292        IoModelFetchData(&iomodel->riftinfo,&iomodel->numrifts,NULL,iomodel_handle,"riftinfo");
  • issm/trunk/src/c/objects/Loads/Penpair.cpp

    r4575 r4887  
    2222
    2323        this->hnodes=NULL;
     24        this->parameters=NULL;
    2425        return;
    2526}
     
    2728/*FUNCTION Penpair::creation {{{1*/
    2829Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
    29 
    3030       
    3131        this->id=penpair_id;
    3232        this->analysis_type=in_analysis_type;
    3333        this->hnodes=new Hook(penpair_node_ids,2);
    34        
    35         return;
    36 }
    37 /*}}}1*/
    38 /*FUNCTION Penpair::creation {{{1*/
    39 Penpair::Penpair(int penpair_id, Hook* penpair_hnodes,int in_analysis_type){
    40 
    41         /*all the initialization has been done by the initializer, just fill in the id: */
    42         this->id=penpair_id;
    43         this->analysis_type=in_analysis_type;
    44         this->hnodes=penpair_hnodes;
     34        this->parameters=NULL;
    4535       
    4636        return;
     
    140130        hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
    141131
     132        /*parameters: may not exist even yet, so let Configure handle it: */
     133        this->parameters=NULL;
     134
    142135        /*return: */
    143136        *pmarshalled_dataset=marshalled_dataset;
     
    164157        /*now deal with hooks and objects: */
    165158        penpair->hnodes=(Hook*)this->hnodes->copy();
     159
     160        /*point parameters: */
     161        penpair->parameters=this->parameters;
    166162
    167163        return penpair;
     
    177173         * datasets, using internal ids and offsets hidden in hooks: */
    178174        hnodes->configure(nodesin);
     175        /*point parameters to real dataset: */
     176        this->parameters=parametersin;
    179177
    180178}
     
    187185        hnodes->configure(nodesin);
    188186
     187        /*point parameters to real dataset: */
     188        this->parameters=parametersin;
    189189}
    190190/*}}}1*/
    191191/*FUNCTION Penpair::CreateKMatrix {{{1*/
    192192void  Penpair::CreateKMatrix(Mat Kgg){
    193 
     193        /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
    194194        /*No loads applied, do nothing: */
    195195        return;
     
    207207/*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/
    208208void  Penpair::PenaltyCreateKMatrix(Mat Kgg,double kmax){
    209        
    210         /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
    211         /*No loads applied, do nothing: */
    212         return;
     209        int analysis_type;
     210
     211        /*Retrieve parameters: */
     212        this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     213
     214        if (analysis_type==DiagnosticHorizAnalysisEnum){
     215                PenaltyCreateKMatrixDiagnosticHoriz(Kgg,kmax);
     216        }
     217        else{
     218                ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumAsString(analysis_type));
     219        }
    213220}
    214221/*}}}1*/
     
    225232}
    226233/*}}}*/
     234
     235/*Update virtual functions definitions:*/
     236/*FUNCTION Penpair::InputUpdateFromConstant(double constant, int name) {{{1*/
     237void  Penpair::InputUpdateFromConstant(double constant, int name){
     238        /*Nothing updated yet*/
     239}
     240/*}}}*/
     241/*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{1*/
     242void  Penpair::InputUpdateFromConstant(int constant, int name){
     243        /*Nothing updated yet*/
     244}
     245/*}}}*/
     246/*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{1*/
     247void  Penpair::InputUpdateFromConstant(bool constant, int name){
     248        /*Nothing updated yet*/
     249}
     250/*}}}*/
     251
     252/*Penpair management:*/
     253/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz {{{1*/
     254void  Penpair::PenaltyCreateKMatrixDiagnosticHoriz(Mat Kgg,double kmax){
     255       
     256        const int numgrids=2;
     257        const int NDOF2=2;
     258        const int numdof=numgrids*NDOF2;
     259        int       doflist[numdof];
     260        int       numberofdofspernode;
     261
     262        double Ke[4][4]={0.0};
     263        double penalty_offset;
     264
     265        /*pointers: */
     266        Node** nodes=NULL;
     267
     268        /*Get dof list: */
     269        GetDofList(&doflist[0],&numberofdofspernode);
     270
     271        /*recover pointers: */
     272        nodes=(Node**)hnodes->deliverp();
     273
     274        /*recover parameters: */
     275        parameters->FindParam(&penalty_offset,PenaltyOffsetEnum);
     276
     277        //Create elementary matrix: add penalty to
     278        Ke[0][0]=kmax*pow((double)10.0,penalty_offset);
     279        Ke[0][2]=-kmax*pow((double)10.0,penalty_offset);
     280        Ke[2][0]=-kmax*pow((double)10.0,penalty_offset);
     281        Ke[2][2]=kmax*pow((double)10.0,penalty_offset);
     282
     283        Ke[1][1]=kmax*pow((double)10.0,penalty_offset);
     284        Ke[1][3]=-kmax*pow((double)10.0,penalty_offset);
     285        Ke[3][1]=-kmax*pow((double)10.0,penalty_offset);
     286        Ke[3][3]=kmax*pow((double)10.0,penalty_offset);
     287       
     288        /*Add Ke to global matrix Kgg: */
     289        MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES);
     290}
     291/*}}}1*/
     292/*FUNCTION Penpair::GetDofList {{{1*/
     293void  Penpair::GetDofList(int* doflist,int* pnumberofdofspernode){
     294
     295        int i,j;
     296        int doflist_per_node[MAXDOFSPERNODE];
     297        int numberofdofspernode;
     298
     299        /*pointers: */
     300        Node** nodes=NULL;
     301
     302        /*recover pointers: */
     303        nodes=(Node**)hnodes->deliverp();
     304
     305        /*Some checks for debugging*/
     306        ISSMASSERT(doflist);
     307        ISSMASSERT(pnumberofdofspernode);
     308        ISSMASSERT(nodes);
     309
     310        /*Build doflist from nodes*/
     311        for(i=0;i<2;i++){
     312                nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
     313                for(j=0;j<numberofdofspernode;j++){
     314                        doflist[i*numberofdofspernode+j]=doflist_per_node[j];
     315                }
     316        }
     317
     318        /*Assign output pointers:*/
     319        *pnumberofdofspernode=numberofdofspernode;
     320
     321}
     322/*}}}*/
  • issm/trunk/src/c/objects/Loads/Penpair.h

    r4575 r4887  
    2222                Hook* hnodes;  //hook to 2 nodes
    2323
     24                Parameters* parameters; //pointer to solution parameters
     25
    2426        public:
    2527
     
    2729                Penpair();
    2830                Penpair(int penpair_id,int* penpair_node_ids,int analysis_type);
    29                 Penpair(int penpair_id,Hook* penpair_hnodes,int analysis_type);
    3031                ~Penpair();
    3132                /*}}}*/
     
    4546                void  InputUpdateFromVector(int* vector, int name, int type){ISSMERROR("Not implemented yet!");}
    4647                void  InputUpdateFromVector(bool* vector, int name, int type){ISSMERROR("Not implemented yet!");}
    47                 void  InputUpdateFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");}
    48                 void  InputUpdateFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
    49                 void  InputUpdateFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
     48                void  InputUpdateFromConstant(double constant, int name);
     49                void  InputUpdateFromConstant(int constant, int name);
     50                void  InputUpdateFromConstant(bool constant, int name);
    5051                void  InputUpdateFromSolution(double* solution){ISSMERROR("Not implemented yet!");}
    5152                /*}}}*/
     
    5960                bool  InAnalysis(int analysis_type);
    6061                /*}}}*/
     62                        /*Penpair management: {{{1*/
     63                void  PenaltyCreateKMatrixDiagnosticHoriz(Mat Kgg,double kmax);
     64                void  GetDofList(int* doflist,int* pnumberofdofspernode);
     65                /*}}}*/
    6166};
    6267
Note: See TracChangeset for help on using the changeset viewer.