Changeset 2907
- Timestamp:
- 01/25/10 16:46:58 (15 years ago)
- Location:
- issm/trunk/src/c/objects
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Beam.cpp
r2334 r2907 18 18 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Beam constructor {{{1*/ 20 22 Beam::Beam(){ 21 23 return; 22 24 } 23 25 /*}}}*/ 26 /*FUNCTION Beam destructor {{{1*/ 24 27 Beam::~Beam(){ 25 28 return; 26 29 } 27 30 /*}}}*/ 31 /*FUNCTION Beam creation {{{1*/ 28 32 Beam::Beam(int beam_id, int beam_mid, int beam_mparid, int beam_numparid, int beam_g[2], double beam_h[2], double beam_s[2],double beam_b[2],double beam_k[2],bool beam_onbed){ 29 33 … … 53 57 return; 54 58 } 55 56 #undef __FUNCT__ 57 #define __FUNCT__ "Beam::Echo" 58 void Beam::Echo(void){ 59 60 printf("Beam:\n"); 61 printf(" id: %i\n",id); 62 printf(" mid: %i\n",mid); 63 printf(" mparid: %i\n",mparid); 64 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 65 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 66 printf(" matice_offset=%i\n",matice_offset); 67 printf(" matpar_offset=%i\n",matpar_offset); 68 printf(" h=[%g,%g]\n",h[0],h[1]); 69 printf(" s=[%g,%g]\n",s[0],s[1]); 70 printf(" b=[%g,%g]\n",b[0],b[1]); 71 printf(" k=[%g,%g]\n",k[0],k[1]); 72 printf(" onbed=%i\n",onbed); 73 printf(" nodes: \n"); 74 if(nodes[0])nodes[0]->Echo(); 75 if(nodes[1])nodes[1]->Echo(); 76 if(matice)matice->Echo(); 77 if(matpar)matpar->Echo(); 78 79 return; 80 } 81 82 #undef __FUNCT__ 83 #define __FUNCT__ "Beam::DeepEcho" 84 void Beam::DeepEcho(void){ 85 86 printf("Beam:\n"); 87 printf(" id: %i\n",id); 88 printf(" mid: %i\n",mid); 89 printf(" mparid: %i\n",mparid); 90 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 91 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 92 printf(" matice_offset=%i\n",matice_offset); 93 printf(" matpar_offset=%i\n",matpar_offset); 94 printf(" h=[%g,%g]\n",h[0],h[1]); 95 printf(" s=[%g,%g]\n",s[0],s[1]); 96 printf(" b=[%g,%g]\n",b[0],b[1]); 97 printf(" k=[%g,%g]\n",k[0],k[1]); 98 printf(" onbed=%i\n",onbed); 99 printf(" nodes: \n"); 100 if(nodes[0])nodes[0]->Echo(); 101 if(nodes[1])nodes[1]->Echo(); 102 if(matice)matice->Echo(); 103 if(matpar)matpar->Echo(); 104 105 return; 106 } 59 /*}}}*/ 60 61 /*Object marshall*/ 62 /*FUNCTION Beam Marshall{{{1*/ 107 63 void Beam::Marshall(char** pmarshalled_dataset){ 108 64 … … 142 98 return; 143 99 } 144 100 /*}}}*/ 101 /*FUNCTION Beam MarshallSize{{{1*/ 145 102 int Beam::MarshallSize(){ 146 103 return sizeof(id) … … 164 121 +sizeof(int); //sizeof(int) for enum type 165 122 } 166 167 char* Beam::GetName(void){ 168 return "beam"; 169 } 170 123 /*}}}*/ 124 /*FUNCTION Beam Demarshall{{{1*/ 171 125 void Beam::Demarshall(char** pmarshalled_dataset){ 172 126 … … 209 163 return; 210 164 } 211 int Beam::Enum(void){ 212 213 return BeamEnum(); 214 215 } 216 int Beam::GetId(void){ return id; } 217 218 int Beam::MyRank(void){ 219 extern int my_rank; 220 return my_rank; 221 } 222 223 165 /*}}}*/ 166 167 /*Object functions*/ 168 /*FUNCTION Beam ComputePressure{{{1*/ 169 #undef __FUNCT__ 170 #define __FUNCT__ "Beam::ComputePressure" 171 void Beam::ComputePressure(Vec p_g){ 172 173 int i; 174 const int numgrids=2; 175 int doflist[numgrids]; 176 double pressure[numgrids]; 177 double rho_ice,g; 178 double xyz_list[numgrids][3]; 179 180 /*Get node data: */ 181 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 182 183 /*Get dof list on which we will plug the pressure values: */ 184 GetDofList1(&doflist[0]); 185 186 /*pressure is lithostatic: */ 187 rho_ice=matpar->GetRhoIce(); 188 g=matpar->GetG(); 189 for(i=0;i<numgrids;i++){ 190 pressure[i]=rho_ice*g*(s[i]-xyz_list[i][2]); 191 } 192 193 /*plug local pressure values into global pressure vector: */ 194 VecSetValues(p_g,numgrids,doflist,(const double*)pressure,INSERT_VALUES); 195 196 } 197 /*}}}*/ 198 /*FUNCTION Beam Configure{{{1*/ 224 199 #undef __FUNCT__ 225 200 #define __FUNCT__ "Beam::Configure" … … 250 225 251 226 } 252 227 /*}}}*/ 228 /*FUNCTION Beam copy{{{1*/ 229 Object* Beam::copy() { 230 231 return new Beam(*this); 232 233 } 234 /*}}}*/ 235 /*FUNCTION Beam CreateKMatrix{{{1*/ 253 236 #undef __FUNCT__ 254 237 #define __FUNCT__ "Beam::CreateKMatrix" … … 271 254 272 255 } 273 274 256 /*}}}*/ 257 /*FUNCTION Beam CreateKMatrixDiagnosticHutter{{{1*/ 275 258 #undef __FUNCT__ 276 259 #define __FUNCT__ "Beam::CreateKMatrixDiagnosticHutter" … … 307 290 308 291 } 309 310 292 /*}}}*/ 293 /*FUNCTION Beam CreatePVector{{{1*/ 311 294 #undef __FUNCT__ 312 295 #define __FUNCT__ "Beam::CreatePVector" … … 326 309 327 310 } 328 329 311 /*}}}*/ 312 /*FUNCTION Beam CreatePVectorDiagnosticHutter{{{1*/ 330 313 #undef __FUNCT__ 331 314 #define __FUNCT__ "Beam::CreatePVectorDiagnosticHutter" … … 442 425 xfree((void**)&gauss_weights); 443 426 } 444 445 427 /*}}}*/ 428 /*FUNCTION Beam DeepEcho{{{1*/ 429 #undef __FUNCT__ 430 #define __FUNCT__ "Beam::DeepEcho" 431 void Beam::DeepEcho(void){ 432 433 printf("Beam:\n"); 434 printf(" id: %i\n",id); 435 printf(" mid: %i\n",mid); 436 printf(" mparid: %i\n",mparid); 437 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 438 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 439 printf(" matice_offset=%i\n",matice_offset); 440 printf(" matpar_offset=%i\n",matpar_offset); 441 printf(" h=[%g,%g]\n",h[0],h[1]); 442 printf(" s=[%g,%g]\n",s[0],s[1]); 443 printf(" b=[%g,%g]\n",b[0],b[1]); 444 printf(" k=[%g,%g]\n",k[0],k[1]); 445 printf(" onbed=%i\n",onbed); 446 printf(" nodes: \n"); 447 if(nodes[0])nodes[0]->Echo(); 448 if(nodes[1])nodes[1]->Echo(); 449 if(matice)matice->Echo(); 450 if(matpar)matpar->Echo(); 451 452 return; 453 } 454 /*}}}*/ 455 /*FUNCTION Beam Du{{{1*/ 456 #undef __FUNCT__ 457 #define __FUNCT__ "Beam::Du" 458 void Beam::Du(_p_Vec*,void*,int,int){ 459 throw ErrorException(__FUNCT__," not supported yet!"); 460 } 461 /*}}}*/ 462 /*FUNCTION Beam Echo {{{1*/ 463 #undef __FUNCT__ 464 #define __FUNCT__ "Beam::Echo" 465 void Beam::Echo(void){ 466 467 printf("Beam:\n"); 468 printf(" id: %i\n",id); 469 printf(" mid: %i\n",mid); 470 printf(" mparid: %i\n",mparid); 471 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 472 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 473 printf(" matice_offset=%i\n",matice_offset); 474 printf(" matpar_offset=%i\n",matpar_offset); 475 printf(" h=[%g,%g]\n",h[0],h[1]); 476 printf(" s=[%g,%g]\n",s[0],s[1]); 477 printf(" b=[%g,%g]\n",b[0],b[1]); 478 printf(" k=[%g,%g]\n",k[0],k[1]); 479 printf(" onbed=%i\n",onbed); 480 printf(" nodes: \n"); 481 if(nodes[0])nodes[0]->Echo(); 482 if(nodes[1])nodes[1]->Echo(); 483 if(matice)matice->Echo(); 484 if(matpar)matpar->Echo(); 485 486 return; 487 } 488 /*}}}*/ 489 /*FUNCTION Beam Enum{{{1*/ 490 int Beam::Enum(void){ 491 492 return BeamEnum(); 493 494 } 495 /*}}}*/ 496 /*FUNCTION Beam GetBedList{{{1*/ 497 #undef __FUNCT__ 498 #define __FUNCT__ "Beam::GetBedList" 499 void Beam::GetBedList(double*){ 500 throw ErrorException(__FUNCT__," not supported yet!"); 501 } 502 /*}}}*/ 503 /*FUNCTION Beam GetDofList{{{1*/ 504 void Beam::GetDofList(int* doflist,int* pnumberofdofspernode){ 505 506 int i,j; 507 int doflist_per_node[MAXDOFSPERNODE]; 508 int numberofdofspernode; 509 510 for(i=0;i<2;i++){ 511 nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode); 512 for(j=0;j<numberofdofspernode;j++){ 513 doflist[i*numberofdofspernode+j]=doflist_per_node[j]; 514 } 515 } 516 517 /*Assign output pointers:*/ 518 *pnumberofdofspernode=numberofdofspernode; 519 520 } 521 /*}}}*/ 522 /*FUNCTION Beam GetDofList1{{{1*/ 523 void Beam::GetDofList1(int* doflist){ 524 525 int i; 526 for(i=0;i<2;i++){ 527 doflist[i]=nodes[i]->GetDofList1(); 528 } 529 530 } 531 /*}}}*/ 532 /*FUNCTION Beam GetId{{{1*/ 533 int Beam::GetId(void){ return id; } 534 /*}}}*/ 535 /*FUNCTION Beam GetJacobianDeterminant{{{1*/ 536 #undef __FUNCT__ 537 #define __FUNCT__ "Beam::GetJacobianDeterminant" 538 void Beam::GetJacobianDeterminant(double* pJdet,double* z_list, double gauss_coord){ 539 540 541 double Jdet; 542 543 Jdet=1.0/2.0*(z_list[1]-z_list[0]); 544 545 if(Jdet<0){ 546 throw ErrorException(__FUNCT__," negative jacobian determinant!"); 547 } 548 549 *pJdet=Jdet; 550 } 551 /*}}}*/ 552 /*FUNCTION Beam GetMatPar{{{1*/ 553 void* Beam::GetMatPar(){ 554 return matpar; 555 } 556 /*}}}*/ 557 /*FUNCTION Beam GetName{{{1*/ 558 char* Beam::GetName(void){ 559 return "beam"; 560 } 561 /*}}}*/ 562 /*FUNCTION Beam GetNodalFunctions{{{1*/ 563 #undef __FUNCT__ 564 #define __FUNCT__ "Beam::GetNodalFunctions" 565 void Beam::GetNodalFunctions(double* l1l2, double gauss_coord){ 566 567 /*This routine returns the values of the nodal functions at the gaussian point.*/ 568 569 /*First nodal function: */ 570 l1l2[0]=.5*gauss_coord+.5; 571 572 /*Second nodal function: */ 573 l1l2[1]=-.5*gauss_coord+.5; 574 } 575 /*}}}*/ 576 /*FUNCTION Beam GetNodes{{{1*/ 577 void Beam::GetNodes(void** vpnodes){ 578 int i; 579 Node** pnodes=(Node**)vpnodes; 580 581 for(i=0;i<3;i++){ 582 pnodes[i]=nodes[i]; 583 } 584 } 585 /*}}}*/ 586 /*FUNCTION Beam GetOnBed{{{1*/ 587 #undef __FUNCT__ 588 #define __FUNCT__ "Beam::GetOnBed" 589 int Beam::GetOnBed(){ 590 throw ErrorException(__FUNCT__," not supported yet!"); 591 } 592 /*}}}*/ 593 /*FUNCTION Beam GetParameterValue{{{1*/ 594 #undef __FUNCT__ 595 #define __FUNCT__ "Beam::GetParameterValue" 596 void Beam::GetParameterValue(double* pvalue, double* value_list,double gauss_coord){ 597 598 double l1l2[2]; 599 600 GetNodalFunctions(&l1l2[0],gauss_coord); 601 602 *pvalue=l1l2[0]*value_list[0]+l1l2[1]*value_list[1]; 603 } 604 /*}}}*/ 605 /*FUNCTION Beam GetShelf{{{1*/ 606 #undef __FUNCT__ 607 #define __FUNCT__ "Beam::GetShelf" 608 int Beam::GetShelf(){ 609 throw ErrorException(__FUNCT__," not supported yet!"); 610 } 611 /*}}}*/ 612 /*FUNCTION Beam GetThicknessList{{{1*/ 613 #undef __FUNCT__ 614 #define __FUNCT__ "Beam::GetThicknessList" 615 void Beam::GetThicknessList(double* thickness_list){ 616 throw ErrorException(__FUNCT__," not supported yet!"); 617 } 618 /*}}}*/ 619 /*FUNCTION Beam Gradj{{{1*/ 620 #undef __FUNCT__ 621 #define __FUNCT__ "Beam::Gradj" 622 void Beam::Gradj(_p_Vec*, void*, int, int,char*){ 623 throw ErrorException(__FUNCT__," not supported yet!"); 624 } 625 /*}}}*/ 626 /*FUNCTION Beam GradjB{{{1*/ 627 #undef __FUNCT__ 628 #define __FUNCT__ "Beam::GradjB" 629 void Beam::GradjB(_p_Vec*, void*, int, int){ 630 throw ErrorException(__FUNCT__," not supported yet!"); 631 } 632 /*}}}*/ 633 /*FUNCTION Beam GradjDrag{{{1*/ 634 #undef __FUNCT__ 635 #define __FUNCT__ "Beam::GradjDrag" 636 void Beam::GradjDrag(_p_Vec*, void*, int,int ){ 637 throw ErrorException(__FUNCT__," not supported yet!"); 638 } 639 /*}}}*/ 640 /*FUNCTION Beam MassFlux{{{1*/ 641 #undef __FUNCT__ 642 #define __FUNCT__ "Beam::MassFlux" 643 double Beam::MassFlux( double* segment,double* ug){ 644 throw ErrorException(__FUNCT__," not supported yet!"); 645 } 646 /*}}}*/ 647 /*FUNCTION Beam MaticeConfiguration{{{1*/ 648 #undef __FUNCT__ 649 #define __FUNCT__ "Beam::MaticeConfiguration" 650 void Beam::MaticeConfiguration(Matice* beam_matice,int beam_matice_offset){ 651 matice=beam_matice; 652 matice_offset=beam_matice_offset; 653 } 654 /*}}}*/ 655 /*FUNCTION Beam MatparConfiguration{{{1*/ 656 #undef __FUNCT__ 657 #define __FUNCT__ "Beam::MatparConfiguration" 658 void Beam::MatparConfiguration(Matpar* beam_matpar,int beam_matpar_offset){ 659 660 matpar=beam_matpar; 661 matpar_offset=beam_matpar_offset; 662 663 } 664 /*}}}*/ 665 /*FUNCTION Beam Misfit{{{1*/ 666 #undef __FUNCT__ 667 #define __FUNCT__ "Beam::Misfit" 668 double Beam::Misfit(void*,int,int ){ 669 throw ErrorException(__FUNCT__," not supported yet!"); 670 } 671 /*}}}*/ 672 /*FUNCTION Beam MyRank{{{1*/ 673 int Beam::MyRank(void){ 674 extern int my_rank; 675 return my_rank; 676 } 677 /*}}}*/ 678 /*FUNCTION Beam NodeConfiguration{{{1*/ 679 #undef __FUNCT__ 680 #define __FUNCT__ "Beam::NodeConfiguration" 681 void Beam::NodeConfiguration(int* beam_node_ids,Node* beam_nodes[2],int* beam_node_offsets){ 682 683 int i; 684 for(i=0;i<2;i++){ 685 node_ids[i]=beam_node_ids[i]; 686 nodes[i]=beam_nodes[i]; 687 node_offsets[i]=beam_node_offsets[i]; 688 } 689 690 } 691 /*}}}*/ 692 /*FUNCTION Beam UpdateFromInputs{{{1*/ 446 693 #undef __FUNCT__ 447 694 #define __FUNCT__ "Beam::UpdateFromInputs" … … 483 730 484 731 } 485 486 void Beam::GetDofList(int* doflist,int* pnumberofdofspernode){ 487 488 int i,j; 489 int doflist_per_node[MAXDOFSPERNODE]; 490 int numberofdofspernode; 491 492 for(i=0;i<2;i++){ 493 nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode); 494 for(j=0;j<numberofdofspernode;j++){ 495 doflist[i*numberofdofspernode+j]=doflist_per_node[j]; 496 } 497 } 498 499 /*Assign output pointers:*/ 500 *pnumberofdofspernode=numberofdofspernode; 501 502 } 503 504 void Beam::GetDofList1(int* doflist){ 505 506 int i; 507 for(i=0;i<2;i++){ 508 doflist[i]=nodes[i]->GetDofList1(); 509 } 510 511 } 512 513 514 void* Beam::GetMatPar(){ 515 return matpar; 516 } 517 518 519 void Beam::GetNodes(void** vpnodes){ 520 int i; 521 Node** pnodes=(Node**)vpnodes; 522 523 for(i=0;i<3;i++){ 524 pnodes[i]=nodes[i]; 525 } 526 } 527 528 529 Object* Beam::copy() { 530 531 return new Beam(*this); 532 533 } 534 535 536 #undef __FUNCT__ 537 #define __FUNCT__ "Beam::NodeConfiguration" 538 void Beam::NodeConfiguration(int* beam_node_ids,Node* beam_nodes[2],int* beam_node_offsets){ 539 540 int i; 541 for(i=0;i<2;i++){ 542 node_ids[i]=beam_node_ids[i]; 543 nodes[i]=beam_nodes[i]; 544 node_offsets[i]=beam_node_offsets[i]; 545 } 546 547 } 548 #undef __FUNCT__ 549 #define __FUNCT__ "Beam::MaticeConfiguration" 550 void Beam::MaticeConfiguration(Matice* beam_matice,int beam_matice_offset){ 551 matice=beam_matice; 552 matice_offset=beam_matice_offset; 553 } 554 555 #undef __FUNCT__ 556 #define __FUNCT__ "Beam::MatparConfiguration" 557 void Beam::MatparConfiguration(Matpar* beam_matpar,int beam_matpar_offset){ 558 559 matpar=beam_matpar; 560 matpar_offset=beam_matpar_offset; 561 562 } 563 564 565 566 #undef __FUNCT__ 567 #define __FUNCT__ "Beam::GetShelf" 568 int Beam::GetShelf(){ 569 throw ErrorException(__FUNCT__," not supported yet!"); 570 } 571 #undef __FUNCT__ 572 #define __FUNCT__ "Beam::GetOnBed" 573 int Beam::GetOnBed(){ 574 throw ErrorException(__FUNCT__," not supported yet!"); 575 } 576 577 578 #undef __FUNCT__ 579 #define __FUNCT__ "Beam::GetBedList" 580 void Beam::GetBedList(double*){ 581 throw ErrorException(__FUNCT__," not supported yet!"); 582 } 583 584 #undef __FUNCT__ 585 #define __FUNCT__ "Beam::Du" 586 void Beam::Du(_p_Vec*,void*,int,int){ 587 throw ErrorException(__FUNCT__," not supported yet!"); 588 } 589 #undef __FUNCT__ 590 #define __FUNCT__ "Beam::Gradj" 591 void Beam::Gradj(_p_Vec*, void*, int, int,char*){ 592 throw ErrorException(__FUNCT__," not supported yet!"); 593 } 594 #undef __FUNCT__ 595 #define __FUNCT__ "Beam::GradjDrag" 596 void Beam::GradjDrag(_p_Vec*, void*, int,int ){ 597 throw ErrorException(__FUNCT__," not supported yet!"); 598 } 599 #undef __FUNCT__ 600 #define __FUNCT__ "Beam::GradjB" 601 void Beam::GradjB(_p_Vec*, void*, int, int){ 602 throw ErrorException(__FUNCT__," not supported yet!"); 603 } 604 #undef __FUNCT__ 605 #define __FUNCT__ "Beam::Misfit" 606 double Beam::Misfit(void*,int,int ){ 607 throw ErrorException(__FUNCT__," not supported yet!"); 608 } 609 610 #undef __FUNCT__ 611 #define __FUNCT__ "Beam::GetThicknessList" 612 void Beam::GetThicknessList(double* thickness_list){ 613 throw ErrorException(__FUNCT__," not supported yet!"); 614 } 615 616 #undef __FUNCT__ 617 #define __FUNCT__ "Beam::GetParameterValue" 618 void Beam::GetParameterValue(double* pvalue, double* value_list,double gauss_coord){ 619 620 double l1l2[2]; 621 622 GetNodalFunctions(&l1l2[0],gauss_coord); 623 624 *pvalue=l1l2[0]*value_list[0]+l1l2[1]*value_list[1]; 625 } 626 627 628 #undef __FUNCT__ 629 #define __FUNCT__ "Beam::GetNodalFunctions" 630 void Beam::GetNodalFunctions(double* l1l2, double gauss_coord){ 631 632 /*This routine returns the values of the nodal functions at the gaussian point.*/ 633 634 /*First nodal function: */ 635 l1l2[0]=.5*gauss_coord+.5; 636 637 /*Second nodal function: */ 638 l1l2[1]=-.5*gauss_coord+.5; 639 } 640 641 #undef __FUNCT__ 642 #define __FUNCT__ "Beam::GetJacobianDeterminant" 643 void Beam::GetJacobianDeterminant(double* pJdet,double* z_list, double gauss_coord){ 644 645 646 double Jdet; 647 648 Jdet=1.0/2.0*(z_list[1]-z_list[0]); 649 650 if(Jdet<0){ 651 throw ErrorException(__FUNCT__," negative jacobian determinant!"); 652 } 653 654 *pJdet=Jdet; 655 } 656 657 #undef __FUNCT__ 658 #define __FUNCT__ "Beam::ComputePressure" 659 void Beam::ComputePressure(Vec p_g){ 660 661 int i; 662 const int numgrids=2; 663 int doflist[numgrids]; 664 double pressure[numgrids]; 665 double rho_ice,g; 666 double xyz_list[numgrids][3]; 667 668 /*Get node data: */ 669 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 670 671 /*Get dof list on which we will plug the pressure values: */ 672 GetDofList1(&doflist[0]); 673 674 /*pressure is lithostatic: */ 675 rho_ice=matpar->GetRhoIce(); 676 g=matpar->GetG(); 677 for(i=0;i<numgrids;i++){ 678 pressure[i]=rho_ice*g*(s[i]-xyz_list[i][2]); 679 } 680 681 /*plug local pressure values into global pressure vector: */ 682 VecSetValues(p_g,numgrids,doflist,(const double*)pressure,INSERT_VALUES); 683 684 } 685 #undef __FUNCT__ 686 #define __FUNCT__ "Beam::MassFlux" 687 double Beam::MassFlux( double* segment,double* ug){ 688 throw ErrorException(__FUNCT__," not supported yet!"); 689 } 732 /*}}}*/ -
issm/trunk/src/c/objects/Friction.cpp
r2359 r2907 11 11 --------------------------------------------------*/ 12 12 13 /*FUNCTION NewFriction{{{1*/ 13 14 Friction* NewFriction(void) 14 15 { … … 17 18 return (Friction*)xmalloc(sizeof(Friction)); 18 19 } 19 20 /*}}}*/ 21 /*FUNCTION FrictionEcho{{{1*/ 20 22 void FrictionEcho(Friction* friction){ 21 23 … … 49 51 printf("\n"); 50 52 } 51 52 53 /*}}}*/ 54 /*FUNCTION FrictionInit {{{1*/ 53 55 /*-------------------------------------------------- 54 56 FrictionInit … … 71 73 return 1; 72 74 } 73 75 /*}}}*/ 76 /*FUNCTION DeleteFriction {{{1*/ 74 77 /*-------------------------------------------------- 75 78 DeleteFriction … … 86 89 xfree((void**)pfriction); 87 90 } 88 89 91 /*}}}*/ 92 /*FUNCTION FrictionGetAlpha2 {{{1*/ 90 93 /*-------------------------------------------------- 91 94 FrictionGetAlpha2 … … 138 141 } 139 142 } 140 143 /*}}}*/ 144 /*FUNCTION FrictionGetAlphaComplement {{{1*/ 141 145 /*-------------------------------------------------- 142 146 FrictionGetAlphaComplement … … 180 184 } 181 185 } 186 /*}}}*/ -
issm/trunk/src/c/objects/Icefront.cpp
r2005 r2907 19 19 20 20 21 /*Object constructors and destructor*/ 22 /*FUNCTION Icefront constructor {{{1*/ 21 23 Icefront::Icefront(){ 22 24 return; 23 25 } 24 26 /*}}}*/ 27 /*FUNCTION Icefront creation {{{1*/ 25 28 Icefront::Icefront(char icefront_type[ICEFRONTSTRING],int icefront_sid, int icefront_mparid, int icefront_eid, int icefront_element_type, 26 29 int icefront_node_ids[MAX_ICEFRONT_GRIDS],double icefront_h[MAX_ICEFRONT_GRIDS],double icefront_b[MAX_ICEFRONT_GRIDS]){ … … 51 54 return; 52 55 } 53 56 /*}}}*/ 57 /*FUNCTION Icefront destructor {{{1*/ 54 58 Icefront::~Icefront(){ 55 59 return; 56 60 } 57 58 void Icefront::Echo(void){ 61 /*}}}*/ 62 63 /*Object marshall*/ 64 /*FUNCTION Icefront Demarshall {{{1*/ 65 void Icefront::Demarshall(char** pmarshalled_dataset){ 59 66 60 67 int i; 61 62 printf("Icefront:\n"); 63 printf(" type: %s\n",type); 64 printf(" sid: %i\n",sid); 65 66 printf(" mparid: %i\n",mparid); 67 printf(" matpar_offset: %i\n",matpar_offset); 68 printf(" matpar: \n"); 69 70 printf(" element_type: %i\n",element_type); 71 printf(" eid: %i\n",eid); 72 printf(" element_offset: %i\n",eid); 73 printf(" element\n"); 74 75 if (strcmp(type,"segment")==0){ 76 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 77 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 78 printf(" h=[%g,%g]\n",h[0],h[1]); 79 printf(" b=[%g,%g]\n",b[0],b[1]); 80 for(i=0;i<2;i++){ 81 if(nodes[i])nodes[i]->Echo(); 82 } 83 } 84 else{ 85 printf(" node_ids=[%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3]); 86 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3]); 87 printf(" h=[%g,%g,%g,%g]\n",h[0],h[1],h[2],h[3]); 88 printf(" b=[%g,%g,%g,%g]\n",b[0],b[1],b[2],b[3]); 89 for(i=0;i<4;i++){ 90 if(nodes[i])nodes[i]->Echo(); 91 } 92 } 93 68 char* marshalled_dataset=NULL; 69 70 /*recover marshalled_dataset: */ 71 marshalled_dataset=*pmarshalled_dataset; 72 73 /*this time, no need to get enum type, the pointer directly points to the beginning of the 74 *object data (thanks to DataSet::Demarshall):*/ 75 76 memcpy(&type,marshalled_dataset,sizeof(type));marshalled_dataset+=sizeof(type); 77 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid); 78 79 memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid); 80 memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset); 81 82 memcpy(&element_type,marshalled_dataset,sizeof(element_type));marshalled_dataset+=sizeof(element_type); 83 memcpy(&eid,marshalled_dataset,sizeof(eid));marshalled_dataset+=sizeof(eid); 84 memcpy(&element_offset,marshalled_dataset,sizeof(element_offset));marshalled_dataset+=sizeof(element_offset); 85 86 memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 87 memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 88 89 memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h); 90 memcpy(&b,marshalled_dataset,sizeof(b));marshalled_dataset+=sizeof(b); 91 92 for(i=0;i<MAX_ICEFRONT_GRIDS;i++)nodes[i]=NULL; 93 matpar=NULL; 94 element=NULL; 95 96 /*return: */ 97 *pmarshalled_dataset=marshalled_dataset; 94 98 return; 95 99 } 96 void Icefront::DeepEcho(void){ 97 98 int i; 99 100 printf("Icefront:\n"); 101 printf(" type: %s\n",type); 102 printf(" sid: %i\n",sid); 103 104 printf(" mparid: %i\n",mparid); 105 printf(" matpar_offset: %i\n",matpar_offset); 106 printf(" matpar: \n"); 107 108 printf(" element_type: %i\n",element_type); 109 printf(" eid: %i\n",eid); 110 printf(" element_offset: %i\n",eid); 111 printf(" element\n"); 112 113 if (strcmp(type,"segment")==0){ 114 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 115 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 116 printf(" h=[%g,%g]\n",h[0],h[1]); 117 printf(" b=[%g,%g]\n",b[0],b[1]); 118 for(i=0;i<2;i++){ 119 if(nodes[i])nodes[i]->Echo(); 120 } 121 } 122 else{ 123 printf(" node_ids=[%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3]); 124 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3]); 125 printf(" h=[%g,%g,%g,%g]\n",h[0],h[1],h[2],h[3]); 126 printf(" b=[%g,%g,%g,%g]\n",b[0],b[1],b[2],b[3]); 127 for(i=0;i<4;i++){ 128 if(nodes[i])nodes[i]->Echo(); 129 } 130 } 131 132 return; 133 } 100 /*}}}*/ 101 /*FUNCTION Icefront Marshall {{{1*/ 134 102 void Icefront::Marshall(char** pmarshalled_dataset){ 135 103 … … 166 134 return; 167 135 } 168 136 /*}}}*/ 137 /*FUNCTION Icefront MarshallSize{{{1*/ 169 138 int Icefront::MarshallSize(){ 170 139 … … 182 151 sizeof(int); //sizeof(int) for enum type 183 152 } 184 185 char* Icefront::GetName(void){ 186 return "icefront"; 187 } 188 189 190 void Icefront::Demarshall(char** pmarshalled_dataset){ 191 192 int i; 193 char* marshalled_dataset=NULL; 194 195 /*recover marshalled_dataset: */ 196 marshalled_dataset=*pmarshalled_dataset; 197 198 /*this time, no need to get enum type, the pointer directly points to the beginning of the 199 *object data (thanks to DataSet::Demarshall):*/ 200 201 memcpy(&type,marshalled_dataset,sizeof(type));marshalled_dataset+=sizeof(type); 202 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid); 203 204 memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid); 205 memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset); 206 207 memcpy(&element_type,marshalled_dataset,sizeof(element_type));marshalled_dataset+=sizeof(element_type); 208 memcpy(&eid,marshalled_dataset,sizeof(eid));marshalled_dataset+=sizeof(eid); 209 memcpy(&element_offset,marshalled_dataset,sizeof(element_offset));marshalled_dataset+=sizeof(element_offset); 210 211 memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 212 memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 213 214 memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h); 215 memcpy(&b,marshalled_dataset,sizeof(b));marshalled_dataset+=sizeof(b); 216 217 for(i=0;i<MAX_ICEFRONT_GRIDS;i++)nodes[i]=NULL; 218 matpar=NULL; 219 element=NULL; 220 221 /*return: */ 222 *pmarshalled_dataset=marshalled_dataset; 223 return; 224 } 225 226 int Icefront::Enum(void){ 227 228 return IcefrontEnum(); 229 230 } 231 232 int Icefront::GetId(void){ return sid; } 233 234 int Icefront::MyRank(void){ 235 extern int my_rank; 236 return my_rank; 237 } 238 void Icefront::DistributeNumDofs(int* numdofspernode,int analysis_type,int sub_analysis_type){return;} 239 153 /*}}}*/ 154 155 /*Object functions*/ 156 /*FUNCTION Icefront Configure {{{1*/ 240 157 #undef __FUNCT__ 241 158 #define __FUNCT__ "Icefront::Configure" … … 271 188 272 189 } 273 274 275 190 /*}}}*/ 191 /*FUNCTION Icefront copy {{{1*/ 192 Object* Icefront::copy() { 193 return new Icefront(*this); 194 } 195 /*}}}*/ 196 /*FUNCTION Icefront CreateKMatrix {{{1*/ 276 197 #undef __FUNCT__ 277 198 #define __FUNCT__ "Icefront::CreateKMatrix" … … 284 205 285 206 } 286 207 /*}}}*/ 208 /*FUNCTION Icefront CreatePVector {{{1*/ 287 209 #undef __FUNCT__ 288 210 #define __FUNCT__ "Icefront::CreatePVector" … … 314 236 } 315 237 } 316 317 238 /*}}}*/ 239 /*FUNCTION Icefront CreatePVectorDiagnosticHoriz {{{1*/ 318 240 #undef __FUNCT__ 319 241 #define __FUNCT__ "Icefront::CreatePVectorDiagnosticHoriz" … … 328 250 } 329 251 } 330 252 /*}}}*/ 253 /*FUNCTION Icefront CreatePVectorDiagnosticHorizStokes {{{1*/ 331 254 #undef __FUNCT__ 332 255 #define __FUNCT__ "Icefront::CreatePVectorDiagnosticHorizSegment" … … 443 366 444 367 } 445 368 /*}}}*/ 369 /*FUNCTION Icefront CreatePVectorDiagnosticHorizQuad {{{1*/ 446 370 #undef __FUNCT__ 447 371 #define __FUNCT__ "Icefont::CreatePVectorDiagnosticHorizQuad" … … 605 529 606 530 } 607 608 531 /*}}}*/ 532 /*FUNCTION Icefront CreatePVectorDiagnosticStokes {{{1*/ 609 533 #undef __FUNCT__ 610 534 #define __FUNCT__ "Icefont::CreatePVectorDiagnosticStokes" … … 767 691 768 692 } 769 770 771 #undef __FUNCT__ 772 #define __FUNCT__ "Icefront::UpdateFromInputs" 773 void Icefront::UpdateFromInputs(void* vinputs){ 693 /*}}}*/ 694 /*FUNCTION Icefront DeepEcho {{{1*/ 695 void Icefront::DeepEcho(void){ 774 696 775 697 int i; 776 int numberofdofspernode; 777 778 /*element: */ 779 double* h_param=NULL; 780 double* b_param=NULL; 781 int dofs[1]={0}; 782 783 ParameterInputs* inputs=NULL; 784 785 inputs=(ParameterInputs*)vinputs; 786 787 if(strcmp(type,"quad")==0){ 788 inputs->Recover("thickness",&h[0],1,dofs,4,(void**)nodes); 789 inputs->Recover("bed",&b[0],1,dofs,4,(void**)nodes); 698 699 printf("Icefront:\n"); 700 printf(" type: %s\n",type); 701 printf(" sid: %i\n",sid); 702 703 printf(" mparid: %i\n",mparid); 704 printf(" matpar_offset: %i\n",matpar_offset); 705 printf(" matpar: \n"); 706 707 printf(" element_type: %i\n",element_type); 708 printf(" eid: %i\n",eid); 709 printf(" element_offset: %i\n",eid); 710 printf(" element\n"); 711 712 if (strcmp(type,"segment")==0){ 713 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 714 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 715 printf(" h=[%g,%g]\n",h[0],h[1]); 716 printf(" b=[%g,%g]\n",b[0],b[1]); 717 for(i=0;i<2;i++){ 718 if(nodes[i])nodes[i]->Echo(); 719 } 790 720 } 791 721 else{ 792 inputs->Recover("thickness",&h[0],1,dofs,2,(void**)nodes); 793 inputs->Recover("bed",&h[0],1,dofs,2,(void**)nodes); 794 } 795 796 797 } 798 722 printf(" node_ids=[%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3]); 723 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3]); 724 printf(" h=[%g,%g,%g,%g]\n",h[0],h[1],h[2],h[3]); 725 printf(" b=[%g,%g,%g,%g]\n",b[0],b[1],b[2],b[3]); 726 for(i=0;i<4;i++){ 727 if(nodes[i])nodes[i]->Echo(); 728 } 729 } 730 731 return; 732 } 733 /*}}}*/ 734 /*FUNCTION Icefront DistributeNumDofs {{{1*/ 735 void Icefront::DistributeNumDofs(int* numdofspernode,int analysis_type,int sub_analysis_type){return;} 736 737 /*}}}*/ 738 /*FUNCTION Icefront Echo {{{1*/ 739 void Icefront::Echo(void){ 740 741 int i; 742 743 printf("Icefront:\n"); 744 printf(" type: %s\n",type); 745 printf(" sid: %i\n",sid); 746 747 printf(" mparid: %i\n",mparid); 748 printf(" matpar_offset: %i\n",matpar_offset); 749 printf(" matpar: \n"); 750 751 printf(" element_type: %i\n",element_type); 752 printf(" eid: %i\n",eid); 753 printf(" element_offset: %i\n",eid); 754 printf(" element\n"); 755 756 if (strcmp(type,"segment")==0){ 757 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]); 758 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]); 759 printf(" h=[%g,%g]\n",h[0],h[1]); 760 printf(" b=[%g,%g]\n",b[0],b[1]); 761 for(i=0;i<2;i++){ 762 if(nodes[i])nodes[i]->Echo(); 763 } 764 } 765 else{ 766 printf(" node_ids=[%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3]); 767 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3]); 768 printf(" h=[%g,%g,%g,%g]\n",h[0],h[1],h[2],h[3]); 769 printf(" b=[%g,%g,%g,%g]\n",b[0],b[1],b[2],b[3]); 770 for(i=0;i<4;i++){ 771 if(nodes[i])nodes[i]->Echo(); 772 } 773 } 774 775 return; 776 } 777 /*}}}*/ 778 /*FUNCTION Icefront Enum {{{1*/ 779 int Icefront::Enum(void){ 780 781 return IcefrontEnum(); 782 783 } 784 /*}}}*/ 785 /*FUNCTION Icefront GetDofList{{{1*/ 799 786 #undef __FUNCT__ 800 787 #define __FUNCT__ "Icefront::GetDofList" … … 828 815 829 816 } 830 831 832 #undef __FUNCT__ 833 #define __FUNCT__ "Icefront::SegmentPressureLoad" 834 835 void Icefront::SegmentPressureLoad(double* pe_g,double rho_water,double rho_ice,double gravity, double* thickness_list, double* bed_list, double* normal,double length,int fill){ 836 837 double nx,ny; 838 double h1,h2,b1,b2; 839 int num_gauss; 840 double* segment_gauss_coord=NULL; 841 double* gauss_weights=NULL; 842 int ig; 843 double Jdet; 844 double thickness,bed; 845 double ice_pressure,water_pressure,air_pressure; 846 double surface_under_water,base_under_water; 847 double pressure; 848 849 nx=normal[0]; 850 ny=normal[1]; 851 852 //Get gaussian points and weights. order 2 since we have a product of 2 nodal functions 853 num_gauss=3; 854 GaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss); 855 856 //recover thickness and bed at two grids 857 h1=thickness_list[0]; 858 h2=thickness_list[1]; 859 b1=bed_list[0]; 860 b2=bed_list[1]; 861 862 //compute Jacobian of segment 863 Jdet=1./2.*length; 864 865 for(ig=0;ig<num_gauss;ig++){ 866 867 thickness=h1*(1+segment_gauss_coord[ig])/2+h2*(1-segment_gauss_coord[ig])/2; 868 bed=b1*(1+segment_gauss_coord[ig])/2+b2*(1-segment_gauss_coord[ig])/2; 869 870 if (fill==WaterEnum()){ 871 //icefront ends in water: 872 ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2); 873 air_pressure=0; 874 875 //Now deal with water pressure 876 surface_under_water=min(0,thickness+bed); // 0 if the top of the glacier is above water level 877 base_under_water=min(0,bed); // 0 if the bottom of the glacier is above water level 878 water_pressure=1.0/2.0*gravity*rho_water*(pow(surface_under_water,2) - pow(base_under_water,2)); 879 } 880 else if (fill==AirEnum()){ 881 ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2); 882 air_pressure=0; 883 water_pressure=0; 884 } 885 else{ 886 throw ErrorException(__FUNCT__," fill type not supported yet"); 887 } 888 889 pressure = ice_pressure + water_pressure + air_pressure; 890 891 pe_g[2*0+0]+= pressure*Jdet*gauss_weights[ig]*(1+segment_gauss_coord[ig])/2*nx; 892 pe_g[2*0+1]+= pressure*Jdet*gauss_weights[ig]*(1+segment_gauss_coord[ig])/2*ny; 893 pe_g[2*1+0]+= pressure*Jdet*gauss_weights[ig]*(1-segment_gauss_coord[ig])/2*nx; 894 pe_g[2*1+1]+= pressure*Jdet*gauss_weights[ig]*(1-segment_gauss_coord[ig])/2*ny; 895 896 } //for(ig=0;ig<num_gauss;ig++) 897 898 xfree((void**)&segment_gauss_coord); 899 xfree((void**)&gauss_weights); 900 } 901 817 /*}}}*/ 818 /*FUNCTION Icefront GetId {{{1*/ 819 int Icefront::GetId(void){ return sid; } 820 /*}}}*/ 821 /*FUNCTION Icefront GetName {{{1*/ 822 char* Icefront::GetName(void){ 823 return "icefront"; 824 } 825 /*}}}*/ 826 /*FUNCTION Icefront MyRank {{{1*/ 827 int Icefront::MyRank(void){ 828 extern int my_rank; 829 return my_rank; 830 } 831 /*}}}*/ 832 /*FUNCTION Icefront PenaltyCreateKMatrix {{{1*/ 902 833 #undef __FUNCT__ 903 834 #define __FUNCT__ "Icefront::PenaltyCreateKMatrix" … … 905 836 /*do nothing: */ 906 837 } 907 838 /*}}}*/ 839 /*FUNCTION Icefront PenaltyCreatePVector{{{1*/ 908 840 #undef __FUNCT__ 909 841 #define __FUNCT__ "Icefront::PenaltyCreatePVector" … … 911 843 /*do nothing: */ 912 844 } 913 914 Object* Icefront::copy() { 915 return new Icefront(*this); 916 } 917 918 845 /*}}}*/ 846 /*FUNCTION Icefront QuadPressureLoad {{{1*/ 919 847 #undef __FUNCT__ 920 848 #define __FUNCT__ "Icefront::QuadPressureLoad" … … 1173 1101 delete tria; 1174 1102 } 1175 1103 /*}}}*/ 1104 /*FUNCTION Icefront QuadPressureLoadStokes {{{1*/ 1176 1105 #undef __FUNCT__ 1177 1106 #define __FUNCT__ "Icefront::QuadPressureLoadStokes" … … 1430 1359 delete tria; 1431 1360 } 1361 /*}}}*/ 1362 /*FUNCTION Icefront SegmentPressureLoad {{{1*/ 1363 #undef __FUNCT__ 1364 #define __FUNCT__ "Icefront::SegmentPressureLoad" 1365 1366 void Icefront::SegmentPressureLoad(double* pe_g,double rho_water,double rho_ice,double gravity, double* thickness_list, double* bed_list, double* normal,double length,int fill){ 1367 1368 double nx,ny; 1369 double h1,h2,b1,b2; 1370 int num_gauss; 1371 double* segment_gauss_coord=NULL; 1372 double* gauss_weights=NULL; 1373 int ig; 1374 double Jdet; 1375 double thickness,bed; 1376 double ice_pressure,water_pressure,air_pressure; 1377 double surface_under_water,base_under_water; 1378 double pressure; 1379 1380 nx=normal[0]; 1381 ny=normal[1]; 1382 1383 //Get gaussian points and weights. order 2 since we have a product of 2 nodal functions 1384 num_gauss=3; 1385 GaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss); 1386 1387 //recover thickness and bed at two grids 1388 h1=thickness_list[0]; 1389 h2=thickness_list[1]; 1390 b1=bed_list[0]; 1391 b2=bed_list[1]; 1392 1393 //compute Jacobian of segment 1394 Jdet=1./2.*length; 1395 1396 for(ig=0;ig<num_gauss;ig++){ 1397 1398 thickness=h1*(1+segment_gauss_coord[ig])/2+h2*(1-segment_gauss_coord[ig])/2; 1399 bed=b1*(1+segment_gauss_coord[ig])/2+b2*(1-segment_gauss_coord[ig])/2; 1400 1401 if (fill==WaterEnum()){ 1402 //icefront ends in water: 1403 ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2); 1404 air_pressure=0; 1405 1406 //Now deal with water pressure 1407 surface_under_water=min(0,thickness+bed); // 0 if the top of the glacier is above water level 1408 base_under_water=min(0,bed); // 0 if the bottom of the glacier is above water level 1409 water_pressure=1.0/2.0*gravity*rho_water*(pow(surface_under_water,2) - pow(base_under_water,2)); 1410 } 1411 else if (fill==AirEnum()){ 1412 ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2); 1413 air_pressure=0; 1414 water_pressure=0; 1415 } 1416 else{ 1417 throw ErrorException(__FUNCT__," fill type not supported yet"); 1418 } 1419 1420 pressure = ice_pressure + water_pressure + air_pressure; 1421 1422 pe_g[2*0+0]+= pressure*Jdet*gauss_weights[ig]*(1+segment_gauss_coord[ig])/2*nx; 1423 pe_g[2*0+1]+= pressure*Jdet*gauss_weights[ig]*(1+segment_gauss_coord[ig])/2*ny; 1424 pe_g[2*1+0]+= pressure*Jdet*gauss_weights[ig]*(1-segment_gauss_coord[ig])/2*nx; 1425 pe_g[2*1+1]+= pressure*Jdet*gauss_weights[ig]*(1-segment_gauss_coord[ig])/2*ny; 1426 1427 } //for(ig=0;ig<num_gauss;ig++) 1428 1429 xfree((void**)&segment_gauss_coord); 1430 xfree((void**)&gauss_weights); 1431 } 1432 /*}}}*/ 1433 /*FUNCTION Icefront UpdateFromInputs {{{1*/ 1434 #undef __FUNCT__ 1435 #define __FUNCT__ "Icefront::UpdateFromInputs" 1436 void Icefront::UpdateFromInputs(void* vinputs){ 1437 1438 int i; 1439 int numberofdofspernode; 1440 1441 /*element: */ 1442 double* h_param=NULL; 1443 double* b_param=NULL; 1444 int dofs[1]={0}; 1445 1446 ParameterInputs* inputs=NULL; 1447 1448 inputs=(ParameterInputs*)vinputs; 1449 1450 if(strcmp(type,"quad")==0){ 1451 inputs->Recover("thickness",&h[0],1,dofs,4,(void**)nodes); 1452 inputs->Recover("bed",&b[0],1,dofs,4,(void**)nodes); 1453 } 1454 else{ 1455 inputs->Recover("thickness",&h[0],1,dofs,2,(void**)nodes); 1456 inputs->Recover("bed",&h[0],1,dofs,2,(void**)nodes); 1457 } 1458 1459 1460 } 1461 /*}}}*/ -
issm/trunk/src/c/objects/Input.cpp
r803 r2907 19 19 20 20 21 /*Object constructors and destructor*/ 22 /*FUNCTION Input::constructor {{{1*/ 21 23 Input::Input(){ 22 24 return; 23 25 } 24 26 /*}}}*/ 27 /*FUNCTION Input::destructor {{{1*/ 25 28 Input::~Input(){ 26 29 … … 28 31 return; 29 32 } 30 33 /*}}}*/ 34 /*FUNCTION Input::creation(char* input_name,int input_integer) {{{1*/ 35 Input::Input(char* input_name,int input_integer){ 36 37 strcpy(name,input_name); 38 type=INTEGER; 39 integer=input_integer; 40 41 ndof=0; 42 numberofnodes=0; 43 vector=NULL; 44 45 ar* input_name,double input_scalar} 46 /*}}}*/ 47 /*FUNCTION Input::creation(char* input_name,double input_scalar) {{{1*/ 48 Input::Input(char* input_name,double input_scalar){ 49 50 strcpy(name,input_name); 51 type=DOUBLE; 52 scalar=input_scalar; 53 54 ndof=0; 55 numberofnodes=0; 56 vector=NULL; 57 58 } 59 /*}}}*/ 60 /*FUNCTION Input::creation(char* input_name,char* input_string) {{{1*/ 31 61 Input::Input(char* input_name,char* input_string){ 32 62 … … 38 68 vector=NULL; 39 69 } 40 41 Input::Input(char* input_name,int input_integer){ 42 43 strcpy(name,input_name); 44 type=INTEGER; 45 integer=input_integer; 46 47 ndof=0; 48 numberofnodes=0; 49 vector=NULL; 50 51 } 52 53 Input::Input(char* input_name,double input_scalar){ 54 55 strcpy(name,input_name); 56 type=DOUBLE; 57 scalar=input_scalar; 58 59 ndof=0; 60 numberofnodes=0; 61 vector=NULL; 62 63 } 64 70 /*}}}*/ 71 /*FUNCTION Input::creation(char* input_name,double* input_vector,int input_ndof,int input_numberofnodes) {{{1*/ 65 72 Input::Input(char* input_name,double* input_vector,int input_ndof,int input_numberofnodes){ 66 73 … … 73 80 74 81 } 75 82 /*}}}*/ 83 /*FUNCTION Input::creation(char* input_name,Vec input_vector,int input_ndof, int input_numberofnode) {{{1*/ 76 84 Input::Input(char* input_name,Vec input_vector,int input_ndof, int input_numberofnodes){ 77 85 … … 83 91 84 92 } 85 86 void Input::Echo(void){ 87 88 int i,j; 89 90 printf("Input:\n"); 91 printf(" name: %s\n",name); 92 printf(" type: %i\n",type); 93 if(type==STRING) printf(" string: %s\n",string); 94 if(type==INTEGER) printf(" integer: %i\n",integer); 95 if(type==DOUBLE) printf(" double: %g\n",scalar); 96 if(type==DOUBLEVEC) printf(" doublevec:%p\n",vector); 97 } 98 93 /*}}}*/ 94 95 /*Object marshall*/ 96 /*FUNCTION Input::Demarshall {{{1*/ 97 #undef __FUNCT__ 98 #define __FUNCT__ "Input::Demarshall" 99 void Input::Demarshall(char** pmarshalled_dataset){ 100 throw ErrorException(__FUNCT__,"not supported yet!"); 101 } 102 /*}}}*/ 103 /*FUNCTION Input::Marshall {{{1*/ 104 #undef __FUNCT__ 105 #define __FUNCT__ "Input::Marshall" 106 void Input::Marshall(char** pmarshalled_dataset){ 107 throw ErrorException(__FUNCT__,"not supported yet!"); 108 } 109 /*}}}*/ 110 /*FUNCTION Input::MarshallSize {{{1*/ 111 #undef __FUNCT__ 112 #define __FUNCT__ "Input::MarshallSize" 113 int Input::MarshallSize(){ 114 throw ErrorException(__FUNCT__,"not supported yet!"); 115 } 116 /*}}}*/ 117 118 /*Object functions*/ 119 /*FUNCTION Input::copy {{{1*/ 120 Object* Input::copy() { 121 122 return new Input(*this); 123 124 } 125 /*}}}*/ 126 /*FUNCTION Input::DeepEcho {{{1*/ 99 127 void Input::DeepEcho(void){ 100 128 … … 114 142 } 115 143 } 144 /*}}}*/ 145 /*FUNCTION Input::Echo {{{1*/ 146 void Input::Echo(void){ 147 148 int i,j; 149 150 printf("Input:\n"); 151 printf(" name: %s\n",name); 152 printf(" type: %i\n",type); 153 if(type==STRING) printf(" string: %s\n",string); 154 if(type==INTEGER) printf(" integer: %i\n",integer); 155 if(type==DOUBLE) printf(" double: %g\n",scalar); 156 if(type==DOUBLEVEC) printf(" doublevec:%p\n",vector); 157 } 158 /*}}}*/ 159 /*FUNCTION Input::Enum {{{1*/ 116 160 int Input::Enum(void){ 117 161 … … 119 163 120 164 } 121 122 int Input::MyRank(void){ 123 extern int my_rank; 124 return my_rank; 125 } 126 127 128 int Input::IsSameName(char* input_name){ 129 if (strcmp(input_name,name)==0)return 1; 130 else return 0; 131 } 132 133 134 void Input::Recover(double* valuesin, int ndofin, int* dofsin,int numnodesin,void** vpnodesin){ 135 136 //ex: 137 // double values[6]; 138 // int ndof=2; 139 // int dofs[2]={0,2} //dofs 0 and 2 140 // for a tria, 3 nodes 141 //input->Recover(&values[0],ndof,dofs,3,this->nodes); //ie: recover values for dofs 0 and 2 of all nodes of the tria 142 143 int* doflist=NULL; 144 int dof1; 145 int dof; 146 int i,j; 147 148 Node** nodes=NULL; 149 Node* node=NULL; 150 151 /*recover pointer to nodes: */ 152 nodes=(Node**)vpnodesin; 153 154 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i%s"," cannot recover values from a ",type," input type")); 155 156 /*Ok, we are trying to fill values. values is of size ndof*numnodes. The dofs 157 * for picking up the values are found in the numnodes nodes. We firt build the dof list: */ 158 doflist=(int*)xmalloc(ndofin*numnodesin*sizeof(int)); 159 160 for(i=0;i<numnodesin;i++){ 161 node=nodes[i]; 162 163 /*Get 1d dof of this node: */ 164 dof1=node->GetDofList1(); 165 166 for(j=0;j<ndofin;j++){ 167 dof=dofsin[j]; 168 doflist[i*ndofin+j]=dof1*ndof+dof; 169 } 170 } 171 172 for(i=0;i<ndofin*numnodesin;i++){ 173 valuesin[i]=vector[doflist[i]]; 174 } 175 176 xfree((void**)&doflist); 177 } 178 179 Object* Input::copy() { 180 181 return new Input(*this); 182 183 } 184 185 186 void Input::Recover(int* pinteger){ 187 *pinteger=integer; 188 } 189 190 void Input::Recover(char** pstring){ 191 char* outstring=NULL; 192 193 outstring=(char*)xmalloc((strlen(string)+1)*sizeof(char)); 194 strcpy(outstring,string); 195 *pstring=outstring; 196 197 } 198 199 void Input::Recover(double* pdouble){ 200 201 *pdouble=scalar; 202 203 } 204 205 #undef __FUNCT__ 206 #define __FUNCT__ "Input::GetId" 207 int Input::GetId(){ 208 throw ErrorException(__FUNCT__,"not supported yet!"); 209 } 210 211 #undef __FUNCT__ 212 #define __FUNCT__ "Input::Marshall" 213 void Input::Marshall(char** pmarshalled_dataset){ 214 throw ErrorException(__FUNCT__,"not supported yet!"); 215 } 216 217 #undef __FUNCT__ 218 #define __FUNCT__ "Input::MarshallSize" 219 int Input::MarshallSize(){ 220 throw ErrorException(__FUNCT__,"not supported yet!"); 221 } 222 223 #undef __FUNCT__ 224 #define __FUNCT__ "Input::GetName" 225 char* Input::GetName(){ 226 throw ErrorException(__FUNCT__,"not supported yet!"); 227 } 228 229 #undef __FUNCT__ 230 #define __FUNCT__ "Input::Demarshall" 231 void Input::Demarshall(char** pmarshalled_dataset){ 232 throw ErrorException(__FUNCT__,"not supported yet!"); 233 } 234 165 /*}}}*/ 166 /*FUNCTION Input::Get {{{1*/ 235 167 #undef __FUNCT__ 236 168 #define __FUNCT__ "Input::Get" … … 279 211 return outvector; 280 212 } 213 /*}}}*/ 214 /*FUNCTION Input::GetId {{{1*/ 215 #undef __FUNCT__ 216 #define __FUNCT__ "Input::GetId" 217 int Input::GetId(){ 218 throw ErrorException(__FUNCT__,"not supported yet!"); 219 } 220 /*}}}*/ 221 /*FUNCTION Input::GetName {{{1*/ 222 #undef __FUNCT__ 223 #define __FUNCT__ "Input::GetName" 224 char* Input::GetName(){ 225 throw ErrorException(__FUNCT__,"not supported yet!"); 226 } 227 /*}}}*/ 228 /*FUNCTION Input::IsSameName {{{1*/ 229 int Input::IsSameName(char* input_name){ 230 if (strcmp(input_name,name)==0)return 1; 231 else return 0; 232 } 233 /*}}}*/ 234 /*FUNCTION Input::MyRank {{{1*/ 235 int Input::MyRank(void){ 236 extern int my_rank; 237 return my_rank; 238 } 239 /*}}}*/ 240 /*FUNCTION Input::Recover(double* valuesin, int ndofin, int* dofsin,int numnodesin,void** vpnodesin) {{{1*/ 241 void Input::Recover(double* valuesin, int ndofin, int* dofsin,int numnodesin,void** vpnodesin){ 242 243 //ex: 244 // double values[6]; 245 // int ndof=2; 246 // int dofs[2]={0,2} //dofs 0 and 2 247 // for a tria, 3 nodes 248 //input->Recover(&values[0],ndof,dofs,3,this->nodes); //ie: recover values for dofs 0 and 2 of all nodes of the tria 249 250 int* doflist=NULL; 251 int dof1; 252 int dof; 253 int i,j; 254 255 Node** nodes=NULL; 256 Node* node=NULL; 257 258 /*recover pointer to nodes: */ 259 nodes=(Node**)vpnodesin; 260 261 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i%s"," cannot recover values from a ",type," input type")); 262 263 /*Ok, we are trying to fill values. values is of size ndof*numnodes. The dofs 264 * for picking up the values are found in the numnodes nodes. We firt build the dof list: */ 265 doflist=(int*)xmalloc(ndofin*numnodesin*sizeof(int)); 266 267 for(i=0;i<numnodesin;i++){ 268 node=nodes[i]; 269 270 /*Get 1d dof of this node: */ 271 dof1=node->GetDofList1(); 272 273 for(j=0;j<ndofin;j++){ 274 dof=dofsin[j]; 275 doflist[i*ndofin+j]=dof1*ndof+dof; 276 } 277 } 278 279 for(i=0;i<ndofin*numnodesin;i++){ 280 valuesin[i]=vector[doflist[i]]; 281 } 282 283 xfree((void**)&doflist); 284 } 285 /*}}}*/ 286 /*FUNCTION Input::Recover(int* pinteger) {{{1*/ 287 void Input::Recover(int* pinteger){ 288 *pinteger=integer; 289 } 290 /*}}}*/ 291 /*FUNCTION Input::Recover(double* pdouble) {{{1*/ 292 void Input::Recover(double* pdouble){ 293 294 *pdouble=scalar; 295 296 } 297 /*}}}*/ 298 /*FUNCTION Input::Recover(char** pstring) {{{1*/ 299 void Input::Recover(char** pstring){ 300 char* outstring=NULL; 301 302 outstring=(char*)xmalloc((strlen(string)+1)*sizeof(char)); 303 strcpy(outstring,string); 304 *pstring=outstring; 305 306 } 307 /*}}}*/ 308 309 310 311 312 -
issm/trunk/src/c/objects/Matice.cpp
r1904 r2907 17 17 18 18 19 /*Object constructors and destructor*/ 20 /*FUNCTION Matice::constructor {{{1*/ 19 21 Matice::Matice(){ 20 22 return; 21 23 } 24 /*}}}*/ 25 /*FUNCTION Matice::creation {{{1*/ 22 26 Matice::Matice(int matice_mid,double matice_B,double matice_n){ 23 27 mid=matice_mid; … … 26 30 return; 27 31 } 28 32 /*}}}*/ 33 /*FUNCTION Matice::destructor {{{1*/ 29 34 Matice::~Matice(){ 30 35 return; 31 36 } 32 void Matice::Echo(void){ 37 /*}}}*/ 38 39 /*Object marshall*/ 40 /*FUNCTION Matice::Marshall {{{1*/ 41 void Matice::Marshall(char** pmarshalled_dataset){ 42 43 char* marshalled_dataset=NULL; 44 int enum_type=0; 45 46 /*recover marshalled_dataset: */ 47 marshalled_dataset=*pmarshalled_dataset; 48 49 /*get enum type of Matice: */ 50 enum_type=MaticeEnum(); 51 52 /*marshall enum: */ 53 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 54 55 /*marshall Matice data: */ 56 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid); 57 memcpy(marshalled_dataset,&B,sizeof(B));marshalled_dataset+=sizeof(B); 58 memcpy(marshalled_dataset,&n,sizeof(n));marshalled_dataset+=sizeof(n); 59 60 *pmarshalled_dataset=marshalled_dataset; 61 return; 62 } 63 /*}}}*/ 64 /*FUNCTION Matice::MarshallSize{{{1*/ 65 int Matice::MarshallSize(){ 66 67 return sizeof(mid)+sizeof(B)+sizeof(n)+sizeof(int); //sizeof(int) for enum type 68 } 69 /*}}}*/ 70 /*FUNCTION Matice::Demarshall {{{1*/ 71 void Matice::Demarshall(char** pmarshalled_dataset){ 72 73 char* marshalled_dataset=NULL; 74 75 /*recover marshalled_dataset: */ 76 marshalled_dataset=*pmarshalled_dataset; 77 78 /*this time, no need to get enum type, the pointer directly points to the beginning of the 79 *object data (thanks to DataSet::Demarshall):*/ 80 81 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 82 memcpy(&B,marshalled_dataset,sizeof(B));marshalled_dataset+=sizeof(B); 83 memcpy(&n,marshalled_dataset,sizeof(n));marshalled_dataset+=sizeof(n); 84 85 /*return: */ 86 *pmarshalled_dataset=marshalled_dataset; 87 return; 88 } 89 /*}}}*/ 90 91 /*Object functions*/ 92 /*FUNCTION Matice::copy {{{1*/ 93 Object* Matice::copy() { 94 return new Matice(*this); 95 } 96 /*}}}*/ 97 /*FUNCTION Matice::DeepEcho {{{1*/ 98 void Matice::DeepEcho(void){ 33 99 34 100 printf("Matice:\n"); … … 37 103 printf(" n: %g\n",n); 38 104 return; 39 } 40 void Matice::DeepEcho(void){ 105 } 106 /*}}}*/ 107 /*FUNCTION Matice::DistributeNumDofs {{{1*/ 108 void Matice::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 109 /*}}}*/ 110 /*FUNCTION Matice::Echo {{{1*/ 111 void Matice::Echo(void){ 41 112 42 113 printf("Matice:\n"); … … 45 116 printf(" n: %g\n",n); 46 117 return; 47 } 48 void Matice::Marshall(char** pmarshalled_dataset){ 49 50 char* marshalled_dataset=NULL; 51 int enum_type=0; 52 53 /*recover marshalled_dataset: */ 54 marshalled_dataset=*pmarshalled_dataset; 55 56 /*get enum type of Matice: */ 57 enum_type=MaticeEnum(); 58 59 /*marshall enum: */ 60 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 61 62 /*marshall Matice data: */ 63 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid); 64 memcpy(marshalled_dataset,&B,sizeof(B));marshalled_dataset+=sizeof(B); 65 memcpy(marshalled_dataset,&n,sizeof(n));marshalled_dataset+=sizeof(n); 66 67 *pmarshalled_dataset=marshalled_dataset; 68 return; 69 } 70 71 int Matice::MarshallSize(){ 72 73 return sizeof(mid)+sizeof(B)+sizeof(n)+sizeof(int); //sizeof(int) for enum type 74 } 75 118 } 119 /*}}}*/ 120 /*FUNCTION Matice::Enum {{{1*/ 121 int Matice::Enum(void){ 122 123 return MaticeEnum(); 124 125 } 126 /*}}}*/ 127 /*FUNCTION Matice::GetB {{{1*/ 128 double Matice::GetB(){ 129 return B; 130 } 131 /*}}}*/ 132 /*FUNCTION Matice::GetId {{{1*/ 133 int Matice::GetId(void){ return mid; } 134 /*}}}*/ 135 /*FUNCTION Matice::GetN {{{1*/ 136 double Matice::GetN(){ 137 return n; 138 } 139 /*}}}*/ 140 /*FUNCTION Matice::GetName {{{1*/ 76 141 char* Matice::GetName(void){ 77 142 return "matice"; 78 143 } 79 80 81 void Matice::Demarshall(char** pmarshalled_dataset){ 82 83 char* marshalled_dataset=NULL; 84 85 /*recover marshalled_dataset: */ 86 marshalled_dataset=*pmarshalled_dataset; 87 88 /*this time, no need to get enum type, the pointer directly points to the beginning of the 89 *object data (thanks to DataSet::Demarshall):*/ 90 91 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 92 memcpy(&B,marshalled_dataset,sizeof(B));marshalled_dataset+=sizeof(B); 93 memcpy(&n,marshalled_dataset,sizeof(n));marshalled_dataset+=sizeof(n); 94 95 /*return: */ 96 *pmarshalled_dataset=marshalled_dataset; 97 return; 98 } 99 100 int Matice::Enum(void){ 101 102 return MaticeEnum(); 103 104 } 105 106 int Matice::GetId(void){ return mid; } 107 108 int Matice::MyRank(void){ 109 extern int my_rank; 110 return my_rank; 111 } 112 void Matice::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 113 114 #undef __FUNCT__ 115 #define __FUNCT__ "Matice::UpdateFromInputs" 116 void Matice::UpdateFromInputs(void* inputs){ 117 118 //throw ErrorException(__FUNCT__," not supported yet!"); 119 120 } 121 122 #undef __FUNCT__ 123 #define __FUNCT__ "Matice::SetB" 124 void Matice::SetB(double B_param){ 125 B=B_param; 126 } 127 128 144 /*}}}*/ 145 /*FUNCTION Matice::GetViscosity2d {{{1*/ 129 146 #undef __FUNCT__ 130 147 #define __FUNCT__ "MatIce::GetViscosity2d" … … 188 205 *pviscosity=viscosity; 189 206 } 190 191 Object* Matice::copy() { 192 return new Matice(*this); 193 } 194 195 196 #undef __FUNCT__ 197 #define __FUNCT__ "MatIce::GetViscosityComplement" 198 void Matice::GetViscosityComplement(double* pviscosity_complement, double* epsilon){ 199 200 /*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]: 201 * 202 * 2* (1-n)/2n 203 * mu2= ------------------------------------------------------------------- 204 * 2[ (du/dx)^2+(dv/dy)^2+1/4*(du/dy+dv/dx)^2+du/dx*dv/dy ]^[(3n-1)/2n] 205 * 206 * where mu2 is the second viscosity, (u,v) the velocity 207 * vector, and n the flow law exponent. 208 * 209 * If epsilon is NULL, it means this is the first time Gradjb is being run, and we 210 * return mu20, initial viscosity. 211 */ 212 213 /*output: */ 214 double viscosity_complement; 215 216 /*input strain rate: */ 217 double exx,eyy,exy; 218 219 /*Intermediary value A and exponent e: */ 220 double A,e; 221 222 if(epsilon){ 223 exx=*(epsilon+0); 224 eyy=*(epsilon+1); 225 exy=*(epsilon+2); 226 227 /*Build viscosity: mu2=B/(2*A^e) */ 228 A=pow(exx,2)+pow(eyy,2)+pow(exy,2)+exx*eyy; 229 if(A==0){ 230 /*Maximum viscosity_complement for 0 shear areas: */ 231 viscosity_complement=4.5*pow((double)10,(double)17); 232 } 233 else{ 234 e=(n-1)/2/n; 235 236 viscosity_complement=1/(2*pow(A,e)); 237 } 238 } 239 else{ 240 viscosity_complement=4.5*pow((double)10,(double)17); 241 } 242 243 #ifdef _ISSM_DEBUG_ 244 printf("viscosity_complement %lf\n",viscosity_complement); 245 #endif 246 247 /*Return: */ 248 *pviscosity_complement=viscosity_complement; 249 } 250 207 /*}}}*/ 208 /*FUNCTION Matice::GetViscosity3d {{{1*/ 251 209 #undef __FUNCT__ 252 210 #define __FUNCT__ "MatIce::GetViscosity3d" … … 313 271 *pviscosity3d=viscosity3d; 314 272 } 315 273 /*}}}*/ 274 /*FUNCTION Matice::GetViscosity3dStokes {{{1*/ 316 275 #undef __FUNCT__ 317 276 #define __FUNCT__ "MatIce::GetViscosity3dStokes" … … 382 341 *pviscosity3d=viscosity3d; 383 342 } 384 double Matice::GetB(){ 385 return B; 386 } 387 388 double Matice::GetN(){ 389 return n; 390 } 391 343 /*}}}*/ 344 /*FUNCTION Matice::GetViscosityComplement {{{1*/ 345 #undef __FUNCT__ 346 #define __FUNCT__ "MatIce::GetViscosityComplement" 347 void Matice::GetViscosityComplement(double* pviscosity_complement, double* epsilon){ 348 349 /*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]: 350 * 351 * 2* (1-n)/2n 352 * mu2= ------------------------------------------------------------------- 353 * 2[ (du/dx)^2+(dv/dy)^2+1/4*(du/dy+dv/dx)^2+du/dx*dv/dy ]^[(3n-1)/2n] 354 * 355 * where mu2 is the second viscosity, (u,v) the velocity 356 * vector, and n the flow law exponent. 357 * 358 * If epsilon is NULL, it means this is the first time Gradjb is being run, and we 359 * return mu20, initial viscosity. 360 */ 361 362 /*output: */ 363 double viscosity_complement; 364 365 /*input strain rate: */ 366 double exx,eyy,exy; 367 368 /*Intermediary value A and exponent e: */ 369 double A,e; 370 371 if(epsilon){ 372 exx=*(epsilon+0); 373 eyy=*(epsilon+1); 374 exy=*(epsilon+2); 375 376 /*Build viscosity: mu2=B/(2*A^e) */ 377 A=pow(exx,2)+pow(eyy,2)+pow(exy,2)+exx*eyy; 378 if(A==0){ 379 /*Maximum viscosity_complement for 0 shear areas: */ 380 viscosity_complement=4.5*pow((double)10,(double)17); 381 } 382 else{ 383 e=(n-1)/2/n; 384 385 viscosity_complement=1/(2*pow(A,e)); 386 } 387 } 388 else{ 389 viscosity_complement=4.5*pow((double)10,(double)17); 390 } 391 392 #ifdef _ISSM_DEBUG_ 393 printf("viscosity_complement %lf\n",viscosity_complement); 394 #endif 395 396 /*Return: */ 397 *pviscosity_complement=viscosity_complement; 398 } 399 /*}}}*/ 400 /*FUNCTION Matice::MyRank {{{1*/ 401 int Matice::MyRank(void){ 402 extern int my_rank; 403 return my_rank; 404 } 405 /*}}}*/ 406 /*FUNCTION Matice::SetB {{{1*/ 407 #undef __FUNCT__ 408 #define __FUNCT__ "Matice::SetB" 409 void Matice::SetB(double B_param){ 410 B=B_param; 411 } 412 /*}}}*/ 413 /*FUNCTION Matice::UpdateFromInputs {{{1*/ 414 #undef __FUNCT__ 415 #define __FUNCT__ "Matice::UpdateFromInputs" 416 void Matice::UpdateFromInputs(void* inputs){ 417 418 //throw ErrorException(__FUNCT__," not supported yet!"); 419 420 } 421 /*}}}*/ -
issm/trunk/src/c/objects/Matpar.cpp
r803 r2907 17 17 18 18 19 /*Object constructors and destructor*/ 20 /*FUNCTION Matpar::constructor {{{1*/ 19 21 Matpar::Matpar(){ 20 22 return; 21 23 } 24 /*}}}1*/ 25 /*FUNCTION Matpar::creation {{{1*/ 22 26 Matpar::Matpar(int matpar_mid, double matpar_rho_ice, double matpar_rho_water, double matpar_heatcapacity, double matpar_thermalconductivity, double matpar_latentheat, double matpar_beta, double matpar_meltingpoint, double matpar_mixed_layer_capacity, double matpar_thermal_exchange_velocity, double matpar_g){ 23 27 … … 37 41 return; 38 42 } 39 43 /*}}}1*/ 44 /*FUNCTION Matpar::destructor{{{1*/ 40 45 Matpar::~Matpar(){ 41 46 return; 42 47 } 43 void Matpar::Echo(void){ 48 /*}}}1*/ 49 50 /*Object marshall*/ 51 /*FUNCTION Matpar::Demarshall {{{1*/ 52 void Matpar::Demarshall(char** pmarshalled_dataset){ 53 54 char* marshalled_dataset=NULL; 55 56 /*recover marshalled_dataset: */ 57 marshalled_dataset=*pmarshalled_dataset; 58 59 /*this time, no need to get enum type, the pointer directly points to the beginning of the 60 *object data (thanks to DataSet::Demarshall):*/ 61 62 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 63 memcpy(&rho_ice,marshalled_dataset,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice); 64 memcpy(&rho_water,marshalled_dataset,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water); 65 memcpy(&heatcapacity,marshalled_dataset,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity); 66 memcpy(&thermalconductivity,marshalled_dataset,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity); 67 memcpy(&latentheat,marshalled_dataset,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat); 68 memcpy(&beta,marshalled_dataset,sizeof(beta));marshalled_dataset+=sizeof(beta); 69 memcpy(&meltingpoint,marshalled_dataset,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint); 70 memcpy(&mixed_layer_capacity,marshalled_dataset,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity); 71 memcpy(&thermal_exchange_velocity,marshalled_dataset,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity); 72 memcpy(&g,marshalled_dataset,sizeof(g));marshalled_dataset+=sizeof(g); 73 74 /*return: */ 75 *pmarshalled_dataset=marshalled_dataset; 76 return; 77 } 78 /*}}}1*/ 79 /*FUNCTION Matpar::Marshall {{{1*/ 80 void Matpar::Marshall(char** pmarshalled_dataset){ 81 82 char* marshalled_dataset=NULL; 83 int enum_type=0; 84 85 /*recover marshalled_dataset: */ 86 marshalled_dataset=*pmarshalled_dataset; 87 88 /*get enum type of Matpar: */ 89 enum_type=MatparEnum(); 90 91 /*marshall enum: */ 92 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 93 94 /*marshall Matpar data: */ 95 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid); 96 memcpy(marshalled_dataset,&rho_ice,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice); 97 memcpy(marshalled_dataset,&rho_water,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water); 98 memcpy(marshalled_dataset,&heatcapacity,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity); 99 memcpy(marshalled_dataset,&thermalconductivity,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity); 100 memcpy(marshalled_dataset,&latentheat,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat); 101 memcpy(marshalled_dataset,&beta,sizeof(beta));marshalled_dataset+=sizeof(beta); 102 memcpy(marshalled_dataset,&meltingpoint,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint); 103 memcpy(marshalled_dataset,&mixed_layer_capacity,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity); 104 memcpy(marshalled_dataset,&thermal_exchange_velocity,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity); 105 memcpy(marshalled_dataset,&g,sizeof(g));marshalled_dataset+=sizeof(g); 106 107 *pmarshalled_dataset=marshalled_dataset; 108 return; 109 } 110 /*}}}1*/ 111 /*FUNCTION Matpar::MarshallSize {{{1*/ 112 int Matpar::MarshallSize(){ 113 114 return sizeof(mid)+ 115 sizeof(rho_ice)+ 116 sizeof(rho_water)+ 117 sizeof(heatcapacity)+ 118 sizeof(thermalconductivity)+ 119 sizeof(latentheat)+ 120 sizeof(beta)+ 121 sizeof(meltingpoint)+ 122 sizeof(mixed_layer_capacity)+ 123 sizeof(thermal_exchange_velocity)+ 124 sizeof(g)+ 125 sizeof(int); //sizeof(int) for enum type 126 } 127 /*}}}1*/ 128 129 /*Object functions*/ 130 /*FUNCTION Matpar::copy {{{1*/ 131 Object* Matpar::copy() { 132 return new Matpar(*this); 133 } 134 /*}}}1*/ 135 /*FUNCTION Matpar::DeepEcho {{{1*/ 136 void Matpar::DeepEcho(void){ 44 137 45 138 printf("Matpar:\n"); … … 56 149 printf(" g: %g\n",g); 57 150 return; 58 } 59 60 void Matpar::DeepEcho(void){ 151 } 152 /*}}}1*/ 153 /*FUNCTION Matpar::DistributeNumDofs {{{1*/ 154 void Matpar::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 155 /*}}}1*/ 156 /*FUNCTION Matpar::Echo {{{1*/ 157 void Matpar::Echo(void){ 61 158 62 159 printf("Matpar:\n"); … … 73 170 printf(" g: %g\n",g); 74 171 return; 75 } 76 void Matpar::Marshall(char** pmarshalled_dataset){ 77 78 char* marshalled_dataset=NULL; 79 int enum_type=0; 80 81 /*recover marshalled_dataset: */ 82 marshalled_dataset=*pmarshalled_dataset; 83 84 /*get enum type of Matpar: */ 85 enum_type=MatparEnum(); 86 87 /*marshall enum: */ 88 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 89 90 /*marshall Matpar data: */ 91 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid); 92 memcpy(marshalled_dataset,&rho_ice,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice); 93 memcpy(marshalled_dataset,&rho_water,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water); 94 memcpy(marshalled_dataset,&heatcapacity,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity); 95 memcpy(marshalled_dataset,&thermalconductivity,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity); 96 memcpy(marshalled_dataset,&latentheat,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat); 97 memcpy(marshalled_dataset,&beta,sizeof(beta));marshalled_dataset+=sizeof(beta); 98 memcpy(marshalled_dataset,&meltingpoint,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint); 99 memcpy(marshalled_dataset,&mixed_layer_capacity,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity); 100 memcpy(marshalled_dataset,&thermal_exchange_velocity,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity); 101 memcpy(marshalled_dataset,&g,sizeof(g));marshalled_dataset+=sizeof(g); 102 103 *pmarshalled_dataset=marshalled_dataset; 104 return; 105 } 106 107 int Matpar::MarshallSize(){ 108 109 return sizeof(mid)+ 110 sizeof(rho_ice)+ 111 sizeof(rho_water)+ 112 sizeof(heatcapacity)+ 113 sizeof(thermalconductivity)+ 114 sizeof(latentheat)+ 115 sizeof(beta)+ 116 sizeof(meltingpoint)+ 117 sizeof(mixed_layer_capacity)+ 118 sizeof(thermal_exchange_velocity)+ 119 sizeof(g)+ 120 sizeof(int); //sizeof(int) for enum type 121 } 122 172 } 173 /*}}}1*/ 174 /*FUNCTION Matpar::Enum {{{1*/ 175 int Matpar::Enum(void){ 176 177 return MatparEnum(); 178 179 } 180 /*}}}1*/ 181 /*FUNCTION Matpar::GetBeta {{{1*/ 182 double Matpar::GetBeta(){ 183 return beta; 184 } 185 /*}}}1*/ 186 /*FUNCTION Matpar::GetG {{{1*/ 187 double Matpar::GetG(){ 188 return g; 189 } 190 /*}}}1*/ 191 /*FUNCTION Matpar::GetHeatCapacity {{{1*/ 192 double Matpar::GetHeatCapacity(){ 193 return heatcapacity; 194 } 195 /*}}}1*/ 196 /*FUNCTION Matpar::GetId {{{1*/ 197 int Matpar::GetId(void){ return mid; } 198 /*}}}1*/ 199 /*FUNCTION Matpar::GetLatentHeat {{{1*/ 200 double Matpar::GetLatentHeat(){ 201 return latentheat; 202 } 203 /*}}}1*/ 204 /*FUNCTION Matpar::GetMeltingPoint {{{1*/ 205 double Matpar::GetMeltingPoint(){ 206 return meltingpoint; 207 } 208 /*}}}1*/ 209 /*FUNCTION Matpar::GetMixedLayerCapacity {{{1*/ 210 double Matpar::GetMixedLayerCapacity(){ 211 return mixed_layer_capacity; 212 } 213 /*}}}1*/ 214 /*FUNCTION Matpar::GetName {{{1*/ 123 215 char* Matpar::GetName(void){ 124 216 return "matpar"; 125 217 } 126 127 128 void Matpar::Demarshall(char** pmarshalled_dataset){ 129 130 char* marshalled_dataset=NULL; 131 132 /*recover marshalled_dataset: */ 133 marshalled_dataset=*pmarshalled_dataset; 134 135 /*this time, no need to get enum type, the pointer directly points to the beginning of the 136 *object data (thanks to DataSet::Demarshall):*/ 137 138 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 139 memcpy(&rho_ice,marshalled_dataset,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice); 140 memcpy(&rho_water,marshalled_dataset,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water); 141 memcpy(&heatcapacity,marshalled_dataset,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity); 142 memcpy(&thermalconductivity,marshalled_dataset,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity); 143 memcpy(&latentheat,marshalled_dataset,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat); 144 memcpy(&beta,marshalled_dataset,sizeof(beta));marshalled_dataset+=sizeof(beta); 145 memcpy(&meltingpoint,marshalled_dataset,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint); 146 memcpy(&mixed_layer_capacity,marshalled_dataset,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity); 147 memcpy(&thermal_exchange_velocity,marshalled_dataset,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity); 148 memcpy(&g,marshalled_dataset,sizeof(g));marshalled_dataset+=sizeof(g); 149 150 /*return: */ 151 *pmarshalled_dataset=marshalled_dataset; 152 return; 153 } 154 155 int Matpar::Enum(void){ 156 157 return MatparEnum(); 158 159 } 160 161 int Matpar::GetId(void){ return mid; } 162 218 /*}}}1*/ 219 /*FUNCTION Matpar::GetRhoIce {{{1*/ 220 double Matpar::GetRhoIce(){ 221 222 return rho_ice; 223 } 224 /*}}}1*/ 225 /*FUNCTION Matpar::GetRhoWater {{{1*/ 226 double Matpar::GetRhoWater(){ 227 return rho_water; 228 } 229 /*}}}1*/ 230 /*FUNCTION Matpar::GetThermalConductivity {{{1*/ 231 double Matpar::GetThermalConductivity(){ 232 return thermalconductivity; 233 } 234 /*}}}1*/ 235 /*FUNCTION Matpar::GetThermalExchangeVelocity {{{1*/ 236 double Matpar::GetThermalExchangeVelocity(){ 237 return thermal_exchange_velocity; 238 } 239 /*}}}1*/ 240 /*FUNCTION Matpar::MyRank {{{1*/ 163 241 int Matpar::MyRank(void){ 164 242 extern int my_rank; 165 243 return my_rank; 166 244 } 167 void Matpar::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 168 245 /*}}}1*/ 246 /*FUNCTION Matpar::UpdateFromInputs {{{1*/ 169 247 #undef __FUNCT__ 170 248 #define __FUNCT__ "Matpar::UpdateFromInputs" … … 174 252 175 253 } 176 177 double Matpar::GetG(){ 178 return g; 179 } 180 double Matpar::GetRhoIce(){ 181 182 return rho_ice; 183 } 184 double Matpar::GetRhoWater(){ 185 return rho_water; 186 } 187 188 Object* Matpar::copy() { 189 return new Matpar(*this); 190 } 191 192 double Matpar::GetMixedLayerCapacity(){ 193 return mixed_layer_capacity; 194 } 195 196 double Matpar::GetThermalExchangeVelocity(){ 197 return thermal_exchange_velocity; 198 } 199 200 double Matpar::GetHeatCapacity(){ 201 return heatcapacity; 202 } 203 204 double Matpar::GetThermalConductivity(){ 205 return thermalconductivity; 206 } 207 208 double Matpar::GetLatentHeat(){ 209 return latentheat; 210 } 211 double Matpar::GetBeta(){ 212 return beta; 213 } 214 double Matpar::GetMeltingPoint(){ 215 return meltingpoint; 216 } 217 254 /*}}}1*/ -
issm/trunk/src/c/objects/Model.cpp
r2333 r2907 18 18 #include "stdio.h" 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Model::constructor {{{1*/ 20 22 Model::Model(){ 21 23 … … 24 26 25 27 } 26 28 /*}}}1*/ 29 /*FUNCTION Model::destructor {{{1*/ 27 30 Model::~Model(){ 28 31 … … 30 33 /*do not delete active, it just points to one of the femmodels!*/ 31 34 } 32 33 #undef __FUNCT__ 34 #define __FUNCT__ "Model::Echo" 35 36 void Model::Echo(void){ 37 38 printf("Models echo: \n"); 39 printf(" number of fem models: %i\n",femmodels->Size()); 40 41 } 42 #undef __FUNCT__ 43 #define __FUNCT__ "Model::DeepEcho" 44 45 void Model::DeepEcho(void){ 46 47 femmodels->Echo(); 48 49 } 50 35 /*}}}1*/ 36 37 /*Object functions*/ 38 /*FUNCTION Model::AddFormulation(ConstDataHandle MODEL, int analysis_type,int sub_analysis_type){{{1*/ 51 39 #undef __FUNCT__ 52 40 #define __FUNCT__ "Model::AddFormulation" … … 122 110 123 111 } 124 112 /*}}}1*/ 113 /*FUNCTION Model::AddFormulation(ConstDataHandle MODEL, int analysis_type) {{{1*/ 125 114 #undef __FUNCT__ 126 115 #define __FUNCT__ "Model::AddFormulation" … … 200 189 201 190 } 202 191 /*}}}1*/ 192 /*FUNCTION Model::DeepEcho {{{1*/ 193 #undef __FUNCT__ 194 #define __FUNCT__ "Model::DeepEcho" 195 196 void Model::DeepEcho(void){ 197 198 femmodels->Echo(); 199 200 } 201 /*}}}1*/ 202 /*FUNCTION Model::Echo {{{1*/ 203 #undef __FUNCT__ 204 #define __FUNCT__ "Model::Echo" 205 206 void Model::Echo(void){ 207 208 printf("Models echo: \n"); 209 printf(" number of fem models: %i\n",femmodels->Size()); 210 211 } 212 /*}}}1*/ 213 /*FUNCTION Model::FindParam(int* pparameter,char* parametername {{{1*/ 203 214 #undef __FUNCT__ 204 215 #define __FUNCT__ "Model::FindParam" … … 219 230 220 231 } 232 /*}}}1*/ 233 /*FUNCTION Model::FindParam(double* pparameter,char* parametername ){{{1*/ 221 234 int Model::FindParam(double* pparameter,char* parametername){ 222 235 … … 235 248 236 249 } 250 /*}}}1*/ 251 /*FUNCTION Model::FindParam(double** pparameter,int* pM, int *pN,char* parametername) {{{1*/ 237 252 int Model::FindParam(double** pparameter,int* pM, int *pN,char* parametername){ 238 253 … … 251 266 252 267 } 268 /*}}}1*/ 269 /*FUNCTION Model::FindParam(char** pparameter,char* parametername) {{{1*/ 253 270 int Model::FindParam(char** pparameter,char* parametername){ 254 271 … … 266 283 267 284 } 268 285 /*}}}1*/ 286 /*FUNCTION Model::FindParam(int* pparameter,char* parametername,int analysis_type,int sub_analysis_type) {{{1*/ 269 287 int Model::FindParam(int* pparameter,char* parametername,int analysis_type,int sub_analysis_type){ 270 288 … … 279 297 femmodel->FindParam(pparameter,parametername); 280 298 } 281 299 /*}}}1*/ 300 /*FUNCTION Model::FindParam(double* pparameter,char* parametername,int analysis_type,int sub_analysis_type) {{{1*/ 282 301 int Model::FindParam(double* pparameter,char* parametername,int analysis_type,int sub_analysis_type){ 283 302 … … 292 311 femmodel->FindParam(pparameter,parametername); 293 312 } 294 295 313 /*}}}1*/ 314 /*FUNCTION Model::FindParam(double** pparameter,int* pM, int* pN,char* parametername,int analysis_type,int sub_analysis_type) {{{1*/ 296 315 int Model::FindParam(double** pparameter,int* pM, int* pN,char* parametername,int analysis_type,int sub_analysis_type){ 297 316 … … 306 325 femmodel->FindParam(pparameter,pM, pN,parametername); 307 326 } 308 327 /*}}}1*/ 328 /*FUNCTION Model::FindParam(char** pparameter,char* parametername,int analysis_type,int sub_analysis_type) {{{1*/ 309 329 int Model::FindParam(char** pparameter,char* parametername,int analysis_type,int sub_analysis_type){ 310 330 … … 319 339 femmodel->FindParam(pparameter,parametername); 320 340 } 321 341 /*}}}1*/ 342 /*FUNCTION Model::FindParam(int* pparameter,char* parametername,int analysis_type) {{{1*/ 322 343 int Model::FindParam(int* pparameter,char* parametername,int analysis_type){ 323 344 … … 332 353 femmodel->FindParam(pparameter,parametername); 333 354 } 334 355 /*}}}1*/ 356 /*FUNCTION Model::FindParam(double* pparameter,char* parametername,int analysis_type) {{{1*/ 335 357 int Model::FindParam(double* pparameter,char* parametername,int analysis_type){ 336 358 … … 345 367 femmodel->FindParam(pparameter,parametername); 346 368 } 347 348 369 /*}}}1*/ 370 /*FUNCTION Model::FindParam(double** pparameter,int* pM, int* pN,char* parametername,int analysis_type) {{{1*/ 349 371 int Model::FindParam(double** pparameter,int* pM, int* pN,char* parametername,int analysis_type){ 350 372 … … 359 381 femmodel->FindParam(pparameter,pM,pN,parametername); 360 382 } 361 383 /*}}}1*/ 384 /*FUNCTION Model::FindParam(char** pparameter,char* parametername,int analysis_type) {{{1*/ 362 385 int Model::FindParam(char** pparameter,char* parametername,int analysis_type){ 363 386 … … 372 395 femmodel->FindParam(pparameter,parametername); 373 396 } 374 397 /*}}}1*/ 398 /*FUNCTION Model::GetActiveFormulation {{{1*/ 399 FemModel* Model::GetActiveFormulation(){return active;} 400 /*}}}1*/ 401 /*FUNCTION Model::GetFormulation(int analysis_type,int sub_analysis_type) {{{1*/ 375 402 #undef __FUNCT__ 376 403 #define __FUNCT__ "Model::GetFormulation" … … 402 429 else return femmodel; 403 430 } 404 431 /*}}}1*/ 432 /*FUNCTION Model::GetFormulation(int analysis_type) {{{1*/ 405 433 #undef __FUNCT__ 406 434 #define __FUNCT__ "Model::GetFormulation" … … 431 459 else return femmodel; 432 460 } 433 434 435 FemModel* Model::GetActiveFormulation(){return active;} 436 437 461 /*}}}1*/ 462 /*FUNCTION Model::SetActiveFormulation {{{1*/ 438 463 void* Model::SetActiveFormulation(FemModel* femmodel){ 439 464 active=femmodel; 440 465 } 441 466 /*}}}1*/ -
issm/trunk/src/c/objects/Node.cpp
r2584 r2907 18 18 #include "../include/typedefs.h" 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Node constructor {{{1*/ 20 22 Node::Node(){ 21 23 return; 22 24 } 25 /*}}}*/ 26 /*FUNCTION Node constructor {{{1*/ 23 27 Node::Node(int node_id,int node_partitionborder,int node_numdofs, double node_x[3],double node_sigma,int node_onbed,int node_onsurface,int node_upper_node_id,int node_onshelf,int node_onsheet){ 24 28 … … 52 56 return; 53 57 } 54 58 /*}}}*/ 59 /*FUNCTION Node destructeur{{{1*/ 55 60 Node::~Node(){ 56 61 return; 57 62 } 58 59 void Node::Echo(void){ 60 61 int i; 62 63 printf("Node:\n"); 64 printf(" id: %i\n",id); 65 printf(" partitionborder: %i\n",partitionborder); 66 printf(" clone: %i\n",clone); 67 printf(" numberofdofs: %i\n",numberofdofs); 68 printf(" x=[%g,%g,%g]\n",x[0],x[1],x[2]); 69 printf(" sigma=%g\n",sigma); 70 printf(" onbed: %i\n",onbed); 71 printf(" onsurface: %i\n",onsurface); 72 printf(" onshelf: %i\n",onshelf); 73 printf(" onsheet: %i\n",onsheet); 74 printf(" upper_node_id=%i\n",upper_node_id); 75 printf(" upper_node_offset=%i\n",upper_node_offset); 76 printf(" doflist:|"); 77 for(i=0;i<numberofdofs;i++){ 78 if(i>MAXDOFSPERNODE)break; 79 printf("%i|",doflist[i]); 80 } 81 printf(" doflist1:|"); 82 printf("%i|",doflist1[0]); 83 printf("\n"); 84 85 printf(" set membership: m,n,f,s sets \n"); 86 for(i=0;i<numberofdofs;i++){ 87 if(i>MAXDOFSPERNODE)break; 88 printf(" dof %i: %i %i %i %i\n",i,mset[i],nset[i],fset[i],sset[i]); 89 } 90 printf("\n"); 91 if(upper_node)printf(" upper_node pointer: %p\n",upper_node); 92 93 return; 94 } 95 96 void Node::DeepEcho(void){ 97 98 int i; 99 100 printf("Node:\n"); 101 printf(" id: %i\n",id); 102 printf(" partitionborder: %i\n",partitionborder); 103 printf(" clone: %i\n",clone); 104 printf(" numberofdofs: %i\n",numberofdofs); 105 printf(" x=[%g,%g,%g]\n",x[0],x[1],x[2]); 106 printf(" sigma=%g\n",sigma); 107 printf(" onbed: %i\n",onbed); 108 printf(" onsurface: %i\n",onsurface); 109 printf(" onshelf: %i\n",onshelf); 110 printf(" onsheet: %i\n",onsheet); 111 printf(" upper_node_id=%i\n",upper_node_id); 112 printf(" upper_node_offset=%i\n",upper_node_offset); 113 printf(" doflist:|"); 114 for(i=0;i<numberofdofs;i++){ 115 if(i>MAXDOFSPERNODE)break; 116 printf("%i|",doflist[i]); 117 } 118 printf(" doflist1:|"); 119 printf("%i|",doflist1[0]); 120 printf("\n"); 121 122 printf(" set membership: m,n,f,s sets \n"); 123 for(i=0;i<numberofdofs;i++){ 124 if(i>MAXDOFSPERNODE)break; 125 printf(" dof %i: %i %i %i %i\n",i,mset[i],nset[i],fset[i],sset[i]); 126 } 127 printf("\n"); 128 if(upper_node)printf(" upper_node pointer: %p\n",upper_node); 129 130 return; 131 } 63 /*}}}*/ 64 65 /*Object marshall*/ 66 /*FUNCTION Node Marshall{{{1*/ 132 67 void Node::Marshall(char** pmarshalled_dataset){ 133 68 … … 168 103 return; 169 104 } 170 105 /*}}}*/ 106 /*FUNCTION Node MarshallSize{{{1*/ 171 107 int Node::MarshallSize(){ 172 108 … … 192 128 sizeof(int); //sizeof(int) for enum type 193 129 } 194 195 char* Node::GetName(void){ 196 return "node"; 197 } 198 199 130 /*}}}*/ 131 /*FUNCTION Node Demarshall{{{1*/ 200 132 void Node::Demarshall(char** pmarshalled_dataset){ 201 133 … … 235 167 return; 236 168 } 237 238 int Node::Enum(void){ 239 240 return NodeEnum(); 241 242 } 243 int Node::GetId(void){ return id; } 244 245 int Node::MyRank(void){ 246 extern int my_rank; 247 248 return my_rank; 249 } 250 251 void Node::DistributeDofs(int* pdofcount,int* pdofcount1){ 252 253 int i; 254 extern int my_rank; 255 int dofcount; 256 int dofcount1; 257 258 dofcount=*pdofcount; 259 dofcount1=*pdofcount1; 260 261 if(clone){ 262 /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/ 263 return; 264 } 265 266 /*This node should distribute dofs, go ahead: */ 267 for(i=0;i<numberofdofs;i++){ 268 doflist[i]=dofcount+i; 269 } 270 dofcount+=numberofdofs; 271 272 doflist1[0]=dofcount1; 273 dofcount1+=1; 274 275 /*Assign output pointers: */ 276 *pdofcount=dofcount; 277 *pdofcount1=dofcount1; 278 279 return; 280 } 281 282 void Node::UpdateDofs(int dofcount,int dofcount1){ 283 284 int i; 285 extern int my_rank; 286 287 if(clone){ 288 /*This node is a clone, don't update the dofs!: */ 289 return; 290 } 291 292 /*This node should update the dofs, go ahead: */ 293 for(i=0;i<numberofdofs;i++){ 294 doflist[i]+=dofcount; 295 } 296 doflist1[0]+=dofcount1; 297 298 return; 299 } 300 301 void Node::ShowBorderDofs(int* borderdofs,int* borderdofs1){ 302 303 int j; 304 extern int my_rank; 305 306 /*Is this node on the partition border? */ 307 if(!partitionborder)return; 308 309 /*Are we the cpu that created this node's dof list? */ 310 if(clone)return; 311 312 /*Ok, we are on the partition border, and we did create the 313 * dofs for this node, plug the doflist into borderdofs: */ 314 for(j=0;j<numberofdofs;j++){ 315 *(borderdofs+numberofdofs*(id-1)+j)=doflist[j]; 316 } 317 *(borderdofs1+(id-1)+0)=doflist1[0]; 318 319 return; 320 } 321 322 void Node::UpdateBorderDofs(int* allborderdofs,int* allborderdofs1){ 323 324 int j; 325 extern int my_rank; 326 327 /*Is this node on the partition border? */ 328 if(!partitionborder)return; 329 330 /*Are we the cpu that created this node's dof list? */ 331 if(clone==0)return; 332 333 /*Ok, we are on the partition border, but we did not create 334 * the dofs for this node. Therefore, our doflist is garbage right 335 * now. Go pick it up in the allborderdofs: */ 336 for(j=0;j<numberofdofs;j++){ 337 doflist[j]=*(allborderdofs+numberofdofs*(id-1)+j); 338 } 339 doflist1[0]=*(allborderdofs1+(id-1)+0); 340 return; 341 } 169 /*}}}*/ 170 171 /*Object functions*/ 172 /*FUNCTION Node ApplyConstraints{{{1*/ 173 void Node::ApplyConstraint(Vec yg,int dof,double value){ 174 175 int index; 176 177 /*First, dof should be added in the s set, describing which 178 * dofs are constrained to a certain value (dirichlet boundary condition*/ 179 180 DofInSSet(dof-1); 181 182 /*Second, we should add value into yg, at dof corresponding to doflist[dof], unless 183 * we are a clone!*/ 184 185 if(!clone){ 186 187 index=doflist[dof-1]; //matlab indexing 188 189 VecSetValues(yg,1,&index,&value,INSERT_VALUES); 190 191 } 192 193 } 194 /*}}}*/ 195 /*FUNCTION Node Configure {{{1*/ 196 #undef __FUNCT__ 197 #define __FUNCT__ "Node::Configure" 198 void Node::Configure(void* pnodes){ 199 200 DataSet* nodes=NULL; 201 202 /*Recover pointers :*/ 203 nodes=(DataSet*)pnodes; 204 205 /*Link this node with its upper node: */ 206 ResolvePointers((Object**)&upper_node,&upper_node_id,&upper_node_offset,1,nodes); 207 208 } 209 /*}}}*/ 210 /*FUNCTION Node copy {{{1*/ 211 Object* Node::copy() { 212 return new Node(*this); 213 } 214 /*}}}*/ 215 /*FUNCTION Node CreatePartition{{{1*/ 342 216 void Node::CreatePartition(Vec partition){ 343 217 … … 352 226 return; 353 227 } 354 355 void Node::SetClone(int* minranks){ 356 357 extern int my_rank; 358 359 if (minranks[id-1]==my_rank){ 360 clone=0; 361 } 362 else{ 363 /*!there is a cpu with lower rank that has the same node, 364 therefore, I am a clone*/ 365 clone=1; 366 } 367 368 } 369 370 371 int Node::GetNumberOfDofs(){ 372 373 return numberofdofs; 374 375 } 376 377 int Node::IsClone(){ 378 379 return clone; 380 381 } 382 383 384 void Node::ApplyConstraint(Vec yg,int dof,double value){ 385 386 int index; 387 388 /*First, dof should be added in the s set, describing which 389 * dofs are constrained to a certain value (dirichlet boundary condition*/ 390 391 DofInSSet(dof-1); 392 393 /*Second, we should add value into yg, at dof corresponding to doflist[dof], unless 394 * we are a clone!*/ 395 396 if(!clone){ 397 398 index=doflist[dof-1]; //matlab indexing 399 400 VecSetValues(yg,1,&index,&value,INSERT_VALUES); 401 402 } 403 404 } 405 406 407 void Node::DofInSSet(int dof){ 408 409 /*Put dof for this node into the s set (ie, this dof will be constrained 410 * to a fixed value during computations. */ 411 412 mset[dof]=0; //m and n are mutually exclusive (m for rigid body modes) 413 nset[dof]=1; 414 fset[dof]=0; //n splits into f (for which we solve) and s (single point constraints) 415 sset[dof]=1; 416 } 417 418 void Node::DofInMSet(int dof){ 419 420 /*Put dof for this node into the m set (m set is for rigid body modes)*/ 421 422 mset[dof]=1; //m and n are mutually exclusive (m for rigid body modes) 423 nset[dof]=0; 424 fset[dof]=0; //n splits into f (for which we solve) and s (single point constraints) 425 sset[dof]=0; 426 } 427 428 int Node::DofIsInMSet(int dof){ 429 430 if (mset[dof])return 1; 431 else return 0; 432 433 } 434 435 int Node::GetDof(int dofindex){ 436 437 return doflist[dofindex]; 438 439 } 440 441 228 /*}}}*/ 229 /*FUNCTION Node CreateVecSets {{{1*/ 442 230 void Node::CreateVecSets(Vec pv_g,Vec pv_m,Vec pv_n,Vec pv_f,Vec pv_s){ 443 231 … … 472 260 473 261 } 474 475 void Node::GetDofList(int* outdoflist,int* pnumberofdofspernode){ 262 /*}}}*/ 263 /*FUNCTION Node DeepEcho{{{1*/ 264 void Node::DeepEcho(void){ 476 265 477 266 int i; 267 268 printf("Node:\n"); 269 printf(" id: %i\n",id); 270 printf(" partitionborder: %i\n",partitionborder); 271 printf(" clone: %i\n",clone); 272 printf(" numberofdofs: %i\n",numberofdofs); 273 printf(" x=[%g,%g,%g]\n",x[0],x[1],x[2]); 274 printf(" sigma=%g\n",sigma); 275 printf(" onbed: %i\n",onbed); 276 printf(" onsurface: %i\n",onsurface); 277 printf(" onshelf: %i\n",onshelf); 278 printf(" onsheet: %i\n",onsheet); 279 printf(" upper_node_id=%i\n",upper_node_id); 280 printf(" upper_node_offset=%i\n",upper_node_offset); 281 printf(" doflist:|"); 478 282 for(i=0;i<numberofdofs;i++){ 479 outdoflist[i]=doflist[i]; 480 } 481 /*Assign output pointers:*/ 482 *pnumberofdofspernode=numberofdofs; 483 } 484 485 int Node::GetDofList1(void){ 486 return doflist1[0]; 487 } 488 489 double Node::GetX(){return x[0];} 490 double Node::GetY(){return x[1];} 491 double Node::GetZ(){return x[2];} 492 double Node::GetSigma(){return sigma;} 493 494 Object* Node::copy() { 495 return new Node(*this); 496 } 497 498 #undef __FUNCT__ 499 #define __FUNCT__ "Node::UpdateFromInputs" 500 void Node::UpdateFromInputs(void* vinputs){ 501 502 ParameterInputs* inputs=NULL; 503 Node* node=this; 504 int dof[1]={0}; 505 506 /*Recover parameter inputs: */ 507 inputs=(ParameterInputs*)vinputs; 508 509 /*Update internal data if inputs holds new values: */ 510 inputs->Recover("x",&x[0],1,dof,1,(void**)&node); 511 inputs->Recover("y",&x[1],1,dof,1,(void**)&node); 512 inputs->Recover("z",&x[2],1,dof,1,(void**)&node); 513 514 515 } 516 517 #undef __FUNCT__ 518 #define __FUNCT__ "Node::Configure" 519 void Node::Configure(void* pnodes){ 520 521 DataSet* nodes=NULL; 522 523 /*Recover pointers :*/ 524 nodes=(DataSet*)pnodes; 525 526 /*Link this node with its upper node: */ 527 ResolvePointers((Object**)&upper_node,&upper_node_id,&upper_node_offset,1,nodes); 528 529 } 530 531 #undef __FUNCT__ 532 #define __FUNCT__ "Node::GetUpperNode" 533 Node* Node::GetUpperNode(){ 534 return upper_node; 535 } 536 537 int Node::IsOnBed(){ 538 return onbed; 539 } 540 541 int Node::IsOnSurface(){ 542 return onsurface; 543 } 544 545 int Node::IsOnShelf(){ 546 return onshelf; 547 } 548 549 int Node::IsOnSheet(){ 550 return onsheet; 283 if(i>MAXDOFSPERNODE)break; 284 printf("%i|",doflist[i]); 285 } 286 printf(" doflist1:|"); 287 printf("%i|",doflist1[0]); 288 printf("\n"); 289 290 printf(" set membership: m,n,f,s sets \n"); 291 for(i=0;i<numberofdofs;i++){ 292 if(i>MAXDOFSPERNODE)break; 293 printf(" dof %i: %i %i %i %i\n",i,mset[i],nset[i],fset[i],sset[i]); 294 } 295 printf("\n"); 296 if(upper_node)printf(" upper_node pointer: %p\n",upper_node); 297 298 return; 551 299 } 552 void Node::FreezeDof(int dof){ 553 554 DofInSSet(dof-1); //with 0 displacement for this dof. 555 556 } 557 300 /*}}}*/ 301 /*FUNCTION Node DistributeDofs{{{1*/ 302 void Node::DistributeDofs(int* pdofcount,int* pdofcount1){ 303 304 int i; 305 extern int my_rank; 306 int dofcount; 307 int dofcount1; 308 309 dofcount=*pdofcount; 310 dofcount1=*pdofcount1; 311 312 if(clone){ 313 /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/ 314 return; 315 } 316 317 /*This node should distribute dofs, go ahead: */ 318 for(i=0;i<numberofdofs;i++){ 319 doflist[i]=dofcount+i; 320 } 321 dofcount+=numberofdofs; 322 323 doflist1[0]=dofcount1; 324 dofcount1+=1; 325 326 /*Assign output pointers: */ 327 *pdofcount=dofcount; 328 *pdofcount1=dofcount1; 329 330 return; 331 } 332 /*}}}*/ 333 /*FUNCTION Node DofInMSet{{{1*/ 334 void Node::DofInMSet(int dof){ 335 336 /*Put dof for this node into the m set (m set is for rigid body modes)*/ 337 338 mset[dof]=1; //m and n are mutually exclusive (m for rigid body modes) 339 nset[dof]=0; 340 fset[dof]=0; //n splits into f (for which we solve) and s (single point constraints) 341 sset[dof]=0; 342 } 343 /*}}}*/ 344 /*FUNCTION Node DofInSSet {{{1*/ 345 void Node::DofInSSet(int dof){ 346 347 /*Put dof for this node into the s set (ie, this dof will be constrained 348 * to a fixed value during computations. */ 349 350 mset[dof]=0; //m and n are mutually exclusive (m for rigid body modes) 351 nset[dof]=1; 352 fset[dof]=0; //n splits into f (for which we solve) and s (single point constraints) 353 sset[dof]=1; 354 } 355 /*}}}*/ 356 /*FUNCTION Node DofIsInMSet{{{1*/ 357 int Node::DofIsInMSet(int dof){ 358 359 if (mset[dof])return 1; 360 else return 0; 361 362 } 363 /*}}}*/ 364 /*FUNCTION Node Echo{{{1*/ 365 void Node::Echo(void){ 366 367 int i; 368 369 printf("Node:\n"); 370 printf(" id: %i\n",id); 371 printf(" partitionborder: %i\n",partitionborder); 372 printf(" clone: %i\n",clone); 373 printf(" numberofdofs: %i\n",numberofdofs); 374 printf(" x=[%g,%g,%g]\n",x[0],x[1],x[2]); 375 printf(" sigma=%g\n",sigma); 376 printf(" onbed: %i\n",onbed); 377 printf(" onsurface: %i\n",onsurface); 378 printf(" onshelf: %i\n",onshelf); 379 printf(" onsheet: %i\n",onsheet); 380 printf(" upper_node_id=%i\n",upper_node_id); 381 printf(" upper_node_offset=%i\n",upper_node_offset); 382 printf(" doflist:|"); 383 for(i=0;i<numberofdofs;i++){ 384 if(i>MAXDOFSPERNODE)break; 385 printf("%i|",doflist[i]); 386 } 387 printf(" doflist1:|"); 388 printf("%i|",doflist1[0]); 389 printf("\n"); 390 391 printf(" set membership: m,n,f,s sets \n"); 392 for(i=0;i<numberofdofs;i++){ 393 if(i>MAXDOFSPERNODE)break; 394 printf(" dof %i: %i %i %i %i\n",i,mset[i],nset[i],fset[i],sset[i]); 395 } 396 printf("\n"); 397 if(upper_node)printf(" upper_node pointer: %p\n",upper_node); 398 399 return; 400 } 401 /*}}}*/ 402 /*FUNCTION Node Enum{{{1*/ 403 int Node::Enum(void){ 404 405 return NodeEnum(); 406 407 } 408 /*}}}*/ 409 /*FUNCTION Node FieldDepthAverageAtBase{{{1*/ 558 410 #undef __FUNCT__ 559 411 #define __FUNCT__ "Node::FieldDepthAverageAtBase" … … 678 530 } 679 531 } 680 532 /*}}}*/ 533 /*FUNCTION Node FieldExtrude {{{1*/ 681 534 #undef __FUNCT__ 682 535 #define __FUNCT__ "Node::FieldExtrude" … … 789 642 } //if (extrude) 790 643 } 791 644 /*}}}*/ 645 /*FUNCTION Node FreezeDof{{{1*/ 646 void Node::FreezeDof(int dof){ 647 648 DofInSSet(dof-1); //with 0 displacement for this dof. 649 650 } 651 /*}}}*/ 652 /*FUNCTION Node GetDof {{{1*/ 653 int Node::GetDof(int dofindex){ 654 655 return doflist[dofindex]; 656 657 } 658 /*}}}*/ 659 /*FUNCTION Node GetDofList{{{1*/ 660 void Node::GetDofList(int* outdoflist,int* pnumberofdofspernode){ 661 662 int i; 663 for(i=0;i<numberofdofs;i++){ 664 outdoflist[i]=doflist[i]; 665 } 666 /*Assign output pointers:*/ 667 *pnumberofdofspernode=numberofdofs; 668 } 669 /*}}}*/ 670 /*FUNCTION Node GetDOfList1{{{1*/ 671 int Node::GetDofList1(void){ 672 return doflist1[0]; 673 } 674 /*}}}*/ 675 /*FUNCTION Node GetId{{{1*/ 676 int Node::GetId(void){ return id; } 677 /*}}}*/ 678 /*FUNCTION Node GetName{{{1*/ 679 char* Node::GetName(void){ 680 return "node"; 681 } 682 /*}}}*/ 683 /*FUNCTION Node GetNumberOfDofs{{{1*/ 684 int Node::GetNumberOfDofs(){ 685 686 return numberofdofs; 687 688 } 689 /*}}}*/ 690 /*FUNCTION Node GetSigma {{{1*/ 691 double Node::GetSigma(){return sigma;} 692 /*}}}*/ 693 /*FUNCTION Node GetUpperNode {{{1*/ 694 #undef __FUNCT__ 695 #define __FUNCT__ "Node::GetUpperNode" 696 Node* Node::GetUpperNode(){ 697 return upper_node; 698 } 699 /*}}}*/ 700 /*FUNCTION Node GetX {{{1*/ 701 double Node::GetX(){return x[0];} 702 /*}}}*/ 703 /*FUNCTION Node GetY {{{1*/ 704 double Node::GetY(){return x[1];} 705 /*}}}*/ 706 /*FUNCTION Node GetZ {{{1*/ 707 double Node::GetZ(){return x[2];} 708 /*}}}*/ 709 /*FUNCTION Node IsClone {{{1*/ 710 int Node::IsClone(){ 711 712 return clone; 713 714 } 715 /*}}}*/ 716 /*FUNCTION Node IsOnBed {{{1*/ 717 int Node::IsOnBed(){ 718 return onbed; 719 } 720 /*}}}*/ 721 /*FUNCTION Node IsOnSheet {{{1*/ 722 int Node::IsOnSheet(){ 723 return onsheet; 724 } 725 /*}}}*/ 726 /*FUNCTION Node IsOnShelf {{{1*/ 727 int Node::IsOnShelf(){ 728 return onshelf; 729 } 730 /*}}}*/ 731 /*FUNCTION Node IsOnSurface {{{1*/ 732 int Node::IsOnSurface(){ 733 return onsurface; 734 } 735 /*}}}*/ 736 /*FUNCTION Node MyRank{{{1*/ 737 int Node::MyRank(void){ 738 extern int my_rank; 739 740 return my_rank; 741 } 742 /*}}}*/ 743 /*FUNCTION Node SetClone {{{1*/ 744 void Node::SetClone(int* minranks){ 745 746 extern int my_rank; 747 748 if (minranks[id-1]==my_rank){ 749 clone=0; 750 } 751 else{ 752 /*!there is a cpu with lower rank that has the same node, 753 therefore, I am a clone*/ 754 clone=1; 755 } 756 757 } 758 /*}}}*/ 759 /*FUNCTION Node ShowBorderDofs{{{1*/ 760 void Node::ShowBorderDofs(int* borderdofs,int* borderdofs1){ 761 762 int j; 763 extern int my_rank; 764 765 /*Is this node on the partition border? */ 766 if(!partitionborder)return; 767 768 /*Are we the cpu that created this node's dof list? */ 769 if(clone)return; 770 771 /*Ok, we are on the partition border, and we did create the 772 * dofs for this node, plug the doflist into borderdofs: */ 773 for(j=0;j<numberofdofs;j++){ 774 *(borderdofs+numberofdofs*(id-1)+j)=doflist[j]; 775 } 776 *(borderdofs1+(id-1)+0)=doflist1[0]; 777 778 return; 779 } 780 /*}}}*/ 781 /*FUNCTION Node UpdateBorderDofs{{{1*/ 782 void Node::UpdateBorderDofs(int* allborderdofs,int* allborderdofs1){ 783 784 int j; 785 extern int my_rank; 786 787 /*Is this node on the partition border? */ 788 if(!partitionborder)return; 789 790 /*Are we the cpu that created this node's dof list? */ 791 if(clone==0)return; 792 793 /*Ok, we are on the partition border, but we did not create 794 * the dofs for this node. Therefore, our doflist is garbage right 795 * now. Go pick it up in the allborderdofs: */ 796 for(j=0;j<numberofdofs;j++){ 797 doflist[j]=*(allborderdofs+numberofdofs*(id-1)+j); 798 } 799 doflist1[0]=*(allborderdofs1+(id-1)+0); 800 return; 801 } 802 /*}}}*/ 803 /*FUNCTION Node UpdateDofs{{{1*/ 804 void Node::UpdateDofs(int dofcount,int dofcount1){ 805 806 int i; 807 extern int my_rank; 808 809 if(clone){ 810 /*This node is a clone, don't update the dofs!: */ 811 return; 812 } 813 814 /*This node should update the dofs, go ahead: */ 815 for(i=0;i<numberofdofs;i++){ 816 doflist[i]+=dofcount; 817 } 818 doflist1[0]+=dofcount1; 819 820 return; 821 } 822 /*}}}*/ 823 /*FUNCTION Node UpdateFromInputs {{{1*/ 824 #undef __FUNCT__ 825 #define __FUNCT__ "Node::UpdateFromInputs" 826 void Node::UpdateFromInputs(void* vinputs){ 827 828 ParameterInputs* inputs=NULL; 829 Node* node=this; 830 int dof[1]={0}; 831 832 /*Recover parameter inputs: */ 833 inputs=(ParameterInputs*)vinputs; 834 835 /*Update internal data if inputs holds new values: */ 836 inputs->Recover("x",&x[0],1,dof,1,(void**)&node); 837 inputs->Recover("y",&x[1],1,dof,1,(void**)&node); 838 inputs->Recover("z",&x[2],1,dof,1,(void**)&node); 839 840 841 } 842 /*}}}*/ 843 /*FUNCTION Node UpdateNodePosition {{{1*/ 792 844 void Node::UpdateNodePosition(double* thickness,double* bed){ 793 845 … … 800 852 801 853 } 854 /*}}}*/ -
issm/trunk/src/c/objects/Numpar.cpp
r2409 r2907 18 18 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Numpar::constructor {{{1*/ 20 22 Numpar::Numpar(){ 21 23 return; 22 24 } 23 24 25 /*}}}*/ 26 /*FUNCTION Numpar::creation {{{1*/ 25 27 Numpar::Numpar(int numpar_id){ 26 28 id=numpar_id; … … 40 42 return; 41 43 } 44 /*}}}*/ 45 /*FUNCTION Numpar::destructor {{{1*/ 42 46 Numpar::~Numpar(){ 43 47 return; 44 48 } 45 46 47 #undef __FUNCT__ 48 #define __FUNCT__ "Numpar::Echo" 49 void Numpar::Echo(void){ 50 51 printf("Numpar:\n"); 52 printf(" id: %i\n",id); 53 printf(" meanvel: %g\n",meanvel); 54 printf(" epsvel: %g\n",epsvel); 55 printf(" artdiff: %i\n",artdiff); 56 printf(" viscosity_overshoot: %g\n",viscosity_overshoot); 57 printf(" stokesreconditioning: %g\n",stokesreconditioning); 58 printf(" control_type: %s\n",control_type); 59 printf(" cm_noisedmp: %g\n",cm_noisedmp); 60 printf(" cm_mindmp_value: %g\n",cm_mindmp_value); 61 printf(" cm_mindmp_slope: %g\n",cm_mindmp_slope); 62 printf(" cm_maxdmp_value: %g\n",cm_maxdmp_value); 63 printf(" cm_maxdmp_slope: %g\n",cm_maxdmp_slope); 64 } 65 66 #undef __FUNCT__ 67 #define __FUNCT__ "Numpar::DeepEcho" 68 void Numpar::DeepEcho(void){ 69 70 printf("Numpar:\n"); 71 printf(" id: %i\n",id); 72 printf(" meanvel: %g\n",meanvel); 73 printf(" epsvel: %g\n",epsvel); 74 printf(" artdiff: %i\n",artdiff); 75 printf(" viscosity_overshoot: %g\n",viscosity_overshoot); 76 printf(" stokesreconditioning: %g\n",stokesreconditioning); 77 printf(" control_type: %s\n",control_type); 78 printf(" cm_noisedmp: %g\n",cm_noisedmp); 79 printf(" cm_mindmp_value: %g\n",cm_mindmp_value); 80 printf(" cm_mindmp_slope: %g\n",cm_mindmp_slope); 81 printf(" cm_maxdmp_value: %g\n",cm_maxdmp_value); 82 printf(" cm_maxdmp_slope: %g\n",cm_maxdmp_slope); 83 } 84 85 49 /*}}}*/ 50 51 /*Object marshall*/ 52 /*FUNCTION Numpar::Marshall {{{1*/ 86 53 void Numpar::Marshall(char** pmarshalled_dataset){ 87 54 … … 115 82 return; 116 83 } 117 84 /*}}}*/ 85 /*FUNCTION Numpar::MarshallSize{{{1*/ 118 86 int Numpar::MarshallSize(){ 119 87 return sizeof(id) … … 131 99 +sizeof(int); //sizeof(int) for enum type 132 100 } 133 134 char* Numpar::GetName(void){ 135 return "beam"; 136 } 137 101 /*}}}*/ 102 /*FUNCTION Numpar::Demarshall {{{1*/ 138 103 void Numpar::Demarshall(char** pmarshalled_dataset){ 139 104 … … 164 129 return; 165 130 } 166 int Numpar::Enum(void){ 167 168 return NumparEnum(); 169 170 } 171 int Numpar::GetId(void){ return id; } 172 173 int Numpar::MyRank(void){ 174 extern int my_rank; 175 return my_rank; 176 } 177 178 131 /*}}}*/ 132 133 /*Object functions*/ 134 /*FUNCTION Numpar::Configure {{{1*/ 179 135 #undef __FUNCT__ 180 136 #define __FUNCT__ "Numpar::Configure" … … 202 158 return; 203 159 } 204 205 160 /*}}}*/ 161 /*FUNCTION Numpar::copy {{{1*/ 162 Object* Numpar::copy() { 163 164 return new Numpar(*this); 165 166 } 167 /*}}}*/ 168 /*FUNCTION Numpar::DeepEcho {{{1*/ 169 #undef __FUNCT__ 170 #define __FUNCT__ "Numpar::DeepEcho" 171 void Numpar::DeepEcho(void){ 172 173 printf("Numpar:\n"); 174 printf(" id: %i\n",id); 175 printf(" meanvel: %g\n",meanvel); 176 printf(" epsvel: %g\n",epsvel); 177 printf(" artdiff: %i\n",artdiff); 178 printf(" viscosity_overshoot: %g\n",viscosity_overshoot); 179 printf(" stokesreconditioning: %g\n",stokesreconditioning); 180 printf(" control_type: %s\n",control_type); 181 printf(" cm_noisedmp: %g\n",cm_noisedmp); 182 printf(" cm_mindmp_value: %g\n",cm_mindmp_value); 183 printf(" cm_mindmp_slope: %g\n",cm_mindmp_slope); 184 printf(" cm_maxdmp_value: %g\n",cm_maxdmp_value); 185 printf(" cm_maxdmp_slope: %g\n",cm_maxdmp_slope); 186 } 187 /*}}}*/ 188 /*FUNCTION Numpar::Echo{{{1*/ 189 #undef __FUNCT__ 190 #define __FUNCT__ "Numpar::Echo" 191 void Numpar::Echo(void){ 192 193 printf("Numpar:\n"); 194 printf(" id: %i\n",id); 195 printf(" meanvel: %g\n",meanvel); 196 printf(" epsvel: %g\n",epsvel); 197 printf(" artdiff: %i\n",artdiff); 198 printf(" viscosity_overshoot: %g\n",viscosity_overshoot); 199 printf(" stokesreconditioning: %g\n",stokesreconditioning); 200 printf(" control_type: %s\n",control_type); 201 printf(" cm_noisedmp: %g\n",cm_noisedmp); 202 printf(" cm_mindmp_value: %g\n",cm_mindmp_value); 203 printf(" cm_mindmp_slope: %g\n",cm_mindmp_slope); 204 printf(" cm_maxdmp_value: %g\n",cm_maxdmp_value); 205 printf(" cm_maxdmp_slope: %g\n",cm_maxdmp_slope); 206 } 207 /*}}}*/ 208 /*FUNCTION Numpar::Enum {{{1*/ 209 int Numpar::Enum(void){ 210 211 return NumparEnum(); 212 213 } 214 /*}}}*/ 215 /*FUNCTION Numpar::GetId {{{1*/ 216 int Numpar::GetId(void){ return id; } 217 /*}}}*/ 218 /*FUNCTION Numpar::GetName {{{1*/ 219 char* Numpar::GetName(void){ 220 return "beam"; 221 } 222 /*}}}*/ 223 /*FUNCTION Numpar::MyRank {{{1*/ 224 int Numpar::MyRank(void){ 225 extern int my_rank; 226 return my_rank; 227 } 228 /*}}}*/ 229 /*FUNCTION Numpar::UpdateFromInputs {{{1*/ 206 230 #undef __FUNCT__ 207 231 #define __FUNCT__ "Numpar::UpdateFromInputs" … … 227 251 228 252 } 229 230 Object* Numpar::copy() { 231 232 return new Numpar(*this); 233 234 } 235 253 /*}}}*/ -
issm/trunk/src/c/objects/Param.cpp
r2333 r2907 18 18 19 19 20 Param::Param(){ 21 stringarray=NULL; 22 doublevec=NULL; 23 doublemat=NULL; 24 vec=NULL; 25 mat=NULL; 26 27 return; 28 } 29 20 /*Object constructors and destructor*/ 21 /*FUNCTION Param::constructor {{{1*/ 30 22 #undef __FUNCT__ 31 23 #define __FUNCT__ "Param constructor" … … 47 39 48 40 } 49 41 /*}}}*/ 42 /*FUNCTION Param::creation{{{1*/ 43 Param::Param(){ 44 stringarray=NULL; 45 doublevec=NULL; 46 doublemat=NULL; 47 vec=NULL; 48 mat=NULL; 49 50 return; 51 } 52 /*}}}*/ 53 /*FUNCTION Param::destructor {{{1*/ 50 54 Param::~Param(){ 51 55 … … 93 97 } 94 98 } 95 96 #undef __FUNCT__ 97 #define __FUNCT__ "Param echo" 98 void Param::Echo(void){ 99 100 int i,j; 101 102 printf("Param:\n"); 103 printf(" id: %i\n",id); 104 printf(" name: %s\n",name); 105 106 switch(type){ 107 case STRING: 108 printf(" string value: %s\n",string); 109 break; 110 111 case STRINGARRAY: 112 printf(" string array: %i strings\n",M); 113 for(i=0;i<M;i++){ 114 printf(" %i: %s\n",i,stringarray[i]); 115 } 116 break; 117 118 case DOUBLE: 119 printf(" double value: %g\n",ddouble); 120 break; 121 122 case DOUBLEVEC: 123 /*printf(" double vector. size: %i ndof: %i\n",M,ndof); 124 for(i=0;i<M;i++)printf("%g\n",doublevec[i]);*/ 125 break; 126 127 case DOUBLEMAT: 128 printf(" double matrix. size: %i,%i\n",M,N); 129 for(i=0;i<M;i++){ 130 for(j=0;j<N;j++){ 131 printf("%g ",*(doublemat+N*i+j)); 132 } 133 printf("\n"); 134 } 135 break; 136 137 case PETSCVEC: 138 /*printf(" Petsc vector: \n"); 139 VecView(vec,PETSC_VIEWER_STDOUT_WORLD);*/ 140 break; 141 142 case PETSCMAT: 143 /*printf(" Petsc matrix: \n"); 144 MatView(mat,PETSC_VIEWER_STDOUT_WORLD);*/ 145 break; 146 147 default: 148 throw ErrorException(__FUNCT__,exprintf("%s%i","unknow parameter type ",type)); 149 } 150 } 151 152 #undef __FUNCT__ 153 #define __FUNCT__ "Param Deep Echo" 154 void Param::DeepEcho(void){ 155 156 int i,j; 157 158 printf("Param:\n"); 159 printf(" id: %i\n",id); 160 printf(" name: %s\n",name); 161 162 switch(type){ 163 case STRING: 164 printf(" string value: %s\n",string); 165 break; 166 167 case STRINGARRAY: 168 printf(" string array: %i strings\n",M); 169 for(i=0;i<M;i++){ 170 printf(" %i: %s\n",i,stringarray[i]); 171 } 172 173 case DOUBLE: 174 printf(" double value: %g\n",ddouble); 175 break; 176 177 case DOUBLEVEC: 178 printf(" double vector. size: %i ndof: %i\n",M,ndof); 179 for(i=0;i<M;i++)printf("%g\n",doublevec[i]); 180 break; 181 182 case DOUBLEMAT: 183 printf(" double matrix. size: %i,%i\n",M,N); 184 for(i=0;i<M;i++){ 185 for(j=0;j<N;j++){ 186 printf("%g ",*(doublemat+N*i+j)); 187 } 188 printf("\n"); 189 } 190 break; 191 192 case PETSCVEC: 193 printf(" Petsc vector: \n"); 194 VecView(vec,PETSC_VIEWER_STDOUT_WORLD); 195 break; 196 197 case PETSCMAT: 198 printf(" Petsc matrix: \n"); 199 MatView(mat,PETSC_VIEWER_STDOUT_WORLD); 200 break; 201 202 default: 203 throw ErrorException(__FUNCT__,exprintf("%s%i","unknow parameter type ",type)); 204 } 205 } 206 #undef __FUNCT__ 207 #define __FUNCT__ "Marshall" 208 209 void Param::Marshall(char** pmarshalled_dataset){ 210 211 char* marshalled_dataset=NULL; 212 int enum_type=0; 213 double* serial_vec=NULL; 214 double* serial_mat=NULL; 215 int i; 216 char* tempstring=NULL; 217 218 /*recover marshalled_dataset: */ 219 marshalled_dataset=*pmarshalled_dataset; 220 221 /*get enum type of Param: */ 222 enum_type=ParamEnum(); 223 224 /*marshall enum: */ 225 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 226 227 /*marshall Param data: */ 228 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 229 memcpy(marshalled_dataset,&name,sizeof(name));marshalled_dataset+=sizeof(name); 230 memcpy(marshalled_dataset,&type,sizeof(type));marshalled_dataset+=sizeof(type); 231 memcpy(marshalled_dataset,&ndof,sizeof(ndof));marshalled_dataset+=sizeof(ndof); 232 233 switch(type){ 234 case STRING: 235 memcpy(marshalled_dataset,&string,sizeof(string));marshalled_dataset+=sizeof(string); 236 break; 237 238 case STRINGARRAY: 239 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 240 for(i=0;i<M;i++){ 241 tempstring=stringarray[i]; 242 int size=(strlen(tempstring)+1)*sizeof(char); 243 memcpy(marshalled_dataset,&size,sizeof(size));marshalled_dataset+=sizeof(size); 244 memcpy(marshalled_dataset,tempstring,size);marshalled_dataset+=size; 245 } 246 break; 247 248 case DOUBLE: 249 memcpy(marshalled_dataset,&ddouble,sizeof(ddouble));marshalled_dataset+=sizeof(ddouble); 250 break; 251 case DOUBLEVEC: 252 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 253 if(M){ 254 memcpy(marshalled_dataset,doublevec,M*sizeof(double)); 255 marshalled_dataset+=(M*sizeof(double)); 256 } 257 break; 258 259 case DOUBLEMAT: 260 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 261 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 262 if(M*N){ 263 memcpy(marshalled_dataset,doublemat,M*N*sizeof(double)); 264 marshalled_dataset+=(M*N*sizeof(double)); 265 } 266 break; 267 268 case PETSCVEC: 269 if(vec){ 270 VecGetSize(vec,&M); 271 VecToMPISerial(&serial_vec,vec); 272 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 273 memcpy(marshalled_dataset,serial_vec,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 274 xfree((void**)&serial_vec); 275 } 276 else{ 277 M=0; 278 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 279 } 280 break; 281 282 case PETSCMAT: 283 if(mat){ 284 MatGetSize(mat,&M,&N); 285 MatToSerial(&serial_mat,mat); 286 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 287 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 288 memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 289 xfree((void**)&serial_mat); 290 } 291 else{ 292 M=0; 293 N=0; 294 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 295 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 296 } 297 break; 298 299 default: 300 throw ErrorException(__FUNCT__,exprintf("%s%i","unknown parameter type",type)); 301 break; 302 } 303 304 *pmarshalled_dataset=marshalled_dataset; 305 return; 306 } 307 308 int Param::MarshallSize(){ 309 310 int size; 311 int i; 312 char* tempstring=NULL; 313 314 size=sizeof(id)+ 315 sizeof(name)+ 316 sizeof(type)+ 317 sizeof(ndof)+ 318 sizeof(int); //sizeof(int) for enum type 319 320 switch(type){ 321 case STRING: 322 size+=sizeof(string); 323 break; 324 325 case STRINGARRAY: 326 size+=sizeof(M); 327 for(i=0;i<M;i++){ 328 tempstring=stringarray[i]; 329 size+=sizeof(M); 330 size+=(strlen(tempstring)+1)*sizeof(char); 331 } 332 break; 333 334 case DOUBLE: 335 size+= sizeof(ddouble); 336 break; 337 case DOUBLEVEC: 338 size+= sizeof(M)+M*sizeof(double); 339 break; 340 341 case DOUBLEMAT: 342 size+= sizeof(M)+sizeof(N)+M*N*sizeof(double); 343 break; 344 345 case PETSCVEC: 346 size+= sizeof(M)+M*sizeof(double); 347 break; 348 349 case PETSCMAT: 350 size+= sizeof(M)+sizeof(N)+M*N*sizeof(double); 351 break; 352 353 default: 354 throw ErrorException(__FUNCT__,exprintf("%s%i","unknown parameter type",type)); 355 } 356 357 return size; 358 } 359 360 char* Param::GetName(void){ 361 return "param"; 362 } 363 364 99 /*}}}*/ 100 101 /*Object marshall*/ 102 /*FUNCTION Param::Demarshall {{{1*/ 365 103 void Param::Demarshall(char** pmarshalled_dataset){ 366 104 … … 481 219 return; 482 220 } 483 484 221 /*}}}*/ 222 /*FUNCTION Param::Marshall {{{1*/ 223 #undef __FUNCT__ 224 #define __FUNCT__ "Marshall" 225 226 void Param::Marshall(char** pmarshalled_dataset){ 227 228 char* marshalled_dataset=NULL; 229 int enum_type=0; 230 double* serial_vec=NULL; 231 double* serial_mat=NULL; 232 int i; 233 char* tempstring=NULL; 234 235 /*recover marshalled_dataset: */ 236 marshalled_dataset=*pmarshalled_dataset; 237 238 /*get enum type of Param: */ 239 enum_type=ParamEnum(); 240 241 /*marshall enum: */ 242 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 243 244 /*marshall Param data: */ 245 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 246 memcpy(marshalled_dataset,&name,sizeof(name));marshalled_dataset+=sizeof(name); 247 memcpy(marshalled_dataset,&type,sizeof(type));marshalled_dataset+=sizeof(type); 248 memcpy(marshalled_dataset,&ndof,sizeof(ndof));marshalled_dataset+=sizeof(ndof); 249 250 switch(type){ 251 case STRING: 252 memcpy(marshalled_dataset,&string,sizeof(string));marshalled_dataset+=sizeof(string); 253 break; 254 255 case STRINGARRAY: 256 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 257 for(i=0;i<M;i++){ 258 tempstring=stringarray[i]; 259 int size=(strlen(tempstring)+1)*sizeof(char); 260 memcpy(marshalled_dataset,&size,sizeof(size));marshalled_dataset+=sizeof(size); 261 memcpy(marshalled_dataset,tempstring,size);marshalled_dataset+=size; 262 } 263 break; 264 265 case DOUBLE: 266 memcpy(marshalled_dataset,&ddouble,sizeof(ddouble));marshalled_dataset+=sizeof(ddouble); 267 break; 268 case DOUBLEVEC: 269 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 270 if(M){ 271 memcpy(marshalled_dataset,doublevec,M*sizeof(double)); 272 marshalled_dataset+=(M*sizeof(double)); 273 } 274 break; 275 276 case DOUBLEMAT: 277 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 278 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 279 if(M*N){ 280 memcpy(marshalled_dataset,doublemat,M*N*sizeof(double)); 281 marshalled_dataset+=(M*N*sizeof(double)); 282 } 283 break; 284 285 case PETSCVEC: 286 if(vec){ 287 VecGetSize(vec,&M); 288 VecToMPISerial(&serial_vec,vec); 289 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 290 memcpy(marshalled_dataset,serial_vec,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 291 xfree((void**)&serial_vec); 292 } 293 else{ 294 M=0; 295 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 296 } 297 break; 298 299 case PETSCMAT: 300 if(mat){ 301 MatGetSize(mat,&M,&N); 302 MatToSerial(&serial_mat,mat); 303 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 304 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 305 memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 306 xfree((void**)&serial_mat); 307 } 308 else{ 309 M=0; 310 N=0; 311 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 312 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 313 } 314 break; 315 316 default: 317 throw ErrorException(__FUNCT__,exprintf("%s%i","unknown parameter type",type)); 318 break; 319 } 320 321 *pmarshalled_dataset=marshalled_dataset; 322 return; 323 } 324 /*}}}*/ 325 /*FUNCTION Param::MarshallSize {{{1*/ 326 int Param::MarshallSize(){ 327 328 int size; 329 int i; 330 char* tempstring=NULL; 331 332 size=sizeof(id)+ 333 sizeof(name)+ 334 sizeof(type)+ 335 sizeof(ndof)+ 336 sizeof(int); //sizeof(int) for enum type 337 338 switch(type){ 339 case STRING: 340 size+=sizeof(string); 341 break; 342 343 case STRINGARRAY: 344 size+=sizeof(M); 345 for(i=0;i<M;i++){ 346 tempstring=stringarray[i]; 347 size+=sizeof(M); 348 size+=(strlen(tempstring)+1)*sizeof(char); 349 } 350 break; 351 352 case DOUBLE: 353 size+= sizeof(ddouble); 354 break; 355 case DOUBLEVEC: 356 size+= sizeof(M)+M*sizeof(double); 357 break; 358 359 case DOUBLEMAT: 360 size+= sizeof(M)+sizeof(N)+M*N*sizeof(double); 361 break; 362 363 case PETSCVEC: 364 size+= sizeof(M)+M*sizeof(double); 365 break; 366 367 case PETSCMAT: 368 size+= sizeof(M)+sizeof(N)+M*N*sizeof(double); 369 break; 370 371 default: 372 throw ErrorException(__FUNCT__,exprintf("%s%i","unknown parameter type",type)); 373 } 374 375 return size; 376 } 377 /*}}}*/ 378 379 /*Object functions*/ 380 /*FUNCTION Param::copy {{{1*/ 381 Object* Param::copy() { 382 return new Param(*this); 383 } 384 /*}}}*/ 385 /*FUNCTION Param::Echo {{{1*/ 386 #undef __FUNCT__ 387 #define __FUNCT__ "Param echo" 388 void Param::Echo(void){ 389 390 int i,j; 391 392 printf("Param:\n"); 393 printf(" id: %i\n",id); 394 printf(" name: %s\n",name); 395 396 switch(type){ 397 case STRING: 398 printf(" string value: %s\n",string); 399 break; 400 401 case STRINGARRAY: 402 printf(" string array: %i strings\n",M); 403 for(i=0;i<M;i++){ 404 printf(" %i: %s\n",i,stringarray[i]); 405 } 406 break; 407 408 case DOUBLE: 409 printf(" double value: %g\n",ddouble); 410 break; 411 412 case DOUBLEVEC: 413 /*printf(" double vector. size: %i ndof: %i\n",M,ndof); 414 for(i=0;i<M;i++)printf("%g\n",doublevec[i]);*/ 415 break; 416 417 case DOUBLEMAT: 418 printf(" double matrix. size: %i,%i\n",M,N); 419 for(i=0;i<M;i++){ 420 for(j=0;j<N;j++){ 421 printf("%g ",*(doublemat+N*i+j)); 422 } 423 printf("\n"); 424 } 425 break; 426 427 case PETSCVEC: 428 /*printf(" Petsc vector: \n"); 429 VecView(vec,PETSC_VIEWER_STDOUT_WORLD);*/ 430 break; 431 432 case PETSCMAT: 433 /*printf(" Petsc matrix: \n"); 434 MatView(mat,PETSC_VIEWER_STDOUT_WORLD);*/ 435 break; 436 437 default: 438 throw ErrorException(__FUNCT__,exprintf("%s%i","unknow parameter type ",type)); 439 } 440 } 441 /*}}}*/ 442 /*FUNCTION Param::Enum {{{1*/ 485 443 int Param::Enum(void){ 486 444 487 445 return ParamEnum(); 488 446 } 489 447 /*}}}*/ 448 /*FUNCTION Param::DeepEcho {{{1*/ 449 #undef __FUNCT__ 450 #define __FUNCT__ "Param Deep Echo" 451 void Param::DeepEcho(void){ 452 453 int i,j; 454 455 printf("Param:\n"); 456 printf(" id: %i\n",id); 457 printf(" name: %s\n",name); 458 459 switch(type){ 460 case STRING: 461 printf(" string value: %s\n",string); 462 break; 463 464 case STRINGARRAY: 465 printf(" string array: %i strings\n",M); 466 for(i=0;i<M;i++){ 467 printf(" %i: %s\n",i,stringarray[i]); 468 } 469 470 case DOUBLE: 471 printf(" double value: %g\n",ddouble); 472 break; 473 474 case DOUBLEVEC: 475 printf(" double vector. size: %i ndof: %i\n",M,ndof); 476 for(i=0;i<M;i++)printf("%g\n",doublevec[i]); 477 break; 478 479 case DOUBLEMAT: 480 printf(" double matrix. size: %i,%i\n",M,N); 481 for(i=0;i<M;i++){ 482 for(j=0;j<N;j++){ 483 printf("%g ",*(doublemat+N*i+j)); 484 } 485 printf("\n"); 486 } 487 break; 488 489 case PETSCVEC: 490 printf(" Petsc vector: \n"); 491 VecView(vec,PETSC_VIEWER_STDOUT_WORLD); 492 break; 493 494 case PETSCMAT: 495 printf(" Petsc matrix: \n"); 496 MatView(mat,PETSC_VIEWER_STDOUT_WORLD); 497 break; 498 499 default: 500 throw ErrorException(__FUNCT__,exprintf("%s%i","unknow parameter type ",type)); 501 } 502 } 503 /*}}}*/ 504 /*FUNCTION Param::DistributeNumDofs {{{1*/ 505 void Param::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 506 /*}}}*/ 507 /*FUNCTION Param::GetM {{{1*/ 508 int Param::GetM(){ 509 return M; 510 } 511 /*}}}*/ 512 /*FUNCTION Param::GetN {{{1*/ 513 int Param::GetN(){ 514 return N; 515 } 516 /*}}}*/ 517 /*FUNCTION Param::GetNdof {{{1*/ 518 int Param::GetNdof(){ 519 return ndof; 520 } 521 /*}}}*/ 522 /*FUNCTION Param::GetParameterValue(Mat* pmat) {{{1*/ 523 #undef __FUNCT__ 524 #define __FUNCT__ "GetParameterValue" 525 526 void Param::GetParameterValue(Mat* pmat){ 527 528 Mat outmat=NULL; 529 530 if(type!=PETSCMAT) throw ErrorException(__FUNCT__,exprintf("%s%i"," error message: trying to recover a Petsc mat from a param with type",type)); 531 532 if(mat){ 533 MatDuplicate(mat,MAT_COPY_VALUES,&outmat); 534 } 535 *pmat=outmat; 536 } 537 /*}}}*/ 538 /*FUNCTION Param::GetName {{{1*/ 539 char* Param::GetName(void){ 540 return "param"; 541 } 542 /*}}}*/ 543 /*FUNCTION Param::GetParameterName {{{1*/ 490 544 char* Param::GetParameterName(void){ 491 545 return name; 492 546 } 493 547 /*}}}*/ 548 /*FUNCTION Param::GetParameterValue(double* pdouble) {{{1*/ 494 549 #undef __FUNCT__ 495 550 #define __FUNCT__ "GetParameterValue" … … 499 554 *pdouble=ddouble; 500 555 } 501 556 /*}}}*/ 557 /*FUNCTION Param::GetParameterValue(int* pinteger) {{{1*/ 502 558 #undef __FUNCT__ 503 559 #define __FUNCT__ "GetParameterValue" … … 507 563 *pinteger=(int)ddouble; 508 564 } 509 565 /*}}}*/ 566 /*FUNCTION Param::GetParameterValue(char** pstring) {{{1*/ 510 567 #undef __FUNCT__ 511 568 #define __FUNCT__ "GetParameterValue" … … 520 577 521 578 } 522 579 /*}}}*/ 580 /*FUNCTION Param::GetParameterValue(char*** pstringarray) {{{1*/ 523 581 #undef __FUNCT__ 524 582 #define __FUNCT__ "GetParameterValue" … … 537 595 *pstringarray=outstringarray; 538 596 } 539 597 /*}}}*/ 598 /*FUNCTION Param::GetParameterValue(double** pdoublearray) {{{1*/ 540 599 #undef __FUNCT__ 541 600 #define __FUNCT__ "GetParameterValue" … … 566 625 *pdoublearray=outdoublearray; 567 626 } 568 627 /*}}}*/ 628 /*FUNCTION Param::GetParameterValue(Vec* pvec) {{{1*/ 569 629 #undef __FUNCT__ 570 630 #define __FUNCT__ "GetParameterValue" … … 581 641 *pvec=outvec; 582 642 } 583 584 #undef __FUNCT__ 585 #define __FUNCT__ "GetParameterValue" 586 587 void Param::GetParameterValue(Mat* pmat){ 588 589 Mat outmat=NULL; 590 591 if(type!=PETSCMAT) throw ErrorException(__FUNCT__,exprintf("%s%i"," error message: trying to recover a Petsc mat from a param with type",type)); 592 593 if(mat){ 594 MatDuplicate(mat,MAT_COPY_VALUES,&outmat); 595 } 596 *pmat=outmat; 597 } 598 643 /*}}}*/ 644 /*FUNCTION Param::GetId {{{1*/ 599 645 int Param::GetId(void){ return id; } 600 646 /*}}}*/ 647 /*FUNCTION Param::GetType {{{1*/ 648 int Param::GetType(){ 649 return type; 650 } 651 /*}}}*/ 652 /*FUNCTION Param::MyRank {{{1*/ 601 653 int Param::MyRank(void){ 602 654 extern int my_rank; 603 655 return my_rank; 604 656 } 605 606 void Param::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 607 608 609 int Param::GetType(){ 610 return type; 611 } 612 613 Object* Param::copy() { 614 return new Param(*this); 615 } 616 657 /*}}}*/ 658 /*FUNCTION Param::SetDouble(double value) {{{1*/ 617 659 #undef __FUNCT__ 618 660 #define __FUNCT__ "SetDouble" … … 621 663 ddouble=value; 622 664 } 623 665 /*}}}*/ 666 /*FUNCTION Param::SetDouble(int value) {{{1*/ 624 667 #undef __FUNCT__ 625 668 #define __FUNCT__ "SetDouble" … … 628 671 ddouble=(double)value; 629 672 } 630 631 673 /*}}}*/ 674 /*FUNCTION Param::SetDoubleMat {{{1*/ 675 #undef __FUNCT__ 676 #define __FUNCT__ "SetDoubleMat" 677 void Param::SetDoubleMat(double* value,int pM,int pN){ 678 679 if (type!=DOUBLEMAT) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublematrix type",type)); 680 681 this->M=pM; 682 this->N=pN; 683 if(this->M*this->N){ 684 xfree((void**)&doublemat); doublemat=(double*)xcalloc(M*N,sizeof(double)); 685 memcpy(doublemat,value,M*N*sizeof(double)); 686 } 687 } 688 /*}}}*/ 689 /*FUNCTION Param::SetDoubleVec(double* value,int size) {{{1*/ 690 #undef __FUNCT__ 691 #define __FUNCT__ "SetDoubleVec" 692 void Param::SetDoubleVec(double* value,int size){ 693 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublevecfor type",type)); 694 695 M=size; 696 if(M){ 697 xfree((void**)&doublevec); doublevec=(double*)xmalloc(M*sizeof(double)); 698 memcpy(doublevec,value,M*sizeof(double)); 699 } 700 ndof=0; //this vector will not be repartitioned. 701 702 } 703 /*}}}*/ 704 /*FUNCTION Param::SetDoubleVec(double* value,int size, int numberofdofs) {{{1*/ 705 #undef __FUNCT__ 706 #define __FUNCT__ "SetDoubleVec" 707 void Param::SetDoubleVec(double* value,int size, int numberofdofs){ 708 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublevecfor type",type)); 709 710 M=size; 711 if(M){ 712 xfree((void**)&doublevec); doublevec=(double*)xmalloc(M*sizeof(double)); 713 memcpy(doublevec,value,M*sizeof(double)); 714 } 715 ndof=numberofdofs; 716 } 717 /*}}}*/ 718 /*FUNCTION Param::SetString {{{1*/ 632 719 #undef __FUNCT__ 633 720 #define __FUNCT__ "SetString" … … 636 723 strcpy(string,value); 637 724 } 638 725 /*}}}*/ 726 /*FUNCTION Param::SetStringArray {{{1*/ 639 727 #undef __FUNCT__ 640 728 #define __FUNCT__ "SetStringArray" … … 651 739 } 652 740 } 653 654 655 int Param::GetM(){ 656 return M; 657 } 658 659 int Param::GetNdof(){ 660 return ndof; 661 } 662 663 int Param::GetN(){ 664 return N; 665 } 666 667 #undef __FUNCT__ 668 #define __FUNCT__ "SetDoubleVec" 669 void Param::SetDoubleVec(double* value,int size){ 670 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublevecfor type",type)); 671 672 M=size; 673 if(M){ 674 xfree((void**)&doublevec); doublevec=(double*)xmalloc(M*sizeof(double)); 675 memcpy(doublevec,value,M*sizeof(double)); 676 } 677 ndof=0; //this vector will not be repartitioned. 678 679 } 680 681 #undef __FUNCT__ 682 #define __FUNCT__ "SetDoubleVec" 683 void Param::SetDoubleVec(double* value,int size, int numberofdofs){ 684 if (type!=DOUBLEVEC) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublevecfor type",type)); 685 686 M=size; 687 if(M){ 688 xfree((void**)&doublevec); doublevec=(double*)xmalloc(M*sizeof(double)); 689 memcpy(doublevec,value,M*sizeof(double)); 690 } 691 ndof=numberofdofs; 692 } 693 694 741 /*}}}*/ 742 /*FUNCTION Param::SetVec {{{1*/ 695 743 #undef __FUNCT__ 696 744 #define __FUNCT__ "SetVec" … … 710 758 711 759 } 712 713 714 #undef __FUNCT__ 715 #define __FUNCT__ "SetDoubleMat" 716 void Param::SetDoubleMat(double* value,int pM,int pN){ 717 718 if (type!=DOUBLEMAT) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set doublematrix type",type)); 719 720 this->M=pM; 721 this->N=pN; 722 if(this->M*this->N){ 723 xfree((void**)&doublemat); doublemat=(double*)xcalloc(M*N,sizeof(double)); 724 memcpy(doublemat,value,M*N*sizeof(double)); 725 } 726 } 760 /*}}}*/ -
issm/trunk/src/c/objects/ParameterInputs.cpp
r2333 r2907 18 18 #include "./objects.h" 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION ParameterInputs::constructor {{{1*/ 20 22 ParameterInputs::ParameterInputs(){ 21 23 … … 23 25 24 26 } 25 27 /*}}}*/ 28 /*FUNCTION ParameterInputs::destructor {{{1*/ 26 29 ParameterInputs::~ParameterInputs(){ 27 30 … … 29 32 30 33 } 31 34 /*}}}*/ 35 /*FUNCTION ParameterInputs::purge {{{1*/ 36 void ParameterInputs::purge(char* name){ 37 38 int i; 39 Input* input=NULL; 40 41 /*Go through dataset, and figure out if an Input 42 * already has the name "name". If so, delete it : */ 43 44 for(i=0;i<dataset->Size();i++){ 45 input=(Input*)dataset->GetObjectByOffset(i); 46 47 if (input->IsSameName(name)){ 48 /*delete object: */ 49 dataset->DeleteObject(input); 50 } 51 } 52 } 53 /*}}}*/ 54 55 /*Object functions*/ 56 /*FUNCTION ParameterInputs::Add(char* name,char* string) {{{1*/ 57 void ParameterInputs::Add(char* name,char* string){ 58 59 Input* input=NULL; 60 61 /*First, purge object with same name: */ 62 this->purge(name); 63 64 /*We are sure an input of the same name does not exist. Create new 65 * input: */ 66 input=new Input(name,string); 67 68 /*Add input to dataset: */ 69 dataset->AddObject(input); 70 71 } 72 /*}}}*/ 73 /*FUNCTION ParameterInputs::Add(char* name,int integer) {{{1*/ 74 void ParameterInputs::Add(char* name,int integer){ 75 76 Input* input=NULL; 77 78 /*First, purge object with same name: */ 79 this->purge(name); 80 81 /*We are sure an input of the same name does not exist. Create new 82 * input: */ 83 input=new Input(name,integer); 84 85 /*Add input to dataset: */ 86 dataset->AddObject(input); 87 } 88 /*}}}*/ 89 /*FUNCTION ParameterInputs::Add(char* name,double scalar) {{{1*/ 90 void ParameterInputs::Add(char* name,double scalar){ 91 92 Input* input=NULL; 93 94 /*First, purge object with same name: */ 95 this->purge(name); 96 97 /*We are sure an input of the same name does not exist. Create new 98 * input: */ 99 input=new Input(name,scalar); 100 101 /*Add input to dataset: */ 102 dataset->AddObject(input); 103 104 } 105 /*}}}*/ 106 /*FUNCTION ParameterInputs::Add(char* name,double* vector,int ndof,int numberofnodes) {{{1*/ 107 void ParameterInputs::Add(char* name,double* vector,int ndof,int numberofnodes){ 108 109 Input* input=NULL; 110 111 /*First, purge object with same name: */ 112 this->purge(name); 113 114 /*We are sure an input of the same name does not exist. Create new 115 * input: */ 116 input=new Input(name,vector,ndof,numberofnodes); 117 118 /*Add input to dataset: */ 119 dataset->AddObject(input); 120 121 } 122 /*}}}*/ 123 /*FUNCTION ParameterInputs::Add(char* name,Vec petscvector,int ndof, int numberofnodes) {{{1*/ 124 void ParameterInputs::Add(char* name,Vec petscvector,int ndof, int numberofnodes){ 125 126 Input* input=NULL; 127 128 /*First, purge object with same name: */ 129 this->purge(name); 130 131 /*We are sure an input of the same name does not exist. Create new 132 * input: */ 133 input=new Input(name,petscvector,ndof,numberofnodes); 134 135 /*Add input to dataset: */ 136 dataset->AddObject(input); 137 138 } 139 /*}}}*/ 140 /*FUNCTION ParameterInputs::DeepEcho {{{1*/ 141 void ParameterInputs::DeepEcho(){ 142 143 printf("ParameterInputs echo: \n"); 144 dataset->DeepEcho(); 145 146 } 147 /*}}}*/ 148 /*FUNCTION ParameterInputs::Echo {{{1*/ 32 149 void ParameterInputs::Echo(){ 33 150 … … 36 153 37 154 } 38 39 void ParameterInputs::DeepEcho(){ 40 41 printf("ParameterInputs echo: \n"); 42 dataset->DeepEcho(); 43 44 } 45 void ParameterInputs::purge(char* name){ 46 47 int i; 48 Input* input=NULL; 49 50 /*Go through dataset, and figure out if an Input 51 * already has the name "name". If so, delete it : */ 52 53 for(i=0;i<dataset->Size();i++){ 54 input=(Input*)dataset->GetObjectByOffset(i); 55 56 if (input->IsSameName(name)){ 57 /*delete object: */ 58 dataset->DeleteObject(input); 59 } 60 } 61 } 62 63 64 void ParameterInputs::Add(char* name,char* string){ 65 66 Input* input=NULL; 67 68 /*First, purge object with same name: */ 69 this->purge(name); 70 71 /*We are sure an input of the same name does not exist. Create new 72 * input: */ 73 input=new Input(name,string); 74 75 /*Add input to dataset: */ 76 dataset->AddObject(input); 77 78 } 79 80 void ParameterInputs::Add(char* name,int integer){ 81 82 Input* input=NULL; 83 84 /*First, purge object with same name: */ 85 this->purge(name); 86 87 /*We are sure an input of the same name does not exist. Create new 88 * input: */ 89 input=new Input(name,integer); 90 91 /*Add input to dataset: */ 92 dataset->AddObject(input); 93 } 94 95 96 void ParameterInputs::Add(char* name,double scalar){ 97 98 Input* input=NULL; 99 100 /*First, purge object with same name: */ 101 this->purge(name); 102 103 /*We are sure an input of the same name does not exist. Create new 104 * input: */ 105 input=new Input(name,scalar); 106 107 /*Add input to dataset: */ 108 dataset->AddObject(input); 109 110 } 111 112 void ParameterInputs::Add(char* name,double* vector,int ndof,int numberofnodes){ 113 114 Input* input=NULL; 115 116 /*First, purge object with same name: */ 117 this->purge(name); 118 119 /*We are sure an input of the same name does not exist. Create new 120 * input: */ 121 input=new Input(name,vector,ndof,numberofnodes); 122 123 /*Add input to dataset: */ 124 dataset->AddObject(input); 125 126 } 127 128 void ParameterInputs::Add(char* name,Vec petscvector,int ndof, int numberofnodes){ 129 130 Input* input=NULL; 131 132 /*First, purge object with same name: */ 133 this->purge(name); 134 135 /*We are sure an input of the same name does not exist. Create new 136 * input: */ 137 input=new Input(name,petscvector,ndof,numberofnodes); 138 139 /*Add input to dataset: */ 140 dataset->AddObject(input); 141 142 } 155 /*}}}*/ 156 /*FUNCTION ParameterInputs::Get {{{1*/ 157 #undef __FUNCT__ 158 #define __FUNCT__ "ParameterInputs::Get" 159 Vec ParameterInputs::Get(char* name,int* dofs, int numdofs){ 160 161 int i; 162 Input* input=NULL; 163 int found=0; 164 165 /*output: */ 166 Vec ug=NULL; 167 168 /*Go through dataset, and figure out if an Input 169 * has the name "name": */ 170 for(i=0;i<dataset->Size();i++){ 171 input=(Input*)dataset->GetObjectByOffset(i); 172 173 if (input->IsSameName(name)){ 174 found=1; 175 break; 176 } 177 } 178 179 if(found==0)return NULL; 180 181 /*call submethod: */ 182 ug=input->Get(dofs,numdofs); 183 184 return ug; 185 } 186 /*}}}*/ 187 /*FUNCTION ParameterInputs::Recover(char* name, char** pstring) {{{1*/ 143 188 int ParameterInputs::Recover(char* name, char** pstring){ 144 189 … … 165 210 166 211 } 212 /*}}}*/ 213 /*FUNCTION ParameterInputs::Recover(char* name, int* pinteger) {{{1*/ 167 214 int ParameterInputs::Recover(char* name, int* pinteger){ 168 215 … … 190 237 return found; 191 238 } 239 /*}}}*/ 240 /*FUNCTION ParameterInputs::Recover(char* name, double* pscalar) {{{1*/ 192 241 int ParameterInputs::Recover(char* name, double* pscalar){ 193 242 … … 216 265 217 266 } 218 267 /*}}}*/ 268 /*FUNCTION ParameterInputs::Recover(char* name,double* values, int ndof, int* dofs,int numnodes,void** pnodes) {{{1*/ 219 269 #undef __FUNCT__ 220 270 #define __FUNCT__ "ParameterInputs::Recover" … … 246 296 return 1; 247 297 } 248 249 #undef __FUNCT__ 250 #define __FUNCT__ "ParameterInputs::Get" 251 Vec ParameterInputs::Get(char* name,int* dofs, int numdofs){ 252 253 int i; 254 Input* input=NULL; 255 int found=0; 256 257 /*output: */ 258 Vec ug=NULL; 259 260 /*Go through dataset, and figure out if an Input 261 * has the name "name": */ 262 for(i=0;i<dataset->Size();i++){ 263 input=(Input*)dataset->GetObjectByOffset(i); 264 265 if (input->IsSameName(name)){ 266 found=1; 267 break; 268 } 269 } 270 271 if(found==0)return NULL; 272 273 /*call submethod: */ 274 ug=input->Get(dofs,numdofs); 275 276 return ug; 277 } 278 298 /*}}}*/ 299 /*FUNCTION ParameterInputs::UpdateFromDakota {{{1*/ 279 300 #undef __FUNCT__ 280 301 #define __FUNCT__ "ParameterInputs::UpdateFromDakota" … … 359 380 360 381 } 382 /*}}}*/ -
issm/trunk/src/c/objects/Pengrid.cpp
r2342 r2907 18 18 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Pengrid::constructor {{{1*/ 20 22 Pengrid::Pengrid(){ 21 23 return; 22 24 } 23 25 /*}}}1*/ 26 /*FUNCTION Pengrid::creation {{{1*/ 24 27 Pengrid::Pengrid(int pengrid_id, int pengrid_node_id,int pengrid_mparid, int pengrid_dof, int pengrid_active, double pengrid_penalty_offset,int pengrid_thermal_steadystate,int pengrid_stabilize_constraints){ 25 28 … … 42 45 return; 43 46 } 44 47 /*}}}1*/ 48 /*FUNCTION Pengrid::destructor {{{1*/ 45 49 Pengrid::~Pengrid(){ 46 50 return; 47 51 } 48 49 void Pengrid::Echo(void){ 50 51 printf("Pengrid:\n"); 52 printf(" id: %i\n",id); 53 printf(" mparid: %i\n",mparid); 54 printf(" dof: %i\n",dof); 55 printf(" active: %i\n",active); 56 printf(" penalty_offset: %g\n",penalty_offset); 57 printf(" thermal_steadystate: %i\n",thermal_steadystate); 58 printf(" node_id: [%i]\n",node_id); 59 printf(" node_offset: [%i]\n",node_offset); 60 printf(" matpar_offset=%i\n",matpar_offset); 61 62 return; 63 } 64 void Pengrid::DeepEcho(void){ 65 66 printf("Pengrid:\n"); 67 printf(" id: %i\n",id); 68 printf(" mparid: %i\n",mparid); 69 printf(" dof: %i\n",dof); 70 printf(" active: %i\n",active); 71 printf(" penalty_offset: %g\n",penalty_offset); 72 printf(" thermal_steadystate: %i\n",thermal_steadystate); 73 printf(" node_id: [%i]\n",node_id); 74 printf(" node_offset: [%i]\n",node_offset); 75 printf(" matpar_offset=%i\n",matpar_offset); 76 77 if(node)node->Echo(); 78 if(matpar)matpar->Echo(); 79 return; 80 } 52 /*}}}1*/ 53 54 /*Object marshall*/ 55 /*FUNCTION Pengrid::Marshall {{{1*/ 81 56 void Pengrid::Marshall(char** pmarshalled_dataset){ 82 57 … … 110 85 return; 111 86 } 112 87 /*}}}1*/ 88 /*FUNCTION Pengrid::MarshallSize {{{1*/ 113 89 int Pengrid::MarshallSize(){ 114 90 … … 127 103 sizeof(int); //sizeof(int) for enum type 128 104 } 129 130 char* Pengrid::GetName(void){ 131 return "pengrid"; 132 } 133 134 105 /*}}}1*/ 106 /*FUNCTION Pengrid::Demarshall {{{1*/ 135 107 void Pengrid::Demarshall(char** pmarshalled_dataset){ 136 108 … … 163 135 return; 164 136 } 137 /*}}}1*/ 138 139 /*Object functions*/ 140 /*FUNCTION Pengrid::copy {{{1*/ 141 Object* Pengrid::copy() { 142 return new Pengrid(*this); 143 } 144 /*}}}1*/ 145 /*FUNCTION Pengrid::Configure {{{1*/ 146 #undef __FUNCT__ 147 #define __FUNCT__ "Pengrid::Configure" 148 149 void Pengrid::Configure(void* pelementsin,void* pnodesin,void* pmaterialsin){ 150 151 DataSet* nodesin=NULL; 152 DataSet* materialsin=NULL; 153 154 /*Recover pointers :*/ 155 nodesin=(DataSet*)pnodesin; 156 materialsin=(DataSet*)pmaterialsin; 157 158 /*Link this load with its nodes: */ 159 ResolvePointers((Object**)&node,&node_id,&node_offset,1,nodesin); 160 ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin); 161 } 162 /*}}}1*/ 163 /*FUNCTION Pengrid::CreateKMatrix {{{1*/ 164 #undef __FUNCT__ 165 #define __FUNCT__ "Pengrid::CreateKMatrix" 166 167 void Pengrid::CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type){ 168 169 /*No loads applied, do nothing: */ 170 return; 171 172 } 173 /*}}}1*/ 174 /*FUNCTION Pengrid::CreatePVector {{{1*/ 175 #undef __FUNCT__ 176 #define __FUNCT__ "Pengrid::CreatePVector" 177 void Pengrid::CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type){ 178 179 /*No loads applied, do nothing: */ 180 return; 181 182 } 183 /*}}}1*/ 184 /*FUNCTION Pengrid::DeepEcho {{{1*/ 185 void Pengrid::DeepEcho(void){ 186 187 printf("Pengrid:\n"); 188 printf(" id: %i\n",id); 189 printf(" mparid: %i\n",mparid); 190 printf(" dof: %i\n",dof); 191 printf(" active: %i\n",active); 192 printf(" penalty_offset: %g\n",penalty_offset); 193 printf(" thermal_steadystate: %i\n",thermal_steadystate); 194 printf(" node_id: [%i]\n",node_id); 195 printf(" node_offset: [%i]\n",node_offset); 196 printf(" matpar_offset=%i\n",matpar_offset); 197 198 if(node)node->Echo(); 199 if(matpar)matpar->Echo(); 200 return; 201 } 202 /*}}}1*/ 203 /*FUNCTION Pengrid::DistributenumDofs {{{1*/ 204 void Pengrid::DistributeNumDofs(int* numdofpernode,int analysis_type,int sub_analysis_type){return;} 205 /*}}}1*/ 206 /*FUNCTION Pengrid::Echo {{{1*/ 207 void Pengrid::Echo(void){ 208 209 printf("Pengrid:\n"); 210 printf(" id: %i\n",id); 211 printf(" mparid: %i\n",mparid); 212 printf(" dof: %i\n",dof); 213 printf(" active: %i\n",active); 214 printf(" penalty_offset: %g\n",penalty_offset); 215 printf(" thermal_steadystate: %i\n",thermal_steadystate); 216 printf(" node_id: [%i]\n",node_id); 217 printf(" node_offset: [%i]\n",node_offset); 218 printf(" matpar_offset=%i\n",matpar_offset); 219 220 return; 221 } 222 /*}}}1*/ 223 /*FUNCTION Pengrid::Enum {{{1*/ 165 224 int Pengrid::Enum(void){ 166 225 167 226 return PengridEnum(); 168 227 } 169 228 /*}}}1*/ 229 /*FUNCTION Pengrid::GetDofList {{{1*/ 230 void Pengrid::GetDofList(int* doflist,int* pnumberofdofspernode){ 231 232 int j; 233 int doflist_per_node[MAXDOFSPERNODE]; 234 int numberofdofspernode; 235 236 node->GetDofList(&doflist_per_node[0],&numberofdofspernode); 237 for(j=0;j<numberofdofspernode;j++){ 238 doflist[j]=doflist_per_node[j]; 239 } 240 241 /*Assign output pointers:*/ 242 *pnumberofdofspernode=numberofdofspernode; 243 } 244 /*}}}1*/ 245 /*FUNCTION Pengrid::GetId {{{1*/ 170 246 int Pengrid::GetId(void){ return id; } 171 247 /*}}}1*/ 248 /*FUNCTION Pengrid::GetName {{{1*/ 249 char* Pengrid::GetName(void){ 250 return "pengrid"; 251 } 252 /*}}}1*/ 253 /*FUNCTION Pengrid::MyRank {{{1*/ 172 254 int Pengrid::MyRank(void){ 173 255 extern int my_rank; 174 256 return my_rank; 175 257 } 176 void Pengrid::DistributeNumDofs(int* numdofpernode,int analysis_type,int sub_analysis_type){return;} 177 178 #undef __FUNCT__ 179 #define __FUNCT__ "Pengrid::Configure" 180 181 void Pengrid::Configure(void* pelementsin,void* pnodesin,void* pmaterialsin){ 182 183 DataSet* nodesin=NULL; 184 DataSet* materialsin=NULL; 185 186 /*Recover pointers :*/ 187 nodesin=(DataSet*)pnodesin; 188 materialsin=(DataSet*)pmaterialsin; 189 190 /*Link this load with its nodes: */ 191 ResolvePointers((Object**)&node,&node_id,&node_offset,1,nodesin); 192 ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin); 193 } 194 195 196 #undef __FUNCT__ 197 #define __FUNCT__ "Pengrid::CreateKMatrix" 198 199 void Pengrid::CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type){ 200 201 /*No loads applied, do nothing: */ 202 return; 203 204 } 205 206 #undef __FUNCT__ 207 #define __FUNCT__ "Pengrid::CreatePVector" 208 void Pengrid::CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type){ 209 210 /*No loads applied, do nothing: */ 211 return; 212 213 } 214 #undef __FUNCT__ 215 #define __FUNCT__ "Pengrid::UpdateFromInputs" 216 void Pengrid::UpdateFromInputs(void* inputs){ 217 218 } 219 258 /*}}}1*/ 259 /*FUNCTION Pengrid::PenaltyConstrain {{{1*/ 260 #undef __FUNCT__ 261 #define __FUNCT__ "Pengrid::PenaltyConstrain" 262 void Pengrid::PenaltyConstrain(int* punstable,void* vinputs,int analysis_type,int sub_analysis_type){ 263 264 if ((analysis_type==DiagnosticAnalysisEnum()) && ((sub_analysis_type==StokesAnalysisEnum()))){ 265 266 /*No penalty to check*/ 267 return; 268 269 } 270 else if (analysis_type==ThermalAnalysisEnum()){ 271 272 PenaltyConstrainThermal(punstable,vinputs,analysis_type,sub_analysis_type); 273 274 } 275 else if (analysis_type==MeltingAnalysisEnum()){ 276 277 /*No penalty to check*/ 278 return; 279 280 } 281 else{ 282 throw ErrorException(__FUNCT__,exprintf("%s%i%s%i%s","analysis: ",analysis_type," and sub_analysis_type: ",sub_analysis_type," not supported yet")); 283 } 284 285 } 286 /*}}}1*/ 287 /*FUNCTION Pengrid::PenaltyConstrainThermal {{{1*/ 288 #undef __FUNCT__ 289 #define __FUNCT__ "Pengrid::PenaltyConstrainThermal" 290 void Pengrid::PenaltyConstrainThermal(int* punstable,void* vinputs,int analysis_type,int sub_analysis_type){ 291 292 // The penalty is stable if it doesn't change during to successive iterations. 293 294 int found=0; 295 const int numgrids=1; 296 297 298 double pressure; 299 double temperature; 300 double beta,t_pmp; 301 double meltingpoint; 302 int new_active; 303 int dofs1[1]={0}; 304 int unstable=0; 305 int reset_penalties=0; 306 307 ParameterInputs* inputs=NULL; 308 309 /*check that pengrid is not a clone (penalty to be added only once)*/ 310 if (node->IsClone()){ 311 unstable=0; 312 *punstable=unstable; 313 return; 314 } 315 316 /*recover pointers: */ 317 inputs=(ParameterInputs*)vinputs; 318 319 //First recover beta, pressure and temperature vectors; 320 found=inputs->Recover("pressure",&pressure,1,dofs1,numgrids,(void**)&node); 321 if(!found)throw ErrorException(__FUNCT__," could not find pressure in inputs!"); 322 323 found=inputs->Recover("temperature",&temperature,1,dofs1,numgrids,(void**)&node); 324 if(!found)throw ErrorException(__FUNCT__," could not find temperature in inputs!"); 325 326 found=inputs->Recover("reset_penalties",&reset_penalties); 327 328 if(reset_penalties)zigzag_counter=0; 329 330 //Compute pressure melting point 331 meltingpoint=matpar->GetMeltingPoint(); 332 beta=matpar->GetBeta(); 333 334 t_pmp=meltingpoint-beta*pressure; 335 336 //Figure out if temperature is over melting_point, in which case, this penalty needs to be activated. 337 338 if (temperature>t_pmp){ 339 new_active=1; 340 } 341 else{ 342 new_active=0; 343 } 344 345 346 //Figure out stability of this penalty 347 if (active==new_active){ 348 unstable=0; 349 } 350 else{ 351 unstable=1; 352 if(stabilize_constraints)zigzag_counter++; 353 } 354 355 /*If penalty keeps zigzagging more than 5 times: */ 356 if(stabilize_constraints){ 357 if(zigzag_counter>stabilize_constraints){ 358 unstable=0; 359 active=1; 360 } 361 } 362 363 //Set penalty flag 364 active=new_active; 365 366 //*Assign output pointers:*/ 367 *punstable=unstable; 368 } 369 /*}}}1*/ 370 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/ 220 371 #undef __FUNCT__ 221 372 #define __FUNCT__ "Pengrid::PenaltyCreateKMatrix" … … 241 392 242 393 } 243 394 /*}}}1*/ 395 /*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{1*/ 244 396 #undef __FUNCT__ 245 397 #define __FUNCT__ "Pengrid::PenaltyCreateKMatrixDiagnosticStokes" … … 280 432 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES); 281 433 } 282 283 #undef __FUNCT__ 284 #define __FUNCT__ "Pengrid::PenaltyCreateKMatrixThermal" 285 void Pengrid::PenaltyCreateKMatrixThermal(Mat Kgg,void* vinputs,double kmax,int analysis_type,int sub_analysis_type){ 286 287 int found=0; 288 289 const int numgrids=1; 290 const int NDOF1=1; 291 const int numdof=numgrids*NDOF1; 292 double Ke[numdof][numdof]; 293 int doflist[numdof]; 294 int numberofdofspernode; 295 296 ParameterInputs* inputs=NULL; 297 298 /*recover pointers: */ 299 inputs=(ParameterInputs*)vinputs; 300 301 302 if(!active)return; 303 304 /*Get dof list: */ 305 GetDofList(&doflist[0],&numberofdofspernode); 306 307 Ke[0][0]=kmax*pow((double)10,penalty_offset); 308 309 /*Add Ke to global matrix Kgg: */ 310 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES); 311 } 312 434 /*}}}1*/ 435 /*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{1*/ 313 436 #undef __FUNCT__ 314 437 #define __FUNCT__ "Pengrid::PenaltyCreateKMatrixMelting" … … 359 482 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES); 360 483 } 361 484 /*}}}1*/ 485 /*FUNCTION Pengrid::PenaltyCreateKMatrixThermal {{{1*/ 486 #undef __FUNCT__ 487 #define __FUNCT__ "Pengrid::PenaltyCreateKMatrixThermal" 488 void Pengrid::PenaltyCreateKMatrixThermal(Mat Kgg,void* vinputs,double kmax,int analysis_type,int sub_analysis_type){ 489 490 int found=0; 491 492 const int numgrids=1; 493 const int NDOF1=1; 494 const int numdof=numgrids*NDOF1; 495 double Ke[numdof][numdof]; 496 int doflist[numdof]; 497 int numberofdofspernode; 498 499 ParameterInputs* inputs=NULL; 500 501 /*recover pointers: */ 502 inputs=(ParameterInputs*)vinputs; 503 504 505 if(!active)return; 506 507 /*Get dof list: */ 508 GetDofList(&doflist[0],&numberofdofspernode); 509 510 Ke[0][0]=kmax*pow((double)10,penalty_offset); 511 512 /*Add Ke to global matrix Kgg: */ 513 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES); 514 } 515 /*}}}1*/ 516 /*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/ 362 517 #undef __FUNCT__ 363 518 #define __FUNCT__ "Pengrid::PenaltyCreatePVector" … … 385 540 386 541 } 387 388 Object* Pengrid::copy() { 389 return new Pengrid(*this); 390 } 391 392 393 void Pengrid::GetDofList(int* doflist,int* pnumberofdofspernode){ 394 395 int j; 396 int doflist_per_node[MAXDOFSPERNODE]; 397 int numberofdofspernode; 398 399 node->GetDofList(&doflist_per_node[0],&numberofdofspernode); 400 for(j=0;j<numberofdofspernode;j++){ 401 doflist[j]=doflist_per_node[j]; 402 } 403 404 /*Assign output pointers:*/ 405 *pnumberofdofspernode=numberofdofspernode; 406 } 407 408 void Pengrid::PenaltyCreatePVectorThermal(Vec pg, void* vinputs, double kmax,int analysis_type,int sub_analysis_type){ 409 410 const int numgrids=1; 411 const int NDOF1=1; 412 const int numdof=numgrids*NDOF1; 413 int doflist[numdof]; 414 double P_terms[numdof]={0.0}; 415 int numberofdofspernode; 416 int found=0; 417 double pressure; 418 int dofs1[1]={0}; 419 double meltingpoint; 420 double beta; 421 double t_pmp; 422 423 ParameterInputs* inputs=NULL; 424 425 /*recover pointers: */ 426 inputs=(ParameterInputs*)vinputs; 427 428 if(!active)return; 429 430 /*Get dof list: */ 431 GetDofList(&doflist[0],&numberofdofspernode); 432 433 //First recover pressure 434 found=inputs->Recover("pressure",&pressure,1,dofs1,numgrids,(void**)&node); 435 if(!found)throw ErrorException(__FUNCT__," could not find pressure in inputs!"); 436 437 //Compute pressure melting point 438 meltingpoint=matpar->GetMeltingPoint(); 439 beta=matpar->GetBeta(); 440 t_pmp=meltingpoint-beta*pressure; 441 442 //Add penalty load 443 P_terms[0]=kmax*pow((double)10,penalty_offset)*t_pmp; 444 445 /*Add P_terms to global vector pg: */ 446 VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES); 447 } 448 542 /*}}}1*/ 543 /*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{1*/ 449 544 void Pengrid::PenaltyCreatePVectorMelting(Vec pg, void* vinputs, double kmax,int analysis_type,int sub_analysis_type){ 450 545 … … 517 612 VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES); 518 613 } 519 520 521 #undef __FUNCT__ 522 #define __FUNCT__ "Pengrid::PenaltyConstrain" 523 void Pengrid::PenaltyConstrain(int* punstable,void* vinputs,int analysis_type,int sub_analysis_type){ 524 525 if ((analysis_type==DiagnosticAnalysisEnum()) && ((sub_analysis_type==StokesAnalysisEnum()))){ 526 527 /*No penalty to check*/ 528 return; 529 530 } 531 else if (analysis_type==ThermalAnalysisEnum()){ 532 533 PenaltyConstrainThermal(punstable,vinputs,analysis_type,sub_analysis_type); 534 535 } 536 else if (analysis_type==MeltingAnalysisEnum()){ 537 538 /*No penalty to check*/ 539 return; 540 541 } 542 else{ 543 throw ErrorException(__FUNCT__,exprintf("%s%i%s%i%s","analysis: ",analysis_type," and sub_analysis_type: ",sub_analysis_type," not supported yet")); 544 } 545 546 } 547 548 #undef __FUNCT__ 549 #define __FUNCT__ "Pengrid::PenaltyConstrainThermal" 550 void Pengrid::PenaltyConstrainThermal(int* punstable,void* vinputs,int analysis_type,int sub_analysis_type){ 551 552 // The penalty is stable if it doesn't change during to successive iterations. 553 554 int found=0; 614 /*}}}1*/ 615 /*FUNCTION Pengrid::PenaltyCreatePVectorThermal {{{1*/ 616 void Pengrid::PenaltyCreatePVectorThermal(Vec pg, void* vinputs, double kmax,int analysis_type,int sub_analysis_type){ 617 555 618 const int numgrids=1; 556 557 619 const int NDOF1=1; 620 const int numdof=numgrids*NDOF1; 621 int doflist[numdof]; 622 double P_terms[numdof]={0.0}; 623 int numberofdofspernode; 624 int found=0; 558 625 double pressure; 559 double temperature; 560 double beta,t_pmp; 626 int dofs1[1]={0}; 561 627 double meltingpoint; 562 int new_active; 563 int dofs1[1]={0}; 564 int unstable=0; 565 int reset_penalties=0; 566 628 double beta; 629 double t_pmp; 630 567 631 ParameterInputs* inputs=NULL; 568 569 /*check that pengrid is not a clone (penalty to be added only once)*/570 if (node->IsClone()){571 unstable=0;572 *punstable=unstable;573 return;574 }575 632 576 633 /*recover pointers: */ 577 634 inputs=(ParameterInputs*)vinputs; 578 635 579 //First recover beta, pressure and temperature vectors; 636 if(!active)return; 637 638 /*Get dof list: */ 639 GetDofList(&doflist[0],&numberofdofspernode); 640 641 //First recover pressure 580 642 found=inputs->Recover("pressure",&pressure,1,dofs1,numgrids,(void**)&node); 581 643 if(!found)throw ErrorException(__FUNCT__," could not find pressure in inputs!"); 582 583 found=inputs->Recover("temperature",&temperature,1,dofs1,numgrids,(void**)&node);584 if(!found)throw ErrorException(__FUNCT__," could not find temperature in inputs!");585 586 found=inputs->Recover("reset_penalties",&reset_penalties);587 588 if(reset_penalties)zigzag_counter=0;589 644 590 645 //Compute pressure melting point 591 646 meltingpoint=matpar->GetMeltingPoint(); 592 647 beta=matpar->GetBeta(); 593 594 648 t_pmp=meltingpoint-beta*pressure; 595 649 596 //Figure out if temperature is over melting_point, in which case, this penalty needs to be activated. 597 598 if (temperature>t_pmp){ 599 new_active=1; 600 } 601 else{ 602 new_active=0; 603 } 604 605 606 //Figure out stability of this penalty 607 if (active==new_active){ 608 unstable=0; 609 } 610 else{ 611 unstable=1; 612 if(stabilize_constraints)zigzag_counter++; 613 } 614 615 /*If penalty keeps zigzagging more than 5 times: */ 616 if(stabilize_constraints){ 617 if(zigzag_counter>stabilize_constraints){ 618 unstable=0; 619 active=1; 620 } 621 } 622 623 //Set penalty flag 624 active=new_active; 625 626 //*Assign output pointers:*/ 627 *punstable=unstable; 628 } 650 //Add penalty load 651 P_terms[0]=kmax*pow((double)10,penalty_offset)*t_pmp; 652 653 /*Add P_terms to global vector pg: */ 654 VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES); 655 } 656 /*}}}1*/ 657 /*FUNCTION Pengrid::UpdateFromInputs {{{1*/ 658 #undef __FUNCT__ 659 #define __FUNCT__ "Pengrid::UpdateFromInputs" 660 void Pengrid::UpdateFromInputs(void* inputs){ 661 662 } 663 /*}}}1*/ -
issm/trunk/src/c/objects/Penpair.cpp
r1897 r2907 18 18 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Penpair::constructor {{{1*/ 20 22 Penpair::Penpair(){ 21 23 return; 22 24 } 23 25 /*}}}1*/ 26 /*FUNCTION Penpair::creation {{{1*/ 24 27 Penpair::Penpair(int penpair_id, double penpair_penalty_offset,int penpair_penalty_lock,int penpair_node_ids[2],int penpair_dof){ 25 28 … … 39 42 return; 40 43 } 41 44 /*}}}1*/ 45 /*FUNCTION Penpair::destructor {{{1*/ 42 46 Penpair::~Penpair(){ 43 47 return; 44 48 } 49 /*}}}1*/ 45 50 46 void Penpair::Echo(void){ 51 /*Object marshall*/ 52 /*FUNCTION Penpair::Marshall {{{1*/ 53 void Penpair::Marshall(char** pmarshalled_dataset){ 54 55 char* marshalled_dataset=NULL; 56 int enum_type=0; 57 58 /*recover marshalled_dataset: */ 59 marshalled_dataset=*pmarshalled_dataset; 60 61 /*get enum type of Penpair: */ 62 enum_type=PenpairEnum(); 63 64 /*marshall enum: */ 65 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 66 67 /*marshall Penpair data: */ 68 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 69 memcpy(marshalled_dataset,&penalty_offset,sizeof(penalty_offset));marshalled_dataset+=sizeof(penalty_offset); 70 memcpy(marshalled_dataset,&penalty_lock,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock); 71 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof); 72 memcpy(marshalled_dataset,&node_ids,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 73 memcpy(marshalled_dataset,&node_offsets,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 74 75 *pmarshalled_dataset=marshalled_dataset; 76 return; 77 } 78 /*}}}1*/ 79 /*FUNCTION Penpair::MarshallSize {{{1*/ 80 int Penpair::MarshallSize(){ 81 82 return sizeof(id)+ 83 sizeof(penalty_offset)+ 84 sizeof(penalty_lock)+ 85 sizeof(dof)+ 86 sizeof(node_ids)+ 87 sizeof(node_offsets)+ 88 sizeof(int); //sizeof(int) for enum type 89 } 90 /*}}}1*/ 91 /*FUNCTION Penpair::Demarshall {{{1*/ 92 void Penpair::Demarshall(char** pmarshalled_dataset){ 93 94 int i; 95 char* marshalled_dataset=NULL; 96 97 /*recover marshalled_dataset: */ 98 marshalled_dataset=*pmarshalled_dataset; 99 100 /*this time, no need to get enum type, the pointer directly points to the beginning of the 101 *object data (thanks to DataSet::Demarshall):*/ 102 103 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 104 memcpy(&penalty_offset,marshalled_dataset,sizeof(penalty_offset));marshalled_dataset+=sizeof(penalty_offset); 105 memcpy(&penalty_lock,marshalled_dataset,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock); 106 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof); 107 memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 108 memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 109 110 for(i=0;i<2;i++){ 111 nodes[i]=NULL; 112 } 113 114 /*return: */ 115 *pmarshalled_dataset=marshalled_dataset; 116 return; 117 } 118 /*}}}1*/ 119 120 /*Object functions*/ 121 /*FUNCTION Penpair::Configure {{{1*/ 122 #undef __FUNCT__ 123 #define __FUNCT__ "Penpair::Configure" 124 125 void Penpair::Configure(void* pelementsin,void* pnodesin,void* pmaterialsin){ 126 127 DataSet* elementsin=NULL; 128 DataSet* nodesin=NULL; 129 130 /*Recover pointers :*/ 131 elementsin=(DataSet*)pelementsin; 132 nodesin=(DataSet*)pnodesin; 133 /*Link this load with its nodes: */ 134 ResolvePointers((Object**)nodes,node_ids,node_offsets,2,nodesin); 135 136 } 137 /*}}}1*/ 138 /*FUNCTION Penpair::copy {{{1*/ 139 Object* Penpair::copy() { 140 return new Penpair(*this); 141 } 142 /*}}}1*/ 143 /*FUNCTION Penpair::CreateKMatrix {{{1*/ 144 #undef __FUNCT__ 145 #define __FUNCT__ "Penpair::CreateKMatrix" 146 147 void Penpair::CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type){ 148 149 /*No loads applied, do nothing: */ 150 return; 151 152 } 153 /*}}}1*/ 154 /*FUNCTION Penpair::CreatePVector {{{1*/ 155 #undef __FUNCT__ 156 #define __FUNCT__ "Penpair::CreatePVector" 157 void Penpair::CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type){ 158 159 /*No loads applied, do nothing: */ 160 return; 161 162 } 163 /*}}}1*/ 164 /*FUNCTION Penpair::DeepEcho {{{1*/ 165 void Penpair::DeepEcho(void){ 47 166 48 167 int i; … … 60 179 } 61 180 return; 62 } 63 void Penpair::DeepEcho(void){ 181 } 182 /*}}}1*/ 183 /*FUNCTION Penpair::Echo {{{1*/ 184 void Penpair::Echo(void){ 64 185 65 186 int i; … … 77 198 } 78 199 return; 79 } 80 void Penpair::Marshall(char** pmarshalled_dataset){ 81 82 char* marshalled_dataset=NULL; 83 int enum_type=0; 84 85 /*recover marshalled_dataset: */ 86 marshalled_dataset=*pmarshalled_dataset; 87 88 /*get enum type of Penpair: */ 89 enum_type=PenpairEnum(); 90 91 /*marshall enum: */ 92 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 93 94 /*marshall Penpair data: */ 95 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 96 memcpy(marshalled_dataset,&penalty_offset,sizeof(penalty_offset));marshalled_dataset+=sizeof(penalty_offset); 97 memcpy(marshalled_dataset,&penalty_lock,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock); 98 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof); 99 memcpy(marshalled_dataset,&node_ids,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 100 memcpy(marshalled_dataset,&node_offsets,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 101 102 *pmarshalled_dataset=marshalled_dataset; 103 return; 104 } 105 106 int Penpair::MarshallSize(){ 107 108 return sizeof(id)+ 109 sizeof(penalty_offset)+ 110 sizeof(penalty_lock)+ 111 sizeof(dof)+ 112 sizeof(node_ids)+ 113 sizeof(node_offsets)+ 114 sizeof(int); //sizeof(int) for enum type 115 } 116 200 } 201 /*}}}1*/ 202 /*FUNCTION Penpair::Enum {{{1*/ 203 int Penpair::Enum(void){ 204 205 return PenpairEnum(); 206 } 207 /*}}}1*/ 208 /*FUNCTION Penpair::GetId {{{1*/ 209 int Penpair::GetId(void){ return id; } 210 /*}}}1*/ 211 /*FUNCTION Penpair::GetName {{{1*/ 117 212 char* Penpair::GetName(void){ 118 213 return "penpair"; 119 214 } 120 121 122 void Penpair::Demarshall(char** pmarshalled_dataset){ 123 124 int i; 125 char* marshalled_dataset=NULL; 126 127 /*recover marshalled_dataset: */ 128 marshalled_dataset=*pmarshalled_dataset; 129 130 /*this time, no need to get enum type, the pointer directly points to the beginning of the 131 *object data (thanks to DataSet::Demarshall):*/ 132 133 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 134 memcpy(&penalty_offset,marshalled_dataset,sizeof(penalty_offset));marshalled_dataset+=sizeof(penalty_offset); 135 memcpy(&penalty_lock,marshalled_dataset,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock); 136 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof); 137 memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 138 memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 139 140 for(i=0;i<2;i++){ 141 nodes[i]=NULL; 142 } 143 144 /*return: */ 145 *pmarshalled_dataset=marshalled_dataset; 146 return; 147 } 148 int Penpair::Enum(void){ 149 150 return PenpairEnum(); 151 } 152 153 int Penpair::GetId(void){ return id; } 154 215 /*}}}1*/ 216 /*FUNCTION Penpair::MyRank {{{1*/ 155 217 int Penpair::MyRank(void){ 156 218 extern int my_rank; 157 219 return my_rank; 158 220 } 159 160 #undef __FUNCT__ 161 #define __FUNCT__ "Penpair::Configure" 162 163 void Penpair::Configure(void* pelementsin,void* pnodesin,void* pmaterialsin){ 164 165 DataSet* elementsin=NULL; 166 DataSet* nodesin=NULL; 167 168 /*Recover pointers :*/ 169 elementsin=(DataSet*)pelementsin; 170 nodesin=(DataSet*)pnodesin; 171 /*Link this load with its nodes: */ 172 ResolvePointers((Object**)nodes,node_ids,node_offsets,2,nodesin); 173 174 } 175 176 #undef __FUNCT__ 177 #define __FUNCT__ "Penpair::CreateKMatrix" 178 179 void Penpair::CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type){ 180 181 /*No loads applied, do nothing: */ 182 return; 183 184 } 185 186 #undef __FUNCT__ 187 #define __FUNCT__ "Penpair::CreatePVector" 188 void Penpair::CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type){ 189 190 /*No loads applied, do nothing: */ 191 return; 192 193 } 194 #undef __FUNCT__ 195 #define __FUNCT__ "Penpair::UpdateFromInputs" 196 void Penpair::UpdateFromInputs(void* inputs){ 197 198 } 199 221 /*}}}1*/ 222 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/ 200 223 #undef __FUNCT__ 201 224 #define __FUNCT__ "Penpair::PenaltyCreateKMatrix" … … 205 228 return; 206 229 } 207 230 /*}}}1*/ 231 /*FUNCTION Penpair::PenaltyCreatePVector {{{1*/ 208 232 #undef __FUNCT__ 209 233 #define __FUNCT__ "Penpair::PenaltyCreatePVector" … … 212 236 return; 213 237 } 214 215 Object* Penpair::copy() { 216 return new Penpair(*this); 217 } 218 238 /*}}}1*/ 239 /*FUNCTION Penpair::UpdateFromInputs {{{1*/ 240 #undef __FUNCT__ 241 #define __FUNCT__ "Penpair::UpdateFromInputs" 242 void Penpair::UpdateFromInputs(void* inputs){ 243 244 } 245 /*}}}1*/ -
issm/trunk/src/c/objects/Result.cpp
r1959 r2907 18 18 #include "../include/typedefs.h" 19 19 20 /*Object constructors and destructor*/ 21 /*FUNCTION Result::constructor {{{1*/ 20 22 Result::Result(){ 21 23 return; 22 24 } 23 25 /*}}}1*/ 26 /*FUNCTION Result::destructor {{{1*/ 27 Result::~Result(){ 28 xfree((void**)&fieldname); 29 VecFree(&field); 30 xfree((void**)&dfield); 31 xfree((void**)&cfield); 32 } 33 /*}}}1*/ 34 /*FUNCTION Result::Result(const Result& result) {{{1*/ 24 35 Result::Result(const Result& result){ 25 36 … … 52 63 } 53 64 } 54 65 /*}}}1*/ 66 /*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,Vec result_field) {{{1*/ 55 67 #undef __FUNCT__ 56 68 #define __FUNCT__ "Result::Result" … … 73 85 cfield=NULL; 74 86 } 75 87 /*}}}1*/ 88 /*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fldname,double* result_field,int result_size){{{1*/ 76 89 #undef __FUNCT__ 77 90 #define __FUNCT__ "Result::Result" … … 96 109 cfield=NULL; 97 110 } 98 111 /*}}}1*/ 112 /*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field) {{{1*/ 99 113 #undef __FUNCT__ 100 114 #define __FUNCT__ "Result::Result" … … 118 132 dfield=NULL; 119 133 } 120 121 Result::~Result(){ 122 xfree((void**)&fieldname); 123 VecFree(&field); 124 xfree((void**)&dfield); 125 xfree((void**)&cfield); 126 } 134 /*}}}1*/ 127 135 128 void Result::Echo(void){ 136 /*Object marshall*/ 137 /*FUNCTION Result::Marshall {{{1*/ 138 #undef __FUNCT__ 139 #define __FUNCT__ "Result::Marshall" 140 void Result::Marshall(char** pmarshalled_dataset){ 141 142 throw ErrorException(__FUNCT__," not supported yet!"); 143 144 } 145 /*}}}1*/ 146 /*FUNCTION Result::MarshallSize {{{1*/ 147 #undef __FUNCT__ 148 #define __FUNCT__ "Result::MarshallSize" 149 int Result::MarshallSize(){ 150 151 throw ErrorException(__FUNCT__," not supported yet!"); 152 } 153 /*}}}1*/ 154 /*FUNCTION Result::Demarshall {{{1*/ 155 #undef __FUNCT__ 156 #define __FUNCT__ "Result::Demarshall" 157 void Result::Demarshall(char** pmarshalled_dataset){ 158 159 throw ErrorException(__FUNCT__," not supported yet!"); 160 } 161 /*}}}1*/ 162 163 /*Object functions*/ 164 /*FUNCTION Result::copy {{{1*/ 165 Object* Result::copy() { 166 return new Result(*this); 167 } 168 /*}}}1*/ 169 /*FUNCTION Result::DeepEcho {{{1*/ 170 void Result::DeepEcho(void){ 129 171 130 172 printf("Result:\n"); … … 144 186 printf(" field string %s\n",cfield); 145 187 } 146 } 147 148 void Result::DeepEcho(void){ 188 } 189 /*}}}1*/ 190 /*FUNCTION Result::Echo {{{1*/ 191 void Result::Echo(void){ 149 192 150 193 printf("Result:\n"); … … 164 207 printf(" field string %s\n",cfield); 165 208 } 166 } 167 168 #undef __FUNCT__ 169 #define __FUNCT__ "Result::Marshall" 170 void Result::Marshall(char** pmarshalled_dataset){ 171 172 throw ErrorException(__FUNCT__," not supported yet!"); 173 174 } 175 176 #undef __FUNCT__ 177 #define __FUNCT__ "Result::MarshallSize" 178 int Result::MarshallSize(){ 179 180 throw ErrorException(__FUNCT__," not supported yet!"); 181 } 182 209 } 210 /*}}}1*/ 211 /*FUNCTION Result::Enum {{{1*/ 212 int Result::Enum(void){ 213 214 return ResultEnum(); 215 216 } 217 /*}}}1*/ 218 /*FUNCTION Result::GetFieldName {{{1*/ 219 char* Result::GetFieldName(){ 220 return fieldname; 221 } 222 /*}}}1*/ 223 /*FUNCTION Result::GetField(Vec* pfield) {{{1*/ 224 void Result::GetField(Vec* pfield){ 225 226 VecDuplicatePatch(pfield,field); 227 228 } 229 /*}}}1*/ 230 /*FUNCTION Result::GetField(char** pcfield) {{{1*/ 231 void Result::GetField(char** pcfield){ 232 233 char* string=NULL; 234 235 string=(char*)xmalloc((strlen(cfield)+1)*sizeof(char)); 236 strcpy(string,cfield); 237 238 *pcfield=string; 239 } 240 /*}}}1*/ 241 /*FUNCTION Result::GetField(double** pfield) {{{1*/ 242 void Result::GetField(double** pfield){ 243 *pfield=(double*)xmalloc(size*sizeof(double)); 244 memcpy(*pfield,dfield,size*sizeof(double)); 245 } 246 /*}}}1*/ 247 /*FUNCTION Result::GetId {{{1*/ 248 int Result::GetId(void){ return id; } 249 /*}}}1*/ 250 /*FUNCTION Result::GetName {{{1*/ 183 251 char* Result::GetName(void){ 184 252 return "result"; 185 253 } 186 187 188 #undef __FUNCT__ 189 #define __FUNCT__ "Result::Demarshall" 190 void Result::Demarshall(char** pmarshalled_dataset){ 191 192 throw ErrorException(__FUNCT__," not supported yet!"); 193 } 194 195 int Result::Enum(void){ 196 197 return ResultEnum(); 198 199 } 200 int Result::GetId(void){ return id; } 201 254 /*}}}1*/ 255 /*FUNCTION Result::GetStep {{{1*/ 256 int Result::GetStep(){ 257 return step; 258 } 259 /*}}}1*/ 260 /*FUNCTION Result::GetTime {{{1*/ 261 double Result::GetTime(){ 262 return time; 263 } 264 /*}}}1*/ 265 /*FUNCTION Result::MyRank {{{1*/ 202 266 int Result::MyRank(void){ 203 267 extern int my_rank; … … 205 269 return my_rank; 206 270 } 207 208 double Result::GetTime(){ 209 return time; 210 } 211 212 int Result::GetStep(){ 213 return step; 214 } 215 216 char* Result::GetFieldName(){ 217 return fieldname; 218 } 219 271 /*}}}1*/ 272 /*FUNCTION Result::WriteData {{{1*/ 220 273 void Result::WriteData(FILE* fid){ 221 274 … … 247 300 } 248 301 } 249 250 251 void Result::GetField(Vec* pfield){ 252 253 VecDuplicatePatch(pfield,field); 254 255 } 256 257 void Result::GetField(char** pcfield){ 258 259 char* string=NULL; 260 261 string=(char*)xmalloc((strlen(cfield)+1)*sizeof(char)); 262 strcpy(string,cfield); 263 264 *pcfield=string; 265 } 266 267 void Result::GetField(double** pfield){ 268 *pfield=(double*)xmalloc(size*sizeof(double)); 269 memcpy(*pfield,dfield,size*sizeof(double)); 270 } 271 272 Object* Result::copy() { 273 return new Result(*this); 274 } 275 276 302 /*}}}1*/ -
issm/trunk/src/c/objects/Rgb.cpp
r803 r2907 16 16 #include "./objects.h" 17 17 18 18 /*Object constructors and destructor*/ 19 /*FUNCTION Rgb::constructor {{{1*/ 19 20 Rgb::Rgb(){ 20 21 return; 21 22 } 23 /*}}}1*/ 24 /*FUNCTION Rgb::creation {{{1*/ 22 25 Rgb::Rgb(int rgb_id,int rgb_nodeid1,int rgb_nodeid2, int rgb_dof){ 23 26 … … 29 32 return; 30 33 } 31 34 /*}}}1*/ 35 /*FUNCTION Rgb::destructor {{{1*/ 32 36 Rgb::~Rgb(){ 33 37 return; 34 38 } 39 /*}}}1*/ 35 40 36 void Rgb::Echo(void){ 37 38 printf("Rgb:\n"); 39 printf(" id: %i\n",id); 40 printf(" nodeid1: %i\n",nodeid1); 41 printf(" nodeid2: %i\n",nodeid2); 42 printf(" dof: %i\n",dof); 43 return; 44 } 45 void Rgb::DeepEcho(void){ 46 47 printf("Rgb:\n"); 48 printf(" id: %i\n",id); 49 printf(" nodeid1: %i\n",nodeid1); 50 printf(" nodeid2: %i\n",nodeid2); 51 printf(" dof: %i\n",dof); 52 return; 53 } 41 /*Object marshall*/ 42 /*FUNCTION Rgb::Marshall {{{1*/ 54 43 void Rgb::Marshall(char** pmarshalled_dataset){ 55 44 … … 75 64 return; 76 65 } 77 66 /*}}}1*/ 67 /*FUNCTION Rgb::MarshallSize {{{1*/ 78 68 int Rgb::MarshallSize(){ 79 69 … … 84 74 sizeof(int); //sizeof(int) for enum type 85 75 } 86 87 char* Rgb::GetName(void){ 88 return "rgb"; 89 } 90 91 76 /*}}}1*/ 77 /*FUNCTION Rgb::Demarshall {{{1*/ 92 78 void Rgb::Demarshall(char** pmarshalled_dataset){ 93 79 … … 109 95 return; 110 96 } 97 /*}}}1*/ 98 99 /*Object functions*/ 100 /*FUNCTION Rgb::copy {{{1*/ 101 Object* Rgb::copy() { 102 return new Rgb(*this); 103 } 104 /*}}}1*/ 105 /*FUNCTION Rgb::DeepEcho {{{1*/ 106 void Rgb::DeepEcho(void){ 107 108 printf("Rgb:\n"); 109 printf(" id: %i\n",id); 110 printf(" nodeid1: %i\n",nodeid1); 111 printf(" nodeid2: %i\n",nodeid2); 112 printf(" dof: %i\n",dof); 113 return; 114 } 115 /*}}}1*/ 116 /*FUNCTION Rgb::Echo {{{1*/ 117 void Rgb::Echo(void){ 118 119 printf("Rgb:\n"); 120 printf(" id: %i\n",id); 121 printf(" nodeid1: %i\n",nodeid1); 122 printf(" nodeid2: %i\n",nodeid2); 123 printf(" dof: %i\n",dof); 124 return; 125 } 126 /*}}}1*/ 127 /*FUNCTION Rgb::Enum {{{1*/ 111 128 int Rgb::Enum(void){ 112 129 … … 114 131 115 132 } 133 /*}}}1*/ 134 /*FUNCTION Rgb::GetId {{{1*/ 116 135 int Rgb::GetId(void){ return id; } 117 136 /*}}}1*/ 137 /*FUNCTION Rgb::GetName {{{1*/ 138 char* Rgb::GetName(void){ 139 return "rgb"; 140 } 141 /*}}}1*/ 142 /*FUNCTION Rgb::GetNodeId1{{{1*/ 143 int Rgb::GetNodeId1(){ 144 145 return nodeid1; 146 } 147 /*}}}1*/ 148 /*FUNCTION Rgb::GetNodeId2 {{{1*/ 149 int Rgb::GetNodeId2(){ 150 151 return nodeid2; 152 } 153 /*}}}1*/ 154 /*FUNCTION Rgb::GetDof {{{1*/ 155 int Rgb::GetDof(){ 156 return dof; 157 } 158 /*}}}1*/ 159 /*FUNCTION Rgb::MyRank {{{1*/ 118 160 int Rgb::MyRank(void){ 119 161 extern int my_rank; 120 162 return my_rank; 121 163 } 122 123 int Rgb::GetNodeId1(){ 124 125 return nodeid1; 126 } 127 int Rgb::GetNodeId2(){ 128 129 return nodeid2; 130 } 131 132 int Rgb::GetDof(){ 133 return dof; 134 } 135 Object* Rgb::copy() { 136 return new Rgb(*this); 137 } 138 164 /*}}}1*/
Note:
See TracChangeset
for help on using the changeset viewer.