Changeset 13877
- Timestamp:
- 11/05/12 13:56:10 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r13875 r13877 299 299 ./modules/StringToEnumx/StringToEnumx.cpp\ 300 300 ./modules/StringToEnumx/StringToEnumx.h\ 301 ./modules/SystemMatricesx/SystemMatricesx.cpp\302 ./modules/SystemMatricesx/SystemMatricesx.h\303 301 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\ 304 302 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\ -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r13875 r13877 518 518 } 519 519 /*}}}*/ 520 void FemModel::SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax){/*{{{*/ 521 522 /*intermediary: */ 523 int i; 524 int fsize,ssize; 525 int connectivity, numberofdofspernode; 526 int analysis_type, configuration_type; 527 Element *element = NULL; 528 Load *load = NULL; 529 530 /*output: */ 531 Matrix<IssmDouble> *Kff = NULL; 532 Matrix<IssmDouble> *Kfs = NULL; 533 Vector<IssmDouble> *pf = NULL; 534 Vector<IssmDouble> *df = NULL; 535 IssmDouble kmax; 536 537 /*Display message*/ 538 if(VerboseModule()) _pprintLine_(" Generating matrices"); 539 540 /*retrive parameters: */ 541 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 542 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 543 this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum); 544 545 /*Get size of matrices: */ 546 fsize=this->nodes->NumberOfDofs(configuration_type,FsetEnum); 547 ssize=this->nodes->NumberOfDofs(configuration_type,SsetEnum); 548 549 numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum); 550 551 /*Compute penalty free mstiffness matrix and load vector*/ 552 Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode); 553 Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode); 554 df =new Vector<IssmDouble>(fsize); 555 556 /*Fill stiffness matrix from elements: */ 557 for (i=0;i<this->elements->Size();i++){ 558 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 559 element->CreateKMatrix(Kff,Kfs,df); 560 } 561 562 /*Fill stiffness matrix from loads if loads have the current configuration_type: */ 563 for (i=0;i<this->loads->Size();i++){ 564 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 565 if (load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff,Kfs); 566 } 567 568 /*Assemble matrices*/ 569 Kff->Assemble(); 570 Kfs->Assemble(); 571 df->Assemble(); 572 573 /*Create Load vector*/ 574 pf=new Vector<IssmDouble>(fsize); 575 576 /*Fill right hand side vector, from elements: */ 577 for (i=0;i<this->elements->Size();i++){ 578 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 579 element->CreatePVector(pf); 580 } 581 582 /*Fill right hand side from loads if loads have the current configuration_type: */ 583 for (i=0;i<this->loads->Size();i++){ 584 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 585 if (load->InAnalysis(configuration_type)) load->CreatePVector(pf); 586 } 587 pf->Assemble(); 588 589 /*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */ 590 kmax=Kff->Norm(NORM_INF); 591 592 /*Now, deal with penalties*/ 593 /*Fill stiffness matrix from loads: */ 594 for (i=0;i<this->loads->Size();i++){ 595 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 596 if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax); 597 } 598 599 /*Assemble matrices*/ 600 Kff->Assemble(); 601 Kfs->Assemble(); 602 603 /*Fill right hand side vector, from loads: */ 604 for (i=0;i<this->loads->Size();i++){ 605 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 606 if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax); 607 } 608 609 /*Assemble vector*/ 610 pf->Assemble(); 611 612 /*Assign output pointers: */ 613 if(pKff) *pKff=Kff; 614 else xdelete(&Kff); 615 if(pKfs) *pKfs=Kfs; 616 else xdelete(&Kfs); 617 if(ppf) *ppf=pf; 618 else xdelete(&pf); 619 if(pdf) *pdf=df; 620 else xdelete(&df); 621 if(pkmax) *pkmax=kmax; 622 } 623 /*}}}*/ 520 624 void FemModel::TimeAdaptx(IssmDouble* pdt){/*{{{*/ 521 625 -
issm/trunk-jpl/src/c/classes/FemModel.h
r13875 r13877 89 89 void ThicknessAbsGradientx( IssmDouble* pJ, bool process_units,int weight_index); 90 90 #endif 91 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax); 91 92 void TimeAdaptx(IssmDouble* pdt); 92 93 void UpdateConstraintsx(void); -
issm/trunk-jpl/src/c/modules/modules.h
r13875 r13877 91 91 #include "./SpcNodesx/SpcNodesx.h" 92 92 #include "./SurfaceAreax/SurfaceAreax.h" 93 #include "./SystemMatricesx/SystemMatricesx.h"94 93 #include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h" 95 94 #include "./TriaSearchx/TriaSearchx.h" -
issm/trunk-jpl/src/c/solvers/solver_adjoint_linear.cpp
r13693 r13877 26 26 femmodel->UpdateConstraintsx(); 27 27 28 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);28 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 29 29 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 30 30 Reduceloadx(pf, Kfs, ys,true); xdelete(&Kfs); //true means spc = 0 -
issm/trunk-jpl/src/c/solvers/solver_linear.cpp
r13693 r13877 24 24 femmodel->UpdateConstraintsx(); 25 25 26 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);26 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 27 27 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 28 28 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); -
issm/trunk-jpl/src/c/solvers/solver_newton.cpp
r13759 r13877 56 56 57 57 /*Solver forward model*/ 58 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);58 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 59 59 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 60 60 Reduceloadx(pf,Kfs,ys);xdelete(&Kfs); … … 83 83 84 84 /*Prepare next iteration using Newton's method*/ 85 SystemMatricesx(&Kff,&Kfs,&pf,NULL,&kmax,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);85 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 86 86 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 87 87 Reduceloadx(pf,Kfs,ys); xdelete(&Kfs); -
issm/trunk-jpl/src/c/solvers/solver_nonlinear.cpp
r13798 r13877 24 24 Vector<IssmDouble>* ys = NULL; 25 25 26 Loads* loads=NULL;26 Loads* savedloads=NULL; 27 27 bool converged; 28 28 int constraints_converged; … … 33 33 int min_mechanical_constraints; 34 34 int max_nonlinear_iterations; 35 int 35 int configuration_type; 36 36 37 37 /*Recover parameters: */ … … 42 42 43 43 /*Were loads requested as output? : */ 44 if(conserve_loads) loads=static_cast<Loads*>(femmodel->loads->Copy()); //protect loads from being modified by the solution 45 else loads=static_cast<Loads*>(femmodel->loads); //modify loads in this solution 44 if(conserve_loads){ 45 savedloads = static_cast<Loads*>(femmodel->loads->Copy()); 46 } 46 47 47 48 count=1; … … 49 50 50 51 /*Start non-linear iteration using input velocity: */ 51 GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices, 52 GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 52 53 Reducevectorgtofx(&uf, ug, femmodel->nodes,femmodel->parameters); 53 54 … … 62 63 xdelete(&old_uf);old_uf=uf; 63 64 64 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);65 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 65 66 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 66 67 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); … … 72 73 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 73 74 74 ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices, loads,femmodel->materials,femmodel->parameters);75 ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 75 76 if(VerboseConvergence()) _pprintLine_(" number of unstable constraints: " << num_unstable_constraints); 76 77 … … 108 109 109 110 /*clean-up*/ 110 if(conserve_loads) delete loads; 111 if(conserve_loads){ 112 delete femmodel->loads; 113 femmodel->loads=savedloads; 114 } 111 115 xdelete(&uf); 112 116 xdelete(&ug); -
issm/trunk-jpl/src/c/solvers/solver_stokescoupling_nonlinear.cpp
r13759 r13877 63 63 64 64 /*solve: */ 65 SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);65 femmodel->SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL); 66 66 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 67 67 Reduceloadx(pf_horiz, Kfs_horiz, ys); xdelete(&Kfs_horiz); … … 77 77 78 78 /*solve: */ 79 SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert, &df_vert,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);79 femmodel->SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert, &df_vert,NULL); 80 80 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 81 81 Reduceloadx(pf_vert, Kfs_vert, ys); xdelete(&Kfs_vert); -
issm/trunk-jpl/src/c/solvers/solver_thermal_nonlinear.cpp
r13693 r13877 53 53 for(;;){ 54 54 55 SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);55 femmodel->SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset); 56 56 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 57 57 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); xdelete(&tf);
Note:
See TracChangeset
for help on using the changeset viewer.