Changeset 6260
- Timestamp:
- 10/12/10 14:17:01 (14 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r6201 r6260 321 321 AdjointEnum, 322 322 GradientEnum, 323 Gradient1Enum, 324 Gradient2Enum, 325 Gradient3Enum, 323 326 OldGradientEnum, 324 327 ConnectivityEnum, -
issm/trunk/src/c/EnumDefinitions/EnumToString.cpp
r6201 r6260 283 283 case AdjointEnum : return "Adjoint"; 284 284 case GradientEnum : return "Gradient"; 285 case Gradient1Enum : return "Gradient1"; 286 case Gradient2Enum : return "Gradient2"; 287 case Gradient3Enum : return "Gradient3"; 285 288 case OldGradientEnum : return "OldGradient"; 286 289 case ConnectivityEnum : return "Connectivity"; -
issm/trunk/src/c/EnumDefinitions/StringToEnum.cpp
r6201 r6260 281 281 else if (strcmp(name,"Adjoint")==0) return AdjointEnum; 282 282 else if (strcmp(name,"Gradient")==0) return GradientEnum; 283 else if (strcmp(name,"Gradient1")==0) return Gradient1Enum; 284 else if (strcmp(name,"Gradient2")==0) return Gradient2Enum; 285 else if (strcmp(name,"Gradient3")==0) return Gradient3Enum; 283 286 else if (strcmp(name,"OldGradient")==0) return OldGradientEnum; 284 287 else if (strcmp(name,"Connectivity")==0) return ConnectivityEnum; -
issm/trunk/src/c/objects/Elements/Penta.cpp
r6240 r6260 583 583 if (iomodel->dhdt){ 584 584 for(j=0;j<6;j++)nodeinputs[j]=iomodel->dhdt[penta_vertex_ids[j]-1]/iomodel->yts; 585 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs ));585 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs,i+1)); 586 586 } 587 587 break; … … 589 589 if (iomodel->vx){ 590 590 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vx[penta_vertex_ids[j]-1]/iomodel->yts; 591 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs ));591 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,i+1)); 592 592 } 593 593 break; … … 595 595 if (iomodel->vy){ 596 596 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vy[penta_vertex_ids[j]-1]/iomodel->yts; 597 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs ));597 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,i+1)); 598 598 } 599 599 break; … … 601 601 if (iomodel->drag_coefficient){ 602 602 for(j=0;j<6;j++)nodeinputs[j]=iomodel->drag_coefficient[penta_vertex_ids[j]-1]; 603 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs ));603 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs,i+1)); 604 604 } 605 605 break; -
issm/trunk/src/c/objects/Elements/Tria.cpp
r6244 r6260 649 649 if (iomodel->dhdt){ 650 650 for(j=0;j<3;j++)nodeinputs[j]=iomodel->dhdt[tria_vertex_ids[j]-1]/iomodel->yts; 651 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs ));651 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs,i+1)); 652 652 } 653 653 break; … … 655 655 if (iomodel->vx){ 656 656 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vx[tria_vertex_ids[j]-1]/iomodel->yts; 657 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs ));657 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,i+1)); 658 658 } 659 659 break; … … 661 661 if (iomodel->vy){ 662 662 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vy[tria_vertex_ids[j]-1]/iomodel->yts; 663 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs ));663 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,i+1)); 664 664 } 665 665 break; … … 667 667 if (iomodel->drag_coefficient){ 668 668 for(j=0;j<3;j++)nodeinputs[j]=iomodel->drag_coefficient[tria_vertex_ids[j]-1]; 669 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs ));669 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs,i+1)); 670 670 } 671 671 break; -
issm/trunk/src/c/objects/Inputs/ControlInput.cpp
r6238 r6260 20 20 /*FUNCTION ControlInput::ControlInput(){{{1*/ 21 21 ControlInput::ControlInput(){ 22 values =NULL; 23 savedvalues =NULL; 24 gradient =NULL; 25 } 26 /*}}}*/ 27 /*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues){{{1*/ 28 ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues){ 22 control_id = 0; 23 values = NULL; 24 savedvalues = NULL; 25 gradient = NULL; 26 } 27 /*}}}*/ 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 31 control_id=id; 29 32 enum_type=in_enum_type; 33 30 34 switch(enum_input){ 31 35 case TriaVertexInputEnum: … … 94 98 /*marshall enum_type: */ 95 99 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 100 memcpy(marshalled_dataset,&control_id,sizeof(control_id));marshalled_dataset+=sizeof(control_id); 96 101 97 102 /*marshal values*/ … … 138 143 139 144 size=sizeof(enum_type)+ 145 +sizeof(control_id) 140 146 +3*sizeof(int) //3 flags 141 147 +sizeof(int); //sizeof(int) for enum value … … 159 165 *object data (thanks to DataSet::Demarshall):*/ 160 166 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 167 memcpy(&control_id,marshalled_dataset,sizeof(control_id));marshalled_dataset+=sizeof(control_id); 161 168 162 169 /*Demarshal values*/ … … 233 240 output = new ControlInput(); 234 241 output->enum_type=this->enum_type; 242 output->control_id=this->control_id; 235 243 236 244 if(values) output->values=(Input*)this->values->copy(); … … 273 281 /*FUNCTION ControlInput::SetGradient{{{1*/ 274 282 void ControlInput::SetGradient(Input* gradient_in){ 283 284 /*Get enum for current gradient*/ 285 switch(this->control_id){ 286 case 1: 287 gradient_in->ChangeEnum(Gradient1Enum); 288 break; 289 case 2: 290 gradient_in->ChangeEnum(Gradient2Enum); 291 break; 292 case 3: 293 gradient_in->ChangeEnum(Gradient3Enum); 294 break; 295 default: 296 ISSMERROR("more than 3 controls not implemented yet (Gradient %i was requested). EnumDefinitions.h needs to be updated.",this->control_id); 297 } 298 299 /*Delete old gradient and assign new gradient*/ 275 300 if(gradient) delete gradient; 276 301 gradient=gradient_in; 302 277 303 }/*}}}*/ 278 304 /*FUNCTION ControlInput::SpawnResult{{{1*/ … … 286 312 /*FUNCTION ControlInput::SpawnGradient{{{1*/ 287 313 ElementResult* ControlInput::SpawnGradient(int step, double time){ 288 gradient->SpawnResult(step,time);314 return gradient->SpawnResult(step,time); 289 315 }/*}}}*/ 290 316 /*FUNCTION ControlInput::GetParameterAverage(double* pvalue){{{1*/ -
issm/trunk/src/c/objects/Inputs/ControlInput.h
r6238 r6260 18 18 public: 19 19 int enum_type; 20 int control_id; 20 21 Input* values; 21 22 Input* savedvalues; … … 24 25 /*ControlInput constructors, destructors: {{{1*/ 25 26 ControlInput(); 26 ControlInput(int enum_type,int enum_input,double* pvalues );27 ControlInput(int enum_type,int enum_input,double* pvalues,int id); 27 28 ~ControlInput(); 28 29 /*}}}*/ -
issm/trunk/src/c/objects/Materials/Matice.cpp
r6231 r6260 37 37 this->inputs=new Inputs(); 38 38 39 /*if 2d*/ 40 if(iomodel->dim==2){ 41 42 /*Intermediaries*/ 43 const int num_vertices = 3; //Tria has 3 vertices 44 double nodeinputs[num_vertices]; 45 46 /*Get B*/ 47 if (iomodel->rheology_B) { 48 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 49 this->inputs->AddInput(new TriaVertexInput(RheologyBbarEnum,nodeinputs)); 50 } 51 52 /*Get n*/ 53 if (iomodel->rheology_n) { 54 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_n[index]; 55 this->inputs->AddInput(new TriaVertexInput(RheologyNEnum,nodeinputs)); 56 } 57 58 /*Control Inputs*/ 59 if (iomodel->control_analysis && iomodel->control_type){ 60 for(i=0;i<iomodel->num_control_type;i++){ 61 switch((int)iomodel->control_type[i]){ 62 case RheologyBbarEnum: 63 if (iomodel->rheology_B){ 64 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 65 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs)); 66 } 67 break; 68 } 69 } 70 } 71 } 72 73 /*if 3d*/ 74 else if(iomodel->dim==3){ 75 76 /*Intermediaries*/ 77 const int num_vertices = 6; //Penta has 6 vertices 78 double nodeinputs[num_vertices]; 79 80 /*Get B*/ 81 if (iomodel->rheology_B) { 82 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 83 this->inputs->AddInput(new PentaVertexInput(RheologyBEnum,nodeinputs)); 84 } 85 86 /*Get n*/ 87 if (iomodel->rheology_n) { 88 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_n[index]; 89 this->inputs->AddInput(new PentaVertexInput(RheologyNEnum,nodeinputs)); 90 } 91 92 /*Control Inputs*/ 93 if (iomodel->control_analysis && iomodel->control_type){ 94 for(i=0;i<iomodel->num_control_type;i++){ 95 switch((int)iomodel->control_type[i]){ 96 case RheologyBbarEnum: 97 if (iomodel->rheology_B){ 98 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 99 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs)); 100 } 101 break; 102 } 103 } 104 } 105 } 106 else{ 107 ISSMERROR(" Mesh type not supported yet!"); 108 } 109 39 /*Initialize inputs from IoModel*/ 40 this->InputUpdateFromIoModel(index,iomodel); 110 41 111 42 /*Hooks: */ … … 678 609 double nodeinputs[num_vertices]; 679 610 611 /*Get B*/ 612 if (iomodel->rheology_B) { 613 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 614 this->inputs->AddInput(new TriaVertexInput(RheologyBbarEnum,nodeinputs)); 615 } 616 617 /*Get n*/ 618 if (iomodel->rheology_n) { 619 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_n[index]; 620 this->inputs->AddInput(new TriaVertexInput(RheologyNEnum,nodeinputs)); 621 } 622 680 623 /*Control Inputs*/ 681 624 if (iomodel->control_analysis && iomodel->control_type){ … … 685 628 if (iomodel->rheology_B){ 686 629 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 687 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs ));630 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs,i+1)); 688 631 } 689 632 break; … … 699 642 const int num_vertices = 6; //Penta has 6 vertices 700 643 double nodeinputs[num_vertices]; 644 645 /*Get B*/ 646 if (iomodel->rheology_B) { 647 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 648 this->inputs->AddInput(new PentaVertexInput(RheologyBEnum,nodeinputs)); 649 } 650 651 /*Get n*/ 652 if (iomodel->rheology_n) { 653 for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->rheology_n[index]; 654 this->inputs->AddInput(new PentaVertexInput(RheologyNEnum,nodeinputs)); 655 } 701 656 702 657 /*Control Inputs*/ … … 707 662 if (iomodel->rheology_B){ 708 663 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 709 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs ));664 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs,i+1)); 710 665 } 711 666 break; -
issm/trunk/src/c/objects/Params/DoubleVecParam.cpp
r6163 r6260 146 146 147 147 /*DoubleVecParam virtual functions definitions: */ 148 /*FUNCTION DoubleVecParam::GetParameterValue {{{1*/148 /*FUNCTION DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/ 149 149 void DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){ 150 150 double* output=NULL; … … 158 158 if(pM) *pM=M; 159 159 *pdoublearray=output; 160 } 161 /*}}}*/ 162 /*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{1*/ 163 void DoubleVecParam::GetParameterValue(int** pintarray,int* pM){ 164 #ifdef _SERIAL_ 165 int* output=NULL; 166 int i; 167 168 /*Cast values into integers*/ 169 output=(int*)xmalloc(M*sizeof(int)); 170 for(i=0;i<M;i++) output[i]=(int)values[i]; 171 172 /*Assign output pointers:*/ 173 if(pM) *pM=M; 174 *pintarray=output; 175 #else 176 ISSMERROR("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToString(enum_type)); 177 #endif 160 178 } 161 179 /*}}}*/ -
issm/trunk/src/c/objects/Params/DoubleVecParam.h
r6165 r6260 52 52 void GetParameterValue(bool* pbool){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a bool",enum_type,EnumToString(enum_type));} 53 53 void GetParameterValue(int* pinteger){ISSMERROR("DoubleVec param of enum %i (%s) cannot return an integer",enum_type,EnumToString(enum_type));} 54 void GetParameterValue(int** pintarray,int* pM) {ISSMERROR("DoubleVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToString(enum_type));}54 void GetParameterValue(int** pintarray,int* pM); 55 55 void GetParameterValue(double* pdouble){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a double",enum_type,EnumToString(enum_type));} 56 56 void GetParameterValue(char** pstring){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a string",enum_type,EnumToString(enum_type));}
Note:
See TracChangeset
for help on using the changeset viewer.