Changeset 14731


Ignore:
Timestamp:
04/23/13 22:22:56 (12 years ago)
Author:
Eric.Larour
Message:

CHG: move capabilities implemented for the IssmMpiVec issm toolkit vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h

    r14727 r14731  
    5959                }
    6060                /*}}}*/
    61                 /*FUNCTION IssmMpiVec(int m,int M){{{*/
    62                 /*IssmMpiVec(int min,int Min){
    63                         this->Init(Min,false);
    64                 }*/
    65                 /*}}}*/
    6661                /*FUNCTION IssmMpiVec(int M,bool fromlocalsize){{{*/
    6762                IssmMpiVec(int Min, bool fromlocalsize){
     
    7570
    7671                        if(this->M){
    77                                 this->vector=xNew<doubletype>(Min);
     72                                this->vector=xNew<doubletype>(this->m);
    7873                                xMemCpy<doubletype>(this->vector,buffer,this->m);
    7974                        }
     
    130125                /*FUNCTION Assemble{{{*/
    131126                void Assemble(void){
    132                         _error_("not implemented yet!");
     127                        printf("not imlemented yet!");
     128                        exit(1);
    133129                }
    134130                /*}}}*/
     
    159155                void GetValue(doubletype* pvalue,int dof){
    160156                        _error_("Get value on a MpiVec vector not implemented yet!");
    161 
    162157                }
    163158                /*}}}*/
     
    193188                /*FUNCTION AXPY{{{*/
    194189                void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){
    195                         _error_("not implemented yet!");
     190                        printf("AXPY not implemented yet!");
     191                        exit(1);
    196192                }
    197193                /*}}}*/
    198194                /*FUNCTION AYPX{{{*/
    199195                void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){
    200                         _error_("not implemented yet!");
     196                        printf("AYPX not implemented yet!");
     197                        exit(1);
    201198                }
    202199                /*}}}*/
    203200                /*FUNCTION ToMPISerial{{{*/
    204201                doubletype* ToMPISerial(void){
    205 
    206                         doubletype* buffer=NULL;
    207 
    208                         if(this->M){
    209                                 buffer=xNew<doubletype>(this->M);
    210                                 xMemCpy<doubletype>(buffer,this->vector,this->M);
    211                         }
    212                         return buffer;
     202                       
     203                        printf("IssmMpiVec ToMPISerial not implemented yet!");
     204                        exit(1);
    213205
    214206                }
     
    225217
    226218                        to->M=this->M;
    227                         for(i=0;i<this->M;i++)to->vector[i]=this->vector[i];
     219                        for(i=0;i<this->m;i++)to->vector[i]=this->vector[i];
    228220
    229221                }
     
    232224                doubletype Norm(NormMode mode){
    233225
    234                         doubletype norm;
    235                         int i;
    236 
    237                         switch(mode){
    238                                 case NORM_INF:
    239                                         norm=0; for(i=0;i<this->M;i++)norm=max(norm,fabs(this->vector[i]));
    240                                         return norm;
    241                                         break;
    242                                 case NORM_TWO:
    243                                         norm=0;
    244                                         for(i=0;i<this->M;i++)norm+=pow(this->vector[i],2);
    245                                         return sqrt(norm);
    246                                         break;
    247                                 default:
    248                                         _error_("unknown norm !");
    249                                         break;
    250                         }
     226                        printf("IssmMpiVec Norm not implemented yet!");
     227                        exit(1);
    251228                }
    252229                /*}}}*/
     
    259236                }
    260237                /*}}}*/
    261                 /*FU            /*FUNCTION Dot{{{*/
     238                /*FUNCTION Dot{{{*/
    262239                doubletype Dot(IssmAbsVec<doubletype>* inputin){
    263240
    264241                        int i;
     242                        doubletype local_dot=0;
     243                        doubletype dot=0;
    265244
    266245                        /*Assume inputin is of the correct type, and downcast: */
     
    269248                        input=(IssmMpiVec<doubletype>*)inputin;
    270249
    271 
    272                         doubletype dot=0;
    273                         for(i=0;i<this->M;i++)dot+=this->vector[i]*input->vector[i];
     250                        for(i=0;i<this->m;i++)local_dot+=this->vector[i]*input->vector[i];
     251
     252                        #ifdef _HAVE_MPI_
     253                        /*MPI_SUM all the dots across the cluster: */
     254                        MPI_Reduce(&local_dot, &dot, 1, MPI_DOUBLE, MPI_SUM, 0, IssmComm::GetComm());
     255                        MPI_Bcast(&dot,1,MPI_DOUBLE,0,IssmComm::GetComm());
     256                        #endif
     257
    274258                        return dot;
    275 
    276259                }
    277260                /*}}}*/
     
    290273
    291274                        /*pointwise w=x/y where this->vector is w: */
    292                         for(i=0;i<this->M;i++)this->vector[i]=x->vector[i]/y->vector[i];
     275                        for(i=0;i<this->m;i++)this->vector[i]=x->vector[i]/y->vector[i];
    293276                }
    294277                /*}}}*/
Note: See TracChangeset for help on using the changeset viewer.