Changeset 8799


Ignore:
Timestamp:
07/05/11 16:45:48 (14 years ago)
Author:
Eric.Larour
Message:

Modified API for modules, to take into account new constraint applications, without nodesets

Location:
issm/trunk/src/c/modules
Files:
6 added
3 deleted
12 edited

Legend:

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

    r8798 r8799  
    323323                case IsMacAyealPattynEnum : return "IsMacAyealPattyn";
    324324                case IsStokesEnum : return "IsStokes";
    325                 case KffEnum : return "Kff";
    326325                case LatentHeatEnum : return "LatentHeat";
    327326                case LowmemEnum : return "Lowmem";
  • issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp

    r6580 r8799  
    33 */
    44
     5#include "../VecMergex/VecMergex.h"
    56#include "./Mergesolutionfromftogx.h"
    67
    7 void    Mergesolutionfromftogx( Vec* pug, Vec uf, Vec ys, NodeSets* nodesets,bool flag_ys0){
     8void    Mergesolutionfromftogx( Vec* pug, Vec uf, Vec ys, Nodes* nodes, Parameters* parameters, bool flag_ys0){
    89
    910        /*output: */
    1011        Vec ug=NULL;
    11         Vec ys0=NULL;
    12         int ug_local_size;
    13        
     12
     13        /*intermediary: */
     14        int configuration_type;
     15        int analysis_type;
     16        int gsize,fsize,ssize;
     17
    1418        /*Display message*/
    1519        _printf_(VerboseModule(),"   Merging solution vector from fset to gset\n");
    1620
    17         /*Merge f set back into g set: */
    18         ug=NewVec(nodesets->GetGSize());
    19         if(uf) VecMerge(ug,uf,nodesets->GetPV_F(),nodesets->GetFSize());
     21        /*first, get gsize, fsize and ssize: */
     22        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
     23        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     24        gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
     25        fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
     26        ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
    2027
    21         /*merge single point constraints into g set: */
    22         if(ys){
    23                 if (flag_ys0){
    24 
    25                         /*Create ys0, full of 0: */
    26                         VecDuplicate(ys,&ys0);
    27                         VecSet(ys0,0.0);
    28                         VecAssemblyBegin(ys0);
    29                         VecAssemblyEnd(ys0);
    30 
    31                         VecMerge(ug,ys0,nodesets->GetPV_S(),nodesets->GetSSize());
    32                 }
    33                 else{
    34                         VecMerge(ug,ys,nodesets->GetPV_S(),nodesets->GetSSize());
     28        /*serialize uf and ys: those two vectors will be indexed by the nodes, who are the only ones
     29         *that know which values should be plugged into ug and where: */
     30        if(ssize){
     31                if(flag_ys0){
     32                        VecSet(ys,0.0);
    3533                }
    3634        }
    3735
    38         /*Free ressources:*/
    39         VecFree(&ys0);
     36        /*initialize ug: */
     37        ug=NewVec(gsize);
     38
     39        /*Merge f set back into g set: */
     40        if(fsize){
     41                VecMergex(ug,uf,nodes,parameters,FsetEnum);
     42        }
     43       
     44        /*Merge s set back into g set: */
     45        if(ssize){
     46                VecMergex(ug,ys,nodes,parameters,SsetEnum);
     47        }
    4048
    4149        /*Assign correct pointer*/
  • issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h

    r6580 r8799  
    99
    1010/* local prototypes: */
    11 void    Mergesolutionfromftogx( Vec* pug, Vec uf,Vec ys, NodeSets* nodesets,bool flag_ys0=false);
     11void    Mergesolutionfromftogx( Vec* pug, Vec uf, Vec ys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false);
    1212
    1313#endif  /* _MERGESOLUTIONFROMFTOGX_H */
  • issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r8487 r8799  
    7777        parameters->AddObject(new BoolParam(WaitOnLockEnum,iomodel->waitonlock));
    7878        parameters->AddObject(new IntParam(NumberOfElementsEnum,iomodel->numberofelements));
    79         parameters->AddObject(new BoolParam(KffEnum,iomodel->kff));
    8079        parameters->AddObject(new BoolParam(IoGatherEnum,iomodel->io_gather));
    8180        parameters->AddObject(new IntParam(GroundingLineMigrationEnum,iomodel->gl_migration));
  • issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp

    r6580 r8799  
    66#include "./Reducevectorgtofx.h"
    77 
    8 void Reducevectorgtofx(Vec* puf, Vec ug, NodeSets* nodesets,Parameters* parameters){
     8void Reducevectorgtofx(Vec* puf, Vec ug, Nodes* nodes,Parameters* parameters){
    99
    1010        /*output: */
    1111        Vec uf=NULL;
    1212
    13         /*what type of partitioning: */
    14         bool kffpartitioning=false;
     13        /*variables: */
     14        int i;
     15        int analysis_type;
     16        int configuration_type;
     17        int fsize;
     18        double* ug_serial=NULL;
    1519
    16         /*find parameter: */
    17         parameters->FindParam(&kffpartitioning,KffEnum);
     20        /*first figure out fsize: */
     21        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
     22        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     23        fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
    1824
    19         if(nodesets){
     25        if(fsize==0){
     26                uf=NULL;
     27        }
     28        else{
     29                /*allocate: */
     30                uf=NewVec(fsize);
    2031
    21                 if (nodesets->GetGSize() && nodesets->GetFSize()){
    22                         VecPartition(&uf,ug,nodesets->GetPV_F(),nodesets->GetFSize(),kffpartitioning);
     32                if(nodes->NumberOfNodes(analysis_type)){
     33
     34                        /*serialize ug, so nodes can index into it: */
     35                        VecToMPISerial(&ug_serial,ug);
     36
     37                        /*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */
     38                        for(i=0;i<nodes->Size();i++){
     39
     40                                Node* node=(Node*)nodes->GetObjectByOffset(i);
     41
     42                                /*Check that this node corresponds to our analysis currently being carried out: */
     43                                if (node->InAnalysis(analysis_type)){
     44
     45                                        /*For this object, reduce values for enum set Fset: */
     46                                        node->VecReduce(uf,ug_serial,FsetEnum);
     47                                }
     48                        }
     49
    2350                }
    2451        }
    25        
     52
     53        /*Assemble vector: */
     54        VecAssemblyBegin(uf);
     55        VecAssemblyEnd(uf);
     56
     57
     58        /*Free ressources:*/
     59        xfree((void**)&ug_serial);
     60
    2661        /*Assign output pointers:*/
    2762        *puf=uf;
  • issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h

    r5787 r8799  
    1010
    1111/* local prototypes: */
    12 void    Reducevectorgtofx(Vec* puf, Vec ug, NodeSets* nodesets, Parameters* parameters);
     12void Reducevectorgtofx(Vec* puf, Vec ug, Nodes* nodes,Parameters* parameters);
    1313
    1414#endif  /* _REDUCEVECTORGTOFX_H */
  • issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp

    r5787 r8799  
    66#include "./Reducevectorgtosx.h"
    77
    8 void Reducevectorgtosx( Vec* pys, Vec yg, NodeSets* nodesets,Parameters* parameters){
     8void Reducevectorgtosx(Vec* pys, Vec yg, Nodes* nodes,Parameters* parameters){
    99
    1010        /*output: */
    1111        Vec ys=NULL;
    1212
    13         /*what type of partitioning: */
    14         bool kffpartitioning=false;
     13        /*variables: */
     14        int i;
     15        int analysis_type;
     16        int configuration_type;
     17        int ssize;
     18        double* yg_serial=NULL;
    1519
    16         /*find parameter: */
    17         parameters->FindParam(&kffpartitioning,KffEnum);
     20        /*first figure out ssize: */
     21        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
     22        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     23        ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
    1824
    19         if(nodesets){
    20                 if (nodesets->GetGSize() && nodesets->GetSSize()){
    21                         VecPartition(&ys,yg,nodesets->GetPV_S(),nodesets->GetSSize(),kffpartitioning);
     25        if(ssize==0){
     26                ys=NULL;
     27        }
     28        else{
     29                /*allocate: */
     30                ys=NewVec(ssize);
     31
     32                if(nodes->NumberOfNodes(analysis_type)){
     33
     34                        /*serialize yg, so nodes can index into it: */
     35                        VecToMPISerial(&yg_serial,yg);
     36
     37                        /*Go throygh all nodes, and ask them to retrieve values from yg, and plyg them into ys: */
     38                        for(i=0;i<nodes->Size();i++){
     39
     40                                Node* node=(Node*)nodes->GetObjectByOffset(i);
     41
     42                                /*Check that this node corresponds to our analysis currently being carried out: */
     43                                if (node->InAnalysis(analysis_type)){
     44
     45                                        /*For this object, reduce values for enum set Fset: */
     46                                        node->VecReduce(ys,yg_serial,SsetEnum);
     47                                }
     48                        }
    2249                }
    2350        }
    24        
    25         /*Assign output pointer:*/
     51
     52        /*Assemble vector: */
     53        VecAssemblyBegin(ys);
     54        VecAssemblyEnd(ys);
     55
     56        /*Free ressources:*/
     57        xfree((void**)&yg_serial);
     58
     59        /*Assign output pointers:*/
    2660        *pys=ys;
    2761}
  • issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h

    r5787 r8799  
    1010
    1111/* local prototypes: */
    12 void    Reducevectorgtosx( Vec* pys, Vec yg, NodeSets* nodesets,Parameters* parameters);
     12void Reducevectorgtosx(Vec* pys, Vec yg, Nodes* nodes,Parameters* parameters);
    1313
    1414#endif  /* _REDUCEVECTORGTOSX_H */
  • issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp

    r8798 r8799  
    321321        else if (strcmp(name,"IsMacAyealPattyn")==0) return IsMacAyealPattynEnum;
    322322        else if (strcmp(name,"IsStokes")==0) return IsStokesEnum;
    323         else if (strcmp(name,"Kff")==0) return KffEnum;
    324323        else if (strcmp(name,"LatentHeat")==0) return LatentHeatEnum;
    325324        else if (strcmp(name,"Lowmem")==0) return LowmemEnum;
  • issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp

    r7391 r8799  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void SystemMatricesx(Mat* pKgg, Mat* pKff, Mat* pKfs, Vec* ppg, Vec* ppf, Vec* pdg, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
     11void SystemMatricesx(Mat* pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
    1212       
    1313        /*intermediary: */
    1414        int      i,j;
    15         int      gsize,fsize,ssize;
     15        int      fsize,ssize;
    1616        int      connectivity, numberofdofspernode;
    1717        int      analysis_type, configuration_type;
    1818        Element *element = NULL;
    1919        Load    *load    = NULL;
    20         bool    buildkff=false;
    2120       
    2221        /*output: */
    23         Mat    Kgg  = NULL;
    2422        Mat    Kff  = NULL;
    2523        Mat    Kfs  = NULL;
    26         Vec    pg   = NULL;
    2724        Vec    pf   = NULL;
    28         Vec    dg=NULL;
    2925        Vec    df=NULL;
    3026        double kmax = 0;
     
    3733        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
    3834        parameters->FindParam(&connectivity,ConnectivityEnum);
    39         parameters->FindParam(&buildkff,KffEnum);
    4035
    41         /*Get size of matrix: */
    42         gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
     36        /*Get size of matrices: */
    4337        fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
    4438        ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
     
    5448        if(kflag){
    5549
    56                 if(!buildkff){
    57                         Kgg=NewMat(gsize,gsize,connectivity,numberofdofspernode);
    58                         dg=NewVec(gsize);
    59                 }
    60                 else{
    61                         Kff=NewMat(fsize,fsize,connectivity,numberofdofspernode);
    62                         Kfs=NewMat(fsize,ssize,connectivity,numberofdofspernode);
    63                         df=NewVec(fsize);
    64                 }
     50                Kff=NewMat(fsize,fsize,connectivity,numberofdofspernode);
     51                Kfs=NewMat(fsize,ssize,connectivity,numberofdofspernode);
     52                df=NewVec(fsize);
    6553
    6654                /*Fill stiffness matrix from elements: */
    6755                for (i=0;i<elements->Size();i++){
    6856                        element=(Element*)elements->GetObjectByOffset(i);
    69                         element->CreateKMatrix(Kgg,Kff,Kfs,dg,df);
     57                        element->CreateKMatrix(Kff,Kfs,df);
    7058                }
    7159
     
    7361                for (i=0;i<loads->Size();i++){
    7462                        load=(Load*)loads->GetObjectByOffset(i);
    75                         if (load->InAnalysis(configuration_type)) load->CreateKMatrix(Kgg,Kff,Kfs);
     63                        if (load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff,Kfs);
    7664                }
    7765
    7866                /*Assemble matrix and doftypes and compress matrix to save memory: */
    79                 if(!buildkff){
    80                         MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
    81                         MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
    82                         #if _PETSC_VERSION_ == 2
    83                         MatCompress(Kgg);
    84                         #endif
    85                         VecAssemblyBegin(dg);
    86                         VecAssemblyEnd(dg);
    87                 }
    88                 else{
    89                         MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
    90                         MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
    91                         #if _PETSC_VERSION_ == 2
    92                         MatCompress(Kff);
    93                         #endif
     67                MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
     68                MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
     69                #if _PETSC_VERSION_ == 2
     70                MatCompress(Kff);
     71                #endif
    9472
    95                         MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
    96                         MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
    97                         #if _PETSC_VERSION_ == 2
    98                         MatCompress(Kfs);
    99                         #endif
    100                         VecAssemblyBegin(df);
    101                         VecAssemblyEnd(df);
    102                 }
     73                MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
     74                MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
     75                #if _PETSC_VERSION_ == 2
     76                MatCompress(Kfs);
     77                #endif
     78                VecAssemblyBegin(df);
     79                VecAssemblyEnd(df);
    10380               
    10481        }
     
    10683        if(pflag){
    10784
    108                 if(!buildkff)pg=NewVec(gsize);
    109                 else         pf=NewVec(fsize);
     85                pf=NewVec(fsize);
    11086
    11187                /*Fill right hand side vector, from elements: */
    11288                for (i=0;i<elements->Size();i++){
    11389                        element=(Element*)elements->GetObjectByOffset(i);
    114                         element->CreatePVector(pg,pf);
     90                        element->CreatePVector(pf);
    11591                }
    11692
     
    11894                for (i=0;i<loads->Size();i++){
    11995                        load=(Load*)loads->GetObjectByOffset(i);
    120                         if (load->InAnalysis(configuration_type)) load->CreatePVector(pg,pf);
     96                        if (load->InAnalysis(configuration_type)) load->CreatePVector(pf);
    12197                }
    12298
    123                 if(!buildkff){
    124                         VecAssemblyBegin(pg);
    125                         VecAssemblyEnd(pg);
    126                 }
    127                 else{
    128                         VecAssemblyBegin(pf);
    129                         VecAssemblyEnd(pf);
    130                 }
     99                VecAssemblyBegin(pf);
     100                VecAssemblyEnd(pf);
    131101        }
    132102
    133103        /*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */
    134         if(!buildkff)MatNorm(Kgg,NORM_INFINITY,&kmax);
    135         else MatNorm(Kff,NORM_INFINITY,&kmax);
     104        MatNorm(Kff,NORM_INFINITY,&kmax);
    136105
    137106        /*Now, deal with penalties*/
     
    141110                for (i=0;i<loads->Size();i++){
    142111                        load=(Load*)loads->GetObjectByOffset(i);
    143                         if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kgg,Kff,Kfs,kmax);
     112                        if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax);
    144113                }
    145114
    146115                /*Assemble matrix and compress matrix to save memory: */
    147                 if(!buildkff){
    148                         MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
    149                         MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
    150                         #if _PETSC_VERSION_ == 2
    151                         MatCompress(Kgg);
    152                         #endif
    153                 }
    154                 else{
    155                         MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
    156                         MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
    157                         #if _PETSC_VERSION_ == 2
    158                         MatCompress(Kff);
    159                         #endif
     116                MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
     117                MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
     118                #if _PETSC_VERSION_ == 2
     119                MatCompress(Kff);
     120                #endif
    160121
    161                         MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
    162                         MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
    163                         #if _PETSC_VERSION_ == 2
    164                         MatCompress(Kfs);
    165                         #endif
    166                 }
     122                MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
     123                MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
     124                #if _PETSC_VERSION_ == 2
     125                MatCompress(Kfs);
     126                #endif
    167127        }
    168128
     
    173133                for (i=0;i<loads->Size();i++){
    174134                        load=(Load*)loads->GetObjectByOffset(i);
    175                         if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pg,pf,kmax);
     135                        if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax);
    176136                }
    177137
    178                 if(!buildkff){
    179                         VecAssemblyBegin(pg);
    180                         VecAssemblyEnd(pg);
    181                 }
    182                 else{
    183                         VecAssemblyBegin(pf);
    184                         VecAssemblyEnd(pf);
    185                 }
     138                VecAssemblyBegin(pf);
     139                VecAssemblyEnd(pf);
    186140        }
    187141
    188142        /*Assign output pointers: */
    189         if(pKgg) *pKgg=Kgg;
    190143        if(pKff) *pKff=Kff;
    191144        if(pKfs) *pKfs=Kfs;
    192         if(ppg)  *ppg=pg;
    193145        if(ppf)  *ppf=pf;
    194         if(pdg)  *pdg=dg;
    195146        if(pdf)  *pdf=df;
    196147        if(pkmax) *pkmax=kmax;
  • issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h

    r7391 r8799  
    1010
    1111/* local prototypes: */
    12 void SystemMatricesx(Mat* pKgg, Mat* pKff, Mat* pKfs, Vec* ppg, Vec* ppf, Vec* pdg, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
     12void SystemMatricesx(Mat* pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
    1313                        bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true);
    1414
  • issm/trunk/src/c/modules/modules.h

    r8711 r8799  
    1212#include "./Bamgx/Bamgx.h"
    1313#include "./BamgConvertMeshx/BamgConvertMeshx.h"
    14 #include "./BuildNodeSetsx/BuildNodeSetsx.h"
    1514#include "./Chacox/Chacox.h"
    1615#include "./ComputeBasalStressx/ComputeBasalStressx.h"
     
    8786#include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h"
    8887#include "./Qmux/Qmux.h"
    89 #include "./Reduceloadfromgtofx/Reduceloadfromgtofx.h"
    9088#include "./Reduceloadx/Reduceloadx.h"
    91 #include "./Reducematrixfromgtofx/Reducematrixfromgtofx.h"
    9289#include "./Reducevectorgtosx/Reducevectorgtosx.h"
    9390#include "./Reducevectorgtofx/Reducevectorgtofx.h"
     
    104101#include "./ThicknessAbsGradientx/ThicknessAbsGradientx.h"
    105102#include "./UpdateVertexPositionsx/UpdateVertexPositionsx.h"
     103#include "./UpdateSpcsx/UpdateSpcsx.h"
    106104#include "./VerticesDofx/VerticesDofx.h"
     105#include "./VecMergex/VecMergex.h"
    107106
    108107#endif
Note: See TracChangeset for help on using the changeset viewer.