Changeset 1046
- Timestamp:
- 06/22/09 14:00:59 (16 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 15 edited
-
c/ControlConstrainx/ControlConstrainx.cpp (modified) (2 diffs)
-
c/ControlConstrainx/ControlConstrainx.h (modified) (1 diff)
-
c/Gradjx/Gradjx.cpp (modified) (2 diffs)
-
c/Gradjx/Gradjx.h (modified) (1 diff)
-
c/ModelProcessorx/Control/CreateParametersControl.cpp (modified) (1 diff)
-
c/objects/Tria.cpp (modified) (110 diffs)
-
c/parallel/GradJCompute.cpp (modified) (3 diffs)
-
c/parallel/ProcessResults.cpp (modified) (1 diff)
-
c/parallel/control_core.cpp (modified) (3 diffs)
-
c/parallel/objectivefunctionC.cpp (modified) (2 diffs)
-
m/solutions/cielo/control_core.m (modified) (2 diffs)
-
m/solutions/cielo/controlfinalsol.m (modified) (1 diff)
-
m/solutions/cielo/objectivefunctionC.m (modified) (1 diff)
-
m/solutions/cielo/processresults.m (modified) (1 diff)
-
mex/Gradj/Gradj.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/ControlConstrainx/ControlConstrainx.cpp
r1 r1046 13 13 #include "../EnumDefinitions/EnumDefinitions.h" 14 14 15 void ControlConstrainx( double* p_g, int gsize, double mincontrolconstraint, double maxcontrolconstraint,char* control_type){15 void ControlConstrainx( double* p_g, int numdofnodes, double mincontrolconstraint, double maxcontrolconstraint,char* control_type){ 16 16 17 17 int i; … … 21 21 } 22 22 else{ 23 for(i=0;i< gsize;i=i+2){23 for(i=0;i<numdofnodes;i++){ 24 24 25 25 if(!isnan(mincontrolconstraint)){ -
issm/trunk/src/c/ControlConstrainx/ControlConstrainx.h
r1 r1046 9 9 10 10 /* local prototypes: */ 11 void ControlConstrainx( double* p_g, int gsize, double mincontrolconstraint, double maxcontrolconstraint,char* control_type);11 void ControlConstrainx( double* p_g, int numberofnodes, double mincontrolconstraint, double maxcontrolconstraint,char* control_type); 12 12 13 13 #endif /* _CONTROLCONSTRAINX_H */ -
issm/trunk/src/c/Gradjx/Gradjx.cpp
r465 r1046 13 13 #include "../EnumDefinitions/EnumDefinitions.h" 14 14 15 void Gradjx( Vec* pgrad_g, DataSet* elements,DataSet* nodes, DataSet* loads, DataSet* materials,15 void Gradjx( Vec* pgrad_g, int numberofnodes, DataSet* elements,DataSet* nodes, DataSet* loads, DataSet* materials, 16 16 double* u_g, double* lambda_g, ParameterInputs* inputs,int analysis_type,int sub_analysis_type,char* control_type){ 17 18 int i;19 int gsize;20 int found;21 17 22 18 /*output: */ … … 26 22 elements->Configure(elements,loads, nodes, materials); 27 23 28 /*Get size of matrix: */29 gsize=nodes->NumberOfDofs();30 31 24 /*Allocate grad_g: */ 32 grad_g=NewVec( gsize);25 grad_g=NewVec(numberofnodes); 33 26 34 27 /*Compute gradients: */ -
issm/trunk/src/c/Gradjx/Gradjx.h
r465 r1046 9 9 10 10 /* local prototypes: */ 11 void Gradjx( Vec* pgrad_g, DataSet* elements,DataSet* nodes, DataSet* loads, DataSet* materials,11 void Gradjx( Vec* pgrad_g, int numberofnodes, DataSet* elements,DataSet* nodes, DataSet* loads, DataSet* materials, 12 12 double* u_g, double* lambda_g, ParameterInputs* inputs,int analysis_type,int sub_analysis_type,char* control_type); 13 13 -
issm/trunk/src/c/ModelProcessorx/Control/CreateParametersControl.cpp
r774 r1046 135 135 parameters->AddObject(param); 136 136 137 param_g=(double*)xcalloc(model->numberofnodes *2,sizeof(double));138 for(i=0;i<model->numberofnodes;i++)param_g[ 2*i+0]=control_parameter[i];137 param_g=(double*)xcalloc(model->numberofnodes,sizeof(double)); 138 for(i=0;i<model->numberofnodes;i++)param_g[i]=control_parameter[i]; 139 139 140 140 count++; 141 141 param= new Param(count,"param_g",DOUBLEVEC); 142 param->SetDoubleVec(param_g, 2*model->numberofnodes,2);142 param->SetDoubleVec(param_g,model->numberofnodes,1); 143 143 parameters->AddObject(param); 144 144 -
issm/trunk/src/c/objects/Tria.cpp
r983 r1046 4 4 5 5 #ifdef HAVE_CONFIG_H 6 #include "config.h"6 #include "config.h" 7 7 #else 8 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" … … 33 33 34 34 Tria::Tria(int tria_id,int tria_mid,int tria_mparid,int tria_node_ids[3],double tria_h[3],double tria_s[3],double tria_b[3],double tria_k[3],double tria_melting[3], 35 double tria_accumulation[3],double tria_geothermalflux[3],int tria_friction_type,double tria_p,double tria_q,int tria_shelf,double tria_meanvel,double tria_epsvel,36 double tria_viscosity_overshoot,int tria_artdiff){37 35 double tria_accumulation[3],double tria_geothermalflux[3],int tria_friction_type,double tria_p,double tria_q,int tria_shelf,double tria_meanvel,double tria_epsvel, 36 double tria_viscosity_overshoot,int tria_artdiff){ 37 38 38 int i; 39 39 40 40 id=tria_id; 41 41 mid=tria_mid; … … 66 66 viscosity_overshoot=tria_viscosity_overshoot; 67 67 artdiff=tria_artdiff; 68 68 69 69 return; 70 70 } … … 156 156 /*get enum type of Tria: */ 157 157 enum_type=TriaEnum(); 158 158 159 159 /*marshall enum: */ 160 160 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 161 161 162 162 /*marshall Tria data: */ 163 163 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); … … 187 187 memcpy(marshalled_dataset,&viscosity_overshoot,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot); 188 188 memcpy(marshalled_dataset,&artdiff,sizeof(artdiff));marshalled_dataset+=sizeof(artdiff); 189 189 190 190 *pmarshalled_dataset=marshalled_dataset; 191 191 return; 192 192 } 193 193 194 194 int Tria::MarshallSize(){ 195 195 return sizeof(id) 196 +sizeof(mid)197 +sizeof(mparid)198 +sizeof(node_ids)199 +sizeof(nodes)200 +sizeof(node_offsets)201 +sizeof(matice)202 +sizeof(matice_offset)203 +sizeof(matpar)204 +sizeof(matpar_offset)205 +sizeof(h)206 +sizeof(s)207 +sizeof(b)208 +sizeof(k)209 +sizeof(melting)210 +sizeof(accumulation)211 +sizeof(geothermalflux)212 +sizeof(friction_type)213 +sizeof(onbed)214 +sizeof(p)215 +sizeof(q)216 +sizeof(shelf)217 +sizeof(meanvel)218 +sizeof(epsvel)219 +sizeof(viscosity_overshoot)220 +sizeof(artdiff)221 +sizeof(int); //sizeof(int) for enum type196 +sizeof(mid) 197 +sizeof(mparid) 198 +sizeof(node_ids) 199 +sizeof(nodes) 200 +sizeof(node_offsets) 201 +sizeof(matice) 202 +sizeof(matice_offset) 203 +sizeof(matpar) 204 +sizeof(matpar_offset) 205 +sizeof(h) 206 +sizeof(s) 207 +sizeof(b) 208 +sizeof(k) 209 +sizeof(melting) 210 +sizeof(accumulation) 211 +sizeof(geothermalflux) 212 +sizeof(friction_type) 213 +sizeof(onbed) 214 +sizeof(p) 215 +sizeof(q) 216 +sizeof(shelf) 217 +sizeof(meanvel) 218 +sizeof(epsvel) 219 +sizeof(viscosity_overshoot) 220 +sizeof(artdiff) 221 +sizeof(int); //sizeof(int) for enum type 222 222 } 223 223 … … 291 291 292 292 int i; 293 293 294 294 DataSet* loadsin=NULL; 295 295 DataSet* nodesin=NULL; … … 303 303 /*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */ 304 304 ResolvePointers((Object**)nodes,node_ids,node_offsets,3,nodesin); 305 305 306 306 /*Same for materials: */ 307 307 ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin); … … 317 317 /*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */ 318 318 if (analysis_type==ControlAnalysisEnum()){ 319 319 320 320 CreateKMatrixDiagnosticHoriz( Kgg,inputs,analysis_type,sub_analysis_type); 321 321 } 322 322 else if (analysis_type==DiagnosticAnalysisEnum()){ 323 323 324 324 if (sub_analysis_type==HorizAnalysisEnum()){ 325 325 … … 361 361 int doflist[numdof]; 362 362 int numberofdofspernode; 363 363 364 364 /* gaussian points: */ 365 365 int num_gauss,ig; … … 375 375 double newviscosity; //viscosity 376 376 double oldviscosity; //viscosity 377 377 378 378 /* strain rate: */ 379 379 double epsilon[3]; /* epsilon=[exx,eyy,exy];*/ … … 389 389 double Ke_gg[numdof][numdof]; //local element stiffness matrix 390 390 double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix evaluated at the gaussian point. 391 391 392 392 double Jdet; 393 393 394 394 /*input parameters for structural analysis (diagnostic): */ 395 395 double vxvy_list[numgrids][2]={{0,0},{0,0},{0,0}}; … … 414 414 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gg[i][j]=0.0; 415 415 416 #ifdef _DEBUGELEMENTS_416 #ifdef _DEBUGELEMENTS_ 417 417 if(my_rank==RANK && id==ELID){ 418 418 printf("El id %i Rank %i TriaElemnet input list before gaussian loop: \n",ELID,RANK); 419 419 printf(" rho_ice: %g \n",matpar->GetRhoIce()); 420 420 printf(" gravity: %g \n",matpar->GetG()) 421 printf(" rho_water: %g \n",matpar->GetRhoWater());421 printf(" rho_water: %g \n",matpar->GetRhoWater()); 422 422 printf(" Velocity: \n"); 423 423 for (i=0;i<numgrids;i++){ … … 430 430 printf(" bed [%g %g %g]\n",b[0],b[1],b[2]); 431 431 } 432 #endif432 #endif 433 433 434 434 … … 436 436 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 437 437 438 #ifdef _DEBUGELEMENTS_438 #ifdef _DEBUGELEMENTS_ 439 439 if(my_rank==RANK && id==ELID){ 440 440 printf(" gaussian points: \n"); … … 443 443 } 444 444 } 445 #endif445 #endif 446 446 447 447 /* Start looping on the number of gaussian points: */ … … 460 460 GetStrainRate(&epsilon[0],&vxvy_list[0][0],&xyz_list[0][0],gauss_l1l2l3); 461 461 GetStrainRate(&oldepsilon[0],&oldvxvy_list[0][0],&xyz_list[0][0],gauss_l1l2l3); 462 462 463 463 /*Get viscosity: */ 464 464 matice->GetViscosity2d(&viscosity, &epsilon[0]); 465 465 matice->GetViscosity2d(&oldviscosity, &oldepsilon[0]); 466 466 467 467 /* Get Jacobian determinant: */ 468 468 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); 469 469 470 470 /* Build the D matrix: we plug the gaussian weight, the thickness, the viscosity, and the jacobian determinant 471 onto this scalar matrix, so that we win some computational time: */471 onto this scalar matrix, so that we win some computational time: */ 472 472 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 473 473 D_scalar=newviscosity*thickness*gauss_weight*Jdet; … … 476 476 D[i][i]=D_scalar; 477 477 } 478 479 #ifdef _DEBUGELEMENTS_478 479 #ifdef _DEBUGELEMENTS_ 480 480 if(my_rank==RANK && id==ELID){ 481 481 printf(" gaussian loop %i\n",ig); … … 492 492 printf(" gauss_weight: %g \n",gauss_weight); 493 493 } 494 #endif494 #endif 495 495 496 496 /*Get B and Bprime matrices: */ … … 500 500 /* Do the triple product tB*D*Bprime: */ 501 501 TripleMultiply( &B[0][0],3,numdof,1, 502 &D[0][0],3,3,0,503 &Bprime[0][0],3,numdof,0,504 &Ke_gg_gaussian[0][0],0);502 &D[0][0],3,3,0, 503 &Bprime[0][0],3,numdof,0, 504 &Ke_gg_gaussian[0][0],0); 505 505 506 506 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ 507 507 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 508 509 #ifdef _DEBUGELEMENTS_508 509 #ifdef _DEBUGELEMENTS_ 510 510 if(my_rank==RANK && id==ELID){ 511 511 printf(" B:\n"); … … 524 524 } 525 525 } 526 #endif526 #endif 527 527 } // for (ig=0; ig<num_gauss; ig++) 528 528 … … 537 537 538 538 539 #ifdef _DEBUGELEMENTS_539 #ifdef _DEBUGELEMENTS_ 540 540 if(my_rank==RANK && id==ELID){ 541 541 printf(" Ke_gg erms:\n"); … … 552 552 553 553 } 554 #endif555 556 cleanup_and_return:554 #endif 555 556 cleanup_and_return: 557 557 xfree((void**)&first_gauss_area_coord); 558 558 xfree((void**)&second_gauss_area_coord); … … 576 576 int doflist[numdof]; 577 577 int numberofdofspernode; 578 578 579 579 /* gaussian points: */ 580 580 int num_gauss,ig; … … 597 597 double Ke_gg_thickness1[numdof][numdof]={0.0}; //stiffness matrix evaluated at the gaussian point. 598 598 double Ke_gg_thickness2[numdof][numdof]={0.0}; //stiffness matrix evaluated at the gaussian point. 599 599 600 600 double Jdettria; 601 601 602 602 /*input parameters for structural analysis (diagnostic): */ 603 603 double vxvy_list[numgrids][2]={0.0}; … … 628 628 vy_list[i]=vxvy_list[i][1]; 629 629 } 630 630 631 631 found=inputs->Recover("dt",&dt); 632 632 if(!found)throw ErrorException(__FUNCT__," could not find dt in inputs!"); … … 645 645 v_gauss[0]=1.0/3.0*(vxvy_list[0][0]+vxvy_list[1][0]+vxvy_list[2][0]); 646 646 v_gauss[1]=1.0/3.0*(vxvy_list[0][1]+vxvy_list[1][1]+vxvy_list[2][1]); 647 647 648 648 K[0][0]=pow(Jdettria,.5)/2.0*fabs(v_gauss[0]); 649 649 K[1][1]=pow(Jdettria,.5)/2.0*fabs(v_gauss[1]); … … 671 671 /* Do the triple product tL*D*L: */ 672 672 TripleMultiply( &L[0],1,numdof,1, 673 &DL_scalar,1,1,0,674 &L[0],1,numdof,0,675 &Ke_gg_gaussian[0][0],0);676 673 &DL_scalar,1,1,0, 674 &L[0],1,numdof,0, 675 &Ke_gg_gaussian[0][0],0); 676 677 677 /*Get B and B prime matrix: */ 678 678 GetB_prog(&B[0][0], &xyz_list[0][0], gauss_l1l2l3); 679 679 GetBPrime_prog(&Bprime[0][0], &xyz_list[0][0], gauss_l1l2l3); 680 680 681 681 //Get vx, vy and their derivatives at gauss point 682 682 GetParameterValue(&vx, &vx_list[0],gauss_l1l2l3); 683 683 GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3); 684 684 685 685 GetParameterDerivativeValue(&dvx[0], &vx_list[0],&xyz_list[0][0], gauss_l1l2l3); 686 686 GetParameterDerivativeValue(&dvy[0], &vy_list[0],&xyz_list[0][0], gauss_l1l2l3); … … 702 702 703 703 TripleMultiply( &B[0][0],2,numdof,1, 704 &DL[0][0],2,2,0,705 &B[0][0],2,numdof,0,706 &Ke_gg_thickness1[0][0],0);704 &DL[0][0],2,2,0, 705 &B[0][0],2,numdof,0, 706 &Ke_gg_thickness1[0][0],0); 707 707 708 708 TripleMultiply( &B[0][0],2,numdof,1, 709 &DLprime[0][0],2,2,0,710 &Bprime[0][0],2,numdof,0,711 &Ke_gg_thickness2[0][0],0);709 &DLprime[0][0],2,2,0, 710 &Bprime[0][0],2,numdof,0, 711 &Ke_gg_thickness2[0][0],0); 712 712 713 713 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ … … 715 715 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_thickness1[i][j]; 716 716 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_thickness2[i][j]; 717 717 718 718 if(artdiff){ 719 719 720 720 /* Compute artificial diffusivity */ 721 721 KDL[0][0]=DL_scalar*K[0][0]; … … 723 723 724 724 TripleMultiply( &Bprime[0][0],2,numdof,1, 725 &KDL[0][0],2,2,0,726 &Bprime[0][0],2,numdof,0,727 &Ke_gg_gaussian[0][0],0);725 &KDL[0][0],2,2,0, 726 &Bprime[0][0],2,numdof,0, 727 &Ke_gg_gaussian[0][0],0); 728 728 729 729 /* Add artificial diffusivity matrix */ 730 730 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 731 732 } 733 734 #ifdef _DEBUGELEMENTS_731 732 } 733 734 #ifdef _DEBUGELEMENTS_ 735 735 if(my_rank==RANK && id==ELID){ 736 736 printf(" B:\n"); … … 749 749 } 750 750 } 751 #endif751 #endif 752 752 } // for (ig=0; ig<num_gauss; ig++) 753 753 … … 755 755 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 756 756 757 #ifdef _DEBUGELEMENTS_757 #ifdef _DEBUGELEMENTS_ 758 758 if(my_rank==RANK && id==ELID){ 759 759 printf(" Ke_gg erms:\n"); … … 770 770 771 771 } 772 #endif773 774 cleanup_and_return:772 #endif 773 774 cleanup_and_return: 775 775 xfree((void**)&first_gauss_area_coord); 776 776 xfree((void**)&second_gauss_area_coord); … … 795 795 int doflist[numdof]; 796 796 int numberofdofspernode; 797 797 798 798 /* gaussian points: */ 799 799 int num_gauss,ig; … … 809 809 double L[numgrids]; 810 810 double Jdettria; 811 811 812 812 /*input parameters for structural analysis (diagnostic): */ 813 813 double accumulation_list[numgrids]={0.0}; … … 861 861 GetParameterValue(&melting_g, &melting_list[0],gauss_l1l2l3); 862 862 GetParameterValue(&thickness_g, &thickness_list[0],gauss_l1l2l3); 863 863 864 864 /* Add value into pe_g: */ 865 865 for( i=0; i<numdof; i++) pe_g[i]+=Jdettria*gauss_weight*(thickness_g+dt*(accumulation_g-melting_g))*L[i]; 866 866 867 867 } // for (ig=0; ig<num_gauss; ig++) 868 868 … … 870 870 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 871 871 872 cleanup_and_return:872 cleanup_and_return: 873 873 xfree((void**)&first_gauss_area_coord); 874 874 xfree((void**)&second_gauss_area_coord); … … 893 893 int doflist[numdof]; 894 894 int numberofdofspernode; 895 895 896 896 /* gaussian points: */ 897 897 int num_gauss,ig; … … 911 911 double Ke_gg[numdof][numdof]; //local element stiffness matrix 912 912 double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag 913 913 914 914 double Jdet; 915 915 916 916 /*slope: */ 917 917 double slope[2]={0.0,0.0}; … … 933 933 /*recover pointers: */ 934 934 inputs=(ParameterInputs*)vinputs; 935 935 936 936 /* Get node coordinates and dof list: */ 937 937 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); … … 953 953 /*Build alpha2_list used by drag stiffness matrix*/ 954 954 Friction* friction=NewFriction(); 955 955 956 956 /*Initialize all fields: */ 957 957 friction->element_type=(char*)xmalloc((strlen("2d")+1)*sizeof(char)); 958 958 strcpy(friction->element_type,"2d"); 959 959 960 960 friction->gravity=matpar->GetG(); 961 961 friction->rho_ice=matpar->GetRhoIce(); … … 974 974 DeleteFriction(&friction); 975 975 976 #ifdef _DEBUGELEMENTS_976 #ifdef _DEBUGELEMENTS_ 977 977 if(my_rank==RANK && id==ELID){ 978 978 printf(" alpha2_list [%g %g %g ]\n",alpha2_list[0],alpha2_list[1],alpha2_list[2]); 979 979 } 980 #endif980 #endif 981 981 982 982 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 983 983 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 984 984 985 #ifdef _DEBUGELEMENTS_985 #ifdef _DEBUGELEMENTS_ 986 986 if(my_rank==RANK && id==ELID){ 987 987 printf(" gaussian points: \n"); … … 990 990 } 991 991 } 992 #endif992 #endif 993 993 994 994 /* Start looping on the number of gaussian points: */ … … 1025 1025 DL[i][i]=DL_scalar; 1026 1026 } 1027 1027 1028 1028 /* Do the triple producte tL*D*L: */ 1029 1029 TripleMultiply( &L[0][0],2,numdof,1, … … 1039 1039 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 1040 1040 1041 cleanup_and_return:1041 cleanup_and_return: 1042 1042 xfree((void**)&first_gauss_area_coord); 1043 1043 xfree((void**)&second_gauss_area_coord); … … 1062 1062 int doflist[numdof]; 1063 1063 int numberofdofspernode; 1064 1064 1065 1065 /* gaussian points: */ 1066 1066 int num_gauss,ig; … … 1079 1079 double Ke_gg[numdof][numdof]; //local element stiffness matrix 1080 1080 double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix evaluated at the gaussian point. 1081 1081 1082 1082 double Jdet; 1083 1083 1084 1084 /* Get node coordinates and dof list: */ 1085 1085 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); … … 1100 1100 gauss_l1l2l3[2]=*(third_gauss_area_coord+ig); 1101 1101 1102 1102 1103 1103 /*Get L matrix: */ 1104 1104 GetL(&L[0][0], &xyz_list[0][0], gauss_l1l2l3,NDOF1); … … 1106 1106 /* Get Jacobian determinant: */ 1107 1107 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); 1108 1108 1109 1109 DL_scalar=gauss_weight*Jdet; 1110 1110 … … 1121 1121 /*Add Ke_gg to global matrix Kgg: */ 1122 1122 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 1123 1124 cleanup_and_return:1123 1124 cleanup_and_return: 1125 1125 xfree((void**)&first_gauss_area_coord); 1126 1126 xfree((void**)&second_gauss_area_coord); … … 1132 1132 #define __FUNCT__ "Tria::CreatePVector" 1133 1133 void Tria::CreatePVector(Vec pg,void* inputs,int analysis_type,int sub_analysis_type){ 1134 1134 1135 1135 /*Just branch to the correct load generator, according to the type of analysis we are carrying out: */ 1136 1136 if (analysis_type==ControlAnalysisEnum()){ 1137 1137 1138 1138 CreatePVectorDiagnosticHoriz( pg,inputs,analysis_type,sub_analysis_type); 1139 1139 1140 1140 } 1141 1141 else if (analysis_type==DiagnosticAnalysisEnum()){ 1142 1142 if (sub_analysis_type==HorizAnalysisEnum()){ 1143 1143 1144 1144 CreatePVectorDiagnosticHoriz( pg,inputs,analysis_type,sub_analysis_type); 1145 1145 1146 1146 } 1147 1147 else throw ErrorException(__FUNCT__,exprintf("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet")); 1148 1148 } 1149 1149 else if (analysis_type==SlopeComputeAnalysisEnum()){ 1150 1150 1151 1151 CreatePVectorSlopeCompute( pg,inputs,analysis_type,sub_analysis_type); 1152 1152 } … … 1174 1174 int doflist[numdof]; 1175 1175 int numberofdofspernode; 1176 1176 1177 1177 /* parameters: */ 1178 1178 double plastic_stress; … … 1215 1215 1216 1216 1217 #ifdef _DEBUGELEMENTS_1217 #ifdef _DEBUGELEMENTS_ 1218 1218 if(my_rank==RANK && id==ELID){ 1219 1219 printf("gravity %g\n",matpar->GetG()); … … 1224 1224 printf("drag [%g,%g,%g]\n",k[0],k[1],k[2]); 1225 1225 } 1226 #endif1226 #endif 1227 1227 1228 1228 … … 1230 1230 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/ 1231 1231 1232 #ifdef _DEBUGELEMENTS_1232 #ifdef _DEBUGELEMENTS_ 1233 1233 if(my_rank==RANK && id==ELID){ 1234 1234 printf(" gaussian points: \n"); … … 1237 1237 } 1238 1238 } 1239 #endif1239 #endif 1240 1240 1241 1241 … … 1251 1251 /*Compute thickness at gaussian point: */ 1252 1252 GetParameterValue(&thickness, &h[0],gauss_l1l2l3); 1253 1253 1254 1254 GetParameterDerivativeValue(&slope[0], &s[0],&xyz_list[0][0], gauss_l1l2l3); 1255 1255 1256 1256 /*In case we have plastic basal drag, compute plastic stress at gaussian point from k1, k2 and k3 fields in the 1257 1257 * element itself: */ … … 1262 1262 /* Get Jacobian determinant: */ 1263 1263 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); 1264 1265 /*Get nodal functions: */1264 1265 /*Get nodal functions: */ 1266 1266 GetNodalFunctions(l1l2l3, gauss_l1l2l3); 1267 1267 … … 1270 1270 1271 1271 1272 #ifdef _DEBUGELEMENTS_1272 #ifdef _DEBUGELEMENTS_ 1273 1273 if(my_rank==RANK && id==ELID){ 1274 1274 printf(" gaussian %i\n",ig); … … 1280 1280 if(friction_type==1)printf(" plastic_stress(%g)\n",plastic_stress); 1281 1281 } 1282 #endif1282 #endif 1283 1283 1284 1284 /*Build pe_g_gaussian vector: */ … … 1303 1303 } //for (ig=0; ig<num_gauss; ig++) 1304 1304 1305 #ifdef _DEBUGELEMENTS_1305 #ifdef _DEBUGELEMENTS_ 1306 1306 if(my_rank==RANK && id==ELID){ 1307 1307 printf(" pe_g->terms\n",ig); … … 1315 1315 } 1316 1316 } 1317 #endif1317 #endif 1318 1318 1319 1319 /*Add pe_g to global vector pg: */ 1320 1320 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 1321 1321 1322 cleanup_and_return:1322 cleanup_and_return: 1323 1323 xfree((void**)&first_gauss_area_coord); 1324 1324 xfree((void**)&second_gauss_area_coord); … … 1342 1342 int doflist[numdof]; 1343 1343 int numberofdofspernode; 1344 1344 1345 1345 /* gaussian points: */ 1346 1346 int num_gauss,ig; … … 1391 1391 1392 1392 GetParameterDerivativeValue(&slope[0], ¶m[0],&xyz_list[0][0], gauss_l1l2l3); 1393 1393 1394 1394 /* Get Jacobian determinant: */ 1395 1395 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); 1396 1397 /*Get nodal functions: */1396 1397 /*Get nodal functions: */ 1398 1398 GetNodalFunctions(l1l2l3, gauss_l1l2l3); 1399 1399 … … 1414 1414 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 1415 1415 1416 cleanup_and_return:1416 cleanup_and_return: 1417 1417 xfree((void**)&first_gauss_area_coord); 1418 1418 xfree((void**)&second_gauss_area_coord); … … 1445 1445 inputs->Recover("accumulation",&accumulation[0],1,dofs,3,(void**)nodes); 1446 1446 inputs->Recover("geothermalflux",&geothermalflux[0],1,dofs,3,(void**)nodes); 1447 1447 1448 1448 //Update material if necessary 1449 1449 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,3,(void**)nodes)){ … … 1452 1452 matice->SetB(B_average); 1453 1453 } 1454 1454 1455 1455 if(inputs->Recover("B",&B_list[0],1,dofs,3,(void**)nodes)){ 1456 1456 B_average=(B_list[0]+B_list[1]+B_list[2])/3.0; … … 1459 1459 1460 1460 } 1461 1461 1462 1462 void Tria::GetDofList(int* doflist,int* pnumberofdofspernode){ 1463 1463 … … 1465 1465 int doflist_per_node[MAXDOFSPERNODE]; 1466 1466 int numberofdofspernode; 1467 1467 1468 1468 for(i=0;i<3;i++){ 1469 1469 nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode); … … 1491 1491 #define __FUNCT__ "Tria::GetParameterValue" 1492 1492 void Tria::GetParameterValue(double* pp, double* plist, double* gauss_l1l2l3){ 1493 1493 1494 1494 /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter value at gaussian 1495 1495 * point specifie by gauss_l1l2l3: */ 1496 1496 1497 1497 /*nodal functions: */ 1498 1498 double l1l2l3[3]; … … 1513 1513 #define __FUNCT__ "Tria::GetParameterDerivativeValue" 1514 1514 void Tria::GetParameterDerivativeValue(double* p, double* plist,double* xyz_list, double* gauss_l1l2l3){ 1515 1515 1516 1516 const int NDOF2=2; 1517 1517 const int numgrids=3; … … 1523 1523 * p is a vector of size 2x1 already allocated. 1524 1524 */ 1525 1525 1526 1526 double dh1dh2dh3_basic[NDOF2][numgrids]; //nodal derivative functions in basic coordinate system. 1527 1527 … … 1548 1548 GetB(&B[0][0], xyz_list, gauss_l1l2l3); 1549 1549 1550 #ifdef _DEBUG_1550 #ifdef _DEBUG_ 1551 1551 printf("B for grid1 : [ %lf %lf \n",B[0][0],B[0][1]); 1552 1552 printf(" [ %lf %lf \n",B[1][0],B[1][1]); … … 1560 1560 printf(" [ %lf %lf \n",B[1][4],B[1][5]); 1561 1561 printf(" [ %lf %lf ]\n",B[2][4],B[2][5]); 1562 1562 1563 1563 for (i=0;i<numgrids;i++){ 1564 1564 printf("Velocity for grid %i %lf %lf\n",i,*(vxvy_list+2*i+0),*(vxvy_list+2*i+1)); 1565 1565 } 1566 #endif1566 #endif 1567 1567 1568 1568 /*Multiply B by velocity, to get strain rate: */ 1569 1569 MatrixMultiply( &B[0][0],3,NDOF2*numgrids,0, 1570 velocity,NDOF2*numgrids,1,0,1571 epsilon,0);1570 velocity,NDOF2*numgrids,1,0, 1571 epsilon,0); 1572 1572 1573 1573 } … … 1581 1581 1582 1582 double x1,x2,x3,y1,y2,y3; 1583 1583 1584 1584 x1=*(xyz_list+3*0+0); 1585 1585 y1=*(xyz_list+3*0+1); … … 1596 1596 printf("%s%s\n",__FUNCT__," error message: negative jacobian determinant!"); 1597 1597 } 1598 1598 1599 1599 } 1600 1600 … … 1607 1607 1608 1608 double x1,x2,x3,y1,y2,y3,z1,z2,z3; 1609 1609 1610 1610 x1=*(xyz_list+3*0+0); 1611 1611 y1=*(xyz_list+3*0+1); … … 1625 1625 printf("%s%s\n",__FUNCT__," error message: negative jacobian determinant!"); 1626 1626 } 1627 1627 1628 1628 } 1629 1629 … … 1643 1643 * We assume B has been allocated already, of size: 3x(NDOF2*numgrids) 1644 1644 */ 1645 1645 1646 1646 int i; 1647 1647 const int NDOF2=2; … … 1654 1654 GetNodalFunctionsDerivativesBasic(&dh1dh2dh3_basic[0][0],xyz_list, gauss_l1l2l3); 1655 1655 1656 #ifdef _DEBUG_1656 #ifdef _DEBUG_ 1657 1657 for (i=0;i<3;i++){ 1658 1658 printf("Node %i dh/dx=%lf dh/dy=%lf \n",i,dh1dh2dh3_basic[0][i],dh1dh2dh3_basic[1][i]); 1659 1659 } 1660 #endif1660 #endif 1661 1661 1662 1662 /*Build B: */ … … 1686 1686 * We assume B' has been allocated already, of size: 3x(NDOF2*numgrids) 1687 1687 */ 1688 1688 1689 1689 int i; 1690 1690 const int NDOF2=2; … … 1726 1726 * We assume L has been allocated already, of size: numgrids (numdof=1), or numdofx(numdof*numgrids) (numdof=2) 1727 1727 */ 1728 1728 1729 1729 int i; 1730 1730 const int NDOF2=2; … … 1737 1737 GetNodalFunctions(l1l2l3, gauss_l1l2l3); 1738 1738 1739 #ifdef _DELUG_1739 #ifdef _DELUG_ 1740 1740 for (i=0;i<3;i++){ 1741 1741 printf("Node %i h=%lf \n",i,l1l2l3[i]); 1742 1742 } 1743 #endif1743 #endif 1744 1744 1745 1745 /*Build L: */ … … 1773 1773 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numgrids) 1774 1774 */ 1775 1775 1776 1776 int i; 1777 1777 const int NDOF1=1; … … 1784 1784 GetNodalFunctions(&l1l2l3[0],gauss_l1l2l3); 1785 1785 1786 #ifdef _DEBUG_1786 #ifdef _DEBUG_ 1787 1787 for (i=0;i<3;i++){ 1788 1788 printf("Node %i h=%lf \n",i,l1l2l3[i]); 1789 1789 } 1790 #endif1790 #endif 1791 1791 1792 1792 /*Build B_prog: */ … … 1811 1811 * We assume B' has been allocated already, of size: 3x(NDOF2*numgrids) 1812 1812 */ 1813 1813 1814 1814 int i; 1815 1815 const int NDOF1=1; … … 1834 1834 #define __FUNCT__ "Tria::GetNodalFunctions" 1835 1835 void Tria::GetNodalFunctions(double* l1l2l3, double* gauss_l1l2l3){ 1836 1836 1837 1837 /*This routine returns the values of the nodal functions at the gaussian point.*/ 1838 1838 … … 1851 1851 #define __FUNCT__ "Tria::GetNodalFunctionsDerivativesBasic" 1852 1852 void Tria::GetNodalFunctionsDerivativesBasic(double* dh1dh2dh3_basic,double* xyz_list, double* gauss_l1l2l3){ 1853 1853 1854 1854 /*This routine returns the values of the nodal functions derivatives (with respect to the 1855 1855 * basic coordinate system: */ … … 1885 1885 #define __FUNCT__ "Tria::GetNodalFunctionsDerivativesParams" 1886 1886 void Tria::GetNodalFunctionsDerivativesParams(double* dl1dl2dl3,double* gauss_l1l2l3){ 1887 1887 1888 1888 /*This routine returns the values of the nodal functions derivatives (with respect to the 1889 1889 * natural coordinate system) at the gaussian point. */ … … 1915 1915 const int NDOF2=2; 1916 1916 const int numgrids=3; 1917 1917 1918 1918 /*Call Jacobian routine to get the jacobian:*/ 1919 1919 GetJacobian(Jinv, xyz_list, gauss_l1l2l3); … … 1921 1921 /*Invert Jacobian matrix: */ 1922 1922 MatrixInverse(Jinv,NDOF2,NDOF2,NULL,0,&Jdet); 1923 1923 1924 1924 } 1925 1925 … … 1935 1935 double x1,y1,x2,y2,x3,y3; 1936 1936 double sqrt3=sqrt(3.0); 1937 1937 1938 1938 x1=*(xyz_list+numgrids*0+0); 1939 1939 y1=*(xyz_list+numgrids*0+1); … … 1958 1958 } 1959 1959 1960 1960 1961 1961 void Tria::GetNodes(void** vpnodes){ 1962 1962 int i; … … 1967 1967 } 1968 1968 } 1969 1969 1970 1970 1971 1971 int Tria::GetOnBed(){ … … 1979 1979 } 1980 1980 void Tria::GetBedList(double* bed_list){ 1981 1981 1982 1982 int i; 1983 1983 for(i=0;i<3;i++)bed_list[i]=b[i]; 1984 1984 1985 1985 } 1986 1986 1987 1987 1988 1988 Object* Tria::copy() { 1989 1989 1990 1990 return new Tria(*this); 1991 1991 … … 1998 1998 1999 1999 int i; 2000 2000 2001 2001 /* node data: */ 2002 2002 const int numgrids=3; … … 2104 2104 throw ErrorException(__FUNCT__,exprintf("%s%g","unsupported type of fit: ",fit)); 2105 2105 } 2106 2106 2107 2107 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2108 2108 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2109 2109 2110 #ifdef _DEBUGELEMENTS_2110 #ifdef _DEBUGELEMENTS_ 2111 2111 if(my_rank==RANK && id==ELID){ 2112 2112 printf(" gaussian points: \n"); … … 2115 2115 } 2116 2116 } 2117 #endif2118 2117 #endif 2118 2119 2119 /* Start looping on the number of gaussian points: */ 2120 2120 for (ig=0; ig<num_gauss; ig++){ … … 2127 2127 /* Get Jacobian determinant: */ 2128 2128 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); 2129 #ifdef _DEBUG_2129 #ifdef _DEBUG_ 2130 2130 printf("Element id %i Jacobian determinant: %lf\n",TriaElementGetID(this),Jdet); 2131 #endif2132 2131 #endif 2132 2133 2133 /* Get nodal functions value at gaussian point:*/ 2134 2134 GetNodalFunctions(l1l2l3, gauss_l1l2l3); … … 2178 2178 throw ErrorException(__FUNCT__,exprintf("%s%g","unsupported type of fit: ",fit)); 2179 2179 } 2180 2180 2181 2181 /*Add due_g_gaussian vector to due_g: */ 2182 2182 for( i=0; i<numdof; i++){ … … 2184 2184 } 2185 2185 } 2186 2186 2187 2187 /*Add due_g to global vector du_g: */ 2188 2188 VecSetValues(du_g,numdof,doflist,(const double*)due_g,ADD_VALUES); 2189 2190 cleanup_and_return:2189 2190 cleanup_and_return: 2191 2191 xfree((void**)&first_gauss_area_coord); 2192 2192 xfree((void**)&second_gauss_area_coord); … … 2221 2221 double xyz_list[numgrids][3]; 2222 2222 int doflist[numdof]; 2223 int doflist1[numgrids]; 2223 2224 int numberofdofspernode; 2224 2225 … … 2251 2252 double lambda,mu; 2252 2253 double bed,thickness,Neff; 2253 2254 2254 2255 /*drag: */ 2255 2256 double pcoeff,qcoeff; … … 2259 2260 2260 2261 /*element vector at the gaussian points: */ 2261 double grade_g[num dof];2262 double grade_g[numgrids]; 2262 2263 double grade_g_gaussian[numgrids]; 2263 2264 … … 2279 2280 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 2280 2281 GetDofList(&doflist[0],&numberofdofspernode); 2282 GetDofList1(&doflist1[0]); 2281 2283 2282 2284 /* Set grade_g to 0: */ 2283 for(i=0;i<num dof;i++) grade_g[i]=0.0;2285 for(i=0;i<numgrids;i++) grade_g[i]=0.0; 2284 2286 2285 2287 /* recover input parameters: */ … … 2388 2390 2389 2391 /*Add gradje_g_gaussian vector to gradje_g: */ 2390 for( i=0; i<numgrids; i++)grade_g[i *numberofdofspernode]+=grade_g_gaussian[i];2392 for( i=0; i<numgrids; i++)grade_g[i]+=grade_g_gaussian[i]; 2391 2393 } 2392 2394 2393 2395 /*Add grade_g to global vector grad_g: */ 2394 VecSetValues(grad_g,num dof,doflist,(const double*)grade_g,ADD_VALUES);2396 VecSetValues(grad_g,numgrids,doflist1,(const double*)grade_g,ADD_VALUES); 2395 2397 2396 2398 cleanup_and_return: … … 2415 2417 double xyz_list[numgrids][3]; 2416 2418 int doflist[numdof]; 2419 int doflist1[numgrids]; 2417 2420 int numberofdofspernode; 2418 2421 … … 2434 2437 2435 2438 /*element vector at the gaussian points: */ 2436 double grade_g[num dof];2439 double grade_g[numgrids]; 2437 2440 double grade_g_gaussian[numgrids]; 2438 2441 … … 2466 2469 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 2467 2470 GetDofList(&doflist[0],&numberofdofspernode); 2471 GetDofList1(&doflist1[0]); 2468 2472 2469 2473 /* Set grade_g to 0: */ 2470 for(i=0;i<num dof;i++) grade_g[i]=0.0;2474 for(i=0;i<numgrids;i++) grade_g[i]=0.0; 2471 2475 2472 2476 /* recover input parameters: */ … … 2529 2533 2530 2534 /*Add grade_g_gaussian to grade_g: */ 2531 for( i=0; i<numgrids;i++) grade_g[i *numberofdofspernode]+=grade_g_gaussian[i];2535 for( i=0; i<numgrids;i++) grade_g[i]+=grade_g_gaussian[i]; 2532 2536 } 2533 2537 2534 2538 /*Add grade_g to global vector grad_g: */ 2535 VecSetValues(grad_g,num dof,doflist,(const double*)grade_g,ADD_VALUES);2539 VecSetValues(grad_g,numgrids,doflist1,(const double*)grade_g,ADD_VALUES); 2536 2540 2537 2541 cleanup_and_return: -
issm/trunk/src/c/parallel/GradJCompute.cpp
r465 r1046 21 21 int analysis_type; 22 22 int sub_analysis_type; 23 int numberofnodes; 23 24 char* solverstring=NULL; 24 25 char* control_type=NULL; … … 44 45 femmodel->parameters->FindParam((void*)&analysis_type,"analysis_type"); 45 46 femmodel->parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type"); 47 femmodel->parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 46 48 femmodel->parameters->FindParam((void*)&solverstring,"solverstring"); 47 49 femmodel->parameters->FindParam((void*)&control_type,"control_type"); … … 69 71 VecToMPISerial(&lambda_g_double,lambda_g);VecFree(&lambda_g); 70 72 71 Gradjx( &grad_g, femmodel->elements,femmodel->nodes, femmodel->loads, femmodel->materials,73 Gradjx( &grad_g, numberofnodes,femmodel->elements,femmodel->nodes, femmodel->loads, femmodel->materials, 72 74 u_g_double,lambda_g_double, inputs,analysis_type,sub_analysis_type,control_type); 73 75 -
issm/trunk/src/c/parallel/ProcessResults.cpp
r1037 r1046 399 399 400 400 for(i=0;i<numberofnodes;i++){ 401 parameter[i]=param_g[ 2*(int)partition[i]];401 parameter[i]=param_g[(int)partition[i]]; 402 402 } 403 403 -
issm/trunk/src/c/parallel/control_core.cpp
r1037 r1046 99 99 100 100 _printf_("\n%s%i%s%i\n"," control method step ",n+1,"/",nsteps); 101 inputs->Add(control_type,param_g, 2,numberofnodes);101 inputs->Add(control_type,param_g,1,numberofnodes); 102 102 inputs->Add("fit",fit[n]); 103 103 … … 123 123 124 124 _printf_("%s\n"," updating parameter using optimized search scalar..."); 125 for(i=0;i< gsize;i++)param_g[i]=param_g[i]+search_scalar*optscal[n]*grad_g_double[i];125 for(i=0;i<numberofnodes;i++)param_g[i]=param_g[i]+search_scalar*optscal[n]*grad_g_double[i]; 126 126 _printf_("%s\n"," done."); 127 127 128 128 _printf_("%s\n"," constraining the new distribution..."); 129 ControlConstrainx( param_g,gsize,mincontrolconstraint,maxcontrolconstraint,control_type);129 ControlConstrainx(param_g,numberofnodes,mincontrolconstraint,maxcontrolconstraint,control_type); 130 130 _printf_("%s\n"," done."); 131 131 … … 138 138 /*Write results to disk: */ 139 139 _printf_("%s\n"," preparing final velocity solution..."); 140 inputs->Add(control_type,param_g, 2,numberofnodes);140 inputs->Add(control_type,param_g,1,numberofnodes); 141 141 inputs->Add("fit",fit[n]); 142 142 -
issm/trunk/src/c/parallel/objectivefunctionC.cpp
r758 r1046 64 64 65 65 /*First copy param_g so we don't modify it: */ 66 param_g_copy=(double*)xmalloc( gsize*sizeof(double));67 memcpy(param_g_copy,param_g, gsize*sizeof(double));66 param_g_copy=(double*)xmalloc(numberofnodes*sizeof(double)); 67 memcpy(param_g_copy,param_g,numberofnodes*sizeof(double)); 68 68 69 69 /*First, update param_g using search_scalar: */ 70 for(i=0;i< gsize;i++)param_g_copy[i]=param_g_copy[i]+search_scalar*optscal[n]*grad_g[i];70 for(i=0;i<numberofnodes;i++)param_g_copy[i]=param_g_copy[i]+search_scalar*optscal[n]*grad_g[i]; 71 71 72 72 /*Constrain:*/ 73 ControlConstrainx( param_g_copy,gsize,mincontrolconstraint,maxcontrolconstraint,control_type);73 ControlConstrainx(param_g_copy,numberofnodes,mincontrolconstraint,maxcontrolconstraint,control_type); 74 74 75 75 /*Add new parameter to inputs: */ 76 inputs->Add(control_type,param_g_copy, 2,numberofnodes);76 inputs->Add(control_type,param_g_copy,1,numberofnodes); 77 77 78 78 //Run diagnostic with updated parameters. … … 85 85 u_g_double,u_g_obs, inputs,analysis_type,sub_analysis_type); 86 86 87 88 87 /*Free ressources:*/ 89 88 xfree((void**)&optscal); -
issm/trunk/src/m/solutions/cielo/control_core.m
r1033 r1046 18 18 %initialize control parameters, gradients and observations 19 19 u_g_obs=m_dh.parameters.u_g_obs; 20 grad_g=zeros(m_dh. nodesets.gsize,1);20 grad_g=zeros(m_dh.parameters.numberofnodes,1); 21 21 param_g=models.dh.parameters.param_g; 22 22 … … 33 33 %update inputs with new fit 34 34 inputs=add(inputs,'fit',m_dh.parameters.fit(n),'double'); 35 inputs=add(inputs,m_dh.parameters.control_type,param_g,'doublevec', 2,m_dh.parameters.numberofnodes);35 inputs=add(inputs,m_dh.parameters.control_type,param_g,'doublevec',1,m_dh.parameters.numberofnodes); 36 36 37 37 %Update inputs in datasets -
issm/trunk/src/m/solutions/cielo/controlfinalsol.m
r980 r1046 6 6 7 7 %From parameters, build inputs for icediagnostic_core, using the final parameters 8 inputs=add(inputs,m.parameters.control_type,param_g,'doublevec', 2,m.parameters.numberofnodes);8 inputs=add(inputs,m.parameters.control_type,param_g,'doublevec',1,m.parameters.numberofnodes); 9 9 results.u_g=diagnostic_core_nonlinear(m,inputs,analysis_type,sub_analysis_type); 10 10 -
issm/trunk/src/m/solutions/cielo/objectivefunctionC.m
r465 r1046 10 10 11 11 %Plug parameter into inputs 12 inputs=add(inputs,m.parameters.control_type,parameter,'doublevec', 2,m.parameters.numberofnodes);12 inputs=add(inputs,m.parameters.control_type,parameter,'doublevec',1,m.parameters.numberofnodes); 13 13 14 14 %Run diagnostic with updated parameters. -
issm/trunk/src/m/solutions/cielo/processresults.m
r980 r1046 124 124 newresults(i).step=results(i).step; 125 125 newresults(i).time=results(i).time; 126 newresults(i).parameter=param_g (1:2:end);126 newresults(i).parameter=param_g; 127 127 128 128 else -
issm/trunk/src/mex/Gradj/Gradj.cpp
r465 r1046 19 19 double* lambda_g=NULL; 20 20 ParameterInputs* inputs=NULL; 21 char* analysis_type_string=NULL; 22 int analysis_type; 23 char* sub_analysis_type_string=NULL; 24 int sub_analysis_type; 21 char* analysis_type_string=NULL; 22 int analysis_type; 23 char* sub_analysis_type_string=NULL; 24 int sub_analysis_type; 25 int numberofnodes; 25 26 26 27 /* output datasets: */ … … 39 40 FetchData((void**)&loads,NULL,NULL,LOADS,"DataSet",NULL); 40 41 FetchData((void**)&materials,NULL,NULL,MATERIALS,"DataSet",NULL); 42 FetchData((void**)&numberofnodes,NULL,NULL,mxGetField(PARAMETERS,0,"numberofnodes"),"Integer",NULL); 41 43 FetchData((void**)&control_type,NULL,NULL,mxGetField(PARAMETERS,0,"control_type"),"String",NULL); 42 44 FetchData((void**)&u_g,NULL,NULL,UG,"Vector","Vec"); … … 52 54 53 55 /*!Call core code: */ 54 Gradjx(&grad_g, elements,nodes,loads,materials,u_g,lambda_g,inputs,analysis_type,sub_analysis_type,control_type);56 Gradjx(&grad_g,numberofnodes,elements,nodes,loads,materials,u_g,lambda_g,inputs,analysis_type,sub_analysis_type,control_type); 55 57 56 58 /*write output : */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/issm/chrome/common/trac_banner.png)