Changeset 11716


Ignore:
Timestamp:
03/14/12 17:09:20 (13 years ago)
Author:
Mathieu Morlighem
Message:

Added support for empty vectors in serial mode

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/io/Matlab/FetchMatlabData.cpp

    r11695 r11716  
    286286                /*Check dataref is not pointing to NaN: */
    287287                if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
    288                         outmatrix=NULL;
     288                        outmatrix=new Matrix(0,0);
    289289                }
    290290                else{
     
    434434        if(mxIsEmpty(dataref)){
    435435                /*Nothing to pick up. Just initialize matrix pointer to NULL: */
    436                 vector=NULL;
     436                vector=new Vector(0);
    437437        }
    438438        else if (mxIsClass(dataref,"double") ){
  • issm/trunk-jpl/src/c/io/Matlab/WriteMatlabData.cpp

    r11695 r11716  
    114114       
    115115        if(vector){
    116                
    117116                /*call toolkit routine: */
    118117                dataref=vector->ToMatlabVector();
  • issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp

    r11715 r11716  
    1616void    Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters){
    1717
    18         /*output: */
    19         Vector* uf=NULL;
    20         uf=new Vector();
    21 
    2218        /*Intermediary: */
    2319        int analysis_type;
     20
     21        /*output: */
     22        Vector *uf=new Vector();
     23
     24        /*In debugging mode, check that stiffness matrix and load vectors are not NULL (they can be empty)*/
     25        _assert_(Kff);
     26        _assert_(pf);
    2427
    2528        #ifdef _HAVE_PETSC_
    2629        Vec uf0_vector = NULL;
    2730        Vec df_vector  = NULL;
    28         if(uf0) uf0_vector=uf0->vector;
    29         if(df)  df_vector = df->vector;
     31        if(uf0) uf0_vector = uf0->vector;
     32        if(df)  df_vector  = df->vector;
    3033
    3134        /*In serial mode, the Petsc Options database has not been initialized properly: */
     
    3740        SolverxPetsc(&uf->vector,Kff->matrix,pf->vector,uf0_vector,df_vector,parameters);
    3841        if(uf->vector == NULL){
    39                 uf->M;
     42                uf->M = 0;
    4043        }
    4144        else{
  • issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp

    r9320 r11716  
    2727int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector){
    2828
    29 
    30         int i;
    31         int rows;
    32         int* idxm=NULL;
    33         double* values=NULL;
     29        int     i;
     30        int     rows;
     31        int    *idxm   = NULL;
     32        double *values = NULL;
    3433
    3534        /*output: */
     
    3736
    3837        /*Get size of vector: */
    39         VecGetSize(vector,&rows);
     38        if(vector){
     39                VecGetSize(vector,&rows);
     40                if(rows){
     41                        idxm=(int*)xmalloc(rows*sizeof(int));
     42                        values=(double*)xmalloc(rows*sizeof(double));
     43                        for(i=0;i<rows;i++)idxm[i]=i;
    4044
    41         if(rows){
    42                 idxm=(int*)xmalloc(rows*sizeof(int));
    43                 values=(double*)xmalloc(rows*sizeof(double));
    44                 for(i=0;i<rows;i++)idxm[i]=i;
    45                  
    46                 VecGetValues(vector,rows,idxm,values);
     45                        VecGetValues(vector,rows,idxm,values);
     46                }
     47        }
     48        else{
     49                rows=0;
    4750        }
    4851
     
    6164}
    6265
    63 
    6466#endif  //#ifdef _SERIAL_
    65 
Note: See TracChangeset for help on using the changeset viewer.