Changeset 4924
- Timestamp:
- 08/02/10 12:58:09 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r4921 r4924 3318 3318 void Penta::CreatePVectorDiagnosticHutter(Vec pg){ 3319 3319 3320 /*Collapsed formulation: */ 3321 Beam* beam=NULL; 3322 int i; 3320 int i,j,k; 3321 3322 const int numgrids=6; 3323 const int NDOF2=2; 3324 const int numdofs=NDOF2*numgrids; 3325 int doflist[numdofs]; 3326 int numberofdofspernode; 3327 double pe_g[numdofs]={0.0}; 3328 double xyz_list[numgrids][3]; 3329 double z_list[numgrids]; 3330 double z_segment[2]; 3331 double slope2,constant_part; 3332 double gauss[numdofs][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}}; 3333 int node0,node1; 3334 BeamRef* beam=NULL; 3335 3336 /*gaussian points: */ 3337 int num_gauss; 3338 double* segment_gauss_coord=NULL; 3339 double gauss_coord; 3340 double* gauss_weights=NULL; 3341 double gauss_weight; 3342 int ig; 3343 double slope[2]; 3344 3345 double z_g; 3346 double rho_ice,gravity,n,B; 3347 double Jdet; 3348 double ub,vb; 3349 double surface,thickness; 3350 double slopex,slopey; 3323 3351 3324 3352 /*flags: */ 3325 3353 bool onwater; 3354 bool onbed; 3355 bool onsurface; 3356 int connectivity[2]; 3357 3358 /*Inputs*/ 3359 Input* thickness_input; 3360 Input* surface_input; 3361 Input* slopex_input; 3362 Input* slopey_input; 3326 3363 3327 3364 /*recover some inputs: */ … … 3331 3368 if(onwater)return; 3332 3369 3333 /*Spawn 3 beam elements: */ 3370 /*recover doflist: */ 3371 GetDofList(&doflist[0],&numberofdofspernode); 3372 3373 /*recover some inputs: */ 3374 inputs->GetParameterValue(&onbed,ElementOnBedEnum); 3375 inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum); 3376 3377 /*recover parameters: */ 3378 rho_ice=matpar->GetRhoIce(); 3379 gravity=matpar->GetG(); 3380 n=matice->GetN(); 3381 B=matice->GetB(); 3382 3383 //Initilaize beam 3384 beam=new BeamRef(); 3385 3386 //recover extra inputs 3387 thickness_input=inputs->GetInput(ThicknessEnum); 3388 surface_input=inputs->GetInput(SurfaceEnum); 3389 slopex_input=inputs->GetInput(SurfaceSlopeXEnum); 3390 slopey_input=inputs->GetInput(SurfaceSlopeYEnum); 3391 3392 GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids); 3393 for(i=0;i<numgrids;i++)z_list[i]=xyz_list[i][2]; 3394 3395 //Get gaussian points and weights. order 2 since we have a product of 2 nodal functions 3396 num_gauss=3; 3397 GaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss); 3398 3399 /*Loop on the three segments*/ 3334 3400 for(i=0;i<3;i++){ 3335 beam=(Beam*)SpawnBeam(i,i+3); //[0 3], [1 4] and [2 5] are the four vertical edges of the Penta 3336 beam->CreatePVector(pg); 3337 } 3338 3339 /*clean up*/ 3401 slopex_input->GetParameterValue(&slopex, &gauss[i][0]); 3402 slopey_input->GetParameterValue(&slopey, &gauss[i][0]); 3403 surface_input->GetParameterValue(&surface, &gauss[i][0]); 3404 thickness_input->GetParameterValue(&thickness, &gauss[i][0]); 3405 3406 //compute slope2 slopex and slopey 3407 slope2=pow(slopex,2)+pow(slopey,2); 3408 3409 //%compute constant_part 3410 constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2)); 3411 3412 z_segment[0]=z_list[i]; 3413 z_segment[1]=z_list[i+3]; 3414 3415 node0=i; 3416 node1=i+3; 3417 3418 connectivity[0]=nodes[node0]->GetConnectivity(); 3419 connectivity[1]=nodes[node1]->GetConnectivity(); 3420 3421 /*Loop on the Gauss points: */ 3422 for(ig=0;ig<num_gauss;ig++){ 3423 3424 //Pick up the gaussian point and its weight: 3425 gauss_weight=gauss_weights[ig]; 3426 gauss_coord=segment_gauss_coord[ig]; 3427 3428 beam->GetParameterValue(&z_g, &z_segment[0],gauss_coord); 3429 3430 //Get Jacobian determinant: 3431 beam->GetJacobianDeterminant(&Jdet, &z_segment[0],gauss_coord); 3432 3433 if (onsurface){ 3434 for(j=0;j<NDOF2;j++){ 3435 pe_g[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss_weight/(double)connectivity[1]; 3436 } 3437 } 3438 else{//connectivity is too large, should take only half on it 3439 for(j=0;j<NDOF2;j++){ 3440 pe_g[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss_weight*2/(double)connectivity[1]; 3441 } 3442 } 3443 } 3444 3445 //Deal with lower surface 3446 if (onbed){ 3447 3448 //compute ub 3449 constant_part=-1.58*pow((double)10.0,-(double)10.0)*rho_ice*gravity*thickness; 3450 ub=constant_part*slopex; 3451 vb=constant_part*slopey; 3452 3453 //Add to pe: 3454 pe_g[2*node0]+=ub/(double)connectivity[0]; 3455 pe_g[2*node0+1]+=vb/(double)connectivity[0]; 3456 } 3457 } 3458 3459 /*Add pe_g to global vector pg: */ 3460 VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES); 3461 3462 /*Clean up */ 3340 3463 delete beam; 3341 3342 3464 } 3343 3465 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.