Changeset 4286
- Timestamp:
- 06/28/10 23:38:28 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Tria.cpp
r4285 r4286 5110 5110 } 5111 5111 /*}}}*/ 5112 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz(Vec solution){{{1*/ 5113 void Tria::GetSolutionFromInputsDiagnosticHoriz(Vec solution){ 5114 5115 int i; 5116 5117 const int numvertices=3; 5118 const int numdofpervertex=2; 5119 const int numdof=numdofpervertex*numvertices; 5120 double gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}}; 5121 5122 int doflist[numdof]; 5123 double values[numdof]; 5124 double vx; 5125 double vy; 5126 5127 int dummy; 5128 5129 /*Get dof list: */ 5130 GetDofList(&doflist[0],&dummy); 5131 5132 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ 5133 /*P1 element only for now*/ 5134 for(i=0;i<numvertices;i++){ 5135 5136 /*Recover vx and vy*/ 5137 inputs->GetParameterValue(&vx,&gauss[i][0],VxEnum); 5138 inputs->GetParameterValue(&vy,&gauss[i][0],VyEnum); 5139 values[i*numdofpervertex+0]=vx; 5140 values[i*numdofpervertex+1]=vy; 5141 } 5142 5143 /*Add value to global vector*/ 5144 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES); 5145 5146 } 5147 /*}}}*/ 5112 5148 /*FUNCTION Tria::GradjDragStokes {{{1*/ 5113 5149 void Tria::GradjDragStokes(Vec gradient){ … … 5283 5319 } 5284 5320 /*}}}*/ 5321 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{1*/ 5322 void Tria::InputUpdateFromSolutionDiagnosticHoriz(double* solution){ 5323 5324 int i; 5325 5326 const int numvertices=3; 5327 const int numdofpervertex=2; 5328 const int numdof=numdofpervertex*numvertices; 5329 5330 int doflist[numdof]; 5331 double values[numdof]; 5332 double vx[numvertices]; 5333 double vy[numvertices]; 5334 double vz[numvertices]; 5335 double vel[numvertices]; 5336 double pressure[numvertices]; 5337 double thickness[numvertices]; 5338 double rho_ice,g; 5339 double gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}}; 5340 5341 int dummy; 5342 Input* VzInput=NULL; 5343 double* VzPtr=NULL; 5344 5345 /*Get dof list: */ 5346 GetDofList(&doflist[0],&dummy); 5347 5348 /*Use the dof list to index into the solution vector: */ 5349 for(i=0;i<numdof;i++){ 5350 values[i]=solution[doflist[i]]; 5351 } 5352 5353 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ 5354 for(i=0;i<numvertices;i++){ 5355 vx[i]=values[i*numdofpervertex+0]; 5356 vy[i]=values[i*numdofpervertex+1]; 5357 } 5358 5359 /*Get Vz*/ 5360 VzInput=inputs->GetInput(VzEnum); 5361 if (VzInput){ 5362 if (VzInput->Enum()!=TriaVertexInputEnum){ 5363 ISSMERROR("Cannot compute Vel as Vz is of type %s",EnumAsString(VzInput->Enum())); 5364 } 5365 VzInput->GetValuesPtr(&VzPtr,&dummy); 5366 for(i=0;i<numvertices;i++) vz[i]=VzPtr[i]; 5367 } 5368 else{ 5369 for(i=0;i<numvertices;i++) vz[i]=0.0; 5370 } 5371 5372 /*Now Compute vel*/ 5373 for(i=0;i<numvertices;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 5374 5375 /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D, 5376 *so the pressure is just the pressure at the bedrock: */ 5377 rho_ice=matpar->GetRhoIce(); 5378 g=matpar->GetG(); 5379 inputs->GetParameterValues(&thickness[0],&gauss[0][0],3,ThicknessEnum); 5380 5381 for(i=0;i<numvertices;i++){ 5382 pressure[i]=rho_ice*g*thickness[i]; 5383 } 5384 5385 /*Now, we have to move the previous Vx and Vy inputs to old 5386 * status, otherwise, we'll wipe them off: */ 5387 this->inputs->ChangeEnum(VxEnum,VxOldEnum); 5388 this->inputs->ChangeEnum(VyEnum,VyOldEnum); 5389 this->inputs->ChangeEnum(PressureEnum,PressureOldEnum); 5390 5391 /*Add vx and vy as inputs to the tria element: */ 5392 this->inputs->AddInput(new TriaVertexInput(VxEnum,vx)); 5393 this->inputs->AddInput(new TriaVertexInput(VyEnum,vy)); 5394 this->inputs->AddInput(new TriaVertexInput(VelEnum,vel)); 5395 this->inputs->AddInput(new TriaVertexInput(PressureEnum,pressure)); 5396 5397 } 5398 /*}}}*/ 5399 /*FUNCTION Tria::InputUpdateFromSolutionSlopeCompute {{{1*/ 5400 void Tria::InputUpdateFromSolutionSlopeCompute(double* solution){ 5401 ISSMERROR(" not supported yet!"); 5402 } 5403 /*}}}*/ 5404 /*FUNCTION Tria::InputUpdateFromSolutionPrognostic {{{1*/ 5405 void Tria::InputUpdateFromSolutionPrognostic(double* solution){ 5406 5407 int i; 5408 5409 const int numvertices=3; 5410 const int numdofpervertex=1; 5411 const int numdof=numdofpervertex*numvertices; 5412 5413 int doflist[numdof]; 5414 double values[numdof]; 5415 double thickness[numvertices]; 5416 5417 int dummy; 5418 5419 /*Get dof list: */ 5420 GetDofList(&doflist[0],&dummy); 5421 5422 /*Use the dof list to index into the solution vector: */ 5423 for(i=0;i<numdof;i++){ 5424 values[i]=solution[doflist[i]]; 5425 } 5426 5427 /*Add thickness as inputs to the tria element: */ 5428 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,values)); 5429 } 5430 /*}}}*/ 5431 /*FUNCTION Tria::InputUpdateFromSolutionPrognostic2 {{{1*/ 5432 void Tria::InputUpdateFromSolutionPrognostic2(double* solution){ 5433 ISSMERROR(" not supported yet!"); 5434 } 5435 /*}}}*/ 5436 /*FUNCTION Tria::InputUpdateFromSolutionBalancedthickness {{{1*/ 5437 void Tria::InputUpdateFromSolutionBalancedthickness(double* solution){ 5438 5439 int i; 5440 5441 const int numvertices=3; 5442 const int numdofpervertex=1; 5443 const int numdof=numdofpervertex*numvertices; 5444 5445 int doflist[numdof]; 5446 double values[numdof]; 5447 double thickness[numvertices]; 5448 5449 int dummy; 5450 5451 /*Get dof list: */ 5452 GetDofList(&doflist[0],&dummy); 5453 5454 /*Use the dof list to index into the solution vector: */ 5455 for(i=0;i<numdof;i++){ 5456 values[i]=solution[doflist[i]]; 5457 } 5458 5459 /*Add thickness as inputs to the tria element: */ 5460 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,values)); 5461 } 5462 /*}}}*/ 5463 /*FUNCTION Tria::InputUpdateFromSolutionBalancedthickness2 {{{1*/ 5464 void Tria::InputUpdateFromSolutionBalancedthickness2(double* solution){ 5465 ISSMERROR(" not supported yet!"); 5466 } 5467 /*}}}*/ 5468 /*FUNCTION Tria::InputUpdateFromSolutionBalancedvelocities {{{1*/ 5469 void Tria::InputUpdateFromSolutionBalancedvelocities(double* solution){ 5470 ISSMERROR(" not supported yet!"); 5471 } 5472 /*}}}*/ 5473 /*FUNCTION Tria::IsInput{{{1*/ 5474 bool Tria::IsInput(int name){ 5475 if (name==SurfaceSlopeXEnum || 5476 name==SurfaceSlopeYEnum){ 5477 return true; 5478 } 5479 else return false; 5480 } 5481 /*}}}*/ 5285 5482 /*FUNCTION Tria::SetClone {{{1*/ 5286 5483 void Tria::SetClone(int* minranks){
Note:
See TracChangeset
for help on using the changeset viewer.