Changeset 3402
- Timestamp:
- 04/06/10 09:29:13 (15 years ago)
- Location:
- issm/trunk/src/c/objects
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Beam.cpp
r3332 r3402 24 24 } 25 25 /*}}}*/ 26 /*FUNCTION Beam constructor {{{1*/ 27 Beam::Beam(int beam_id,int* beam_node_ids, int beam_matice_id, int beam_matpar_id, int beam_numpar_id, ElementProperties* beamproperties): 28 hnodes(beam_node_ids,2), 29 hmatice(&beam_matice_id,1), 30 hmatpar(&beam_matpar_id,1), 31 hnumpar(&beam_numpar_id,1), 32 properties(beamproperties) 33 { 34 35 /*all the initialization has been done by the initializer, just fill in the id: */ 36 this->id=beam_id; 37 38 return; 39 } 40 /*}}}*/ 41 /*FUNCTION Beam other constructor {{{1*/ 42 Beam::Beam(int beam_id,Hook* beam_hnodes, Hook* beam_hmatice, Hook* beam_hmatpar, Hook* beam_hnumpar, ElementProperties* beam_properties): 43 hnodes(beam_hnodes), 44 hmatice(beam_hmatice), 45 hmatpar(beam_hmatpar), 46 hnumpar(beam_hnumpar), 47 properties(beam_properties) 48 { 49 50 /*all the initialization has been done by the initializer, just fill in the id: */ 51 this->id=beam_id; 52 53 return; 54 } 55 /*}}}*/ 26 56 /*FUNCTION Beam destructor {{{1*/ 27 57 Beam::~Beam(){ … … 29 59 } 30 60 /*}}}*/ 31 /*FUNCTION Beam creation {{{1*/ 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){ 61 62 /*Object management*/ 63 /*FUNCTION Beam Configure{{{1*/ 64 void Beam::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){ 33 65 34 66 int i; 35 67 36 id=beam_id; 37 mid=beam_mid; 38 mparid=beam_mparid; 39 numparid=beam_numparid; 40 for(i=0;i<2;i++){ 41 node_ids[i]=beam_g[i]; 42 node_offsets[i]=UNDEF; 43 nodes[i]=NULL; 44 h[i]=beam_h[i]; 45 s[i]=beam_s[i]; 46 b[i]=beam_b[i]; 47 k[i]=beam_k[i]; 48 } 49 matice=NULL; 50 matice_offset=UNDEF; 51 matpar=NULL; 52 matpar_offset=UNDEF; 53 numpar=NULL; 54 numpar_offset=UNDEF; 55 onbed=beam_onbed; 56 68 DataSet* loadsin=NULL; 69 DataSet* nodesin=NULL; 70 DataSet* materialsin=NULL; 71 DataSet* parametersin=NULL; 72 73 /*Recover pointers :*/ 74 loadsin=(DataSet*)ploadsin; 75 nodesin=(DataSet*)pnodesin; 76 materialsin=(DataSet*)pmaterialsin; 77 parametersin=(DataSet*)pparametersin; 78 79 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 80 * datasets, using internal ids and offsets hidden in hooks: */ 81 hnodes.configure(nodesin); 82 hmatice.configure(materialsin); 83 hmatpar.configure(materialsin); 84 hnumpar.configure(parametersin); 85 86 } 87 /*}}}*/ 88 /*FUNCTION Beam copy{{{1*/ 89 Object* Beam::copy() { 90 91 return new Beam(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,&this->hnumpar,&this->properties); 92 93 } 94 /*}}}*/ 95 /*FUNCTION Beam DeepEcho{{{1*/ 96 void Beam::DeepEcho(void){ 97 98 printf("Beam:\n"); 99 printf(" id: %i\n",id); 100 hnodes.DeepEcho(); 101 hmatice.DeepEcho(); 102 hmatpar.DeepEcho(); 103 hnumpar.DeepEcho(); 104 properties.DeepEcho(); 105 57 106 return; 58 107 } 59 108 /*}}}*/ 60 61 /*Object marshall*/ 62 /*FUNCTION Beam Marshall{{{1*/ 63 void Beam::Marshall(char** pmarshalled_dataset){ 109 /*FUNCTION Beam Demarshall{{{1*/ 110 void Beam::Demarshall(char** pmarshalled_dataset){ 64 111 65 112 char* marshalled_dataset=NULL; 66 int enum_type=0;113 int i; 67 114 68 115 /*recover marshalled_dataset: */ 69 116 marshalled_dataset=*pmarshalled_dataset; 70 117 71 /*get enum type of Beam: */72 enum_type=BeamEnum();73 74 /*marshall enum: */75 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);76 77 /*marshall Beam data: */78 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);79 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);80 memcpy(marshalled_dataset,&mparid,sizeof(mparid));marshalled_dataset+=sizeof(mparid);81 memcpy(marshalled_dataset,&node_ids,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids);82 memcpy(marshalled_dataset,&nodes,sizeof(nodes));marshalled_dataset+=sizeof(nodes);83 memcpy(marshalled_dataset,&node_offsets,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets);84 memcpy(marshalled_dataset,&matice,sizeof(matice));marshalled_dataset+=sizeof(matice);85 memcpy(marshalled_dataset,&matice_offset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset);86 memcpy(marshalled_dataset,&matpar,sizeof(matpar));marshalled_dataset+=sizeof(matpar);87 memcpy(marshalled_dataset,&matpar_offset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset);88 memcpy(marshalled_dataset,&numparid,sizeof(numparid));marshalled_dataset+=sizeof(numparid);89 memcpy(marshalled_dataset,&numpar,sizeof(numpar));marshalled_dataset+=sizeof(numpar);90 memcpy(marshalled_dataset,&numpar_offset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset);91 memcpy(marshalled_dataset,&h,sizeof(h));marshalled_dataset+=sizeof(h);92 memcpy(marshalled_dataset,&s,sizeof(s));marshalled_dataset+=sizeof(s);93 memcpy(marshalled_dataset,&b,sizeof(b));marshalled_dataset+=sizeof(b);94 memcpy(marshalled_dataset,&k,sizeof(k));marshalled_dataset+=sizeof(k);95 memcpy(marshalled_dataset,&onbed,sizeof(onbed));marshalled_dataset+=sizeof(onbed);96 97 *pmarshalled_dataset=marshalled_dataset;98 return;99 }100 /*}}}*/101 /*FUNCTION Beam MarshallSize{{{1*/102 int Beam::MarshallSize(){103 return sizeof(id)104 +sizeof(mid)105 +sizeof(mparid)106 +sizeof(node_ids)107 +sizeof(nodes)108 +sizeof(node_offsets)109 +sizeof(matice)110 +sizeof(matice_offset)111 +sizeof(matpar)112 +sizeof(matpar_offset)113 +sizeof(numparid)114 +sizeof(numpar)115 +sizeof(numpar_offset)116 +sizeof(h)117 +sizeof(s)118 +sizeof(b)119 +sizeof(k)120 +sizeof(onbed)121 +sizeof(int); //sizeof(int) for enum type122 }123 /*}}}*/124 /*FUNCTION Beam Demarshall{{{1*/125 void Beam::Demarshall(char** pmarshalled_dataset){126 127 char* marshalled_dataset=NULL;128 int i;129 130 /*recover marshalled_dataset: */131 marshalled_dataset=*pmarshalled_dataset;132 133 118 /*this time, no need to get enum type, the pointer directly points to the beginning of the 134 119 *object data (thanks to DataSet::Demarshall):*/ 135 136 120 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 137 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 138 memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid); 139 memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids); 140 memcpy(&nodes,marshalled_dataset,sizeof(nodes));marshalled_dataset+=sizeof(nodes); 141 memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets); 142 memcpy(&matice,marshalled_dataset,sizeof(matice));marshalled_dataset+=sizeof(matice); 143 memcpy(&matice_offset,marshalled_dataset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset); 144 memcpy(&matpar,marshalled_dataset,sizeof(matpar));marshalled_dataset+=sizeof(matpar); 145 memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset); 146 memcpy(&numparid,marshalled_dataset,sizeof(numparid));marshalled_dataset+=sizeof(numparid); 147 memcpy(&numpar,marshalled_dataset,sizeof(numpar));marshalled_dataset+=sizeof(numpar); 148 memcpy(&numpar_offset,marshalled_dataset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset); 149 memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h); 150 memcpy(&s,marshalled_dataset,sizeof(s));marshalled_dataset+=sizeof(s); 151 memcpy(&b,marshalled_dataset,sizeof(b));marshalled_dataset+=sizeof(b); 152 memcpy(&k,marshalled_dataset,sizeof(k));marshalled_dataset+=sizeof(k); 153 memcpy(&onbed,marshalled_dataset,sizeof(onbed));marshalled_dataset+=sizeof(onbed); 154 155 /*nodes and materials are not pointing to correct objects anymore:*/ 156 for(i=0;i<2;i++)nodes[i]=NULL; 157 matice=NULL; 158 matpar=NULL; 159 numpar=NULL; 121 122 /*demarshall hooks: */ 123 hnodes.Demarshall(&marshalled_dataset); 124 hmatice.Demarshall(&marshalled_dataset); 125 hmatpar.Demarshall(&marshalled_dataset); 126 hnumpar.Demarshall(&marshalled_dataset); 127 128 /*demarshall properties: */ 129 properties.Demarshall(&marshalled_dataset); 160 130 161 131 /*return: */ 162 132 *pmarshalled_dataset=marshalled_dataset; 163 133 return; 134 } 135 /*}}}*/ 136 /*FUNCTION Beam Echo {{{1*/ 137 void Beam::Echo(void){ 138 139 printf("Beam:\n"); 140 printf(" id: %i\n",id); 141 hnodes.Echo(); 142 hmatice.Echo(); 143 hmatpar.Echo(); 144 hnumpar.Echo(); 145 properties.Echo(); 146 147 return; 148 } 149 /*}}}*/ 150 /*FUNCTION Beam Marshall{{{1*/ 151 void Beam::Marshall(char** pmarshalled_dataset){ 152 153 char* marshalled_dataset=NULL; 154 int enum_type=0; 155 156 /*recover marshalled_dataset: */ 157 marshalled_dataset=*pmarshalled_dataset; 158 159 /*get enum type of Beam: */ 160 enum_type=BeamEnum(); 161 162 /*marshall enum: */ 163 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 164 165 /*marshall Beam data: */ 166 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 167 168 /*Marshall hooks: */ 169 hnodes.Marshall(&marshalled_dataset); 170 hmatice.Marshall(&marshalled_dataset); 171 hmatpar.Marshall(&marshalled_dataset); 172 hnumpar.Marshall(&marshalled_dataset); 173 174 /*Marshall properties: */ 175 properties.Marshall(&marshalled_dataset); 176 177 *pmarshalled_dataset=marshalled_dataset; 178 return; 179 } 180 /*}}}*/ 181 /*FUNCTION Beam MarshallSize{{{1*/ 182 int Beam::MarshallSize(){ 183 184 return sizeof(id) 185 +hnodes.MarshallSize() 186 +hmatice.MarshallSize() 187 +hmatpar.MarshallSize() 188 +hnumpar.MarshallSize() 189 +properties.MarshallSize() 190 +sizeof(int); //sizeof(int) for enum type 191 } 192 /*}}}*/ 193 /*FUNCTION Beam UpdateFromInputs{{{1*/ 194 void Beam::UpdateFromInputs(void* vinputs){ 195 196 int dofs[1]={0}; 197 double temperature_list[2]; 198 double temperature_average; 199 double B_list[2]; 200 double B_average; 201 202 /*dynamic objects pointed to by hooks: */ 203 Node** nodes=NULL; 204 Matpar* matpar=NULL; 205 Matice* matice=NULL; 206 Numpar* numpar=NULL; 207 208 ParameterInputs* inputs=NULL; 209 210 /*recover pointers: */ 211 inputs=(ParameterInputs*)vinputs; 212 213 /*recover objects from hooks: */ 214 nodes=(Node**)hnodes.deliverp(); 215 matpar=(Matpar*)hmatpar.delivers(); 216 matice=(Matice*)hmatice.delivers(); 217 numpar=(Numpar*)hnumpar.delivers(); 218 219 /*Update internal data if inputs holds new values: */ 220 //if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n"); 221 //For now 222 if(this->properties.h) inputs->Recover("thickness",&this->properties.h[0],1,dofs,2,(void**)nodes); 223 //Later 224 /* 225 if(inputs->Recover("thickness",&new_h[0],1,dofs,2,(void**)nodes)){ 226 //density, needed later: 227 double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater()); 228 //Go through grids: 229 for (i=0;i<2;i++){ 230 if(nodes[i]->IsOnShelf()){ 231 this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium; 232 } 233 this->s[i]=this->b[i]+new_h[i]; 234 this->h[i]=new_h[i]; 235 } 236 } 237 */ 238 if (this->properties.s) inputs->Recover("surface",&this->properties.s[0],1,dofs,2,(void**)nodes); 239 if (this->properties.b) inputs->Recover("bed",&this->properties.b[0],1,dofs,2,(void**)nodes); 240 if (this->properties.k) inputs->Recover("drag",&this->properties.k[0],1,dofs,2,(void**)nodes); 241 if (this->properties.melting) inputs->Recover("melting",&this->properties.melting[0],1,dofs,2,(void**)nodes); 242 if (this->properties.accumulation) inputs->Recover("accumulation",&this->properties.accumulation[0],1,dofs,2,(void**)nodes); 243 if (this->properties.geothermalflux) inputs->Recover("geothermalflux",&this->properties.geothermalflux[0],1,dofs,2,(void**)nodes); 244 245 //Update material if necessary 246 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,2,(void**)nodes)){ 247 temperature_average=(temperature_list[0]+temperature_list[1])/2.0; 248 B_average=Paterson(temperature_average); 249 matice->SetB(B_average); 250 } 251 252 if(inputs->Recover("B",&B_list[0],1,dofs,2,(void**)nodes)){ 253 B_average=(B_list[0]+B_list[1])/2.0; 254 matice->SetB(B_average); 255 } 256 164 257 } 165 258 /*}}}*/ … … 176 269 double xyz_list[numgrids][3]; 177 270 271 /*dynamic objects pointed to by hooks: */ 272 Node** nodes=NULL; 273 Matpar* matpar=NULL; 274 Matice* matice=NULL; 275 Numpar* numpar=NULL; 276 277 278 /*Get dof list on which we will plug the pressure values: */ 279 GetDofList1(&doflist[0]); 280 281 /*recover objects from hooks: */ 282 nodes=(Node**)hnodes.deliverp(); 283 matpar=(Matpar*)hmatpar.delivers(); 284 matice=(Matice*)hmatice.delivers(); 285 numpar=(Numpar*)hnumpar.delivers(); 286 178 287 /*Get node data: */ 179 288 GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids); … … 186 295 g=matpar->GetG(); 187 296 for(i=0;i<numgrids;i++){ 188 pressure[i]=rho_ice*g*( s[i]-xyz_list[i][2]);297 pressure[i]=rho_ice*g*(this->properties.s[i]-xyz_list[i][2]); 189 298 } 190 299 191 300 /*plug local pressure values into global pressure vector: */ 192 301 VecSetValues(p_g,numgrids,doflist,(const double*)pressure,INSERT_VALUES); 193 194 }195 /*}}}*/196 /*FUNCTION Beam Configure{{{1*/197 void Beam::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){198 199 int i;200 201 DataSet* loadsin=NULL;202 DataSet* nodesin=NULL;203 DataSet* materialsin=NULL;204 DataSet* parametersin=NULL;205 206 /*Recover pointers :*/207 loadsin=(DataSet*)ploadsin;208 nodesin=(DataSet*)pnodesin;209 materialsin=(DataSet*)pmaterialsin;210 parametersin=(DataSet*)pparametersin;211 212 /*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */213 ResolvePointers((Object**)nodes,node_ids,node_offsets,2,nodesin);214 215 /*Same for materials: */216 ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin);217 ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin);218 219 /*Same for numpar: */220 ResolvePointers((Object**)&numpar,&numparid,&numpar_offset,1,parametersin);221 222 }223 /*}}}*/224 /*FUNCTION Beam copy{{{1*/225 Object* Beam::copy() {226 227 return new Beam(*this);228 302 229 303 } … … 268 342 GetDofList(&doflist[0],&numberofdofspernode); 269 343 270 if ( onbed){344 if (this->properties.onbed){ 271 345 Ke_gg[0][0]=1; 272 346 Ke_gg[1][1]=1; … … 340 414 double ub,vb; 341 415 416 /*dynamic objects pointed to by hooks: */ 417 Node** nodes=NULL; 418 Matpar* matpar=NULL; 419 Matice* matice=NULL; 420 Numpar* numpar=NULL; 421 342 422 ParameterInputs* inputs=NULL; 343 423 344 424 /*recover pointers: */ 345 425 inputs=(ParameterInputs*)vinputs; 426 427 /*recover objects from hooks: */ 428 nodes=(Node**)hnodes.deliverp(); 429 matpar=(Matpar*)hmatpar.delivers(); 430 matice=(Matice*)hmatice.delivers(); 431 numpar=(Numpar*)hnumpar.delivers(); 346 432 347 433 /*recover doflist: */ … … 389 475 390 476 for(j=0;j<NDOF2;j++){ 391 pe_g_gaussian[NDOF2+j]=constant_part*pow(( s[0]-z_g)/B,n)*slope[j]*Jdet*gauss_weight;477 pe_g_gaussian[NDOF2+j]=constant_part*pow((this->properties.s[0]-z_g)/B,n)*slope[j]*Jdet*gauss_weight; 392 478 } 393 479 … … 399 485 400 486 //Deal with lower surface 401 if ( onbed){487 if (this->properties.onbed){ 402 488 403 489 //compute ub 404 constant_part=-1.58*pow((double)10.0,-(double)10.0)*rho_ice*gravity* h[0];490 constant_part=-1.58*pow((double)10.0,-(double)10.0)*rho_ice*gravity*this->properties.h[0]; 405 491 ub=constant_part*slope[0]; 406 492 vb=constant_part*slope[1]; … … 419 505 } 420 506 /*}}}*/ 421 /*FUNCTION Beam DeepEcho{{{1*/422 void Beam::DeepEcho(void){423 424 printf("Beam:\n");425 printf(" id: %i\n",id);426 printf(" mid: %i\n",mid);427 printf(" mparid: %i\n",mparid);428 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]);429 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]);430 printf(" matice_offset=%i\n",matice_offset);431 printf(" matpar_offset=%i\n",matpar_offset);432 printf(" h=[%g,%g]\n",h[0],h[1]);433 printf(" s=[%g,%g]\n",s[0],s[1]);434 printf(" b=[%g,%g]\n",b[0],b[1]);435 printf(" k=[%g,%g]\n",k[0],k[1]);436 printf(" onbed=%i\n",onbed);437 printf(" nodes: \n");438 if(nodes[0])nodes[0]->Echo();439 if(nodes[1])nodes[1]->Echo();440 if(matice)matice->Echo();441 if(matpar)matpar->Echo();442 443 return;444 }445 /*}}}*/446 507 /*FUNCTION Beam Du{{{1*/ 447 508 void Beam::Du(_p_Vec*,void*,int,int){ 448 509 ISSMERROR(" not supported yet!"); 449 }450 /*}}}*/451 /*FUNCTION Beam Echo {{{1*/452 void Beam::Echo(void){453 454 printf("Beam:\n");455 printf(" id: %i\n",id);456 printf(" mid: %i\n",mid);457 printf(" mparid: %i\n",mparid);458 printf(" node_ids=[%i,%i]\n",node_ids[0],node_ids[1]);459 printf(" node_offsets=[%i,%i]\n",node_offsets[0],node_offsets[1]);460 printf(" matice_offset=%i\n",matice_offset);461 printf(" matpar_offset=%i\n",matpar_offset);462 printf(" h=[%g,%g]\n",h[0],h[1]);463 printf(" s=[%g,%g]\n",s[0],s[1]);464 printf(" b=[%g,%g]\n",b[0],b[1]);465 printf(" k=[%g,%g]\n",k[0],k[1]);466 printf(" onbed=%i\n",onbed);467 printf(" nodes: \n");468 if(nodes[0])nodes[0]->Echo();469 if(nodes[1])nodes[1]->Echo();470 if(matice)matice->Echo();471 if(matpar)matpar->Echo();472 473 return;474 510 } 475 511 /*}}}*/ … … 492 528 int doflist_per_node[MAXDOFSPERNODE]; 493 529 int numberofdofspernode; 530 531 /*dynamic objects pointed to by hooks: */ 532 Node** nodes=NULL; 533 534 /*recover objects from hooks: */ 535 nodes=(Node**)hnodes.deliverp(); 494 536 495 537 for(i=0;i<2;i++){ … … 508 550 void Beam::GetDofList1(int* doflist){ 509 551 552 /*dynamic objects pointed to by hooks: */ 553 Node** nodes=NULL; 554 555 /*recover objects from hooks: */ 556 nodes=(Node**)hnodes.deliverp(); 557 510 558 int i; 511 559 for(i=0;i<2;i++){ … … 535 583 /*FUNCTION Beam GetMatPar{{{1*/ 536 584 void* Beam::GetMatPar(){ 585 586 /*dynamic objects pointed to by hooks: */ 587 Matpar* matpar=NULL; 588 589 /*recover objects from hooks: */ 590 matpar=(Matpar*)hmatpar.delivers(); 591 537 592 return matpar; 538 593 } … … 558 613 void Beam::GetNodes(void** vpnodes){ 559 614 int i; 560 Node** pnodes=(Node**)vpnodes; 561 615 Node** pnodes=NULL; 616 617 /*dynamic objects pointed to by hooks: */ 618 Node** nodes=NULL; 619 620 /*recover nodes: */ 621 pnodes=(Node**)vpnodes; 622 623 /*recover objects from hooks: */ 624 nodes=(Node**)hnodes.deliverp(); 625 562 626 for(i=0;i<3;i++){ 563 627 pnodes[i]=nodes[i]; … … 612 676 /*FUNCTION Beam MaticeConfiguration{{{1*/ 613 677 void Beam::MaticeConfiguration(Matice* beam_matice,int beam_matice_offset){ 614 matice=beam_matice; 615 matice_offset=beam_matice_offset; 678 679 /*dynamic objects pointed to by hooks: */ 680 Matice* matice=NULL; 681 682 /*recover objects from hooks: */ 683 matice=(Matice*)hmatice.delivers(); 684 685 ISSMERROR("not supported yet!"); 686 687 /*matice=beam_matice; 688 matice_offset=beam_matice_offset;*/ 616 689 } 617 690 /*}}}*/ … … 619 692 void Beam::MatparConfiguration(Matpar* beam_matpar,int beam_matpar_offset){ 620 693 621 matpar=beam_matpar; 622 matpar_offset=beam_matpar_offset; 694 /*dynamic objects pointed to by hooks: */ 695 Matpar* matpar=NULL; 696 697 /*recover objects from hooks: */ 698 matpar=(Matpar*)hmatpar.delivers(); 699 700 ISSMERROR("not supported yet!"); 701 702 /*matpar=beam_matpar; 703 matpar_offset=beam_matpar_offset;*/ 623 704 624 705 } … … 638 719 void Beam::NodeConfiguration(int* beam_node_ids,Node* beam_nodes[2],int* beam_node_offsets){ 639 720 640 int i; 721 /*dynamic objects pointed to by hooks: */ 722 Node** nodes=NULL; 723 724 /*recover objects from hooks: */ 725 nodes=(Node**)hnodes.deliverp(); 726 727 ISSMERROR("not supported yet!"); 728 729 /*int i; 641 730 for(i=0;i<2;i++){ 642 731 node_ids[i]=beam_node_ids[i]; 643 732 nodes[i]=beam_nodes[i]; 644 733 node_offsets[i]=beam_node_offsets[i]; 645 } 734 }*/ 646 735 647 736 } … … 652 741 } 653 742 /*}}}*/ 654 /*FUNCTION Beam UpdateFromInputs{{{1*/655 void Beam::UpdateFromInputs(void* vinputs){656 657 int dofs[1]={0};658 double temperature_list[2];659 double temperature_average;660 double B_list[2];661 double B_average;662 663 ParameterInputs* inputs=NULL;664 665 /*recover pointers: */666 inputs=(ParameterInputs*)vinputs;667 668 /*Update internal data if inputs holds new values: */669 inputs->Recover("thickness",&h[0],1,dofs,2,(void**)nodes);670 inputs->Recover("surface",&s[0],1,dofs,2,(void**)nodes);671 inputs->Recover("bed",&b[0],1,dofs,2,(void**)nodes);672 inputs->Recover("drag",&k[0],1,dofs,2,(void**)nodes);673 674 //Update material if necessary675 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,2,(void**)nodes)){676 temperature_average=(temperature_list[0]+temperature_list[1])/2.0;677 B_average=Paterson(temperature_average);678 matice->SetB(B_average);679 }680 if(inputs->Recover("temperature",&temperature_list[0],1,dofs,2,(void**)nodes)){681 temperature_average=(temperature_list[0]+temperature_list[1])/2.0;682 B_average=Paterson(temperature_average);683 matice->SetB(B_average);684 }685 686 if(inputs->Recover("B",&B_list[0],1,dofs,2,(void**)nodes)){687 B_average=(B_list[0]+B_list[1])/2.0;688 matice->SetB(B_average);689 }690 691 }692 /*}}}*/ -
issm/trunk/src/c/objects/Beam.h
r3180 r3402 12 12 #include "./Matpar.h" 13 13 #include "./ParameterInputs.h" 14 #include "./ElementProperties.h" 15 #include "./Hook.h" 16 17 class Object; 18 class DataSet; 14 19 15 20 class Beam: public Element{ … … 20 25 int id; 21 26 22 /*nodes: */23 int node_ids[2]; //node ids24 Node* nodes[2]; //node pointers25 int node_offsets[2]; //node offsets in nodes dataset27 Hook hnodes; //hook to 2 nodes 28 Hook hmatice; //hook to 1 matice 29 Hook hmatpar; //hook to 1 matpar 30 Hook hnumpar; //hook to 1 numpar 26 31 27 /*materials: */ 28 int mid; 29 Matice* matice; 30 int matice_offset; 31 32 int mparid; 33 Matpar* matpar; 34 int matpar_offset; 35 36 int numparid; 37 Numpar* numpar; 38 int numpar_offset; 39 40 double h[2]; 41 double s[2]; 42 double b[2]; 43 double k[2]; 44 45 bool onbed; 46 32 ElementProperties properties; 33 47 34 public: 48 35 49 36 Beam(); 50 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); 37 Beam(int beam_id,int* beam_node_ids, int beam_matice_id, int beam_matpar_id, int beam_numpar_id, ElementProperties* beam_properties); 38 Beam(int beam_id,Hook* beam_hnodes, Hook* beam_hmatice, Hook* beam_hmatpar, Hook* beam_hnumpar, ElementProperties* beam_properties); 51 39 ~Beam(); 52 40 -
issm/trunk/src/c/objects/Sing.cpp
r3332 r3402 24 24 } 25 25 /*}}}*/ 26 /*FUNCTION Sing constructor {{{1*/ 27 Sing::Sing(int sing_id,int* sing_node_ids, int sing_matice_id, int sing_matpar_id, int sing_numpar_id, ElementProperties* singproperties): 28 hnodes(sing_node_ids,1), 29 hmatice(&sing_matice_id,1), 30 hmatpar(&sing_matpar_id,1), 31 hnumpar(&sing_numpar_id,1), 32 properties(singproperties) 33 { 34 35 /*all the initialization has been done by the initializer, just fill in the id: */ 36 this->id=sing_id; 37 38 return; 39 } 40 /*}}}*/ 41 /*FUNCTION Sing other constructor {{{1*/ 42 Sing::Sing(int sing_id,Hook* sing_hnodes, Hook* sing_hmatice, Hook* sing_hmatpar, Hook* sing_hnumpar, ElementProperties* sing_properties): 43 hnodes(sing_hnodes), 44 hmatice(sing_hmatice), 45 hmatpar(sing_hmatpar), 46 hnumpar(sing_hnumpar), 47 properties(sing_properties) 48 { 49 50 /*all the initialization has been done by the initializer, just fill in the id: */ 51 this->id=sing_id; 52 53 return; 54 } 55 /*}}}*/ 26 56 /*FUNCTION Sing::destructor {{{1*/ 27 57 Sing::~Sing(){ … … 29 59 } 30 60 /*}}}*/ 31 /*FUNCTION Sing::creation {{{1*/ 32 Sing::Sing(int sing_id, int sing_mid, int sing_mparid, int sing_numparid,int sing_g, double sing_h, double sing_k){ 33 34 id=sing_id; 35 mid=sing_mid; 36 mparid=sing_mparid; 37 numparid=sing_numparid; 38 39 node_id=sing_g; 40 node_offset=UNDEF; 41 node=NULL; 42 43 numpar=NULL; 44 numpar_offset=UNDEF; 45 46 h=sing_h; 47 k=sing_k; 48 49 matice=NULL; 50 matice_offset=UNDEF; 51 matpar=NULL; 52 matpar_offset=UNDEF; 53 54 numpar=NULL; 55 numpar_offset=UNDEF; 56 57 return; 58 } 59 /*}}}*/ 60 61 /*Object marshall*/ 61 62 /*Object management*/ 63 /*FUNCTION Sing::Configure {{{1*/ 64 void Sing::Configure(void* ploadsin, void* pnodesin,void* pmaterialsin,void* pparametersin){ 65 66 int i; 67 68 DataSet* loadsin=NULL; 69 DataSet* nodesin=NULL; 70 DataSet* materialsin=NULL; 71 DataSet* parametersin=NULL; 72 73 /*Recover pointers :*/ 74 loadsin=(DataSet*)ploadsin; 75 nodesin=(DataSet*)pnodesin; 76 materialsin=(DataSet*)pmaterialsin; 77 parametersin=(DataSet*)pparametersin; 78 79 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 80 * datasets, using internal ids and offsets hidden in hooks: */ 81 hnodes.configure(nodesin); 82 hmatice.configure(materialsin); 83 hmatpar.configure(materialsin); 84 hnumpar.configure(parametersin); 85 86 } 87 /*}}}*/ 88 /*FUNCTION Sing::copy {{{1*/ 89 Object* Sing::copy() { 90 91 return new Sing(*this); 92 93 } 94 /*}}}*/ 95 /*FUNCTION Sing::DeepEcho {{{1*/ 96 void Sing::DeepEcho(void){ 97 98 printf("Sing:\n"); 99 printf(" id: %i\n",id); 100 hnodes.DeepEcho(); 101 hmatice.DeepEcho(); 102 hmatpar.DeepEcho(); 103 hnumpar.DeepEcho(); 104 properties.DeepEcho(); 105 106 return; 107 } 108 /*}}}*/ 109 /*FUNCTION Sing::Demarshall {{{1*/ 110 void Sing::Demarshall(char** pmarshalled_dataset){ 111 112 char* marshalled_dataset=NULL; 113 int i; 114 115 /*recover marshalled_dataset: */ 116 marshalled_dataset=*pmarshalled_dataset; 117 118 /*this time, no need to get enum type, the pointer directly points to the beginning of the 119 *object data (thanks to DataSet::Demarshall):*/ 120 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 121 122 /*demarshall hooks: */ 123 hnodes.Demarshall(&marshalled_dataset); 124 hmatice.Demarshall(&marshalled_dataset); 125 hmatpar.Demarshall(&marshalled_dataset); 126 hnumpar.Demarshall(&marshalled_dataset); 127 128 /*demarshall properties: */ 129 properties.Demarshall(&marshalled_dataset); 130 131 /*return: */ 132 *pmarshalled_dataset=marshalled_dataset; 133 return; 134 } 135 /*}}}*/ 136 /*FUNCTION Sing::Echo{{{1*/ 137 138 void Sing::Echo(void){ 139 140 printf("Sing:\n"); 141 printf(" id: %i\n",id); 142 hnodes.Echo(); 143 hmatice.Echo(); 144 hmatpar.Echo(); 145 hnumpar.Echo(); 146 properties.Echo(); 147 148 return; 149 } 150 /*}}}*/ 62 151 /*FUNCTION Sing::Marshall {{{1*/ 63 152 void Sing::Marshall(char** pmarshalled_dataset){ … … 77 166 /*marshall Sing data: */ 78 167 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); 79 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid); 80 memcpy(marshalled_dataset,&mparid,sizeof(mparid));marshalled_dataset+=sizeof(mparid); 81 memcpy(marshalled_dataset,&node_id,sizeof(node_id));marshalled_dataset+=sizeof(node_id); 82 memcpy(marshalled_dataset,&node,sizeof(node));marshalled_dataset+=sizeof(node); 83 memcpy(marshalled_dataset,&node_offset,sizeof(node_offset));marshalled_dataset+=sizeof(node_offset); 84 memcpy(marshalled_dataset,&matice,sizeof(matice));marshalled_dataset+=sizeof(matice); 85 memcpy(marshalled_dataset,&matice_offset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset); 86 memcpy(marshalled_dataset,&matpar,sizeof(matpar));marshalled_dataset+=sizeof(matpar); 87 memcpy(marshalled_dataset,&matpar_offset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset); 88 memcpy(marshalled_dataset,&numparid,sizeof(numparid));marshalled_dataset+=sizeof(numparid); 89 memcpy(marshalled_dataset,&numpar,sizeof(numpar));marshalled_dataset+=sizeof(numpar); 90 memcpy(marshalled_dataset,&numpar_offset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset); 91 memcpy(marshalled_dataset,&h,sizeof(h));marshalled_dataset+=sizeof(h); 92 memcpy(marshalled_dataset,&k,sizeof(k));marshalled_dataset+=sizeof(k); 93 168 169 /*Marshall hooks: */ 170 hnodes.Marshall(&marshalled_dataset); 171 hmatice.Marshall(&marshalled_dataset); 172 hmatpar.Marshall(&marshalled_dataset); 173 hnumpar.Marshall(&marshalled_dataset); 174 175 /*Marshall properties: */ 176 properties.Marshall(&marshalled_dataset); 177 94 178 *pmarshalled_dataset=marshalled_dataset; 95 179 return; … … 98 182 /*FUNCTION Sing::MashallSize {{{1*/ 99 183 int Sing::MarshallSize(){ 184 100 185 return sizeof(id) 101 +sizeof(mid) 102 +sizeof(mparid) 103 +sizeof(node_id) 104 +sizeof(node) 105 +sizeof(node_offset) 106 +sizeof(matice) 107 +sizeof(matice_offset) 108 +sizeof(matpar) 109 +sizeof(matpar_offset) 110 +sizeof(numparid) 111 +sizeof(numpar) 112 +sizeof(numpar_offset) 113 +sizeof(h) 114 +sizeof(k) 186 +hnodes.MarshallSize() 187 +hmatice.MarshallSize() 188 +hmatpar.MarshallSize() 189 +hnumpar.MarshallSize() 190 +properties.MarshallSize() 115 191 +sizeof(int); //sizeof(int) for enum type 116 192 } 117 193 /*}}}*/ 118 /*FUNCTION Sing::Demarshall {{{1*/ 119 void Sing::Demarshall(char** pmarshalled_dataset){ 120 121 char* marshalled_dataset=NULL; 122 int i; 123 124 /*recover marshalled_dataset: */ 125 marshalled_dataset=*pmarshalled_dataset; 126 127 /*this time, no need to get enum type, the pointer directly points to the beginning of the 128 *object data (thanks to DataSet::Demarshall):*/ 129 130 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 131 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid); 132 memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid); 133 memcpy(&node_id,marshalled_dataset,sizeof(node_id));marshalled_dataset+=sizeof(node_id); 134 memcpy(&node,marshalled_dataset,sizeof(node));marshalled_dataset+=sizeof(node); 135 memcpy(&node_offset,marshalled_dataset,sizeof(node_offset));marshalled_dataset+=sizeof(node_offset); 136 memcpy(&matice,marshalled_dataset,sizeof(matice));marshalled_dataset+=sizeof(matice); 137 memcpy(&matice_offset,marshalled_dataset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset); 138 memcpy(&matpar,marshalled_dataset,sizeof(matpar));marshalled_dataset+=sizeof(matpar); 139 memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset); 140 memcpy(&numparid,marshalled_dataset,sizeof(numparid));marshalled_dataset+=sizeof(numparid); 141 memcpy(&numpar,marshalled_dataset,sizeof(numpar));marshalled_dataset+=sizeof(numpar); 142 memcpy(&numpar_offset,marshalled_dataset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset); 143 memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h); 144 memcpy(&k,marshalled_dataset,sizeof(k));marshalled_dataset+=sizeof(k); 145 146 /*nodes and materials are not pointing to correct objects anymore:*/ 147 node=NULL; 148 matice=NULL; 149 matpar=NULL; 150 numpar=NULL; 151 152 /*return: */ 153 *pmarshalled_dataset=marshalled_dataset; 154 return; 194 /*FUNCTION Sing::UpdateFromInputs {{{1*/ 195 void Sing::UpdateFromInputs(void* vinputs){ 196 197 int dofs[1]={0}; 198 double temperature; 199 double B; 200 double B_average; 201 202 /*dynamic objects pointed to by hooks: */ 203 Node** nodes=NULL; 204 Matpar* matpar=NULL; 205 Matice* matice=NULL; 206 Numpar* numpar=NULL; 207 208 ParameterInputs* inputs=NULL; 209 210 /*recover pointers: */ 211 inputs=(ParameterInputs*)vinputs; 212 213 /*Update internal data if inputs holds new values: */ 214 //if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n"); 215 //For now 216 if(this->properties.h) inputs->Recover("thickness",&this->properties.h[0],1,dofs,1,(void**)nodes); 217 //Later 218 /* 219 if(inputs->Recover("thickness",&new_h[0],1,dofs,1,(void**)nodes)){ 220 //density, needed later: 221 double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater()); 222 //Go through grids: 223 for (i=0;i<1;i++){ 224 if(nodes[i]->IsOnShelf()){ 225 this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium; 226 } 227 this->s[i]=this->b[i]+new_h[i]; 228 this->h[i]=new_h[i]; 229 } 230 } 231 */ 232 if (this->properties.k) inputs->Recover("drag",&this->properties.k[0],1,dofs,1,(void**)nodes); 233 234 //Update material if necessary 235 if(inputs->Recover("temperature_average",&temperature,1,dofs,1,(void**)nodes)){ 236 B_average=Paterson(temperature); 237 matice->SetB(B_average); 238 } 239 else if(inputs->Recover("temperature",&temperature,1,dofs,1,(void**)nodes)){ 240 B=Paterson(temperature); 241 matice->SetB(B); 242 } 243 244 if(inputs->Recover("B",&B,1,dofs,1,(void**)nodes)){ 245 matice->SetB(B); 246 } 247 155 248 } 156 249 /*}}}*/ … … 166 259 double rho_ice,g; 167 260 261 /*dynamic objects pointed to by hooks: */ 262 Node** nodes=NULL; 263 Matpar* matpar=NULL; 264 Matice* matice=NULL; 265 Numpar* numpar=NULL; 266 168 267 /*Get dof list on which we will plug the pressure values: */ 169 268 GetDofList1(&doflist[0]); … … 172 271 rho_ice=matpar->GetRhoIce(); 173 272 g=matpar->GetG(); 174 pressure[0]=rho_ice*g* h;273 pressure[0]=rho_ice*g*this->properties.h[0]; 175 274 176 275 /*plug local pressure values into global pressure vector: */ 177 276 VecSetValues(p_g,numgrids,doflist,(const double*)pressure,INSERT_VALUES); 178 179 }180 /*}}}*/181 /*FUNCTION Sing::Configure {{{1*/182 void Sing::Configure(void* ploadsin, void* pnodesin,void* pmaterialsin,void* pparametersin){183 184 int i;185 186 DataSet* nodesin=NULL;187 DataSet* materialsin=NULL;188 DataSet* parametersin=NULL;189 190 /*Recover pointers :*/191 nodesin=(DataSet*)pnodesin;192 materialsin=(DataSet*)pmaterialsin;193 parametersin=(DataSet*)pparametersin;194 195 /*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */196 ResolvePointers((Object**)&node,&node_id,&node_offset,1,nodesin);197 198 /*Same for materials: */199 ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin);200 ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin);201 202 /*Same for numpar: */203 ResolvePointers((Object**)&numpar,&numparid,&numpar_offset,1,parametersin);204 205 }206 /*}}}*/207 /*FUNCTION Sing::copy {{{1*/208 Object* Sing::copy() {209 210 return new Sing(*this);211 277 212 278 } … … 278 344 const int NDOF2=2; 279 345 const int numdofs=NDOF2*numgrids; 280 int doflist[numdofs];346 int doflist[numdofs]; 281 347 int dofs[1]={0}; 282 348 int found=0; … … 288 354 int numberofdofspernode; 289 355 double rho_ice,gravity,n,B; 356 double thickness; 357 358 /*dynamic objects pointed to by hooks: */ 359 Node** node=NULL; 360 Matpar* matpar=NULL; 361 Matice* matice=NULL; 362 Numpar* numpar=NULL; 290 363 291 364 ParameterInputs* inputs=NULL; … … 309 382 n=matice->GetN(); 310 383 B=matice->GetB(); 311 312 ub=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*h*slope[0]; 313 vb=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*h*slope[1]; 384 thickness=this->properties.h[0]; 385 386 ub=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[0]; 387 vb=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[1]; 314 388 315 389 //compute constant_part 316 390 constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2)); 317 391 318 pe_g[0]=ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow( h,n)/(pow(B,n)*(n+1))*slope[0];319 pe_g[1]=vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow( h,n)/(pow(B,n)*(n+1))*slope[1];392 pe_g[0]=ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0]; 393 pe_g[1]=vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1]; 320 394 321 395 VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES); 322 396 323 397 324 }325 /*}}}*/326 /*FUNCTION Sing::DeepEcho {{{1*/327 void Sing::DeepEcho(void){328 329 printf("Sing:\n");330 printf(" id: %i\n",id);331 printf(" mid: %i\n",mid);332 printf(" mparid: %i\n",mparid);333 printf(" node_id=[%i]\n",node_id);334 printf(" node_offset=[%i]\n",node_offset);335 printf(" matice_offset=%i\n",matice_offset);336 printf(" matpar_offset=%i\n",matpar_offset);337 printf(" h=[%g]\n",h);338 printf(" k=[%g]\n",h);339 printf(" node: \n");340 if(node)node->Echo();341 if(matice)matice->Echo();342 if(matpar)matpar->Echo();343 344 return;345 398 } 346 399 /*}}}*/ … … 348 401 void Sing::Du(_p_Vec*,void*,int,int){ 349 402 ISSMERROR(" not supported yet!"); 350 }351 /*}}}*/352 /*FUNCTION Sing::Echo{{{1*/353 354 void Sing::Echo(void){355 356 printf("Sing:\n");357 printf(" id: %i\n",id);358 printf(" mid: %i\n",mid);359 printf(" mparid: %i\n",mparid);360 printf(" node_id=[%i]\n",node_id);361 printf(" node_offset=[%i]\n",node_offset);362 printf(" matice_offset=%i\n",matice_offset);363 printf(" matpar_offset=%i\n",matpar_offset);364 printf(" h=[%g]\n",h);365 printf(" k=[%g]\n",h);366 printf(" node: \n");367 if(node)node->Echo();368 if(matice)matice->Echo();369 if(matpar)matpar->Echo();370 371 return;372 403 } 373 404 /*}}}*/ … … 391 422 int numberofdofspernode; 392 423 393 node->GetDofList(&doflist_per_node[0],&numberofdofspernode); 424 /*dynamic objects pointed to by hooks: */ 425 Node** nodes=NULL; 426 427 /*recover objects from hooks: */ 428 nodes=(Node**)hnodes.deliverp(); 429 430 nodes[0]->GetDofList(&doflist_per_node[0],&numberofdofspernode); 394 431 for(i=0;i<numberofdofspernode;i++){ 395 432 doflist[i]=doflist_per_node[i]; … … 404 441 void Sing::GetDofList1(int* doflist){ 405 442 443 /*dynamic objects pointed to by hooks: */ 444 Node** nodes=NULL; 445 446 /*recover objects from hooks: */ 447 nodes=(Node**)hnodes.deliverp(); 448 406 449 int i; 407 doflist[0]=node ->GetDofList1();450 doflist[0]=nodes[0]->GetDofList1(); 408 451 409 452 } … … 414 457 /*FUNCTION Sing::GetMatPar {{{1*/ 415 458 void* Sing::GetMatPar(){ 459 460 /*dynamic objects pointed to by hooks: */ 461 Matpar* matpar=NULL; 462 463 /*recover objects from hooks: */ 464 matpar=(Matpar*)hmatpar.delivers(); 465 416 466 return matpar; 417 467 } … … 425 475 void Sing::GetNodes(void** vpnodes){ 426 476 427 Node** pnodes=(Node**)vpnodes; 428 429 pnodes[0]=node; 477 Node** pnodes=NULL; 478 479 /*dynamic objects pointed to by hooks: */ 480 Node** nodes=NULL; 481 482 /*recover nodes: */ 483 pnodes=(Node**)vpnodes; 484 485 /*recover objects from hooks: */ 486 nodes=(Node**)hnodes.deliverp(); 487 488 pnodes[0]=nodes[0]; 430 489 } 431 490 /*}}}*/ … … 467 526 /*FUNCTION Sing::MaticeConfiguration {{{1*/ 468 527 void Sing::MaticeConfiguration(Matice* sing_matice,int sing_matice_offset){ 469 matice=sing_matice; 470 matice_offset=sing_matice_offset; 528 529 /*dynamic objects pointed to by hooks: */ 530 Matice* matice=NULL; 531 532 /*recover objects from hooks: */ 533 matice=(Matice*)hmatice.delivers(); 534 535 ISSMERROR("not supported yet!"); 536 537 /*matice=sing_matice; 538 matice_offset=sing_matice_offset;*/ 471 539 } 472 540 /*}}}*/ … … 474 542 void Sing::MatparConfiguration(Matpar* sing_matpar,int sing_matpar_offset){ 475 543 476 matpar=sing_matpar; 477 matpar_offset=sing_matpar_offset; 544 /*dynamic objects pointed to by hooks: */ 545 Matpar* matpar=NULL; 546 547 /*recover objects from hooks: */ 548 matpar=(Matpar*)hmatpar.delivers(); 549 550 ISSMERROR("not supported yet!"); 551 552 /*matpar=sing_matpar; 553 matpar_offset=sing_matpar_offset;*/ 478 554 479 555 } … … 495 571 } 496 572 /*}}}*/ 497 /*FUNCTION Sing::UpdateFromInputs {{{1*/498 void Sing::UpdateFromInputs(void* vinputs){499 500 int dofs[1]={0};501 double temperature;502 double B;503 504 ParameterInputs* inputs=NULL;505 506 /*recover pointers: */507 inputs=(ParameterInputs*)vinputs;508 509 /*Update internal data if inputs holds new values: */510 inputs->Recover("thickness",&h,1,dofs,1,(void**)&node);511 inputs->Recover("drag",&k,1,dofs,1,(void**)&node);512 513 //Update material if necessary514 if(inputs->Recover("temperature_average",&temperature,1,dofs,1,(void**)&node)){515 B=Paterson(temperature);516 matice->SetB(B);517 }518 if(inputs->Recover("temperature",&temperature,1,dofs,1,(void**)&node)){519 B=Paterson(temperature);520 matice->SetB(B);521 }522 523 if(inputs->Recover("B",&B,1,dofs,1,(void**)&node)){524 matice->SetB(B);525 }526 527 }528 /*}}}*/ -
issm/trunk/src/c/objects/Sing.h
r3180 r3402 11 11 #include "./Matpar.h" 12 12 #include "./ParameterInputs.h" 13 #include "./ElementProperties.h" 14 #include "./Hook.h" 13 15 14 16 class Sing: public Element{ … … 16 18 private: 17 19 18 /*id :*/20 /*ids:*/ 19 21 int id; 20 22 21 /*node: */22 int node_id; //node id23 Node* node; //node pointer24 int node_offset; //node offset in nodes dataset23 Hook hnodes; //hook to 2 nodes 24 Hook hmatice; //hook to 1 matice 25 Hook hmatpar; //hook to 1 matpar 26 Hook hnumpar; //hook to 1 numpar 25 27 26 /*material: */ 27 int mid; 28 Matice* matice; 29 int matice_offset; 30 31 int mparid; 32 Matpar* matpar; 33 int matpar_offset; 34 35 int numparid; 36 Numpar* numpar; 37 int numpar_offset; 38 39 double h; 40 double k; 28 ElementProperties properties; 41 29 42 30 public: 43 31 44 32 Sing(); 45 Sing(int sing_id, int sing_mid, int sing_mparid, int sing_numparid,int sing_g, double sing_h, double sing_k); 33 Sing(int sing_id,int* sing_node_ids, int sing_matice_id, int sing_matpar_id, int sing_numpar_id, ElementProperties* sing_properties); 34 Sing(int sing_id,Hook* sing_hnodes, Hook* sing_hmatice, Hook* sing_hmatpar, Hook* sing_hnumpar, ElementProperties* sing_properties); 46 35 ~Sing(); 47 36 -
issm/trunk/src/c/objects/Tria.h
r3388 r3402 19 19 20 20 class Object; 21 class Hook;22 class ElementProperties;23 class DataSet;24 21 25 22 class Tria: public Element{
Note:
See TracChangeset
for help on using the changeset viewer.