Changeset 27728
- Timestamp:
- 05/04/23 17:45:09 (23 months ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Cfdragcoeffabsgrad.cpp
r27685 r27728 29 29 this->definitionenum = -1; 30 30 this->name = NULL; 31 this->J = 0.; 31 32 } 32 33 /*}}}*/ … … 37 38 this->name = xNew<char>(strlen(in_name)+1); 38 39 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 40 41 this->J = 0.; 42 } 43 /*}}}*/ 44 Cfdragcoeffabsgrad::Cfdragcoeffabsgrad(char* in_name, int in_definitionenum, IssmDouble in_J){/*{{{*/ 45 46 this->definitionenum=in_definitionenum; 47 48 this->name = xNew<char>(strlen(in_name)+1); 49 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 50 51 this->J = in_J; 39 52 } 40 53 /*}}}*/ … … 45 58 /*Object virtual function resolutoin: */ 46 59 Object* Cfdragcoeffabsgrad::copy() {/*{{{*/ 47 Cfdragcoeffabsgrad* mf = new Cfdragcoeffabsgrad(this->name,this->definitionenum );60 Cfdragcoeffabsgrad* mf = new Cfdragcoeffabsgrad(this->name,this->definitionenum, this->J); 48 61 return (Object*) mf; 49 62 } … … 69 82 marshallhandle->call(this->definitionenum); 70 83 marshallhandle->call(this->name); 84 marshallhandle->call(this->J); 71 85 } 72 86 /*}}}*/ … … 90 104 91 105 /*recover parameters: */ 92 IssmDouble J =0.;106 IssmDouble J_part=0.; 93 107 IssmDouble J_sum=0.; 94 108 95 109 for(Object* & object : femmodel->elements->objects){ 96 110 Element* element=xDynamicCast<Element*>(object); 97 J +=this->Cfdragcoeffabsgrad_Calculation(element);111 J_part+=this->Cfdragcoeffabsgrad_Calculation(element); 98 112 } 99 113 100 ISSM_MPI_Allreduce ( (void*)&J ,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());114 ISSM_MPI_Allreduce ( (void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 101 115 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 102 J=J_sum;116 this->J=J_sum; 103 117 104 118 return J; -
issm/trunk-jpl/src/c/classes/Cfdragcoeffabsgrad.h
r27681 r27728 16 16 public: 17 17 18 int definitionenum; 19 char *name; 18 int definitionenum; 19 char *name; 20 IssmDouble J; 20 21 21 22 /*Cfdragcoeffabsgrad constructors, destructors :*/ 22 23 Cfdragcoeffabsgrad(); 23 24 Cfdragcoeffabsgrad(char* in_name, int in_definitionenum); 25 Cfdragcoeffabsgrad(char* in_name, int in_definitionenum, IssmDouble in_J); 24 26 ~Cfdragcoeffabsgrad(); 25 27 -
issm/trunk-jpl/src/c/classes/Cflevelsetmisfit.cpp
r27681 r27728 32 32 this->datatime=0.; 33 33 this->timepassedflag = false; 34 } 35 /*}}}*/ 36 Cflevelsetmisfit::Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool in_timepassedflag){/*{{{*/ 34 this->J = 0.; 35 } 36 /*}}}*/ 37 Cflevelsetmisfit::Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime){/*{{{*/ 38 39 this->definitionenum=in_definitionenum; 40 41 this->name = xNew<char>(strlen(in_name)+1); 42 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 43 44 this->model_enum=in_model_enum; 45 this->datatime=in_datatime; 46 this->timepassedflag=false; 47 this->J = 0.; 48 } 49 /*}}}*/ 50 Cflevelsetmisfit::Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool in_timepassedflag, IssmDouble in_J){/*{{{*/ 37 51 38 52 this->definitionenum=in_definitionenum; … … 44 58 this->datatime=in_datatime; 45 59 this->timepassedflag=in_timepassedflag; 60 this->J = in_J; 46 61 } 47 62 /*}}}*/ … … 52 67 /*Object virtual function resolutoin: */ 53 68 Object* Cflevelsetmisfit::copy() {/*{{{*/ 54 Cflevelsetmisfit* mf = new Cflevelsetmisfit(this->name,this->definitionenum, this->model_enum,this->datatime,this->timepassedflag );69 Cflevelsetmisfit* mf = new Cflevelsetmisfit(this->name,this->definitionenum, this->model_enum,this->datatime,this->timepassedflag, this->J); 55 70 return (Object*) mf; 56 71 } … … 82 97 marshallhandle->call(this->datatime); 83 98 marshallhandle->call(this->timepassedflag); 99 marshallhandle->call(this->J); 84 100 } 85 101 /*}}}*/ … … 106 122 /*recover time parameters: */ 107 123 femmodel->parameters->FindParam(&time,TimeEnum); 108 109 IssmDouble J=0.;110 IssmDouble J_sum=0.;111 112 124 if(datatime<=time && !timepassedflag){ 125 126 IssmDouble J_part = 0.; 127 IssmDouble J_sum = 0.; 128 113 129 for(Object* & object : femmodel->elements->objects){ 114 130 Element* element=xDynamicCast<Element*>(object); 115 J +=this->Cflevelsetmisfit_Calculation(element,model_enum);131 J_part+=this->Cflevelsetmisfit_Calculation(element,model_enum); 116 132 } 117 133 118 ISSM_MPI_Allreduce ( (void*)&J ,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());134 ISSM_MPI_Allreduce ( (void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 119 135 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 120 J=J_sum;121 136 122 137 this->timepassedflag = true; 123 return J;138 this->J = J_sum; 124 139 } 125 else return J; 126 } 127 140 141 return this->J; 142 }/*}}}*/ 128 143 IssmDouble Cflevelsetmisfit::Cflevelsetmisfit_Calculation(Element* element, int model_enum){/*{{{*/ 129 144 -
issm/trunk-jpl/src/c/classes/Cflevelsetmisfit.h
r27681 r27728 21 21 IssmDouble datatime; 22 22 bool timepassedflag; 23 IssmDouble J; 23 24 24 25 /*Cflevelsetmisfit constructors, destructors :*/ 25 26 Cflevelsetmisfit(); 26 Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool timepassedflag); 27 Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime); 28 Cflevelsetmisfit(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool timepassedflag, IssmDouble in_J); 27 29 ~Cflevelsetmisfit(); 28 30 -
issm/trunk-jpl/src/c/classes/Cfrheologybbarabsgrad.cpp
r27686 r27728 30 30 this->name = NULL; 31 31 this->weights_enum = UNDEF; 32 this->misfit=0;33 32 this->timepassedflag = false; 33 this->J = 0.; 34 34 } 35 35 /*}}}*/ 36 Cfrheologybbarabsgrad::Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum, bool in_timepassedflag){/*{{{*/ 36 Cfrheologybbarabsgrad::Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum){/*{{{*/ 37 38 this->definitionenum=in_definitionenum; 39 40 this->name = xNew<char>(strlen(in_name)+1); 41 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 42 43 this->weights_enum=in_weights_enum; 44 this->timepassedflag=false; 45 46 this->J=0; 47 } 48 /*}}}*/ 49 Cfrheologybbarabsgrad::Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum, bool in_timepassedflag, IssmDouble in_J){/*{{{*/ 37 50 38 51 this->definitionenum=in_definitionenum; … … 44 57 this->timepassedflag=in_timepassedflag; 45 58 46 this-> misfit=0;59 this->J=in_J; 47 60 } 48 61 /*}}}*/ 49 62 Cfrheologybbarabsgrad::~Cfrheologybbarabsgrad(){/*{{{*/ 50 63 if(this->name)xDelete(this->name); 51 this->misfit=0;52 64 } 53 65 /*}}}*/ 54 66 /*Object virtual function resolutoin: */ 55 67 Object* Cfrheologybbarabsgrad::copy() {/*{{{*/ 56 Cfrheologybbarabsgrad* mf = new Cfrheologybbarabsgrad(this->name,this->definitionenum, this->weights_enum,this->timepassedflag); 57 mf->misfit=this->misfit; 68 Cfrheologybbarabsgrad* mf = new Cfrheologybbarabsgrad(this->name,this->definitionenum, this->weights_enum,this->timepassedflag,this->J); 58 69 return (Object*) mf; 59 70 } … … 83 94 marshallhandle->call(this->weights_enum); 84 95 marshallhandle->call(this->timepassedflag); 85 marshallhandle->call(this-> misfit);96 marshallhandle->call(this->J); 86 97 } 87 98 /*}}}*/ … … 105 116 106 117 /*recover parameters: */ 107 IssmDouble J =0.;118 IssmDouble J_part=0.; 108 119 IssmDouble J_sum=0.; 109 120 110 121 for(Object* & object : femmodel->elements->objects){ 111 122 Element* element=xDynamicCast<Element*>(object); 112 J +=this->Cfrheologybbarabsgrad_Calculation(element,weights_enum);123 J_part+=this->Cfrheologybbarabsgrad_Calculation(element,weights_enum); 113 124 } 114 125 115 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());126 ISSM_MPI_Allreduce( (void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 116 127 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 117 J=J_sum;118 128 119 timepassedflag = true; 120 return J; 129 this->timepassedflag = true; 130 this->J = J_sum; 131 return this->J; 121 132 }/*}}}*/ 122 133 IssmDouble Cfrheologybbarabsgrad::Cfrheologybbarabsgrad_Calculation(Element* element, int weights_enum){/*{{{*/ … … 124 135 int domaintype,numcomponents; 125 136 IssmDouble Jelem=0.; 126 IssmDouble misfit,Jdet;137 IssmDouble Jdet; 127 138 IssmDouble dp[2],weight; 128 139 IssmDouble* xyz_list = NULL; -
issm/trunk-jpl/src/c/classes/Cfrheologybbarabsgrad.h
r27686 r27728 21 21 int weights_enum; 22 22 bool timepassedflag; 23 24 IssmDouble misfit; //value carried over in time. 23 IssmDouble J; 25 24 26 25 /*Cfrheologybbarabsgrad constructors, destructors :*/ 27 26 Cfrheologybbarabsgrad(); 28 Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum, bool timepassedflag); 27 Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum); 28 Cfrheologybbarabsgrad(char* in_name, int in_definitionenum, int in_weights_enum, bool in_timepassedflag, IssmDouble in_J); 29 29 ~Cfrheologybbarabsgrad(); 30 30 -
issm/trunk-jpl/src/c/classes/Cfsurfacelogvel.cpp
r26888 r27728 31 31 this->datatime=0.; 32 32 this->timepassedflag = false; 33 34 } 35 /*}}}*/ 36 Cfsurfacelogvel::Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime, bool in_timepassedflag){/*{{{*/ 33 this->J = 0.; 34 35 } 36 /*}}}*/ 37 Cfsurfacelogvel::Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime){/*{{{*/ 37 38 38 39 this->definitionenum=in_definitionenum; … … 42 43 43 44 this->datatime=in_datatime; 45 46 this->timepassedflag=false; 47 this->J=0.; 48 49 } 50 /*}}}*/ 51 Cfsurfacelogvel::Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime, bool in_timepassedflag,IssmDouble in_J){/*{{{*/ 52 53 this->definitionenum=in_definitionenum; 54 55 this->name = xNew<char>(strlen(in_name)+1); 56 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 57 58 this->datatime=in_datatime; 44 59 this->timepassedflag=in_timepassedflag; 60 this->J=in_J; 45 61 46 62 } … … 52 68 /*Object virtual function resolutoin: */ 53 69 Object* Cfsurfacelogvel::copy() {/*{{{*/ 54 Cfsurfacelogvel* mf = new Cfsurfacelogvel(this->name,this->definitionenum,this->datatime,this->timepassedflag );70 Cfsurfacelogvel* mf = new Cfsurfacelogvel(this->name,this->definitionenum,this->datatime,this->timepassedflag, this->J); 55 71 return (Object*) mf; 56 72 } … … 64 80 _printf_(" datatime: " << datatime << "\n"); 65 81 _printf_(" timepassedflag: "<<timepassedflag<<"\n"); 82 _printf_(" J: "<<J<<"\n"); 66 83 } 67 84 /*}}}*/ … … 78 95 marshallhandle->call(this->datatime); 79 96 marshallhandle->call(this->timepassedflag); 97 marshallhandle->call(this->J); 80 98 } 81 99 /*}}}*/ … … 104 122 if(this->datatime<=time && !this->timepassedflag){ 105 123 106 IssmDouble J =0.;124 IssmDouble J_part=0.; 107 125 IssmDouble J_sum=0.; 108 126 109 127 for(Object* & object : femmodel->elements->objects){ 110 128 Element* element=xDynamicCast<Element*>(object); 111 J +=this->Cfsurfacelogvel_Calculation(element,definitionenum);112 } 113 114 ISSM_MPI_Allreduce ( (void*)&J ,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());129 J_part+=this->Cfsurfacelogvel_Calculation(element,definitionenum); 130 } 131 132 ISSM_MPI_Allreduce ( (void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 115 133 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 116 J=J_sum;117 134 118 135 this->timepassedflag = true; 119 return J_sum; 120 } 121 else{ 122 return 0.; 123 } 136 this->J = J_sum; 137 } 138 139 return this->J; 124 140 }/*}}}*/ 125 141 IssmDouble Cfsurfacelogvel::Cfsurfacelogvel_Calculation(Element* element, int definitionenum){/*{{{*/ -
issm/trunk-jpl/src/c/classes/Cfsurfacelogvel.h
r27681 r27728 20 20 IssmDouble datatime; 21 21 bool timepassedflag; 22 IssmDouble J; 22 23 23 24 /*Cfsurfacelogvel constructors, destructors :*/ 24 25 Cfsurfacelogvel(); 25 Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime, bool timepassedflag); 26 Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime); 27 Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime, bool timepassedflag, IssmDouble in_J); 26 28 ~Cfsurfacelogvel(); 27 29 -
issm/trunk-jpl/src/c/classes/Cfsurfacesquare.cpp
r27681 r27728 32 32 this->datatime = 0.; 33 33 this->timepassedflag = false; 34 } 35 /*}}}*/ 36 Cfsurfacesquare::Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool in_timepassedflag){/*{{{*/ 34 this->J = 0.; 35 } 36 /*}}}*/ 37 Cfsurfacesquare::Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime){/*{{{*/ 38 39 this->definitionenum=in_definitionenum; 40 41 this->name = xNew<char>(strlen(in_name)+1); 42 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 43 44 this->model_enum=in_model_enum; 45 this->datatime=in_datatime; 46 this->timepassedflag=false; 47 this->J=0.; 48 } 49 /*}}}*/ 50 Cfsurfacesquare::Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool in_timepassedflag, IssmDouble in_J){/*{{{*/ 37 51 38 52 this->definitionenum=in_definitionenum; … … 44 58 this->datatime=in_datatime; 45 59 this->timepassedflag=in_timepassedflag; 60 this->J=in_J; 46 61 } 47 62 /*}}}*/ … … 53 68 /*Object virtual function resolutoin: */ 54 69 Object* Cfsurfacesquare::copy() {/*{{{*/ 55 Cfsurfacesquare* mf = new Cfsurfacesquare(this->name,this->definitionenum, this->model_enum,this->datatime,this->timepassedflag );70 Cfsurfacesquare* mf = new Cfsurfacesquare(this->name,this->definitionenum, this->model_enum,this->datatime,this->timepassedflag,this->J); 56 71 return (Object*) mf; 57 72 } … … 66 81 _printf_(" datatime: " << datatime << "\n"); 67 82 _printf_(" timepassedflag: "<<timepassedflag<<"\n"); 83 _printf_(" J: "<<J<<"\n"); 68 84 } 69 85 /*}}}*/ … … 82 98 marshallhandle->call(this->datatime); 83 99 marshallhandle->call(this->timepassedflag); 100 marshallhandle->call(this->J); 84 101 } 85 102 /*}}}*/ … … 110 127 if(this->datatime<=time && !this->timepassedflag){ 111 128 112 IssmDouble J =0.;129 IssmDouble J_part=0.; 113 130 IssmDouble J_sum=0.; 114 131 115 132 for(Object* & object : femmodel->elements->objects){ 116 133 Element* element=xDynamicCast<Element*>(object); 117 J +=this->Cfsurfacesquare_Calculation(element,model_enum);134 J_part+=this->Cfsurfacesquare_Calculation(element,model_enum); 118 135 } 119 136 120 ISSM_MPI_Allreduce ( (void*)&J ,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());137 ISSM_MPI_Allreduce ( (void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 121 138 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 122 139 123 140 this->timepassedflag = true; 124 returnJ_sum;141 this->J = J_sum; 125 142 } 126 else{ 127 return 0.; 128 } 143 144 return this->J; 129 145 } 130 146 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Cfsurfacesquare.h
r27681 r27728 21 21 IssmDouble datatime; 22 22 bool timepassedflag; 23 IssmDouble J; 23 24 24 25 /*Cfsurfacesquare constructors, destructors :*/ 25 26 Cfsurfacesquare(); 26 Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool timepassedflag); 27 Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime); 28 Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, IssmDouble in_datatime, bool timepassedflag, IssmDouble in_J); 27 29 ~Cfsurfacesquare(); 28 30 -
issm/trunk-jpl/src/c/classes/Cfsurfacesquaretransient.cpp
r27721 r27728 159 159 /*Check that we have not yet calculated this cost function*/ 160 160 if(this->passedflags[pos]){ 161 return 0.; 162 //return this->J; //FIXME 161 return this->J; 163 162 } 164 163 … … 172 171 /*Sum across partition*/ 173 172 IssmDouble J_sum; 174 ISSM_MPI_Allreduce( 173 ISSM_MPI_Allreduce((void*)&J_part,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 175 174 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 176 175 … … 180 179 181 180 /*Return full cost function this far*/ 182 //return this->J; //FIXME 183 return J_sum; 181 return this->J; 184 182 }/*}}}*/ 185 183 IssmDouble Cfsurfacesquaretransient::Cfsurfacesquaretransient_Calculation(Element* element, int model_enum){/*{{{*/ -
issm/trunk-jpl/src/c/classes/DependentObject.cpp
r27725 r27728 70 70 71 71 /*DependentObject methods: */ 72 void DependentObject::Re sponsex(IssmDouble* poutput_value,FemModel* femmodel){/*{{{*/72 void DependentObject::RecordResponsex(FemModel* femmodel){/*{{{*/ 73 73 74 74 /*Is this some special type of response for which we need to go in the output definitions? :*/ 75 75 if (StringToEnumx(this->name,false)==-1){ 76 *poutput_value=OutputDefinitionsResponsex(femmodel,this->name);76 this->response_value = OutputDefinitionsResponsex(femmodel,this->name); 77 77 } 78 else femmodel->Responsex(poutput_value,this->name); 78 else{ 79 femmodel->Responsex(&this->response_value, this->name); 80 } 79 81 } 80 82 /*}}}*/ … … 83 85 } 84 86 /*}}}*/ 85 void DependentObject::AddValue(IssmDouble in_value){/*{{{*/86 this->response_value+=in_value;87 }88 /*}}}*/89 87 void DependentObject::ResetResponseValue(){/*{{{*/ 90 88 this->response_value=0.; -
issm/trunk-jpl/src/c/classes/DependentObject.h
r27725 r27728 35 35 36 36 /*DependentObject methods: */ 37 void Re sponsex(IssmDouble *poutput_value,FemModel*femmodel);37 void RecordResponsex(FemModel*femmodel); 38 38 IssmDouble GetValue(void); 39 void AddValue(IssmDouble in_value);40 39 void ResetResponseValue(void); 41 40 -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r27491 r27728 2335 2335 void FemModel::RequestedDependentsx(void){/*{{{*/ 2336 2336 2337 bool isautodiff = false;2338 IssmDouble output_value;2339 2340 int num_dependents;2341 IssmPDouble *dependents;2342 DataSet* dependent_objects=NULL;2343 int my_rank=IssmComm::GetRank();2344 2345 2337 /*AD mode on?: */ 2338 bool isautodiff; 2346 2339 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 2347 2340 2348 2341 if(isautodiff){ 2349 2342 #ifdef _HAVE_AD_ 2343 int num_dependents; 2344 DataSet* dependent_objects=NULL; 2350 2345 parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 2351 2346 parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 2352 2347 if(num_dependents){ 2353 dependents=xNew<IssmPDouble>(num_dependents);2348 IssmPDouble* dependents=xNew<IssmPDouble>(num_dependents); 2354 2349 2355 2350 #if defined(_HAVE_CODIPACK_) … … 2364 2359 2365 2360 /*Go through our dependent variables, and compute the response:*/ 2361 int my_rank=IssmComm::GetRank(); 2366 2362 int i = 0; 2367 2363 for(Object* & object : dependent_objects->objects){ 2368 2364 DependentObject* dep=(DependentObject*)object; 2369 dep->Responsex(&output_value,this); 2365 dep->RecordResponsex(this); 2366 IssmDouble output_value = dep->GetValue(); 2370 2367 if (my_rank==0) { 2371 2368 #if defined(_HAVE_CODIPACK_) … … 2385 2382 i++; 2386 2383 } 2384 xDelete<IssmPDouble>(dependents); 2387 2385 } 2388 2386 delete dependent_objects; 2389 if(num_dependents)xDelete<IssmPDouble>(dependents);2390 2387 #else 2391 2388 _error_("Should not be requesting dependents when an AD library is not available!"); … … 4608 4605 void FemModel::DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){/*{{{*/ 4609 4606 4610 int i,j;4611 int my_rank;4612 4613 4607 /*intermediary: */ 4608 int i,j; 4614 4609 char root[50]; 4615 4610 int index; … … 4631 4626 4632 4627 /*retrieve my_rank: */ 4633 my_rank=IssmComm::GetRank();4628 int my_rank=IssmComm::GetRank(); 4634 4629 4635 4630 /*save the d_responses pointer: */ -
issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp
r27724 r27728 329 329 i++; 330 330 DependentObject* dep=xDynamicCast<DependentObject*>(object); 331 if(solution_type==TransientSolutionEnum) output_value = dep->GetValue(); 332 if(solution_type!=TransientSolutionEnum) dep->Responsex(&output_value,femmodel); 331 332 /*Get cost function for this dependent*/ 333 dep->RecordResponsex(femmodel); 334 IssmDouble output_value = dep->GetValue(); 333 335 334 336 #if defined(_HAVE_CODIPACK_) … … 349 351 _error_("not suppoted"); 350 352 #endif 353 351 354 J+=output_value; 352 355 } -
issm/trunk-jpl/src/c/cores/controlvalidation_core.cpp
r26556 r27728 243 243 244 244 /*Get Dependents*/ 245 IssmDouble output_value;246 245 int num_dependents; 247 246 IssmPDouble *dependents; … … 257 256 DependentObject* dep=xDynamicCast<DependentObject*>(object); 258 257 i++; 259 if(solution_type==TransientSolutionEnum){ 260 output_value = dep->GetValue(); 261 } 262 else{ 263 dep->Responsex(&output_value,femmodel); 264 } 258 dep->RecordResponsex(femmodel); 259 IssmDouble output_value = dep->GetValue(); 260 265 261 _printf0_("=== output ="<<output_value<<" \n"); 266 262 if(my_rank==0) { … … 339 335 for(Object* & object:dependent_objects->objects){ 340 336 DependentObject* dep=xDynamicCast<DependentObject*>(object); 341 if(solution_type==TransientSolutionEnum){ 342 output_value = dep->GetValue(); 343 } 344 else{ 345 dep->Responsex(&output_value,femmodel); 346 } 337 dep->RecordResponsex(femmodel); 338 IssmDouble output_value = dep->GetValue(); 347 339 j+=output_value; 348 340 } -
issm/trunk-jpl/src/c/cores/transient_core.cpp
r27724 r27728 118 118 for(Object* & object:dependent_objects->objects){ 119 119 DependentObject* dep=(DependentObject*)object; 120 IssmDouble output_value; 121 dep->Responsex(&output_value,femmodel); 122 dep->AddValue(output_value); 120 dep->RecordResponsex(femmodel); 123 121 } 124 122 } … … 269 267 270 268 /*parameters: */ 271 IssmDouble output_value;272 269 IssmDouble finaltime,dt,yts,time; 273 270 bool isoceancoupling; … … 342 339 for(Object* & object:dependent_objects->objects){ 343 340 DependentObject* dep=(DependentObject*)object; 344 dep->Responsex(&output_value,femmodel); 345 dep->AddValue(output_value); 341 dep->RecordResponsex(femmodel); 346 342 } 347 343 … … 401 397 IssmDouble output_value = dep->GetValue(); 402 398 403 404 399 J += output_value; 405 400 406 401 tape_codi.registerOutput(J); 407 #if _CODIPACK_MAJOR_==2402 #if _CODIPACK_MAJOR_==2 408 403 codi_global.output_indices.push_back(J.getIdentifier()); 409 #elif _CODIPACK_MAJOR_==1404 #elif _CODIPACK_MAJOR_==1 410 405 codi_global.output_indices.push_back(J.getGradientData()); 411 #else412 #error "_CODIPACK_MAJOR_ not supported"413 #endif406 #else 407 #error "_CODIPACK_MAJOR_ not supported" 408 #endif 414 409 415 410 /*Keep track of output for printing*/ … … 477 472 for(Object* & object:dependent_objects->objects){ 478 473 DependentObject* dep=(DependentObject*)object; 479 dep->Responsex(&output_value,femmodel); 480 dep->AddValue(output_value); 474 dep->RecordResponsex(femmodel); 481 475 } 482 476 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r27725 r27728 151 151 if(num_dependent_objects){ 152 152 iomodel->FindConstant(&names,&dummy,"md.autodiff.dependent_object_names"); 153 iomodel->FetchData(&indices,&dummy,&dummy,"md.autodiff.dependent_object_indices");154 153 155 154 for(i=0;i<num_dependent_objects;i++){ 156 DependentObject* dep=new DependentObject(names[i] ,indices[i]);155 DependentObject* dep=new DependentObject(names[i]); 157 156 dependent_objects->AddObject(dep); 158 157 num_dep++; … … 164 163 } 165 164 xDelete<char*>(names); 166 xDelete<int>(indices);167 165 } 168 166 parameters->AddObject(new DataSetParam(AutodiffDependentObjectsEnum,dependent_objects)); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
r27717 r27728 205 205 206 206 /*First create a cfsurfacesquare object for that specific string (cfsurfacesquare_model_string_s[j]):*/ 207 output_definitions->AddObject(new Cfsurfacesquare(cfsurfacesquare_name_s[j],StringToEnumx(cfsurfacesquare_definitionstring_s[j]),StringToEnumx(cfsurfacesquare_model_string_s[j]),cfsurfacesquare_datatime_s[j] ,false));207 output_definitions->AddObject(new Cfsurfacesquare(cfsurfacesquare_name_s[j],StringToEnumx(cfsurfacesquare_definitionstring_s[j]),StringToEnumx(cfsurfacesquare_model_string_s[j]),cfsurfacesquare_datatime_s[j])); 208 208 209 209 /*Now, for this particular cfsurfacesquare object, make sure we plug into the elements: the observation, and the weights.*/ … … 413 413 414 414 /*First create a cfrheologybbarabsgrad object for that specific string (cfrheologybbarabsgrad_model_string_s[j]):*/ 415 output_definitions->AddObject(new Cfrheologybbarabsgrad(cfrheologybbarabsgrad_name_s[j],StringToEnumx(cfrheologybbarabsgrad_definitionstring_s[j]),StringToEnumx(cfrheologybbarabsgrad_weights_string_s[j]) ,false));415 output_definitions->AddObject(new Cfrheologybbarabsgrad(cfrheologybbarabsgrad_name_s[j],StringToEnumx(cfrheologybbarabsgrad_definitionstring_s[j]),StringToEnumx(cfrheologybbarabsgrad_weights_string_s[j]))); 416 416 417 417 /*Now, for this particular cfrheologybbarabsgrad object, make sure we plug into the elements: the observation, and the weights.*/ … … 496 496 497 497 /*First create a cfsurfacelogvel object for that specific string (cfsurfacelogvel_modeltring[j]):*/ 498 output_definitions->AddObject(new Cfsurfacelogvel(cfsurfacelogvel_name[j],StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_datatime[j] ,false));498 output_definitions->AddObject(new Cfsurfacelogvel(cfsurfacelogvel_name[j],StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_datatime[j])); 499 499 500 500 /*Now, for this particular cfsurfacelogvel object, make sure we plug into the elements: the observation, and the weights.*/ … … 590 590 591 591 /*First create a cflevelsetmisfit object for that specific string (cflevelsetmisfit_model_string_s[j]):*/ 592 output_definitions->AddObject(new Cflevelsetmisfit(cflevelsetmisfit_name_s[j],StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),StringToEnumx(cflevelsetmisfit_model_string_s[j]),cflevelsetmisfit_datatime_s[j] ,false));592 output_definitions->AddObject(new Cflevelsetmisfit(cflevelsetmisfit_name_s[j],StringToEnumx(cflevelsetmisfit_definitionstring_s[j]),StringToEnumx(cflevelsetmisfit_model_string_s[j]),cflevelsetmisfit_datatime_s[j])); 593 593 594 594 /*Now, for this particular cflevelsetmisfit object, make sure we plug into the elements: the observation, and the weights.*/
Note:
See TracChangeset
for help on using the changeset viewer.