Changeset 25580
- Timestamp:
- 09/17/20 15:44:24 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/DependentObject.cpp
r25524 r25580 16 16 DependentObject::DependentObject(){/*{{{*/ 17 17 this->name=NULL; 18 this->type=0;19 18 this->index=-1; 20 19 this->response_value=0.; 21 20 } 22 21 /*}}}*/ 23 DependentObject::DependentObject(char* in_name, int in_type,int in_index){/*{{{*/22 DependentObject::DependentObject(char* in_name,int in_index){/*{{{*/ 24 23 25 24 this->name=xNew<char>(strlen(in_name)+1); xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 26 this->type=in_type;27 25 this->index=in_index; 28 if(in_type!=0 && in_type!=1)_error_("cannot create an DependentObject of type " << in_type);29 if(in_type==1)_error_("not implemented yet!");30 26 this->response_value=0.; 31 27 32 } 33 /*}}}*/ 34 DependentObject::DependentObject(char* in_name, int in_type,int in_index,IssmDouble in_response){/*{{{*/ 28 }/*}}}*/ 29 DependentObject::DependentObject(char* in_name,int in_index,IssmDouble in_response){/*{{{*/ 35 30 36 31 this->name=xNew<char>(strlen(in_name)+1); xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 37 this->type=in_type;38 32 this->index=in_index; 39 if(in_type!=0 && in_type!=1)_error_("cannot create an DependentObject of type " << in_type);40 if(in_type==1)_error_("not implemented yet!");41 33 this->response_value=in_response; 42 34 43 } 44 /*}}}*/ 35 }/*}}}*/ 45 36 DependentObject::~DependentObject(){ //destructor/*{{{*/ 46 37 xDelete<char>(this->name); 47 } 48 /*}}}*/ 38 }/*}}}*/ 49 39 50 40 /*Object virtual functions definitions:*/ 51 41 Object* DependentObject::copy(void) { /*{{{*/ 52 return new DependentObject(name, type,index,response_value);42 return new DependentObject(name,index,response_value); 53 43 } /*}}}*/ 54 44 void DependentObject::DeepEcho(void){/*{{{*/ … … 60 50 _printf_("DependentObject:\n"); 61 51 _printf_(" name: " << this->name << "\n"); 62 if(this->type==0)63 _printf_(" type: scalar\n");64 else if(this->type==1)65 _printf_(" type: vertex\n");66 else67 _error_(" unknown type: " << this->type);68 52 if(this->index>=0) _printf_(" index: " << this->index << "\n"); 53 _printf_(" value: " << this->value << "\n"); 69 54 } 70 55 /*}}}*/ 71 int 56 int DependentObject::Id(void){ return -1; }/*{{{*/ 72 57 /*}}}*/ 73 int DependentObject::ObjectEnum(void){/*{{{*/58 int DependentObject::ObjectEnum(void){/*{{{*/ 74 59 75 60 return DependentObjectEnum; … … 77 62 } 78 63 /*}}}*/ 79 void 64 void DependentObject::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 80 65 81 66 int object_enum = DependentObjectEnum; … … 85 70 marshallhandle->call(this->name); 86 71 87 marshallhandle->call(this->type);88 72 marshallhandle->call(this->index); 89 73 marshallhandle->call(this->response_value); 90 } 91 /*}}}*/ 74 }/*}}}*/ 92 75 93 76 /*DependentObject methods: */ 94 int DependentObject::NumDependents(void){/*{{{*/95 96 /*Branch according to the type of variable: */97 if(type==0){ /*scalar:*/98 return 1;99 }100 else if(type==1){ /* vector:*/101 _error_("not implemented yet!");102 }103 else _error_("should not have a type of " << type);104 }105 /*}}}*/106 77 void DependentObject::Responsex(IssmDouble* poutput_value,FemModel* femmodel){/*{{{*/ 107 78 -
issm/trunk-jpl/src/c/classes/DependentObject.h
r25524 r25580 18 18 19 19 char* name; 20 int type; /*0: scalar, 1: vertex*/ 21 int index; /*0: scalar, 1: vertex*/ 20 int index; /*0: scalar, 1: vertex*/ 22 21 IssmDouble response_value; 23 22 24 23 /*DependentObject constructors, destructors */ 25 24 DependentObject(); 26 DependentObject(char* name, int type,int index);27 DependentObject(char* name, int type,int index,IssmDouble in_response);25 DependentObject(char* name,int index); 26 DependentObject(char* name,int index,IssmDouble in_response); 28 27 ~DependentObject(); 29 28 30 29 /*Object virtual functions definitions*/ 31 Object *copy(void);32 void DeepEcho();33 void Echo();34 int Id();35 int ObjectEnum();36 void Marshall(MarshallHandle*marshallhandle);30 Object *copy(void); 31 void DeepEcho(); 32 void Echo(); 33 int Id(); 34 int ObjectEnum(); 35 void Marshall(MarshallHandle *marshallhandle); 37 36 38 37 /*DependentObject methods: */ 39 int NumDependents(void); 40 void Responsex(IssmDouble* poutput_value,FemModel* femmodel); 38 void Responsex(IssmDouble *poutput_value,FemModel*femmodel); 41 39 IssmDouble GetValue(void); 42 void AddValue(IssmDouble in_value);43 void ResetResponseValue(void);40 void AddValue(IssmDouble in_value); 41 void ResetResponseValue(void); 44 42 45 43 }; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r23267 r25580 15 15 int num_dep=0; 16 16 char** names=NULL; 17 int* types=NULL;18 17 int dummy; 19 18 char* autodiff_driver=NULL; … … 152 151 if(num_dependent_objects){ 153 152 iomodel->FindConstant(&names,&dummy,"md.autodiff.dependent_object_names"); 154 iomodel->FetchData(&types,&dummy,&dummy,"md.autodiff.dependent_object_types");155 153 iomodel->FetchData(&indices,&dummy,&dummy,"md.autodiff.dependent_object_indices"); 156 154 157 155 for(i=0;i<num_dependent_objects;i++){ 158 DependentObject* dep=new DependentObject(names[i], types[i],indices[i]);156 DependentObject* dep=new DependentObject(names[i],indices[i]); 159 157 dependent_objects->AddObject(dep); 160 num_dep+ =dep->NumDependents();158 num_dep++; 161 159 } 162 160 … … 166 164 } 167 165 xDelete<char*>(names); 168 xDelete<int>(types);169 166 xDelete<int>(indices); 170 167 }
Note:
See TracChangeset
for help on using the changeset viewer.