Changeset 13878


Ignore:
Timestamp:
11/05/12 14:30:01 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added allocation module, to be continued

Location:
issm/trunk-jpl/src/c/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r13877 r13878  
    337337
    338338/*Modules:*/
     339void FemModel::AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf){ /*{{{*/
     340
     341        /*Intermediary*/
     342        int      fsize,ssize;
     343        int      connectivity, numberofdofspernode;
     344        int      analysis_type, configuration_type;
     345
     346        /*output*/
     347        Matrix<IssmDouble> *Kff  = NULL;
     348        Matrix<IssmDouble> *Kfs  = NULL;
     349        Vector<IssmDouble> *pf   = NULL;
     350        Vector<IssmDouble> *df   = NULL;
     351
     352        bool oldalloc=true;
     353
     354        /*retrieve parameters: */
     355        this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     356        this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
     357        this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum);
     358
     359        /*retrieve node info*/
     360        fsize=this->nodes->NumberOfDofs(configuration_type,FsetEnum);
     361        ssize=this->nodes->NumberOfDofs(configuration_type,SsetEnum);
     362        numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum);
     363
     364        if(oldalloc){
     365                Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode);
     366                Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode);
     367                df =new Vector<IssmDouble>(fsize);
     368                pf =new Vector<IssmDouble>(fsize);
     369        }
     370        else{
     371                /*IN PROGRESS*/
     372        }
     373
     374        /*Allocate output pointers*/
     375        *pKff = Kff;
     376        *pKfs = Kfs;
     377        *pdf  = df;
     378        *ppf  = pf;
     379}
     380/*}}}*/
    339381int  FemModel::UpdateVertexPositionsx(void){ /*{{{*/
    340382
     
    522564        /*intermediary: */
    523565        int      i;
    524         int      fsize,ssize;
    525         int      connectivity, numberofdofspernode;
    526         int      analysis_type, configuration_type;
     566        int      configuration_type;
    527567        Element *element = NULL;
    528568        Load    *load    = NULL;
     
    535575        IssmDouble          kmax;
    536576
     577
    537578        /*Display message*/
    538579        if(VerboseModule()) _pprintLine_("   Generating matrices");
    539580
    540581        /*retrive parameters: */
    541         this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    542582        this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
    543         this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum);
    544 
    545         /*Get size of matrices: */
    546         fsize=this->nodes->NumberOfDofs(configuration_type,FsetEnum);
    547         ssize=this->nodes->NumberOfDofs(configuration_type,SsetEnum);
    548 
    549         numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum);
    550583
    551584        /*Compute penalty free mstiffness matrix and load vector*/
    552         Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode);
    553         Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode);
    554         df =new Vector<IssmDouble>(fsize);
    555 
    556         /*Fill stiffness matrix from elements: */
     585        this->AllocateSystemMatrices(&Kff,&Kfs,&df,&pf);
     586
     587        /*Fill stiffness matrix from elements and loads */
    557588        for (i=0;i<this->elements->Size();i++){
    558589                element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
    559590                element->CreateKMatrix(Kff,Kfs,df);
    560591        }
    561 
    562         /*Fill stiffness matrix from loads if loads have the current configuration_type: */
    563592        for (i=0;i<this->loads->Size();i++){
    564593                load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
     
    566595        }
    567596
    568         /*Assemble matrices*/
     597
     598        /*Fill right hand side vector, from elements and loads */
     599        for (i=0;i<this->elements->Size();i++){
     600                element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
     601                element->CreatePVector(pf);
     602        }
     603        for (i=0;i<this->loads->Size();i++){
     604                load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
     605                if (load->InAnalysis(configuration_type)) load->CreatePVector(pf);
     606        }
     607
     608        /*Assemble matrices (required to get kmax)*/
    569609        Kff->Assemble();
    570610        Kfs->Assemble();
    571611        df->Assemble();
    572612
    573         /*Create Load vector*/
    574         pf=new Vector<IssmDouble>(fsize);
    575 
    576         /*Fill right hand side vector, from elements: */
    577         for (i=0;i<this->elements->Size();i++){
    578                 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
    579                 element->CreatePVector(pf);
    580         }
    581 
    582         /*Fill right hand side from loads if loads have the current configuration_type: */
    583         for (i=0;i<this->loads->Size();i++){
    584                 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
    585                 if (load->InAnalysis(configuration_type)) load->CreatePVector(pf);
    586         }
    587         pf->Assemble();
    588 
    589         /*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */
     613        /*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */
    590614        kmax=Kff->Norm(NORM_INF);
    591615
    592         /*Now, deal with penalties*/
    593         /*Fill stiffness matrix from loads: */
     616        /*Now that we have kmax, deal with penalties (only in loads)*/
    594617        for (i=0;i<this->loads->Size();i++){
    595618                load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
    596619                if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax);
    597620        }
    598 
    599         /*Assemble matrices*/
    600         Kff->Assemble();
    601         Kfs->Assemble();
    602 
    603         /*Fill right hand side vector, from loads: */
    604621        for (i=0;i<this->loads->Size();i++){
    605622                load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
     
    607624        }
    608625
    609         /*Assemble vector*/
     626        /*Assemble matrices and vector*/
     627        Kff->Assemble();
     628        Kfs->Assemble();
    610629        pf->Assemble();
    611630
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r13877 r13878  
    5252
    5353                /*Methods:*/
     54                void AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf);
    5455                void Echo();
    5556                void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
Note: See TracChangeset for help on using the changeset viewer.