Changeset 11322
- Timestamp:
- 02/06/12 07:45:50 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 9 added
- 4 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/EnumDefinitions/EnumDefinitions.h
r11292 r11322 28 28 DiagnosticAbstolEnum, 29 29 DiagnosticIcefrontEnum, 30 DiagnosticIsnewtonEnum, 30 31 DiagnosticMaxiterEnum, 31 32 DiagnosticNumRequestedOutputsEnum, -
issm/trunk-jpl/src/c/Makefile.am
r11317 r11322 323 323 ./modules/SystemMatricesx/SystemMatricesx.cpp\ 324 324 ./modules/SystemMatricesx/SystemMatricesx.h\ 325 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\ 326 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\ 325 327 ./modules/ConstraintsStatex/ConstraintsStatex.cpp\ 326 328 ./modules/ConstraintsStatex/ConstraintsStatex.h\ … … 352 354 ./solutions/CorePointerFromSolutionEnum.cpp\ 353 355 ./solvers/solver_linear.cpp\ 354 ./solvers/solver_nonlinear.cpp 356 ./solvers/solver_nonlinear.cpp\ 357 ./solvers/solver_newton.cpp 355 358 #}}} 356 359 #DAKOTA sources {{{1 -
issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp
r11292 r11322 32 32 case DiagnosticAbstolEnum : return "DiagnosticAbstol"; 33 33 case DiagnosticIcefrontEnum : return "DiagnosticIcefront"; 34 case DiagnosticIsnewtonEnum : return "DiagnosticIsnewton"; 34 35 case DiagnosticMaxiterEnum : return "DiagnosticMaxiter"; 35 36 case DiagnosticNumRequestedOutputsEnum : return "DiagnosticNumRequestedOutputs"; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r11275 r11322 40 40 parameters->AddObject(iomodel->CopyConstantObject(DiagnosticReltolEnum)); 41 41 parameters->AddObject(iomodel->CopyConstantObject(DiagnosticAbstolEnum)); 42 parameters->AddObject(iomodel->CopyConstantObject(DiagnosticIsnewtonEnum)); 42 43 parameters->AddObject(iomodel->CopyConstantObject(DiagnosticMaxiterEnum)); 43 44 parameters->AddObject(iomodel->CopyConstantObject(SteadystateReltolEnum)); -
issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp
r11292 r11322 30 30 else if (strcmp(name,"DiagnosticAbstol")==0) return DiagnosticAbstolEnum; 31 31 else if (strcmp(name,"DiagnosticIcefront")==0) return DiagnosticIcefrontEnum; 32 else if (strcmp(name,"DiagnosticIsnewton")==0) return DiagnosticIsnewtonEnum; 32 33 else if (strcmp(name,"DiagnosticMaxiter")==0) return DiagnosticMaxiterEnum; 33 34 else if (strcmp(name,"DiagnosticNumRequestedOutputs")==0) return DiagnosticNumRequestedOutputsEnum; -
issm/trunk-jpl/src/c/modules/modules.h
r11317 r11322 108 108 #include "./SurfaceAreax/SurfaceAreax.h" 109 109 #include "./SystemMatricesx/SystemMatricesx.h" 110 #include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h" 110 111 #include "./TimeAdaptx/TimeAdaptx.h" 111 112 #include "./TriaSearchx/TriaSearchx.h" -
issm/trunk-jpl/src/c/objects/Elements/Element.h
r11318 r11322 30 30 virtual void CreateKMatrix(Mat Kff, Mat Kfs,Vec df)=0; 31 31 virtual void CreatePVector(Vec pf)=0; 32 virtual void CreateJacobianMatrix(Mat Jff)=0; 32 33 virtual void GetSolutionFromInputs(Vec solution)=0; 33 34 virtual int GetNodeIndex(Node* node)=0; -
issm/trunk-jpl/src/c/objects/Elements/Penta.cpp
r11318 r11322 767 767 /*clean up and return*/ 768 768 return pe; 769 } 770 /*}}}*/ 771 /*FUNCTION Penta::CreateJacobianMatrix{{{1*/ 772 void Penta::CreateJacobianMatrix(Mat Jff){ 773 774 /*retrieve parameters: */ 775 ElementMatrix* Ke=NULL; 776 int analysis_type; 777 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 778 779 /*Checks in debugging {{{2*/ 780 _assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs); 781 /*}}}*/ 782 783 /*Skip if water element*/ 784 if(IsOnWater()) return; 785 786 /*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */ 787 switch(analysis_type){ 788 #ifdef _HAVE_DIAGNOSTIC_ 789 case DiagnosticHorizAnalysisEnum: 790 Ke=CreateJacobianDiagnosticPattyn(); 791 break; 792 #endif 793 default: 794 _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type)); 795 } 796 797 /*Add to global matrix*/ 798 if(Ke){ 799 Ke->AddToGlobal(Jff); 800 delete Ke; 801 } 769 802 } 770 803 /*}}}*/ … … 6224 6257 } 6225 6258 /*}}}*/ 6259 /*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{1*/ 6260 ElementMatrix* Penta::CreateJacobianDiagnosticPattyn(void){ 6261 6262 /*Constants*/ 6263 const int numdof=NDOF2*NUMVERTICES; 6264 6265 /*Intermediaries */ 6266 int i,j,ig; 6267 int approximation; 6268 double xyz_list[NUMVERTICES][3]; 6269 double Jdet; 6270 double eps1dotdphii,eps1dotdphij; 6271 double eps2dotdphii,eps2dotdphij; 6272 double mu_prime; 6273 double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 6274 double eps1[3],eps2[3]; 6275 double phi[NUMVERTICES]; 6276 double dphi[3][NUMVERTICES]; 6277 GaussPenta *gauss=NULL; 6278 6279 /*Initialize Jacobian with regular Pattyn (first part of the Gateau derivative)*/ 6280 ElementMatrix* Ke=CreateKMatrixDiagnosticPattyn(); 6281 6282 /*Retrieve all inputs and parameters*/ 6283 inputs->GetInputValue(&approximation,ApproximationEnum); 6284 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 6285 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 6286 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 6287 6288 /* Start looping on the number of gaussian points: */ 6289 gauss=new GaussPenta(5,5); 6290 for (ig=gauss->begin();ig<gauss->end();ig++){ 6291 6292 gauss->GaussPoint(ig); 6293 6294 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 6295 GetNodalFunctionsP1Derivatives(&dphi[0][0],&xyz_list[0][0],gauss); 6296 6297 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 6298 matice->GetViscosityDerivativeEpsSquare(&mu_prime,&epsilon[0]); 6299 eps1[0]=2*epsilon[0]+epsilon[1]; eps2[0]=epsilon[2]; 6300 eps1[1]=epsilon[2]; eps2[1]=epsilon[0]+2*epsilon[1]; 6301 eps1[2]=epsilon[3]; eps2[2]=epsilon[4]; 6302 6303 for(i=0;i<6;i++){ 6304 for(j=0;j<6;j++){ 6305 eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i]+eps1[2]*dphi[2][i]; 6306 eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j]+eps1[2]*dphi[2][j]; 6307 eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i]+eps2[2]*dphi[2][i]; 6308 eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j]+eps2[2]*dphi[2][j]; 6309 6310 Ke->values[12*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii; 6311 Ke->values[12*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii; 6312 Ke->values[12*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii; 6313 Ke->values[12*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii; 6314 } 6315 } 6316 } 6317 6318 /*Transform Coordinate System*/ 6319 TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYEnum); 6320 6321 /*Clean up and return*/ 6322 delete gauss; 6323 return Ke; 6324 } 6325 /*}}}*/ 6226 6326 /*FUNCTION Penta::CreateKMatrixDiagnosticPattynFriction{{{1*/ 6227 6327 ElementMatrix* Penta::CreateKMatrixDiagnosticPattynFriction(void){ -
issm/trunk-jpl/src/c/objects/Elements/Penta.h
r11318 r11322 88 88 void CreateKMatrix(Mat Kff, Mat Kfs,Vec df); 89 89 void CreatePVector(Vec pf); 90 void CreateJacobianMatrix(Mat Jff); 90 91 void DeleteResults(void); 91 92 int GetNodeIndex(Node* node); … … 234 235 ElementMatrix* CreateKMatrixDiagnosticVertVolume(void); 235 236 ElementMatrix* CreateKMatrixDiagnosticVertSurface(void); 237 ElementMatrix* CreateJacobianDiagnosticPattyn(void); 236 238 void InputUpdateFromSolutionDiagnosticHoriz( double* solutiong); 237 239 void InputUpdateFromSolutionDiagnosticMacAyeal( double* solutiong); -
issm/trunk-jpl/src/c/objects/Elements/Tria.cpp
r11318 r11322 1883 1883 name==InversionVyObsEnum || 1884 1884 name==FrictionCoefficientEnum || 1885 name==MaterialsRheologyBbarEnum || 1885 1886 name==GradientEnum || 1886 1887 name==OldGradientEnum || … … 4734 4735 4735 4736 int doflist1[NUMVERTICES]; 4737 Input *input=NULL; 4736 4738 4737 4739 /*Get out if this is not an element input*/ … … 4742 4744 4743 4745 /*Get input (either in element or material)*/ 4744 Input* input=inputs->GetInput(control_enum); 4745 if(!input) _error_("Input %s not found in element",EnumToStringx(control_enum)); 4746 if(control_enum==MaterialsRheologyBbarEnum){ 4747 input=(Input*)matice->inputs->GetInput(control_enum); _assert_(input); 4748 } 4749 else{ 4750 input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 4751 } 4746 4752 4747 4753 /*Check that it is a ControlInput*/ … … 4772 4778 } 4773 4779 new_input = new TriaP1Input(control_enum,values); 4774 4775 4780 4776 4781 if(control_enum==MaterialsRheologyBbarEnum){ -
issm/trunk-jpl/src/c/objects/Elements/Tria.h
r11318 r11322 84 84 void CreateKMatrix(Mat Kff, Mat Kfs,Vec df); 85 85 void CreatePVector(Vec pf); 86 void CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");}; 86 87 int GetNodeIndex(Node* node); 87 88 int Sid(); -
issm/trunk-jpl/src/c/objects/Materials/Matice.cpp
r11291 r11322 521 521 /*Return: */ 522 522 *pviscosity_complement=viscosity_complement; 523 } 524 /*}}}*/ 525 /*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{1*/ 526 void Matice::GetViscosityDerivativeEpsSquare(double* pmu_prime, double* epsilon){ 527 528 /*output: */ 529 double mu_prime; 530 double mu,n,eff2; 531 532 /*input strain rate: */ 533 double exx,eyy,exy,exz,eyz; 534 535 /*Get visocisty and n*/ 536 GetViscosity3d(&mu,epsilon); 537 n=GetN(); 538 539 if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 540 (epsilon[3]==0) && (epsilon[4]==0)){ 541 mu_prime=0.5*pow((double)10,(double)14); 542 } 543 else{ 544 /*Retrive strain rate components: */ 545 exx=epsilon[0]; 546 eyy=epsilon[1]; 547 exy=epsilon[2]; 548 exz=epsilon[3]; 549 eyz=epsilon[4]; 550 eff2 = exx*exx + eyy*eyy + exx*eyy + exy*exy + exz*exz + eyz*eyz; 551 552 mu_prime=(1-n)/(2*n) * mu/eff2; 553 } 554 555 /*Assign output pointers:*/ 556 *pmu_prime=mu_prime; 523 557 } 524 558 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Materials/Matice.h
r10576 r11322 68 68 void GetViscosity3dStokes(double* pviscosity3d, double* epsilon); 69 69 void GetViscosityComplement(double* pviscosity_complement, double* pepsilon); 70 void GetViscosityDerivativeEpsSquare(double* pmu_prime, double* pepsilon); 70 71 double GetB(); 71 72 double GetBbar(); -
issm/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp
r9320 r11322 245 245 246 246 /*ElementMatrix specific routines: */ 247 /*FUNCTION ElementMatrix::AddToGlobal {{{1*/247 /*FUNCTION ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){{{1*/ 248 248 void ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){ 249 249 … … 294 294 } 295 295 /*}}}*/ 296 /*FUNCTION ElementMatrix::AddToGlobal(Mat Jff){{{1*/ 297 void ElementMatrix::AddToGlobal(Mat Jff){ 298 299 int i,j; 300 double* localvalues=NULL; 301 302 /*In debugging mode, check consistency (no NaN, and values not too big)*/ 303 this->CheckConsistency(); 304 305 if(this->dofsymmetrical){ 306 /*only use row dofs to add values into global matrices: */ 307 308 if(this->row_fsize){ 309 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 310 localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double)); 311 for(i=0;i<this->row_fsize;i++){ 312 for(j=0;j<this->row_fsize;j++){ 313 *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]); 314 } 315 } 316 /*add local values into global matrix, using the fglobaldoflist: */ 317 MatSetValues(Jff,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES); 318 319 /*Free ressources:*/ 320 xfree((void**)&localvalues); 321 } 322 323 } 324 else{ 325 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!"); 326 } 327 328 } 329 /*}}}*/ 296 330 /*FUNCTION ElementMatrix::CheckConsistency{{{1*/ 297 331 void ElementMatrix::CheckConsistency(void){ -
issm/trunk-jpl/src/c/objects/Numerics/ElementMatrix.h
r8800 r11322 59 59 /*ElementMatrix specific routines {{{1*/ 60 60 void AddToGlobal(Mat Kff, Mat Kfs); 61 void AddToGlobal(Mat Jff); 61 62 void Echo(void); 62 63 void CheckConsistency(void); -
issm/trunk-jpl/src/c/solutions/controltao_core.cpp
r11318 r11322 25 25 26 26 /*TAO*/ 27 int ierr ,numberofvertices;27 int ierr; 28 28 int num_controls; 29 29 AppCtx user; … … 45 45 46 46 /*Initialize TAO*/ 47 _printf_(VerboseControl(),"%s\n"," Initializing the Toolkit for Advanced Optimization (TAO)"); 47 48 TaoCreate(PETSC_COMM_WORLD,&tao); 48 49 PetscOptionsSetValue("-tao_monitor",""); 49 50 TaoSetFromOptions(tao); 50 51 TaoSetType(tao,"tao_blmvm"); 52 //TaoSetType(tao,"tao_cg"); 53 //TaoSetType(tao,"tao_lmvm"); 51 54 52 55 /*Prepare all TAO parameters*/ 53 56 TaoSetMaximumFunctionEvaluations(tao,50); 54 57 TaoSetMaximumIterations(tao,10); 55 TaoSetTolerances(tao,10e-28,0.0000,0.0000,0.0000,10e-28); 56 57 numberofvertices = femmodel->vertices->NumberOfVertices(); 58 XL=NewVec(numberofvertices); VecSet(XL,1.); 59 XU=NewVec(numberofvertices); VecSet(XU,200.); 58 TaoSetTolerances(tao,0.,0.,0.,0.,0.); 60 59 61 60 GetVectorFromControlInputsx(&X, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); … … 71 70 72 71 /*Solver optimization problem*/ 72 _printf_(VerboseControl(),"%s\n"," Starting optimization"); 73 73 TaoSolve(tao); 74 74 TaoView(tao,PETSC_VIEWER_STDOUT_WORLD); … … 96 96 97 97 /*Set new variable*/ 98 //VecView(X,PETSC_VIEWER_STDOUT_WORLD); 98 99 SetControlInputsFromVectorx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,X); 99 100 … … 118 119 /*Compute objective function*/ 119 120 CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 121 _printf_(true,"f(x)=%g\n",*fcn); 120 122 121 123 /*Compute gradient*/ … … 123 125 VecCopy(gradient,G); VecFree(&gradient); 124 126 VecScale(G,-1.); 127 //VecView(G,PETSC_VIEWER_STDOUT_WORLD); 125 128 126 129 /*Clean-up and return*/ -
issm/trunk-jpl/src/c/solutions/diagnostic_core.cpp
r10650 r11322 16 16 17 17 /*parameters: */ 18 bool dakota_analysis = false; 19 int dim = -1; 20 bool ishutter = false; 21 bool ismacayealpattyn = false; 22 bool isstokes = false; 23 bool conserve_loads = true; 24 bool modify_loads = true; 25 bool control_analysis; 26 int solution_type; 27 int numoutputs = 0; 28 int *requested_outputs = NULL; 18 bool dakota_analysis = false; 19 int dim = -1; 20 bool ishutter = false; 21 bool ismacayealpattyn = false; 22 bool isstokes = false; 23 bool isnewton = false; 24 bool conserve_loads = true; 25 bool modify_loads = true; 26 bool control_analysis; 27 int solution_type; 28 int numoutputs = 0; 29 int *requested_outputs = NULL; 29 30 30 31 /* recover parameters:*/ … … 33 34 femmodel->parameters->FindParam(&ismacayealpattyn,FlowequationIsmacayealpattynEnum); 34 35 femmodel->parameters->FindParam(&isstokes,FlowequationIsstokesEnum); 36 femmodel->parameters->FindParam(&isnewton,DiagnosticIsnewtonEnum); 35 37 femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); 36 38 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); … … 72 74 _printf_(VerboseSolution(),"%s\n"," computing velocities"); 73 75 femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum); 74 solver_nonlinear(femmodel,modify_loads); 76 if(isnewton) 77 solver_newton(femmodel); 78 else 79 solver_nonlinear(femmodel,conserve_loads); 75 80 } 76 81 -
issm/trunk-jpl/src/c/solvers/solver_nonlinear.cpp
r11293 r11322 89 89 } 90 90 91 _printf_(VerboseConvergence(),"\n total number of iterations: %i\n",count-1); 92 91 93 /*clean-up*/ 92 94 if(conserve_loads) delete loads; -
issm/trunk-jpl/src/c/solvers/solvers.h
r7637 r11322 14 14 void solver_thermal_nonlinear(FemModel* femmodel); 15 15 void solver_nonlinear(FemModel* femmodel,bool conserve_loads); 16 void solver_newton(FemModel* femmodel); 16 17 void solver_stokescoupling_nonlinear(FemModel* femmodel,bool conserve_loads); 17 18 void solver_linear(FemModel* femmodel); -
issm/trunk-jpl/src/m/classes/diagnostic.m
r11138 r11322 12 12 reltol = 0; 13 13 abstol = 0; 14 isnewton = 0; 14 15 stokesreconditioning = 0; 15 16 viscosity_overshoot = 0; … … 82 83 checkfield(md,'diagnostic.reltol','size',[1 1]); 83 84 checkfield(md,'diagnostic.abstol','size',[1 1]); 85 checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]); 84 86 checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1); 85 87 checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1); … … 127 129 fielddisplay(obj,'reltol','velocity relative convergence criterion, NaN -> not applied'); 128 130 fielddisplay(obj,'abstol','velocity absolute convergence criterion, NaN -> not applied'); 131 fielddisplay(obj,'isnewton','Apply Newton''s method instead of a Picard fixed point method'); 129 132 fielddisplay(obj,'maxiter','maximum number of nonlinear iterations'); 130 133 fielddisplay(obj,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)'); … … 158 161 WriteData(fid,'object',obj,'fieldname','reltol','format','Double'); 159 162 WriteData(fid,'object',obj,'fieldname','abstol','format','Double'); 163 WriteData(fid,'object',obj,'fieldname','isnewton','format','Boolean'); 160 164 WriteData(fid,'object',obj,'fieldname','stokesreconditioning','format','Double'); 161 165 WriteData(fid,'object',obj,'fieldname','viscosity_overshoot','format','Double'); -
issm/trunk-jpl/src/m/model/loadresultsfromdisk.m
r10538 r11322 10 10 error('loadresultsfromdisk: error message.'); 11 11 end 12 if ~exist(filename,'file'), 13 error(['binary file ' filename ' not found.']); 14 end 12 15 13 16 if ~md.qmu.isdakota, … … 20 23 %load results onto model 21 24 structure=parseresultsfromdisk(filename,~md.settings.io_gather); 25 if isempty(fieldnames(structure)), 26 error(['No result found in binary file ' filename '. Check for solution crash.']); 27 end 22 28 md.results.(structure(1).SolutionType)=structure; 23 29
Note:
See TracChangeset
for help on using the changeset viewer.