Changeset 17472 for issm/trunk-jpl/src/c/classes/Elements/Element.cpp
- Timestamp:
- 03/18/14 22:44:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r17394 r17472 429 429 430 430 }/*}}}*/ 431 void Element::GetNodesSidList(int* sidlist){/*{{{*/ 432 433 _assert_(sidlist); 434 _assert_(nodes); 435 int numnodes = this->GetNumberOfNodes(); 436 for(int i=0;i<numnodes;i++){ 437 sidlist[i]=nodes[i]->Sid(); 438 } 439 } 440 /*}}}*/ 441 void Element::GetNodesLidList(int* lidlist){/*{{{*/ 442 443 _assert_(lidlist); 444 _assert_(nodes); 445 int numnodes = this->GetNumberOfNodes(); 446 for(int i=0;i<numnodes;i++){ 447 lidlist[i]=nodes[i]->Lid(); 448 } 449 } 450 /*}}}*/ 451 void Element::GetVerticesCoordinates(IssmDouble** pxyz_list){/*{{{*/ 452 453 int numvertices = this->GetNumberOfVertices(); 454 IssmDouble* xyz_list = xNew<IssmDouble>(numvertices*3); 455 ::GetVerticesCoordinates(xyz_list,this->vertices,numvertices); 456 457 *pxyz_list = xyz_list; 458 459 }/*}}}*/ 431 460 void Element::GetVerticesSidList(int* sidlist){/*{{{*/ 432 461 … … 439 468 int numvertices = this->GetNumberOfVertices(); 440 469 for(int i=0;i<numvertices;i++) connectivity[i]=this->vertices[i]->Connectivity(); 470 } 471 /*}}}*/ 472 void Element::InputChangeName(int original_enum,int new_enum){/*{{{*/ 473 this->inputs->ChangeEnum(original_enum,new_enum); 474 } 475 /*}}}*/ 476 void Element::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){/*{{{*/ 477 478 /*Intermediaries*/ 479 int i,t,row; 480 IssmDouble time; 481 482 /*Branch on type of vector: nodal or elementary: */ 483 if(vector_type==1){ //nodal vector 484 485 int numvertices = this->GetNumberOfVertices(); 486 int *vertexids = xNew<int>(numvertices); 487 IssmDouble *values = xNew<IssmDouble>(numvertices); 488 489 /*Recover vertices ids needed to initialize inputs*/ 490 _assert_(iomodel->elements); 491 for(i=0;i<numvertices;i++){ 492 vertexids[i]=reCast<int>(iomodel->elements[numvertices*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 493 } 494 495 /*Are we in transient or static? */ 496 if(M==iomodel->numberofvertices){ 497 for(i=0;i<numvertices;i++) values[i]=vector[vertexids[i]-1]; 498 this->AddInput(vector_enum,values,P1Enum); 499 } 500 else if(M==iomodel->numberofvertices+1){ 501 /*create transient input: */ 502 IssmDouble* times = xNew<IssmDouble>(N); 503 for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t]; 504 TransientInput* transientinput=new TransientInput(vector_enum,times,N); 505 for(t=0;t<N;t++){ 506 for(i=0;i<numvertices;i++) values[i]=vector[N*(vertexids[i]-1)+t]; 507 switch(this->ObjectEnum()){ 508 case TriaEnum: transientinput->AddTimeInput(new TriaInput( vector_enum,values,P1Enum)); break; 509 case PentaEnum: transientinput->AddTimeInput(new PentaInput(vector_enum,values,P1Enum)); break; 510 case TetraEnum: transientinput->AddTimeInput(new TetraInput(vector_enum,values,P1Enum)); break; 511 default: _error_("Not implemented yet"); 512 } 513 } 514 this->inputs->AddInput(transientinput); 515 xDelete<IssmDouble>(times); 516 } 517 else _error_("nodal vector is either numberofvertices or numberofvertices+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long"); 518 519 xDelete<IssmDouble>(values); 520 xDelete<int>(vertexids); 521 } 522 else if(vector_type==2){ //element vector 523 /*Are we in transient or static? */ 524 if(M==iomodel->numberofelements){ 525 if (code==5){ //boolean 526 this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool>(vector[this->Sid()]))); 527 } 528 else if (code==6){ //integer 529 this->inputs->AddInput(new IntInput(vector_enum,reCast<int>(vector[this->Sid()]))); 530 } 531 else if (code==7){ //IssmDouble 532 this->inputs->AddInput(new DoubleInput(vector_enum,vector[this->Sid()])); 533 } 534 else _error_("could not recognize nature of vector from code " << code); 535 } 536 else { 537 _error_("transient element inputs not supported yet!"); 538 } 539 } 540 else{ 541 _error_("Cannot add input for vector type " << vector_type << " (not supported)"); 542 } 543 }/*}}}*/ 544 void Element::InputUpdateFromConstant(int constant, int name){/*{{{*/ 545 546 /*Check that name is an element input*/ 547 if(!IsInput(name)) return; 548 549 /*update input*/ 550 this->inputs->AddInput(new IntInput(name,constant)); 551 } 552 /*}}}*/ 553 void Element::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 554 555 /*Check that name is an element input*/ 556 if(!IsInput(name)) return; 557 558 /*update input*/ 559 this->inputs->AddInput(new DoubleInput(name,constant)); 560 } 561 /*}}}*/ 562 void Element::InputUpdateFromConstant(bool constant, int name){/*{{{*/ 563 564 /*Check that name is an element input*/ 565 if(!IsInput(name)) return; 566 567 /*update input*/ 568 this->inputs->AddInput(new BoolInput(name,constant)); 441 569 } 442 570 /*}}}*/ … … 535 663 } 536 664 /*}}}*/ 665 ElementVector* Element::NewElementVector(int approximation_enum){/*{{{*/ 666 return new ElementVector(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 667 } 668 /*}}}*/ 669 ElementMatrix* Element::NewElementMatrix(int approximation_enum){/*{{{*/ 670 return new ElementMatrix(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 671 } 672 /*}}}*/ 673 ElementMatrix* Element::NewElementMatrixCoupling(int number_nodes,int approximation_enum){/*{{{*/ 674 return new ElementMatrix(nodes,number_nodes,this->parameters,approximation_enum); 675 } 676 /*}}}*/ 537 677 void Element::ResultInterpolation(int* pinterpolation,int* pnodesperelement,int output_enum){/*{{{*/ 538 678
Note:
See TracChangeset
for help on using the changeset viewer.