Changeset 8129
- Timestamp:
- 05/04/11 11:28:47 (14 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/DataSet.cpp
r7692 r8129 123 123 * because this is a nasty error: */ 124 124 if (marshalled_dataset!=old_marshalled_dataset){ 125 _error_("final marshalled dataset is different from initial one!");125 _error_("final marshalled dataset \"%s\" is different from initial one!",EnumToString(enum_type)); 126 126 abort(); 127 127 } -
issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r6226 r8129 49 49 IoModelFetchData(&iomodel->cm_responses,NULL,NULL,iomodel_handle,"cm_responses"); 50 50 IoModelFetchData(&iomodel->cm_jump,NULL,NULL,iomodel_handle,"cm_jump"); 51 IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min");52 IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max");53 51 IoModelFetchData(&iomodel->optscal,NULL,NULL,iomodel_handle,"optscal"); 54 52 IoModelFetchData(&iomodel->maxiter,NULL,NULL,iomodel_handle,"maxiter"); … … 57 55 parameters->AddObject(new DoubleVecParam(CmJumpEnum,iomodel->cm_jump,iomodel->nsteps)); 58 56 parameters->AddObject(new DoubleMatParam(OptScalEnum,iomodel->optscal,iomodel->nsteps,iomodel->num_control_type)); 59 parameters->AddObject(new DoubleVecParam(CmMinEnum,iomodel->cm_min,iomodel->num_control_type));60 parameters->AddObject(new DoubleVecParam(CmMaxEnum,iomodel->cm_max,iomodel->num_control_type));61 57 parameters->AddObject(new DoubleVecParam(MaxIterEnum,iomodel->maxiter,iomodel->nsteps)); 62 58 63 59 xfree((void**)&iomodel->cm_responses); 64 60 xfree((void**)&iomodel->cm_jump); 65 xfree((void**)&iomodel->cm_min);66 xfree((void**)&iomodel->cm_max);67 61 xfree((void**)&iomodel->optscal); 68 62 xfree((void**)&iomodel->maxiter); -
issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r6412 r8129 28 28 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 29 29 IoModelFetchData(&iomodel->weights,NULL,NULL,iomodel_handle,"weights"); 30 IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min"); 31 IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max"); 30 32 IoModelFetchData(&iomodel->vx_obs,NULL,NULL,iomodel_handle,"vx_obs"); 31 33 IoModelFetchData(&iomodel->vy_obs,NULL,NULL,iomodel_handle,"vy_obs"); … … 69 71 xfree((void**)&iomodel->elements); 70 72 xfree((void**)&iomodel->weights); 73 xfree((void**)&iomodel->cm_min); 74 xfree((void**)&iomodel->cm_max); 71 75 xfree((void**)&iomodel->control_type); 72 76 xfree((void**)&iomodel->vx_obs); -
issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r7089 r8129 42 42 IoModelFetchData(&iomodel->rheology_n,NULL,NULL,iomodel_handle,"rheology_n"); 43 43 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 44 IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min"); 45 IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max"); 44 46 45 47 /*Create elements and materials: */ … … 65 67 xfree((void**)&iomodel->rheology_n); 66 68 xfree((void**)&iomodel->control_type); 69 xfree((void**)&iomodel->cm_min); 70 xfree((void**)&iomodel->cm_max); 67 71 68 72 /*Add new constrant material property tgo materials, at the end: */ -
issm/trunk/src/c/objects/Elements/Penta.cpp
r8120 r8129 3710 3710 int* control_type=NULL; 3711 3711 Input* input=NULL; 3712 double *cm_min=NULL;3713 double *cm_max=NULL;3714 3712 3715 3713 /*retrieve some parameters: */ 3716 this->parameters->FindParam(&cm_min,NULL,CmMinEnum);3717 this->parameters->FindParam(&cm_max,NULL,CmMaxEnum);3718 3714 this->parameters->FindParam(&num_controls,NumControlsEnum); 3719 3715 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); … … 3732 3728 3733 3729 ((ControlInput*)input)->UpdateValue(scalar); 3734 input->Constrain(cm_min[i],cm_max[i]);3730 ((ControlInput*)input)->Constrain(); 3735 3731 if (save_parameter) ((ControlInput*)input)->SaveValue(); 3736 3732 … … 3742 3738 /*Clean up and return*/ 3743 3739 xfree((void**)&control_type); 3744 xfree((void**)&cm_min);3745 xfree((void**)&cm_max);3746 3740 } 3747 3741 /*}}}*/ … … 3970 3964 int penta_vertex_ids[6]; 3971 3965 double nodeinputs[6]; 3966 double cmmininputs[6]; 3967 double cmmaxinputs[6]; 3972 3968 3973 3969 /*Checks if debuging*/ … … 4074 4070 if (iomodel->dhdt){ 4075 4071 for(j=0;j<6;j++)nodeinputs[j]=iomodel->dhdt[penta_vertex_ids[j]-1]/iomodel->yts; 4076 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs,i+1)); 4072 for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4073 for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4074 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 4077 4075 } 4078 4076 break; … … 4080 4078 if (iomodel->vx){ 4081 4079 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vx[penta_vertex_ids[j]-1]/iomodel->yts; 4082 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,i+1)); 4080 for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4081 for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4082 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 4083 4083 } 4084 4084 break; … … 4086 4086 if (iomodel->vy){ 4087 4087 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vy[penta_vertex_ids[j]-1]/iomodel->yts; 4088 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,i+1)); 4088 for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4089 for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 4090 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 4089 4091 } 4090 4092 break; … … 4092 4094 if (iomodel->drag_coefficient){ 4093 4095 for(j=0;j<6;j++)nodeinputs[j]=iomodel->drag_coefficient[penta_vertex_ids[j]-1]; 4094 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs,i+1)); 4096 for(j=0;j<6;j++)cmmininputs[j]=iomodel->cm_min[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]; 4097 for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->cm_max[(penta_vertex_ids[j]-1)*iomodel->num_control_type+i]; 4098 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 4095 4099 } 4096 4100 break; -
issm/trunk/src/c/objects/Elements/Tria.cpp
r8073 r8129 3662 3662 int* control_type=NULL; 3663 3663 Input* input=NULL; 3664 double *cm_min=NULL;3665 double *cm_max=NULL;3666 3664 3667 3665 /*retrieve some parameters: */ 3668 this->parameters->FindParam(&cm_min,NULL,CmMinEnum);3669 this->parameters->FindParam(&cm_max,NULL,CmMaxEnum);3670 3666 this->parameters->FindParam(&num_controls,NumControlsEnum); 3671 3667 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); … … 3685 3681 3686 3682 ((ControlInput*)input)->UpdateValue(scalar); 3687 input->Constrain(cm_min[i],cm_max[i]);3683 ((ControlInput*)input)->Constrain(); 3688 3684 if (save_parameter) ((ControlInput*)input)->SaveValue(); 3689 3685 … … 3692 3688 /*Clean up and return*/ 3693 3689 xfree((void**)&control_type); 3694 xfree((void**)&cm_min);3695 xfree((void**)&cm_max);3696 3690 } 3697 3691 /*}}}*/ … … 3827 3821 int tria_vertex_ids[3]; 3828 3822 double nodeinputs[3]; 3823 double cmmininputs[3]; 3824 double cmmaxinputs[3]; 3829 3825 3830 3826 /*Checks if debuging*/ … … 3952 3948 if (iomodel->dhdt){ 3953 3949 for(j=0;j<3;j++)nodeinputs[j]=iomodel->dhdt[tria_vertex_ids[j]-1]/iomodel->yts; 3954 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs,i+1)); 3950 for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3951 for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3952 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 3955 3953 } 3956 3954 break; … … 3958 3956 if (iomodel->vx){ 3959 3957 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vx[tria_vertex_ids[j]-1]/iomodel->yts; 3960 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,i+1)); 3958 for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3959 for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3960 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 3961 3961 } 3962 3962 break; … … 3964 3964 if (iomodel->vy){ 3965 3965 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vy[tria_vertex_ids[j]-1]/iomodel->yts; 3966 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,i+1)); 3966 for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3967 for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]/iomodel->yts; 3968 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 3967 3969 } 3968 3970 break; … … 3970 3972 if (iomodel->drag_coefficient){ 3971 3973 for(j=0;j<3;j++)nodeinputs[j]=iomodel->drag_coefficient[tria_vertex_ids[j]-1]; 3972 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs,i+1)); 3974 for(j=0;j<3;j++)cmmininputs[j]=iomodel->cm_min[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]; 3975 for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->cm_max[(tria_vertex_ids[j]-1)*iomodel->num_control_type+i]; 3976 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 3973 3977 } 3974 3978 break; -
issm/trunk/src/c/objects/Inputs/BoolInput.h
r6412 r8129 41 41 Input* SpawnTriaInput(int* indices); 42 42 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");}; 43 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");}; 44 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");}; 43 45 ElementResult* SpawnResult(int step, double time); 44 46 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/ControlInput.cpp
r6412 r8129 23 23 values = NULL; 24 24 savedvalues = NULL; 25 minvalues = NULL; 26 maxvalues = NULL; 25 27 gradient = NULL; 26 28 } 27 29 /*}}}*/ 28 /*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues, int id){{{1*/29 ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues, int id){30 /*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){{{1*/ 31 ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){ 30 32 31 33 control_id=id; … … 36 38 values =new TriaVertexInput(enum_type,pvalues); 37 39 savedvalues=new TriaVertexInput(enum_type,pvalues); 40 minvalues =new TriaVertexInput(enum_type,pmin); 41 maxvalues =new TriaVertexInput(enum_type,pmax); 38 42 break; 39 43 case PentaVertexInputEnum: 40 44 values =new PentaVertexInput(enum_type,pvalues); 41 45 savedvalues=new PentaVertexInput(enum_type,pvalues); 46 minvalues =new PentaVertexInput(enum_type,pmin); 47 maxvalues =new PentaVertexInput(enum_type,pmax); 42 48 break; 43 49 default: … … 51 57 delete values; 52 58 delete savedvalues; 59 delete minvalues; 60 delete maxvalues; 53 61 delete gradient; 54 62 } … … 66 74 printf("ControlInput:\n"); 67 75 printf(" enum: %i (%s)\n",this->enum_type,EnumToString(this->enum_type)); 68 printf("---values: \n"); if (values) values->Echo(); 69 printf("---savedvalues: \n"); if (savedvalues) savedvalues->Echo(); 70 printf("---gradient: \n"); if (gradient) gradient->Echo(); 76 printf("---values: \n"); if (values) values->Echo(); 77 printf("---savedvalues: \n");if (savedvalues) savedvalues->Echo(); 78 printf("---minvalues: \n"); if (minvalues) minvalues->Echo(); 79 printf("---maxvalues: \n"); if (maxvalues) maxvalues->Echo(); 80 printf("---gradient: \n"); if (gradient) gradient->Echo(); 71 81 } 72 82 /*}}}*/ … … 122 132 } 123 133 134 /*marshal minvalues*/ 135 if(!minvalues){ 136 flag=0; 137 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag); 138 } 139 else{ 140 flag=1; 141 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag); 142 this->minvalues->Marshall(&marshalled_dataset); 143 } 144 145 /*marshal maxvalues*/ 146 if(!maxvalues){ 147 flag=0; 148 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag); 149 } 150 else{ 151 flag=1; 152 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag); 153 this->maxvalues->Marshall(&marshalled_dataset); 154 } 155 124 156 /*marshal gradient*/ 125 157 if(!gradient){ … … 144 176 size=sizeof(enum_type)+ 145 177 +sizeof(control_id) 146 + 3*sizeof(int) //3flags178 +5*sizeof(int) //5 flags 147 179 +sizeof(int); //sizeof(int) for enum value 148 180 149 181 if(values) size+=values->MarshallSize(); 150 182 if(savedvalues)size+=savedvalues->MarshallSize(); 183 if(minvalues)size+=minvalues->MarshallSize(); 184 if(maxvalues)size+=maxvalues->MarshallSize(); 151 185 if(gradient) size+=gradient->MarshallSize(); 152 186 return size; … … 203 237 } 204 238 239 /*Demarshal minvalues*/ 240 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int); 241 if(flag){ 242 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int); 243 if(input_enum_type==PentaVertexInputEnum){ 244 minvalues=new PentaVertexInput(); 245 minvalues->Demarshall(&marshalled_dataset); 246 } 247 else if(input_enum_type==TriaVertexInputEnum){ 248 minvalues=new TriaVertexInput(); 249 minvalues->Demarshall(&marshalled_dataset); 250 } 251 else _error_("Not supported yet"); 252 } 253 else{ 254 minvalues=NULL; 255 } 256 257 /*Demarshal maxvalues*/ 258 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int); 259 if(flag){ 260 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int); 261 if(input_enum_type==PentaVertexInputEnum){ 262 maxvalues=new PentaVertexInput(); 263 maxvalues->Demarshall(&marshalled_dataset); 264 } 265 else if(input_enum_type==TriaVertexInputEnum){ 266 maxvalues=new TriaVertexInput(); 267 maxvalues->Demarshall(&marshalled_dataset); 268 } 269 else _error_("Not supported yet"); 270 } 271 else{ 272 maxvalues=NULL; 273 } 274 205 275 /*Demarshal gradient*/ 206 276 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int); … … 244 314 if(values) output->values=(Input*)this->values->copy(); 245 315 if(savedvalues) output->savedvalues=(Input*)this->savedvalues->copy(); 316 if(minvalues) output->minvalues=(Input*)this->minvalues->copy(); 317 if(maxvalues) output->maxvalues=(Input*)this->maxvalues->copy(); 246 318 if(gradient) output->gradient=(Input*)this->gradient->copy(); 247 319 … … 260 332 261 333 /*Object functions*/ 262 /*FUNCTION ControlInput::Constrain{{{1*/ 263 void ControlInput::Constrain(double cm_min, double cm_max){ 264 values->Constrain(cm_min,cm_max); 334 /*FUNCTION ControlInput::Constrain(){{{1*/ 335 void ControlInput::Constrain(void){ 336 337 Input* newvalues=NULL; 338 339 newvalues=this->values->PointwiseMin(maxvalues); 340 delete values; this->values=newvalues; 341 newvalues=this->values->PointwiseMax(minvalues); 342 delete values; this->values=newvalues; 343 }/*}}}*/ 344 /*FUNCTION ControlInput::Constrain(double min, double max){{{1*/ 345 void ControlInput::Constrain(double min, double max){ 346 values->Constrain(min,max); 265 347 }/*}}}*/ 266 348 /*FUNCTION ControlInput::Extrude{{{1*/ -
issm/trunk/src/c/objects/Inputs/ControlInput.h
r6412 r8129 21 21 Input* values; 22 22 Input* savedvalues; 23 Input* minvalues; 24 Input* maxvalues; 23 25 Input* gradient; 24 26 25 27 /*ControlInput constructors, destructors: {{{1*/ 26 28 ControlInput(); 27 ControlInput(int enum_type,int enum_input,double* pvalues, int id);29 ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id); 28 30 ~ControlInput(); 29 31 /*}}}*/ … … 43 45 Input* SpawnTriaInput(int* indices); 44 46 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");}; 47 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");}; 48 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");}; 45 49 ElementResult* SpawnResult(int step, double time); 46 50 /*}}}*/ … … 67 71 void ArtificialNoise(double min,double max){_error_("not implemented yet");}; 68 72 void AXPY(Input* xinput,double scalar){_error_("not implemented yet");}; 69 void Constrain(double cm_min, double cm_max); 73 void Constrain(void); 74 void Constrain(double min,double max); 70 75 double InfinityNorm(void){_error_("not implemented yet");}; 71 76 double Max(void){_error_("not implemented yet");}; -
issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
r6412 r8129 313 313 314 314 /*Intermediaries*/ 315 double AdotBvalue;316 315 double Bvalue; 317 316 … … 327 326 } 328 327 /*}}}*/ 328 /*FUNCTION DoubleInput::PointwiseMin{{{1*/ 329 Input* DoubleInput::PointwiseMin(Input* input){ 330 331 /*Ouput*/ 332 DoubleInput* outinput=NULL; 333 334 /*Intermediaries*/ 335 double min; 336 337 /*Check that inputB is of the same type*/ 338 if (input->Min() < this->Min()) min=input->Min(); 339 else min=this->Min(); 340 341 /*Create new DoubleInput*/ 342 outinput=new DoubleInput(this->enum_type,min); 343 344 /*Return output pointer*/ 345 return outinput; 346 347 } 348 /*}}}*/ 349 /*FUNCTION DoubleInput::PointwiseMax{{{1*/ 350 Input* DoubleInput::PointwiseMax(Input* input){ 351 352 /*Ouput*/ 353 DoubleInput* outinput=NULL; 354 355 /*Intermediaries*/ 356 double max; 357 358 /*Check that inputB is of the same type*/ 359 if (input->Max() > this->Max()) max=input->Max(); 360 else max=this->Max(); 361 362 /*Create new DoubleInput*/ 363 outinput=new DoubleInput(this->enum_type,max); 364 365 /*Return output pointer*/ 366 return outinput; 367 368 } 369 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/DoubleInput.h
r6412 r8129 40 40 Input* SpawnTriaInput(int* indices); 41 41 Input* PointwiseDivide(Input* inputB); 42 Input* PointwiseMin(Input* inputB); 43 Input* PointwiseMax(Input* inputB); 42 44 ElementResult* SpawnResult(int step, double time); 43 45 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/Input.h
r5743 r8129 57 57 virtual Input* SpawnTriaInput(int* indices)=0; 58 58 virtual Input* PointwiseDivide(Input* inputB)=0; 59 virtual Input* PointwiseMax(Input* inputmax)=0; 60 virtual Input* PointwiseMin(Input* inputmin)=0; 59 61 virtual ElementResult* SpawnResult(int step, double time)=0; 60 62 -
issm/trunk/src/c/objects/Inputs/IntInput.h
r6412 r8129 41 41 Input* SpawnTriaInput(int* indices); 42 42 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");}; 43 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");}; 44 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");}; 43 45 ElementResult* SpawnResult(int step, double time); 44 46 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
r6413 r8129 575 575 PentaVertexInput *xinputB = NULL; 576 576 int B_numvalues; 577 double *B_values = NULL;578 577 const int numgrids = 6; 579 578 double AdotBvalues[numgrids]; … … 597 596 } 598 597 /*}}}*/ 598 /*FUNCTION PentaVertexInput::PointwiseMin{{{1*/ 599 Input* PentaVertexInput::PointwiseMin(Input* inputB){ 600 601 /*Ouput*/ 602 PentaVertexInput* outinput=NULL; 603 604 /*Intermediaries*/ 605 int i; 606 PentaVertexInput *xinputB = NULL; 607 int B_numvalues; 608 const int numgrids = 6; 609 double minvalues[numgrids]; 610 611 /*Check that inputB is of the same type*/ 612 if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum())); 613 xinputB=(PentaVertexInput*)inputB; 614 615 /*Create point wise min*/ 616 for(i=0;i<numgrids;i++){ 617 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i]; 618 else minvalues[i]=this->values[i]; 619 } 620 621 /*Create new Penta vertex input (copy of current input)*/ 622 outinput=new PentaVertexInput(this->enum_type,&minvalues[0]); 623 624 /*Return output pointer*/ 625 return outinput; 626 627 } 628 /*}}}*/ 629 /*FUNCTION PentaVertexInput::PointwiseMax{{{1*/ 630 Input* PentaVertexInput::PointwiseMax(Input* inputB){ 631 632 /*Ouput*/ 633 PentaVertexInput* outinput=NULL; 634 635 /*Intermediaries*/ 636 int i; 637 PentaVertexInput *xinputB = NULL; 638 int B_numvalues; 639 const int numgrids = 6; 640 double maxvalues[numgrids]; 641 642 /*Check that inputB is of the same type*/ 643 if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum())); 644 xinputB=(PentaVertexInput*)inputB; 645 646 /*Create point wise max*/ 647 for(i=0;i<numgrids;i++){ 648 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i]; 649 else maxvalues[i]=this->values[i]; 650 } 651 652 /*Create new Penta vertex input (copy of current input)*/ 653 outinput=new PentaVertexInput(this->enum_type,&maxvalues[0]); 654 655 /*Return output pointer*/ 656 return outinput; 657 658 } 659 /*}}}*/ 599 660 /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/ 600 661 void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){ -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.h
r6412 r8129 41 41 Input* SpawnTriaInput(int* indices); 42 42 Input* PointwiseDivide(Input* inputB); 43 Input* PointwiseMin(Input* inputB); 44 Input* PointwiseMax(Input* inputB); 43 45 ElementResult* SpawnResult(int step, double time); 44 46 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
r7089 r8129 403 403 } 404 404 /*}}}*/ 405 /*FUNCTION TriaVertexInput::PointwiseMin{{{1*/ 406 Input* TriaVertexInput::PointwiseMin(Input* inputB){ 407 408 /*Ouput*/ 409 TriaVertexInput* outinput=NULL; 410 411 /*Intermediaries*/ 412 int i; 413 TriaVertexInput *xinputB = NULL; 414 int B_numvalues; 415 const int numgrids = 3; 416 double minvalues[numgrids]; 417 418 /*Check that inputB is of the same type*/ 419 if (inputB->Enum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum())); 420 xinputB=(TriaVertexInput*)inputB; 421 422 /*Create point wise min*/ 423 for(i=0;i<numgrids;i++){ 424 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i]; 425 else minvalues[i]=this->values[i]; 426 } 427 428 /*Create new Tria vertex input (copy of current input)*/ 429 outinput=new TriaVertexInput(this->enum_type,&minvalues[0]); 430 431 /*Return output pointer*/ 432 return outinput; 433 434 } 435 /*}}}*/ 436 /*FUNCTION TriaVertexInput::PointwiseMax{{{1*/ 437 Input* TriaVertexInput::PointwiseMax(Input* inputB){ 438 439 /*Ouput*/ 440 TriaVertexInput* outinput=NULL; 441 442 /*Intermediaries*/ 443 int i; 444 TriaVertexInput *xinputB = NULL; 445 int B_numvalues; 446 const int numgrids = 3; 447 double maxvalues[numgrids]; 448 449 /*Check that inputB is of the same type*/ 450 if (inputB->Enum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum())); 451 xinputB=(TriaVertexInput*)inputB; 452 453 /*Create point wise max*/ 454 for(i=0;i<numgrids;i++){ 455 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i]; 456 else maxvalues[i]=this->values[i]; 457 } 458 459 /*Create new Tria vertex input (copy of current input)*/ 460 outinput=new TriaVertexInput(this->enum_type,&maxvalues[0]); 461 462 /*Return output pointer*/ 463 return outinput; 464 465 } 466 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.h
r6412 r8129 41 41 Input* SpawnTriaInput(int* indices); 42 42 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");}; 43 Input* PointwiseMin(Input* inputB); 44 Input* PointwiseMax(Input* inputB); 43 45 ElementResult* SpawnResult(int step, double time); 44 46 /*}}}*/ -
issm/trunk/src/c/objects/Materials/Matice.cpp
r7834 r8129 608 608 const int num_vertices = 3; //Tria has 3 vertices 609 609 double nodeinputs[num_vertices]; 610 double cmmininputs[num_vertices]; 611 double cmmaxinputs[num_vertices]; 610 612 611 613 /*Get B*/ … … 627 629 case RheologyBbarEnum: 628 630 if (iomodel->rheology_B){ 631 _assert_(iomodel->rheology_B);_assert_(iomodel->cm_min); _assert_(iomodel->cm_max); 629 632 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 630 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs,i+1)); 633 for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->cm_min[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i]; 634 for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->cm_max[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i]; 635 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 631 636 } 632 637 break; … … 642 647 const int num_vertices = 6; //Penta has 6 vertices 643 648 double nodeinputs[num_vertices]; 649 double cmmininputs[num_vertices]; 650 double cmmaxinputs[num_vertices]; 644 651 645 652 /*Get B*/ … … 661 668 case RheologyBbarEnum: 662 669 if (iomodel->rheology_B){ 670 _assert_(iomodel->rheology_B);_assert_(iomodel->cm_min); _assert_(iomodel->cm_max); 663 671 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 664 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs,i+1)); 672 for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->cm_min[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i]; 673 for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->cm_max[int(iomodel->elements[num_vertices*index+j]-1)*iomodel->num_control_type+i]; 674 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 665 675 } 666 676 break;
Note:
See TracChangeset
for help on using the changeset viewer.