Changeset 25512
- Timestamp:
- 09/01/20 16:43:10 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/cores/transient_core.cpp
r25511 r25512 357 357 358 358 for(int i=0;i<Xsize;i++) Xb[i] += X[i].gradient(); 359 InitAdjointFunctor* marshallhandle3 = new InitAdjointFunctor(Yb);359 SetAdjointFunctor* marshallhandle3 = new SetAdjointFunctor(Yb); 360 360 femmodel->Marshall(marshallhandle3); 361 361 delete marshallhandle3; -
issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h
r25511 r25512 20 20 AD_REGISTERINPUT, 21 21 AD_REGISTEROUTPUT, 22 AD_INITADJOINT,23 22 AD_SETADJOINT, 24 23 #endif … … 212 211 } 213 212 }; /*}}}*/ 214 class InitAdjointFunctor: public MarshallHandle{ /*{{{*/215 216 private:217 int double_count;218 IssmDouble::TapeType* tape_codi;219 double* adjoint;220 221 public:222 InitAdjointFunctor(double* adjoint_in) : MarshallHandle(AD_INITADJOINT){223 this->double_count = 0;224 this->tape_codi = &(IssmDouble::getGlobalTape());225 this->adjoint = adjoint_in;226 }227 void Echo(void){228 printf("InitAdjointFunctor Echo:\n");229 printf(" double_count: %i\n",double_count);230 }231 template<typename T> void call(T & value){232 /*General case: do nothing*/233 }234 template<typename T> void call(T* & value,int size){235 /*General case: do nothing*/236 }237 void call(IssmDouble value){238 value.gradient() = adjoint[this->double_count];239 this->double_count++;240 }241 void call(IssmDouble* value,int size){242 if(value){243 for(int i=0;i<size;i++){244 value[i].gradient() = adjoint[this->double_count];245 this->double_count++;246 }247 }248 }249 }; /*}}}*/250 213 class SetAdjointFunctor: public MarshallHandle{ /*{{{*/ 251 214 … … 295 258 case AD_REGISTERINPUT: {RegisterInputFunctor* temp = xDynamicCast<RegisterInputFunctor*>(this); temp->call(value); break;} 296 259 case AD_REGISTEROUTPUT:{RegisterOutputFunctor* temp = xDynamicCast<RegisterOutputFunctor*>(this); temp->call(value); break;} 297 case AD_INITADJOINT: {InitAdjointFunctor* temp = xDynamicCast<InitAdjointFunctor*>(this); temp->call(value); break;}298 260 case AD_SETADJOINT: {SetAdjointFunctor* temp = xDynamicCast<SetAdjointFunctor*>(this); temp->call(value); break;} 299 261 #endif … … 310 272 case AD_REGISTERINPUT: {RegisterInputFunctor* temp = xDynamicCast<RegisterInputFunctor*>(this); temp->call(value,size); break;} 311 273 case AD_REGISTEROUTPUT:{RegisterOutputFunctor* temp = xDynamicCast<RegisterOutputFunctor*>(this); temp->call(value,size); break;} 312 case AD_INITADJOINT: {InitAdjointFunctor* temp = xDynamicCast<InitAdjointFunctor*>(this); temp->call(value,size); break;}313 274 case AD_SETADJOINT: {SetAdjointFunctor* temp = xDynamicCast<SetAdjointFunctor*>(this); temp->call(value,size); break;} 314 275 #endif
Note:
See TracChangeset
for help on using the changeset viewer.