Changeset 14731
- Timestamp:
- 04/23/13 22:22:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h
r14727 r14731 59 59 } 60 60 /*}}}*/ 61 /*FUNCTION IssmMpiVec(int m,int M){{{*/62 /*IssmMpiVec(int min,int Min){63 this->Init(Min,false);64 }*/65 /*}}}*/66 61 /*FUNCTION IssmMpiVec(int M,bool fromlocalsize){{{*/ 67 62 IssmMpiVec(int Min, bool fromlocalsize){ … … 75 70 76 71 if(this->M){ 77 this->vector=xNew<doubletype>( Min);72 this->vector=xNew<doubletype>(this->m); 78 73 xMemCpy<doubletype>(this->vector,buffer,this->m); 79 74 } … … 130 125 /*FUNCTION Assemble{{{*/ 131 126 void Assemble(void){ 132 _error_("not implemented yet!"); 127 printf("not imlemented yet!"); 128 exit(1); 133 129 } 134 130 /*}}}*/ … … 159 155 void GetValue(doubletype* pvalue,int dof){ 160 156 _error_("Get value on a MpiVec vector not implemented yet!"); 161 162 157 } 163 158 /*}}}*/ … … 193 188 /*FUNCTION AXPY{{{*/ 194 189 void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){ 195 _error_("not implemented yet!"); 190 printf("AXPY not implemented yet!"); 191 exit(1); 196 192 } 197 193 /*}}}*/ 198 194 /*FUNCTION AYPX{{{*/ 199 195 void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){ 200 _error_("not implemented yet!"); 196 printf("AYPX not implemented yet!"); 197 exit(1); 201 198 } 202 199 /*}}}*/ 203 200 /*FUNCTION ToMPISerial{{{*/ 204 201 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); 213 205 214 206 } … … 225 217 226 218 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]; 228 220 229 221 } … … 232 224 doubletype Norm(NormMode mode){ 233 225 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); 251 228 } 252 229 /*}}}*/ … … 259 236 } 260 237 /*}}}*/ 261 /*FU /*FUNCTION Dot{{{*/238 /*FUNCTION Dot{{{*/ 262 239 doubletype Dot(IssmAbsVec<doubletype>* inputin){ 263 240 264 241 int i; 242 doubletype local_dot=0; 243 doubletype dot=0; 265 244 266 245 /*Assume inputin is of the correct type, and downcast: */ … … 269 248 input=(IssmMpiVec<doubletype>*)inputin; 270 249 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 274 258 return dot; 275 276 259 } 277 260 /*}}}*/ … … 290 273 291 274 /*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]; 293 276 } 294 277 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.