Changeset 13878
- Timestamp:
- 11/05/12 14:30:01 (12 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/FemModel.cpp
r13877 r13878 337 337 338 338 /*Modules:*/ 339 void FemModel::AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf){ /*{{{*/ 340 341 /*Intermediary*/ 342 int fsize,ssize; 343 int connectivity, numberofdofspernode; 344 int analysis_type, configuration_type; 345 346 /*output*/ 347 Matrix<IssmDouble> *Kff = NULL; 348 Matrix<IssmDouble> *Kfs = NULL; 349 Vector<IssmDouble> *pf = NULL; 350 Vector<IssmDouble> *df = NULL; 351 352 bool oldalloc=true; 353 354 /*retrieve parameters: */ 355 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 356 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 357 this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum); 358 359 /*retrieve node info*/ 360 fsize=this->nodes->NumberOfDofs(configuration_type,FsetEnum); 361 ssize=this->nodes->NumberOfDofs(configuration_type,SsetEnum); 362 numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum); 363 364 if(oldalloc){ 365 Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode); 366 Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode); 367 df =new Vector<IssmDouble>(fsize); 368 pf =new Vector<IssmDouble>(fsize); 369 } 370 else{ 371 /*IN PROGRESS*/ 372 } 373 374 /*Allocate output pointers*/ 375 *pKff = Kff; 376 *pKfs = Kfs; 377 *pdf = df; 378 *ppf = pf; 379 } 380 /*}}}*/ 339 381 int FemModel::UpdateVertexPositionsx(void){ /*{{{*/ 340 382 … … 522 564 /*intermediary: */ 523 565 int i; 524 int fsize,ssize; 525 int connectivity, numberofdofspernode; 526 int analysis_type, configuration_type; 566 int configuration_type; 527 567 Element *element = NULL; 528 568 Load *load = NULL; … … 535 575 IssmDouble kmax; 536 576 577 537 578 /*Display message*/ 538 579 if(VerboseModule()) _pprintLine_(" Generating matrices"); 539 580 540 581 /*retrive parameters: */ 541 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);542 582 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 583 551 584 /*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: */ 585 this->AllocateSystemMatrices(&Kff,&Kfs,&df,&pf); 586 587 /*Fill stiffness matrix from elements and loads */ 557 588 for (i=0;i<this->elements->Size();i++){ 558 589 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 559 590 element->CreateKMatrix(Kff,Kfs,df); 560 591 } 561 562 /*Fill stiffness matrix from loads if loads have the current configuration_type: */563 592 for (i=0;i<this->loads->Size();i++){ 564 593 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); … … 566 595 } 567 596 568 /*Assemble matrices*/ 597 598 /*Fill right hand side vector, from elements and loads */ 599 for (i=0;i<this->elements->Size();i++){ 600 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 601 element->CreatePVector(pf); 602 } 603 for (i=0;i<this->loads->Size();i++){ 604 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 605 if (load->InAnalysis(configuration_type)) load->CreatePVector(pf); 606 } 607 608 /*Assemble matrices (required to get kmax)*/ 569 609 Kff->Assemble(); 570 610 Kfs->Assemble(); 571 611 df->Assemble(); 572 612 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: */ 613 /*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */ 590 614 kmax=Kff->Norm(NORM_INF); 591 615 592 /*Now, deal with penalties*/ 593 /*Fill stiffness matrix from loads: */ 616 /*Now that we have kmax, deal with penalties (only in loads)*/ 594 617 for (i=0;i<this->loads->Size();i++){ 595 618 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 596 619 if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax); 597 620 } 598 599 /*Assemble matrices*/600 Kff->Assemble();601 Kfs->Assemble();602 603 /*Fill right hand side vector, from loads: */604 621 for (i=0;i<this->loads->Size();i++){ 605 622 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); … … 607 624 } 608 625 609 /*Assemble vector*/ 626 /*Assemble matrices and vector*/ 627 Kff->Assemble(); 628 Kfs->Assemble(); 610 629 pf->Assemble(); 611 630 -
issm/trunk-jpl/src/c/classes/FemModel.h
r13877 r13878 52 52 53 53 /*Methods:*/ 54 void AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf); 54 55 void Echo(); 55 56 void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
Note:
See TracChangeset
for help on using the changeset viewer.