Changeset 5651
- Timestamp:
- 09/01/10 16:04:42 (15 years ago)
- Location:
- issm/trunk/src/c/objects
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk/src/c/objects/Elements/Penta.cpp ¶
r5647 r5651 2384 2384 2385 2385 /* 3d gaussian points: */ 2386 int num_gauss,ig; 2387 double* first_gauss_area_coord = NULL; 2388 double* second_gauss_area_coord = NULL; 2389 double* third_gauss_area_coord = NULL; 2390 double* fourth_gauss_vert_coord = NULL; 2391 double* area_gauss_weights = NULL; 2392 double* vert_gauss_weights = NULL; 2393 int ig1,ig2; 2394 double gauss_weight1,gauss_weight2; 2395 double gauss_coord[4]; 2396 int order_area_gauss; 2397 int num_vert_gauss; 2398 int num_area_gauss; 2399 double gauss_weight; 2400 2401 /* 2d gaussian point: */ 2402 int num_gauss2d; 2403 double* first_gauss_area_coord2d = NULL; 2404 double* second_gauss_area_coord2d = NULL; 2405 double* third_gauss_area_coord2d = NULL; 2406 double* gauss_weights2d=NULL; 2407 double gauss_l1l2l3[3]; 2386 int ig; 2387 GaussPenta *gauss=NULL; 2388 GaussTria *gauss_tria=NULL; 2408 2389 2409 2390 /* material data: */ … … 2471 2452 GetDofList(&doflistp,PattynApproximationEnum); //MacAyeal dof list 2472 2453 2473 /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore2474 get tria gaussian points as well as segment gaussian points. For tria gaussian2475 points, order of integration is 2, because we need to integrate the product tB*D*B'2476 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian2477 points, same deal, which yields 3 gaussian points.*/2478 2479 order_area_gauss=5;2480 num_vert_gauss=5;2481 2482 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);2483 2484 2454 /*Retrieve all inputs we will be needing: */ 2485 2455 vx_input=inputs->GetInput(VxEnum); … … 2489 2459 2490 2460 /* Start looping on the number of gaussian points: */ 2491 for (ig1=0; ig1<num_area_gauss; ig1++){ 2492 for (ig2=0; ig2<num_vert_gauss; ig2++){ 2493 2494 /*Pick up the gaussian point: */ 2495 gauss_weight1=*(area_gauss_weights+ig1); 2496 gauss_weight2=*(vert_gauss_weights+ig2); 2497 gauss_weight=gauss_weight1*gauss_weight2; 2498 2499 gauss_coord[0]=*(first_gauss_area_coord+ig1); 2500 gauss_coord[1]=*(second_gauss_area_coord+ig1); 2501 gauss_coord[2]=*(third_gauss_area_coord+ig1); 2502 gauss_coord[3]=*(fourth_gauss_vert_coord+ig2); 2503 2504 /*Get strain rate from velocity: */ 2505 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss_coord,vx_input,vy_input); 2506 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss_coord,vxold_input,vyold_input); 2507 2508 /*Get viscosity: */ 2509 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2510 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2511 2512 /*Get B and Bprime matrices: */ 2513 GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss_coord); 2514 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_coord); 2515 2516 /* Get Jacobian determinant: */ 2517 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 2518 2519 /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant 2520 onto this scalar matrix, so that we win some computational time: */ 2521 2522 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2523 D_scalar=2*newviscosity*gauss_weight*Jdet; 2524 for (i=0;i<3;i++){ 2525 D[i][i]=D_scalar; 2526 } 2527 2528 /* Do the triple product tB*D*Bprime: */ 2529 TripleMultiply( &B[0][0],3,numdofp,1, 2530 &D[0][0],3,3,0, 2531 &Bprime[0][0],3,numdofm,0, 2532 &Ke_gg_gaussian[0][0],0); 2533 2534 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ 2535 for( i=0; i<numdofp; i++){ 2536 for(j=0;j<numdofm; j++){ 2537 Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2538 } 2539 } 2540 } //for (ig2=0; ig2<num_vert_gauss; ig2++) 2541 } //for (ig1=0; ig1<num_area_gauss; ig1++) 2461 gauss=new GaussPenta(5,5); 2462 gauss_tria=new GaussTria(); 2463 for (ig=gauss->begin();ig<gauss->end();ig++){ 2464 2465 gauss->GaussPoint(ig); 2466 gauss->SynchronizeGaussTria(gauss_tria); 2467 2468 /*Get strain rate from velocity: */ 2469 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 2470 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input); 2471 2472 /*Get viscosity: */ 2473 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2474 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2475 2476 /*Get B and Bprime matrices: */ 2477 GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss); 2478 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2479 2480 /* Get Jacobian determinant: */ 2481 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2482 2483 /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant 2484 onto this scalar matrix, so that we win some computational time: */ 2485 2486 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2487 D_scalar=2*newviscosity*gauss->weight*Jdet; 2488 for (i=0;i<3;i++) D[i][i]=D_scalar; 2489 2490 /* Do the triple product tB*D*Bprime: */ 2491 TripleMultiply( &B[0][0],3,numdofp,1, 2492 &D[0][0],3,3,0, 2493 &Bprime[0][0],3,numdofm,0, 2494 &Ke_gg_gaussian[0][0],0); 2495 2496 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ 2497 for( i=0; i<numdofp; i++) for(j=0;j<numdofm; j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2498 } 2542 2499 2543 2500 /*Add Ke_gg and its transpose to global matrix Kgg: */ … … 2558 2515 delete tria->matice; delete tria; 2559 2516 2560 xfree((void**)&first_gauss_area_coord);2561 xfree((void**)&second_gauss_area_coord);2562 xfree((void**)&third_gauss_area_coord);2563 xfree((void**)&fourth_gauss_vert_coord);2564 xfree((void**)&area_gauss_weights);2565 xfree((void**)&vert_gauss_weights);2566 xfree((void**)&first_gauss_area_coord2d);2567 xfree((void**)&second_gauss_area_coord2d);2568 xfree((void**)&third_gauss_area_coord2d);2569 xfree((void**)&gauss_weights2d);2570 2517 xfree((void**)&doflistm); 2571 2518 xfree((void**)&doflistp); 2519 delete gauss; 2520 delete gauss_tria; 2572 2521 } 2573 2522 /*}}}*/ … … 3113 3062 3114 3063 /* 3d gaussian points: */ 3115 int num_gauss,ig; 3116 double* first_gauss_area_coord = NULL; 3117 double* second_gauss_area_coord = NULL; 3118 double* third_gauss_area_coord = NULL; 3119 double* fourth_gauss_vert_coord = NULL; 3120 double* area_gauss_weights = NULL; 3121 double* vert_gauss_weights = NULL; 3122 int ig1,ig2; 3123 double gauss_weight1,gauss_weight2; 3124 double gauss_coord[4]; 3125 int order_area_gauss; 3126 int num_vert_gauss; 3127 int num_area_gauss; 3128 double gauss_weight; 3064 int ig; 3065 GaussPenta *gauss=NULL; 3129 3066 3130 3067 /* matrices: */ … … 3164 3101 GetDofList(&doflist); 3165 3102 3166 /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore3167 get tria gaussian points as well as segment gaussian points. For tria gaussian3168 points, order of integration is 2, because we need to integrate the product tB*D*B'3169 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian3170 points, same deal, which yields 3 gaussian points.*/3171 3172 order_area_gauss=2;3173 num_vert_gauss=2;3174 3175 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);3176 3177 3103 /* Start looping on the number of gaussian points: */ 3178 for (ig1=0; ig1<num_area_gauss; ig1++){ 3179 for (ig2=0; ig2<num_vert_gauss; ig2++){ 3180 3181 /*Pick up the gaussian point: */ 3182 gauss_weight1=*(area_gauss_weights+ig1); 3183 gauss_weight2=*(vert_gauss_weights+ig2); 3184 gauss_weight=gauss_weight1*gauss_weight2; 3185 3186 gauss_coord[0]=*(first_gauss_area_coord+ig1); 3187 gauss_coord[1]=*(second_gauss_area_coord+ig1); 3188 gauss_coord[2]=*(third_gauss_area_coord+ig1); 3189 gauss_coord[3]=*(fourth_gauss_vert_coord+ig2); 3190 3191 /*Get B and Bprime matrices: */ 3192 GetBVert(&B[0][0], &xyz_list[0][0], gauss_coord); 3193 GetBprimeVert(&Bprime[0][0], &xyz_list[0][0], gauss_coord); 3194 3195 /* Get Jacobian determinant: */ 3196 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 3197 DL_scalar=gauss_weight*Jdet; 3198 3199 /* Do the triple product tB*D*Bprime: */ 3200 TripleMultiply( &B[0][0],1,numgrids,1, 3201 &DL_scalar,1,1,0, 3202 &Bprime[0][0],1,numgrids,0, 3203 &Ke_gg_gaussian[0][0],0); 3204 3205 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ 3206 for( i=0; i<numdof; i++){ 3207 for(j=0;j<numdof;j++){ 3208 Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 3209 } 3210 } 3211 } //for (ig2=0; ig2<num_vert_gauss; ig2++) 3212 } //for (ig1=0; ig1<num_area_gauss; ig1++) 3104 gauss=new GaussPenta(2,2); 3105 for (ig=gauss->begin();ig<gauss->end();ig++){ 3106 3107 gauss->GaussPoint(ig); 3108 3109 /*Get B and Bprime matrices: */ 3110 GetBVert(&B[0][0], &xyz_list[0][0], gauss); 3111 GetBprimeVert(&Bprime[0][0], &xyz_list[0][0], gauss); 3112 3113 /* Get Jacobian determinant: */ 3114 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3115 DL_scalar=gauss->weight*Jdet; 3116 3117 /* Do the triple product tB*D*Bprime: */ 3118 TripleMultiply( &B[0][0],1,numgrids,1, 3119 &DL_scalar,1,1,0, 3120 &Bprime[0][0],1,numgrids,0, 3121 &Ke_gg_gaussian[0][0],0); 3122 3123 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ 3124 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 3125 } 3213 3126 3214 3127 /*Add Ke_gg to global matrix Kgg: */ 3215 3128 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 3216 3129 3217 xfree((void**)&first_gauss_area_coord);3218 xfree((void**)&second_gauss_area_coord);3219 xfree((void**)&third_gauss_area_coord);3220 xfree((void**)&fourth_gauss_vert_coord);3221 xfree((void**)&area_gauss_weights);3222 xfree((void**)&vert_gauss_weights);3223 3130 xfree((void**)&doflist); 3131 delete gauss; 3224 3132 } 3225 3133 /*}}}*/ … … 3333 3241 3334 3242 /* gaussian points: */ 3335 int num_area_gauss,igarea,igvert; 3336 double* first_gauss_area_coord = NULL; 3337 double* second_gauss_area_coord = NULL; 3338 double* third_gauss_area_coord = NULL; 3339 double* vert_gauss_coord = NULL; 3340 double* area_gauss_weights = NULL; 3341 double* vert_gauss_weights = NULL; 3342 double gauss_weight,area_gauss_weight,vert_gauss_weight; 3343 double gauss_coord[4]; 3344 double gauss_l1l2l3[3]; 3345 3346 int area_order=5; 3347 int num_vert_gauss=5; 3243 int ig; 3244 GaussPenta *gauss=NULL; 3348 3245 3349 3246 double K[2][2]={0.0}; … … 3392 3289 bool onbed; 3393 3290 bool shelf; 3291 Input* vx_input=NULL; 3292 Input* vy_input=NULL; 3293 Input* vz_input=NULL; 3394 3294 3395 3295 /*retrieve inputs :*/ … … 3417 3317 this->parameters->FindParam(&epsvel,EpsVelEnum); 3418 3318 3419 /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 3420 get tria gaussian points as well as segment gaussian points. For tria gaussian 3421 points, order of integration is 2, because we need to integrate the product tB*D*B' 3422 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 3423 points, same deal, which yields 3 gaussian points.: */ 3424 3425 /*Get gaussian points: */ 3426 area_order=2; 3427 num_vert_gauss=2; 3428 3429 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights,&vert_gauss_coord, &vert_gauss_weights, area_order, num_vert_gauss); 3319 vx_input=inputs->GetInput(VxEnum); 3320 vy_input=inputs->GetInput(VyEnum); 3321 vz_input=inputs->GetInput(VzEnum); 3430 3322 3431 3323 /* Start looping on the number of gaussian points: */ 3432 for (igarea=0; igarea<num_area_gauss; igarea++){ 3433 for (igvert=0; igvert<num_vert_gauss; igvert++){ 3434 /*Pick up the gaussian point: */ 3435 area_gauss_weight=*(area_gauss_weights+igarea); 3436 vert_gauss_weight=*(vert_gauss_weights+igvert); 3437 gauss_weight=area_gauss_weight*vert_gauss_weight; 3438 gauss_coord[0]=*(first_gauss_area_coord+igarea); 3439 gauss_coord[1]=*(second_gauss_area_coord+igarea); 3440 gauss_coord[2]=*(third_gauss_area_coord+igarea); 3441 gauss_coord[3]=*(vert_gauss_coord+igvert); 3442 3443 /* Get Jacobian determinant: */ 3444 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 3445 3446 /*Conduction: */ 3447 3448 /*Get B_conduct matrix: */ 3449 GetBConduct(&B_conduct[0][0],&xyz_list[0][0],gauss_coord); 3450 3451 /*Build D: */ 3452 D_scalar=gauss_weight*Jdet*(thermalconductivity/(rho_ice*heatcapacity)); 3453 3454 if(dt){ 3455 D_scalar=D_scalar*dt; 3456 } 3457 3458 D[0][0]=D_scalar; D[0][1]=0; D[0][2]=0; 3459 D[1][0]=0; D[1][1]=D_scalar; D[1][2]=0; 3460 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar; 3461 3462 /* Do the triple product B'*D*B: */ 3463 MatrixMultiply(&B_conduct[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_conduct[0][0],0); 3464 MatrixMultiply(&tBD_conduct[0][0],numdof,3,0,&B_conduct[0][0],3,numdof,0,&Ke_gaussian_conduct[0][0],0); 3465 3466 /*Advection: */ 3467 3468 /*Get B_advec and Bprime_advec matrices: */ 3469 GetBAdvec(&B_advec[0][0],&xyz_list[0][0],gauss_coord); 3470 GetBprimeAdvec(&Bprime_advec[0][0],&xyz_list[0][0],gauss_coord); 3471 3472 //Build the D matrix 3473 inputs->GetParameterValue(&u, gauss_coord,VxEnum); 3474 inputs->GetParameterValue(&v, gauss_coord,VyEnum); 3475 inputs->GetParameterValue(&w, gauss_coord,VzEnum); 3476 3477 D_scalar=gauss_weight*Jdet; 3478 3479 if(dt){ 3480 D_scalar=D_scalar*dt; 3481 } 3482 3483 D[0][0]=D_scalar*u;D[0][1]=0; D[0][2]=0; 3484 D[1][0]=0; D[1][1]=D_scalar*v;D[1][2]=0; 3485 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar*w; 3486 3487 /* Do the triple product B'*D*Bprime: */ 3488 MatrixMultiply(&B_advec[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_advec[0][0],0); 3489 MatrixMultiply(&tBD_advec[0][0],numdof,3,0,&Bprime_advec[0][0],3,numdof,0,&Ke_gaussian_advec[0][0],0); 3490 3491 /*Transient: */ 3492 if(dt){ 3493 GetNodalFunctionsP1(&L[0], gauss_coord); 3494 D_scalar=gauss_weight*Jdet; 3495 D_scalar=D_scalar; 3496 3497 /* Do the triple product L'*D*L: */ 3498 MatrixMultiply(&L[0],numdof,1,0,&D_scalar,1,1,0,&tLD[0],0); 3499 MatrixMultiply(&tLD[0],numdof,1,0,&L[0],1,numdof,0,&Ke_gaussian_transient[0][0],0); 3500 } 3501 else{ 3502 for(i=0;i<numdof;i++){ 3503 for(j=0;j<numdof;j++){ 3504 Ke_gaussian_transient[i][j]=0; 3505 } 3506 } 3507 } 3508 3509 /*Artifficial diffusivity*/ 3510 if(artdiff){ 3511 /*Build K: */ 3512 D_scalar=gauss_weight*Jdet/(pow(u,2)+pow(v,2)+epsvel); 3513 if(dt){ 3514 D_scalar=D_scalar*dt; 3515 } 3516 K[0][0]=D_scalar*pow(u,2); K[0][1]=D_scalar*fabs(u)*fabs(v); 3517 K[1][0]=D_scalar*fabs(u)*fabs(v);K[1][1]=D_scalar*pow(v,2); 3518 3519 /*Get B_artdiff: */ 3520 GetBArtdiff(&B_artdiff[0][0],&xyz_list[0][0],gauss_coord); 3521 3522 /* Do the triple product B'*K*B: */ 3523 MatrixMultiply(&B_artdiff[0][0],2,numdof,1,&K[0][0],2,2,0,&tBD_artdiff[0][0],0); 3524 MatrixMultiply(&tBD_artdiff[0][0],numdof,2,0,&B_artdiff[0][0],2,numdof,0,&Ke_gaussian_artdiff[0][0],0); 3525 } 3526 else{ 3527 for(i=0;i<numdof;i++){ 3528 for(j=0;j<numdof;j++){ 3529 Ke_gaussian_artdiff[i][j]=0; 3530 } 3531 } 3532 } 3533 3534 /*Add Ke_gaussian to pKe: */ 3535 for(i=0;i<numdof;i++){ 3536 for(j=0;j<numdof;j++){ 3537 K_terms[i][j]+=Ke_gaussian_conduct[i][j]+Ke_gaussian_advec[i][j]+Ke_gaussian_transient[i][j]+Ke_gaussian_artdiff[i][j]; 3538 } 3539 } 3540 } 3324 gauss=new GaussPenta(2,2); 3325 for (ig=gauss->begin();ig<gauss->end();ig++){ 3326 3327 gauss->GaussPoint(ig); 3328 3329 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3330 3331 /*Conduction: */ 3332 3333 /*Get B_conduct matrix: */ 3334 GetBConduct(&B_conduct[0][0],&xyz_list[0][0],gauss); 3335 3336 /*Build D: */ 3337 D_scalar=gauss->weight*Jdet*(thermalconductivity/(rho_ice*heatcapacity)); 3338 3339 if(dt) D_scalar=D_scalar*dt; 3340 3341 D[0][0]=D_scalar; D[0][1]=0; D[0][2]=0; 3342 D[1][0]=0; D[1][1]=D_scalar; D[1][2]=0; 3343 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar; 3344 3345 /* Do the triple product B'*D*B: */ 3346 MatrixMultiply(&B_conduct[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_conduct[0][0],0); 3347 MatrixMultiply(&tBD_conduct[0][0],numdof,3,0,&B_conduct[0][0],3,numdof,0,&Ke_gaussian_conduct[0][0],0); 3348 3349 /*Advection: */ 3350 3351 /*Get B_advec and Bprime_advec matrices: */ 3352 GetBAdvec(&B_advec[0][0],&xyz_list[0][0],gauss); 3353 GetBprimeAdvec(&Bprime_advec[0][0],&xyz_list[0][0],gauss); 3354 3355 //Build the D matrix 3356 vx_input->GetParameterValue(&u, gauss); 3357 vy_input->GetParameterValue(&v, gauss); 3358 vz_input->GetParameterValue(&w, gauss); 3359 3360 D_scalar=gauss->weight*Jdet; 3361 3362 if(dt) D_scalar=D_scalar*dt; 3363 3364 D[0][0]=D_scalar*u;D[0][1]=0; D[0][2]=0; 3365 D[1][0]=0; D[1][1]=D_scalar*v;D[1][2]=0; 3366 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar*w; 3367 3368 /* Do the triple product B'*D*Bprime: */ 3369 MatrixMultiply(&B_advec[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_advec[0][0],0); 3370 MatrixMultiply(&tBD_advec[0][0],numdof,3,0,&Bprime_advec[0][0],3,numdof,0,&Ke_gaussian_advec[0][0],0); 3371 3372 /*Transient: */ 3373 if(dt){ 3374 GetNodalFunctionsP1(&L[0], gauss); 3375 D_scalar=gauss->weight*Jdet; 3376 D_scalar=D_scalar; 3377 3378 /* Do the triple product L'*D*L: */ 3379 MatrixMultiply(&L[0],numdof,1,0,&D_scalar,1,1,0,&tLD[0],0); 3380 MatrixMultiply(&tLD[0],numdof,1,0,&L[0],1,numdof,0,&Ke_gaussian_transient[0][0],0); 3381 } 3382 else{ 3383 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gaussian_transient[i][j]=0; 3384 } 3385 3386 /*Artifficial diffusivity*/ 3387 if(artdiff){ 3388 /*Build K: */ 3389 D_scalar=gauss->weight*Jdet/(pow(u,2)+pow(v,2)+epsvel); 3390 if(dt) D_scalar=D_scalar*dt; 3391 K[0][0]=D_scalar*pow(u,2); K[0][1]=D_scalar*fabs(u)*fabs(v); 3392 K[1][0]=D_scalar*fabs(u)*fabs(v);K[1][1]=D_scalar*pow(v,2); 3393 3394 /*Get B_artdiff: */ 3395 GetBArtdiff(&B_artdiff[0][0],&xyz_list[0][0],gauss); 3396 3397 /* Do the triple product B'*K*B: */ 3398 MatrixMultiply(&B_artdiff[0][0],2,numdof,1,&K[0][0],2,2,0,&tBD_artdiff[0][0],0); 3399 MatrixMultiply(&tBD_artdiff[0][0],numdof,2,0,&B_artdiff[0][0],2,numdof,0,&Ke_gaussian_artdiff[0][0],0); 3400 } 3401 else{ 3402 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gaussian_artdiff[i][j]=0; 3403 } 3404 3405 /*Add Ke_gaussian to pKe: */ 3406 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) K_terms[i][j]+=Ke_gaussian_conduct[i][j]+Ke_gaussian_advec[i][j]+Ke_gaussian_transient[i][j]+Ke_gaussian_artdiff[i][j]; 3541 3407 } 3542 3408 … … 3553 3419 3554 3420 /*Free ressources:*/ 3555 xfree((void**)&first_gauss_area_coord); 3556 xfree((void**)&second_gauss_area_coord); 3557 xfree((void**)&third_gauss_area_coord); 3558 xfree((void**)&area_gauss_weights); 3559 xfree((void**)&vert_gauss_weights); 3560 xfree((void**)&vert_gauss_coord); 3421 delete gauss; 3561 3422 xfree((void**)&doflist); 3562 3423 … … 3906 3767 3907 3768 /* gaussian points: */ 3908 int num_gauss,ig; 3909 double* first_gauss_area_coord = NULL; 3910 double* second_gauss_area_coord = NULL; 3911 double* third_gauss_area_coord = NULL; 3912 double* fourth_gauss_vert_coord = NULL; 3913 double* area_gauss_weights = NULL; 3914 double* vert_gauss_weights = NULL; 3915 double gauss_coord[4]; 3916 int order_area_gauss; 3917 int num_vert_gauss; 3918 int num_area_gauss; 3919 int ig1,ig2; 3920 double gauss_weight1,gauss_weight2; 3921 double gauss_weight; 3769 int ig; 3770 GaussPenta *gauss=NULL; 3922 3771 3923 3772 /* Jacobian: */ … … 3948 3797 GetDofList(&doflist,PattynApproximationEnum); 3949 3798 3950 /*Get gaussian points and weights :*/3951 order_area_gauss=2;3952 num_vert_gauss=3;3953 3954 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);3955 3956 3799 /*Retrieve all inputs we will be needing: */ 3957 3800 thickness_input=inputs->GetInput(ThicknessEnum); … … 3959 3802 3960 3803 /* Start looping on the number of gaussian points: */ 3961 for (ig1=0; ig1<num_area_gauss; ig1++){ 3962 for (ig2=0; ig2<num_vert_gauss; ig2++){ 3963 3964 /*Pick up the gaussian point: */ 3965 gauss_weight1=*(area_gauss_weights+ig1); 3966 gauss_weight2=*(vert_gauss_weights+ig2); 3967 gauss_weight=gauss_weight1*gauss_weight2; 3968 3969 gauss_coord[0]=*(first_gauss_area_coord+ig1); 3970 gauss_coord[1]=*(second_gauss_area_coord+ig1); 3971 gauss_coord[2]=*(third_gauss_area_coord+ig1); 3972 gauss_coord[3]=*(fourth_gauss_vert_coord+ig2); 3973 3974 /*Compute thickness at gaussian point: */ 3975 thickness_input->GetParameterValue(&thickness, gauss_coord); 3976 3977 /*Compute slope at gaussian point: */ 3978 surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss_coord); 3979 3980 /* Get Jacobian determinant: */ 3981 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 3982 3983 /*Get nodal functions: */ 3984 GetNodalFunctionsP1(l1l6, gauss_coord); 3985 3986 /*Compute driving stress: */ 3987 driving_stress_baseline=matpar->GetRhoIce()*matpar->GetG(); 3988 3989 /*Build pe_g_gaussian vector: */ 3990 for (i=0;i<numgrids;i++){ 3991 for (j=0;j<NDOF2;j++){ 3992 pe_g_gaussian[i*NDOF2+j]=-driving_stress_baseline*slope[j]*Jdet*gauss_weight*l1l6[i]; 3993 } 3804 gauss=new GaussPenta(2,3); 3805 for (ig=gauss->begin();ig<gauss->end();ig++){ 3806 3807 gauss->GaussPoint(ig); 3808 3809 /*Compute thickness at gaussian point: */ 3810 thickness_input->GetParameterValue(&thickness, gauss); 3811 3812 /*Compute slope at gaussian point: */ 3813 surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss); 3814 3815 /* Get Jacobian determinant: */ 3816 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3817 3818 /*Get nodal functions: */ 3819 GetNodalFunctionsP1(l1l6, gauss); 3820 3821 /*Compute driving stress: */ 3822 driving_stress_baseline=matpar->GetRhoIce()*matpar->GetG(); 3823 3824 /*Build pe_g_gaussian vector: */ 3825 for (i=0;i<numgrids;i++){ 3826 for (j=0;j<NDOF2;j++){ 3827 pe_g_gaussian[i*NDOF2+j]=-driving_stress_baseline*slope[j]*Jdet*gauss->weight*l1l6[i]; 3994 3828 } 3995 3996 /*Add pe_g_gaussian vector to pe_g: */ 3997 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i]; 3998 3999 } //for (ig2=0; ig2<num_vert_gauss; ig2++) 4000 } //for (ig1=0; ig1<num_area_gauss; ig1++) 3829 } 3830 3831 /*Add pe_g_gaussian vector to pe_g: */ 3832 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i]; 3833 } 4001 3834 4002 3835 /*Add pe_g to global vector pg: */ 4003 3836 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 4004 3837 4005 xfree((void**)&first_gauss_area_coord);4006 xfree((void**)&second_gauss_area_coord);4007 xfree((void**)&third_gauss_area_coord);4008 xfree((void**)&fourth_gauss_vert_coord);4009 xfree((void**)&area_gauss_weights);4010 xfree((void**)&vert_gauss_weights);4011 3838 xfree((void**)&doflist); 3839 delete gauss; 4012 3840 } 4013 3841 /*}}}*/ … … 4294 4122 4295 4123 /* gaussian points: */ 4296 int num_gauss,ig; 4297 double* first_gauss_area_coord = NULL; 4298 double* second_gauss_area_coord = NULL; 4299 double* third_gauss_area_coord = NULL; 4300 double* fourth_gauss_vert_coord = NULL; 4301 double* area_gauss_weights = NULL; 4302 double* vert_gauss_weights = NULL; 4303 double gauss_coord[4]; 4304 int order_area_gauss; 4305 int num_vert_gauss; 4306 int num_area_gauss; 4307 int ig1,ig2; 4308 double gauss_weight1,gauss_weight2; 4309 double gauss_weight; 4124 int ig; 4125 GaussPenta *gauss=NULL; 4310 4126 4311 4127 /* Jacobian: */ … … 4351 4167 GetDofList(&doflist); 4352 4168 4353 /*Get gaussian points and weights :*/4354 order_area_gauss=2;4355 num_vert_gauss=2;4356 4357 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);4358 4359 4169 /*Retrieve all inputs we will be needing: */ 4360 4170 vx_input=inputs->GetInput(VxEnum); … … 4362 4172 4363 4173 /* Start looping on the number of gaussian points: */ 4364 for (ig1=0; ig1<num_area_gauss; ig1++){ 4365 for (ig2=0; ig2<num_vert_gauss; ig2++){ 4366 4367 /*Pick up the gaussian point: */ 4368 gauss_weight1=*(area_gauss_weights+ig1); 4369 gauss_weight2=*(vert_gauss_weights+ig2); 4370 gauss_weight=gauss_weight1*gauss_weight2; 4371 4372 gauss_coord[0]=*(first_gauss_area_coord+ig1); 4373 gauss_coord[1]=*(second_gauss_area_coord+ig1); 4374 gauss_coord[2]=*(third_gauss_area_coord+ig1); 4375 gauss_coord[3]=*(fourth_gauss_vert_coord+ig2); 4376 4377 /*Get velocity derivative, with respect to x and y: */ 4378 4379 vx_input->GetParameterDerivativeValue(&du[0],&xyz_list[0][0],gauss_coord); 4380 vy_input->GetParameterDerivativeValue(&dv[0],&xyz_list[0][0],gauss_coord); 4381 dudx=du[0]; 4382 dvdy=dv[1]; 4383 4384 /* Get Jacobian determinant: */ 4385 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 4386 4387 /*Get nodal functions: */ 4388 GetNodalFunctionsP1(l1l6, gauss_coord); 4389 4390 /*Build pe_g_gaussian vector: */ 4391 for (i=0;i<numgrids;i++){ 4392 pe_g_gaussian[i]=(dudx+dvdy)*Jdet*gauss_weight*l1l6[i]; 4393 } 4394 4395 /*Add pe_g_gaussian vector to pe_g: */ 4396 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i]; 4397 4398 } //for (ig2=0; ig2<num_vert_gauss; ig2++) 4399 } //for (ig1=0; ig1<num_area_gauss; ig1++) 4174 gauss=new GaussPenta(2,2); 4175 for (ig=gauss->begin();ig<gauss->end();ig++){ 4176 4177 gauss->GaussPoint(ig); 4178 4179 /*Get velocity derivative, with respect to x and y: */ 4180 vx_input->GetParameterDerivativeValue(&du[0],&xyz_list[0][0],gauss); 4181 vy_input->GetParameterDerivativeValue(&dv[0],&xyz_list[0][0],gauss); 4182 dudx=du[0]; 4183 dvdy=dv[1]; 4184 4185 /* Get Jacobian determinant: */ 4186 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 4187 4188 /*Get nodal functions: */ 4189 GetNodalFunctionsP1(l1l6, gauss); 4190 4191 /*Build pe_g_gaussian vector: */ 4192 for (i=0;i<numgrids;i++){ 4193 pe_g_gaussian[i]=(dudx+dvdy)*Jdet*gauss->weight*l1l6[i]; 4194 } 4195 4196 /*Add pe_g_gaussian vector to pe_g: */ 4197 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i]; 4198 } 4400 4199 4401 4200 /*Add pe_g to global vector pg: */ 4402 4201 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 4403 4202 4404 xfree((void**)&first_gauss_area_coord);4405 xfree((void**)&second_gauss_area_coord);4406 xfree((void**)&third_gauss_area_coord);4407 xfree((void**)&fourth_gauss_vert_coord);4408 xfree((void**)&area_gauss_weights);4409 xfree((void**)&vert_gauss_weights);4410 4203 xfree((void**)&doflist); 4204 delete gauss; 4411 4205 } 4412 4206 /*}}}*/ … … 4495 4289 4496 4290 /* gaussian points: */ 4497 int num_area_gauss,igarea,igvert; 4498 double* first_gauss_area_coord = NULL; 4499 double* second_gauss_area_coord = NULL; 4500 double* third_gauss_area_coord = NULL; 4501 double* vert_gauss_coord = NULL; 4502 double* area_gauss_weights = NULL; 4503 double* vert_gauss_weights = NULL; 4504 double gauss_weight,area_gauss_weight,vert_gauss_weight; 4505 double gauss_coord[4]; 4506 int area_order=2; 4507 int num_vert_gauss=3; 4291 int ig; 4292 GaussPenta *gauss=NULL; 4508 4293 4509 4294 double temperature_list[numgrids]; … … 4550 4335 Input* vy_input=NULL; 4551 4336 Input* vz_input=NULL; 4337 Input* temperature_input=NULL; 4552 4338 4553 4339 /*retrieve inputs :*/ … … 4574 4360 meltingpoint=matpar->GetMeltingPoint(); 4575 4361 4576 /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore4577 get tria gaussian points as well as segment gaussian points. For tria gaussian4578 points, order of integration is 2, because we need to integrate the product tB*D*B'4579 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian4580 points, same deal, which yields 3 gaussian points.: */4581 4582 /*Get gaussian points: */4583 gaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights,&vert_gauss_coord, &vert_gauss_weights, area_order, num_vert_gauss);4584 4585 4362 /*Retrieve all inputs we will be needing: */ 4586 4363 vx_input=inputs->GetInput(VxEnum); 4587 4364 vy_input=inputs->GetInput(VyEnum); 4588 4365 vz_input=inputs->GetInput(VzEnum); 4366 if (dt) temperature_input=inputs->GetInput(TemperatureEnum); 4589 4367 4590 4368 /* Start looping on the number of gaussian points: */ 4591 for (igarea=0; igarea<num_area_gauss; igarea++){ 4592 for (igvert=0; igvert<num_vert_gauss; igvert++){ 4593 /*Pick up the gaussian point: */ 4594 area_gauss_weight=*(area_gauss_weights+igarea); 4595 vert_gauss_weight=*(vert_gauss_weights+igvert); 4596 gauss_weight=area_gauss_weight*vert_gauss_weight; 4597 gauss_coord[0]=*(first_gauss_area_coord+igarea); 4598 gauss_coord[1]=*(second_gauss_area_coord+igarea); 4599 gauss_coord[2]=*(third_gauss_area_coord+igarea); 4600 gauss_coord[3]=*(vert_gauss_coord+igvert); 4601 4602 /*Compute strain rate and viscosity: */ 4603 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss_coord,vx_input,vy_input,vz_input); 4604 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 4605 4606 /* Get Jacobian determinant: */ 4607 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); 4608 4609 /* Get nodal functions */ 4610 GetNodalFunctionsP1(&L[0], gauss_coord); 4611 4612 /*Build deformational heating: */ 4613 GetPhi(&phi, &epsilon[0], viscosity); 4614 4615 /*Build pe_gaussian */ 4616 scalar_def=phi/(rho_ice*heatcapacity)*Jdet*gauss_weight; 4617 if(dt){ 4618 scalar_def=scalar_def*dt; 4619 } 4620 4621 for(i=0;i<numgrids;i++){ 4622 P_terms[i]+=scalar_def*L[i]; 4623 } 4624 4625 /* Build transient now */ 4626 if(dt){ 4627 inputs->GetParameterValue(&temperature, gauss_coord,TemperatureEnum); 4628 scalar_transient=temperature*Jdet*gauss_weight; 4629 for(i=0;i<numgrids;i++){ 4630 P_terms[i]+=scalar_transient*L[i]; 4631 } 4632 } 4369 gauss=new GaussPenta(2,3); 4370 for (ig=gauss->begin();ig<gauss->end();ig++){ 4371 4372 gauss->GaussPoint(ig); 4373 4374 /*Compute strain rate and viscosity: */ 4375 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 4376 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 4377 4378 /* Get Jacobian determinant: */ 4379 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 4380 4381 /* Get nodal functions */ 4382 GetNodalFunctionsP1(&L[0], gauss); 4383 4384 /*Build deformational heating: */ 4385 GetPhi(&phi, &epsilon[0], viscosity); 4386 4387 /*Build pe_gaussian */ 4388 scalar_def=phi/(rho_ice*heatcapacity)*Jdet*gauss->weight; 4389 if(dt) scalar_def=scalar_def*dt; 4390 4391 for(i=0;i<numgrids;i++) P_terms[i]+=scalar_def*L[i]; 4392 4393 /* Build transient now */ 4394 if(dt){ 4395 temperature_input->GetParameterValue(&temperature, gauss); 4396 scalar_transient=temperature*Jdet*gauss->weight; 4397 for(i=0;i<numgrids;i++) P_terms[i]+=scalar_transient*L[i]; 4633 4398 } 4634 4399 } … … 4653 4418 } 4654 4419 4655 xfree((void**)&first_gauss_area_coord);4656 xfree((void**)&second_gauss_area_coord);4657 xfree((void**)&third_gauss_area_coord);4658 xfree((void**)&vert_gauss_coord);4659 xfree((void**)&area_gauss_weights);4660 xfree((void**)&vert_gauss_weights);4661 4420 xfree((void**)&doflist); 4421 delete gauss; 4662 4422 4663 4423 } … … 5213 4973 /*FUNCTION Penta::GetStrainRate3d{{{1*/ 5214 4974 void Penta::GetStrainRate3d(double* epsilon,double* xyz_list, double* gauss, Input* vx_input, Input* vy_input, Input* vz_input){ 4975 /*Compute the 3d Strain Rate (6 components): 4976 * 4977 * epsilon=[exx eyy ezz exy exz eyz] 4978 */ 4979 4980 int i; 4981 4982 double epsilonvx[6]; 4983 double epsilonvy[6]; 4984 double epsilonvz[6]; 4985 4986 /*Check that both inputs have been found*/ 4987 if (!vx_input || !vy_input || !vz_input){ 4988 ISSMERROR("Input missing. Here are the input pointers we have for vx: %p, vy: %p, vz: %p\n",vx_input,vy_input,vz_input); 4989 } 4990 4991 /*Get strain rate assuming that epsilon has been allocated*/ 4992 vx_input->GetVxStrainRate3d(epsilonvx,xyz_list,gauss); 4993 vy_input->GetVyStrainRate3d(epsilonvy,xyz_list,gauss); 4994 vz_input->GetVzStrainRate3d(epsilonvz,xyz_list,gauss); 4995 4996 /*Sum all contributions*/ 4997 for(i=0;i<6;i++) epsilon[i]=epsilonvx[i]+epsilonvy[i]+epsilonvz[i]; 4998 4999 } 5000 /*}}}*/ 5001 /*FUNCTION Penta::GetStrainRate3d{{{1*/ 5002 void Penta::GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input){ 5215 5003 /*Compute the 3d Strain Rate (6 components): 5216 5004 * -
TabularUnified issm/trunk/src/c/objects/Elements/Penta.h ¶
r5647 r5651 170 170 void GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input); 171 171 void GetStrainRate3d(double* epsilon,double* xyz_list, double* gauss, Input* vx_input, Input* vy_input, Input* vz_input); 172 void GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input); 172 173 Penta* GetUpperElement(void); 173 174 Penta* GetLowerElement(void); -
TabularUnified issm/trunk/src/c/objects/Gauss/GaussPenta.cpp ¶
r5641 r5651 225 225 } 226 226 /*}}}*/ 227 /*FUNCTION GaussPenta::SynchronizeGaussTria{{{1*/ 228 void GaussPenta::SynchronizeGaussTria(GaussTria* gauss_tria){ 229 230 gauss_tria->coord1=this->coord1; 231 gauss_tria->coord2=this->coord2; 232 gauss_tria->coord3=this->coord3; 233 gauss_tria->weight=UNDEF; 234 } 235 /*}}}*/ -
TabularUnified issm/trunk/src/c/objects/Gauss/GaussPenta.h ¶
r5641 r5651 9 9 /*{{{1*/ 10 10 #include "./../../shared/shared.h" 11 class GaussTria; 11 12 /*}}}*/ 12 13 … … 42 43 void GaussVertex(int iv); 43 44 void GaussCenter(void); 45 void SynchronizeGaussTria(GaussTria* gauss_tria); 44 46 }; 45 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.