Changeset 5624
- Timestamp:
- 08/30/10 15:53:35 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5596 r5624 563 563 564 564 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 565 Gauss Tria(&num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights,2);565 GaussLegendreTria(&num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights,2); 566 566 567 567 /*Retrieve all inputs we will be needing: */ … … 2499 2499 get tria gaussian points as well as segment gaussian points. For tria gaussian 2500 2500 points, order of integration is 2, because we need to integrate the product tB*D*B' 2501 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian2501 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 2502 2502 points, same deal, which yields 3 gaussian points.*/ 2503 2503 … … 2505 2505 num_vert_gauss=5; 2506 2506 2507 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);2507 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); 2508 2508 2509 2509 /*Retrieve all inputs we will be needing: */ … … 2830 2830 get tria gaussian points as well as segment gaussian points. For tria gaussian 2831 2831 points, order of integration is 2, because we need to integrate the product tB*D*B' 2832 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian2832 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 2833 2833 points, same deal, which yields 3 gaussian points.*/ 2834 2834 … … 2836 2836 num_vert_gauss=5; 2837 2837 2838 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);2838 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); 2839 2839 2840 2840 /*Retrieve all inputs we will be needing: */ … … 3021 3021 get tria gaussian points as well as segment gaussian points. For tria gaussian 3022 3022 points, order of integration is 2, because we need to integrate the product tB*D*B' 3023 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian3023 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 3024 3024 points, same deal, which yields 3 gaussian points.*/ 3025 3025 … … 3028 3028 3029 3029 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3030 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);3030 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); 3031 3031 3032 3032 /*Retrieve all inputs we will be needing: */ … … 3097 3097 3098 3098 xfree((void**)&first_gauss_area_coord); xfree((void**)&second_gauss_area_coord); xfree((void**)&third_gauss_area_coord); xfree((void**)&area_gauss_weights); 3099 Gauss Tria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, 2);3099 GaussLegendreTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, 2); 3100 3100 3101 3101 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ … … 3249 3249 get tria gaussian points as well as segment gaussian points. For tria gaussian 3250 3250 points, order of integration is 2, because we need to integrate the product tB*D*B' 3251 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian3251 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 3252 3252 points, same deal, which yields 3 gaussian points.*/ 3253 3253 … … 3255 3255 num_vert_gauss=2; 3256 3256 3257 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);3257 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); 3258 3258 3259 3259 /* Start looping on the number of gaussian points: */ … … 3502 3502 get tria gaussian points as well as segment gaussian points. For tria gaussian 3503 3503 points, order of integration is 2, because we need to integrate the product tB*D*B' 3504 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian3504 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 3505 3505 points, same deal, which yields 3 gaussian points.: */ 3506 3506 … … 3509 3509 num_vert_gauss=2; 3510 3510 3511 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);3511 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); 3512 3512 3513 3513 /* Start looping on the number of gaussian points: */ … … 3861 3861 //Get gaussian points and weights. order 2 since we have a product of 2 nodal functions 3862 3862 num_gauss=3; 3863 GaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss);3863 gaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss); 3864 3864 3865 3865 /*Loop on the three segments*/ … … 4034 4034 num_vert_gauss=3; 4035 4035 4036 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);4036 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); 4037 4037 4038 4038 /*Retrieve all inputs we will be needing: */ … … 4197 4197 get tria gaussian points as well as segment gaussian points. For tria gaussian 4198 4198 points, order of integration is 2, because we need to integrate the product tB*D*B' 4199 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian4199 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 4200 4200 points, same deal, which yields 3 gaussian points.*/ 4201 4201 4202 4202 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4203 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);4203 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); 4204 4204 4205 4205 /*Retrieve all inputs we will be needing: */ … … 4285 4285 4286 4286 xfree((void**)&first_gauss_area_coord); xfree((void**)&second_gauss_area_coord); xfree((void**)&third_gauss_area_coord); xfree((void**)&area_gauss_weights); 4287 Gauss Tria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, 2);4287 GaussLegendreTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, 2); 4288 4288 4289 4289 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ … … 4437 4437 num_vert_gauss=2; 4438 4438 4439 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);4439 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); 4440 4440 4441 4441 /*Retrieve all inputs we will be needing: */ … … 4661 4661 get tria gaussian points as well as segment gaussian points. For tria gaussian 4662 4662 points, order of integration is 2, because we need to integrate the product tB*D*B' 4663 which is a polynomial of degree 3 (see Gauss Tria for more details). For segment gaussian4663 which is a polynomial of degree 3 (see GaussLegendreTria for more details). For segment gaussian 4664 4664 points, same deal, which yields 3 gaussian points.: */ 4665 4665 4666 4666 /*Get gaussian points: */ 4667 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);4667 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); 4668 4668 4669 4669 /*Retrieve all inputs we will be needing: */ -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5579 r5624 727 727 728 728 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 729 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);729 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 730 730 731 731 /* Start looping on the number of gaussian points: */ … … 1081 1081 1082 1082 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 1083 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);1083 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4); 1084 1084 1085 1085 /*Retrieve all inputs we will be needing: */ … … 1254 1254 1255 1255 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 1256 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);1256 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4); 1257 1257 1258 1258 /*Retrieve all inputs we will be needing: */ … … 2003 2003 2004 2004 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2005 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2005 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2006 2006 2007 2007 /* Start looping on the number of gaussian points: */ … … 2128 2128 2129 2129 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2130 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2130 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2131 2131 2132 2132 /* Start looping on the number of gaussian points: */ … … 2260 2260 2261 2261 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2262 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2262 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2263 2263 2264 2264 /* Start looping on the number of gaussian points: */ … … 2390 2390 2391 2391 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2392 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2392 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2393 2393 2394 2394 /* Start looping on the number of gaussian points: */ … … 2522 2522 2523 2523 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2524 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2524 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2525 2525 2526 2526 /* Start looping on the number of gaussian points: */ … … 2653 2653 2654 2654 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2655 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);2655 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 2656 2656 2657 2657 /* Start looping on the number of gaussian points: */ … … 3105 3105 3106 3106 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3107 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3107 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3108 3108 3109 3109 /* Start looping on the number of gaussian points: */ … … 3232 3232 3233 3233 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3234 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3234 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3235 3235 3236 3236 /*Retrieve all inputs we will be needed*/ … … 3396 3396 3397 3397 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3398 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3398 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3399 3399 3400 3400 /* Start looping on the number of gaussian points: */ … … 3537 3537 3538 3538 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3539 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3539 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3540 3540 3541 3541 /*Retrieve all inputs we will be needing: */ … … 3695 3695 3696 3696 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3697 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3697 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3698 3698 3699 3699 /* Start looping on the number of gaussian points: */ … … 3838 3838 3839 3839 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3840 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3840 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3841 3841 3842 3842 /* Start looping on the number of gaussian points: */ … … 3979 3979 3980 3980 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 3981 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);3981 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 3982 3982 3983 3983 /* Start looping on the number of gaussian points: */ … … 4118 4118 4119 4119 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4120 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4120 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4121 4121 4122 4122 /*Build normal vector to the surface:*/ … … 4232 4232 4233 4233 /* Get gaussian points and weights: */ 4234 Gauss Tria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4234 GaussLegendreTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4235 4235 4236 4236 /* Start looping on the number of gauss (nodes on the bedrock) */ … … 4358 4358 4359 4359 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4360 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4360 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4361 4361 4362 4362 /* Start looping on the number of gaussian points: */ … … 4506 4506 4507 4507 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4508 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4508 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4509 4509 4510 4510 /*Retrieve all inputs we will be needed*/ … … 4614 4614 4615 4615 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4616 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4616 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4617 4617 4618 4618 /* Start looping on the number of gaussian points: */ … … 4705 4705 heatcapacity=matpar->GetHeatCapacity(); 4706 4706 4707 Gauss Tria (&num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4707 GaussLegendreTria (&num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4708 4708 4709 4709 /* Start looping on the number of gauss (nodes on the bedrock) */ … … 4790 4790 4791 4791 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4792 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4792 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4793 4793 4794 4794 /*retrieve inputs :*/ … … 4874 4874 4875 4875 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4876 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4876 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4877 4877 4878 4878 /*Retrieve all inputs we will be needing: */ … … 4956 4956 4957 4957 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 4958 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);4958 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 4959 4959 4960 4960 /*Retrieve all inputs we will be needing: */ … … 5047 5047 5048 5048 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5049 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5049 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5050 5050 5051 5051 /*Retrieve all inputs we will be needing: */ … … 5166 5166 5167 5167 /* Get gaussian points and weights: */ 5168 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/5168 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/ 5169 5169 5170 5170 /* Start looping on the number of gaussian points: */ … … 5275 5275 5276 5276 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5277 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5277 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5278 5278 5279 5279 /* Start looping on the number of gaussian points: */ … … 5511 5511 5512 5512 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5513 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5513 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5514 5514 5515 5515 /* Start looping on the number of gaussian points: */ … … 5750 5750 5751 5751 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5752 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5752 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5753 5753 5754 5754 /* Start looping on the number of gaussian points: */ … … 5908 5908 5909 5909 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5910 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5910 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5911 5911 5912 5912 /*Retrieve all inputs we will be needing: */ … … 5996 5996 5997 5997 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 5998 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);5998 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 5999 5999 6000 6000 /*Retrieve all inputs we will be needing: */ … … 6082 6082 6083 6083 /* Get gaussian points and weights: */ 6084 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/6084 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/ 6085 6085 6086 6086 /*Retrieve all inputs we will be needing: */ … … 6193 6193 /* Ice/ocean heat exchange flux on ice shelf base */ 6194 6194 6195 Gauss Tria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);6195 GaussLegendreTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 6196 6196 6197 6197 /*Retrieve all inputs we will be needing: */ … … 6325 6325 6326 6326 /* Ice/ocean heat exchange flux on ice shelf base */ 6327 Gauss Tria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);6327 GaussLegendreTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 6328 6328 6329 6329 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ … … 6844 6844 6845 6845 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 6846 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);6846 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4); 6847 6847 6848 6848 /* Start looping on the number of gaussian points: */ -
issm/trunk/src/c/objects/Loads/Icefront.cpp
r5596 r5624 456 456 //Get gaussian points and weights. order 2 since we have a product of 2 nodal functions 457 457 num_gauss=3; 458 GaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss);458 gaussSegment(&segment_gauss_coord, &gauss_weights, num_gauss); 459 459 460 460 for(ig=0;ig<num_gauss;ig++){ … … 916 916 917 917 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 918 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);918 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 919 919 920 920 //Recover the surface of the four nodes … … 1177 1177 1178 1178 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 1179 Gauss Tria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);1179 GaussLegendreTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 1180 1180 1181 1181 //Recover the surface of the four nodes -
issm/trunk/src/c/objects/Loads/Numericalflux.cpp
r5578 r5624 455 455 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 456 456 num_gauss=2; 457 GaussSegment(&gauss_coords, &gauss_weights,num_gauss);457 gaussSegment(&gauss_coords, &gauss_weights,num_gauss); 458 458 459 459 /* Start looping on the number of gaussian points: */ … … 598 598 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 599 599 num_gauss=2; 600 GaussSegment(&gauss_coords, &gauss_weights,num_gauss);600 gaussSegment(&gauss_coords, &gauss_weights,num_gauss); 601 601 602 602 /* Start looping on the number of gaussian points: */ … … 745 745 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 746 746 num_gauss=2; 747 GaussSegment(&gauss_coords, &gauss_weights,num_gauss);747 gaussSegment(&gauss_coords, &gauss_weights,num_gauss); 748 748 749 749 /* Start looping on the number of gaussian points: */ -
issm/trunk/src/c/shared/Numerics/GaussPoints.cpp
r4417 r5624 10 10 11 11 /*General Gauss points*/ 12 /*FUNCTION GaussLegendre {{{1*/13 void GaussLegendre ( double** pxgaus, double** pxwgt, int ngaus){12 /*FUNCTION GaussLegendreLinear {{{1*/ 13 void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus){ 14 14 /* Gauss-Legendre quadrature points. 15 15 … … 88 88 } 89 89 }/*}}}1*/ 90 /*FUNCTION GaussLobatto{{{1*/ 91 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ) { 92 /*Gauss-Lobatto quadrature points. 93 94 The recurrence coefficients for Legendre polynomials on (-1,1) 95 are defined (from the ORTHPOL subroutine RECUR with ipoly=1) as: 96 97 alpha(i)=0. 98 beta (i)=1./(4.-1./(i-1)^2)) 99 100 and then modified for the Gauss-Lobatto quadrature rule on (-1,1) 101 (from the ORTHPOL subroutine LOB). 102 103 For degree p, the required number of Gauss-Lobatto points is 104 n>=(p+1)/2+1 (one more than Gauss-Legendre).*/ 105 106 int i; 107 double *alpha,*beta; 108 double left=-1.,right= 1.; 109 double p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det; 110 111 /*p= 1, npoint= 1 (Gauss-Legendre)*/ 112 static double wgt1[]={2.000000000000000}; 113 static double xi1[]={0.000000000000000}; 114 115 /*p= 1, npoint= 2*/ 116 static double wgt2[]={1.000000000000000, 1.000000000000000}; 117 static double xi2[]={-1.000000000000000, 1.000000000000000}; 118 119 /*p= 3, npoint= 3*/ 120 static double wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333}; 121 static double xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000}; 122 123 /*p= 5, npoint= 4*/ 124 static double wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667}; 125 static double xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000}; 126 127 /*p= 7, npoint= 5*/ 128 static double wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000}; 129 static double xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000}; 130 131 static double* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 }; 132 static double* xip [MAX_LINE_GLOB_PTS]={xi1 ,xi2 ,xi3 ,xi4 ,xi5 }; 133 134 static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(double), 135 sizeof(wgt2 )/sizeof(double), 136 sizeof(wgt3 )/sizeof(double), 137 sizeof(wgt4 )/sizeof(double), 138 sizeof(wgt5 )/sizeof(double)}; 139 140 // _printf_("Gauss-Lobatto recurrence coefficients ngaus=%d\n",ngaus); 141 *pxgaus = (double *) xmalloc(ngaus*sizeof(double)); 142 *pxwgt = (double *) xmalloc(ngaus*sizeof(double)); 143 144 /* check to see if Gauss points need to be calculated */ 145 if (ngaus <= MAX_LINE_GLOB_PTS) { 146 147 /* copy the points from the static arrays (noting that the pointers 148 could be returned directly, but then the calling function would 149 have to know to not free them) */ 150 for (i=0; i<ngaus; i++) { 151 (*pxgaus)[i]=xip [ngaus-1][i]; 152 (*pxwgt )[i]=wgtp[ngaus-1][i]; 153 } 154 } 155 else { 156 157 /* calculate the Gauss points using recurrence relations */ 158 alpha=(double *) xmalloc(ngaus*sizeof(double)); 159 beta =(double *) xmalloc(ngaus*sizeof(double)); 160 161 /* calculate the Legendre recurrence coefficients */ 162 alpha[0]=0.; 163 beta [0]=2.; 164 165 for (i=1; i<ngaus; i++) { 166 alpha[i]=0.; 167 beta [i]=1./(4.-1./(i*i)); 168 } 169 170 /* calculate the Gauss-Lobatto quadrature formula */ 171 for (i=0; i<ngaus-1; i++) { 172 pm1l=p0l; 173 p0l=p1l; 174 pm1r=p0r; 175 p0r=p1r; 176 p1l=(left -alpha[i])*p0l-beta[i]*pm1l; 177 p1r=(right-alpha[i])*p0r-beta[i]*pm1r; 178 } 179 180 /* Normalize system to prevent underflow: 181 [ p1l p0l ]{ a } = {left *p1l} 182 [ p1r p0r ]{ b } {right*p1r} 183 dividing by p1l in the first equation and p1r in the second. */ 184 185 // det=p1l*p0r-p1r*p0l; 186 det=p0r/p1r-p0l/p1l; 187 // alpha[ngaus-1]=(left*p1l*p0r-right*p1r*p0l)/det; 188 // beta [ngaus-1]=(right-left)*p1l*p1r/det; 189 alpha[ngaus-1]=(left *(p0r/p1r)-right*(p0l/p1l))/det; 190 beta [ngaus-1]=(right -left )/det; 191 192 /* calculate the Gauss points */ 193 GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta ); 194 xfree((void **)&beta ); 195 xfree((void **)&alpha); 196 } 197 198 }/*}}}1*/ 199 /*FUNCTION GaussRecur{{{1*/ 200 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ) { 201 /*Gauss quadrature points from recursion coefficients. 202 * 203 *The routine uses the algorithm from the ORTHPOL routine GAUSS, which 204 *finds the eigenvalues of a tridiagonal matrix.*/ 205 206 /*Intermediaries*/ 207 int i,j,k,l,m,ii,mml,iter; 208 double p,g,r,s,c,f,b; 209 double* work; 210 211 if (n==1){ 212 zero[0] =alpha[0]; 213 weight[0]=beta[0]; 214 return; 215 } 216 217 work=(double*)xmalloc(n*sizeof(double)); 218 219 zero[0] =alpha[0]; 220 weight[0]=1.; 221 work[n-1]=0.; 222 for (i=1; i<=n-1; i++){ 223 zero[i]=alpha[i]; 224 work[i-1]=sqrt(beta[i]); 225 weight[i]=0; 226 } 227 228 for (l=0; l<=n-1; l++){ 229 iter=0; 230 do { 231 232 /* Look for a small subdiagonal element. */ 233 for (m=l; m<=n-1; m++) { 234 if (m == n-1) break; 235 if (fabs(work[m]) 236 <= DBL_EPSILON*(fabs(zero[m])+fabs(zero[m+1]))) 237 break; 238 } 239 p=zero[l]; 240 if (m==l) break; 241 ++iter; 242 243 /* Form shift. */ 244 g=(zero[l+1]-p)/(2.*work[l]); 245 r=sqrt(g*g+1.); 246 // g=zero[m]-p+work[l]/(g+FortranSign(r,g)); 247 g=zero[m]-p+work[l]/(g+(g>=0 ? fabs(r) : -fabs(r))); 248 s=1.; 249 c=1.; 250 p=0.; 251 mml=m-l; 252 253 /* For i=m-1 step -1 until l do ... */ 254 for (ii=1; ii<=mml; ii++) { 255 i=m-ii; 256 f=s*work[i]; 257 b=c*work[i]; 258 if (fabs(f) >= fabs(g)) { 259 c=g/f; 260 r=sqrt(c*c+1.); 261 work[i+1]=f*r; 262 s=1./r; 263 c*=s; 264 } 265 else { 266 s=f/g; 267 r=sqrt(s*s+1.); 268 work[i+1]=g*r; 269 c=1./r; 270 s*=c; 271 } 272 g=zero[i+1]-p; 273 r=(zero[i]-g)*s+2.*c*b; 274 p=s*r; 275 zero[i+1]=g+p; 276 g=c*r-b; 277 278 /* Form first component of vector. */ 279 f=weight[i+1]; 280 weight[i+1]=s*weight[i]+c*f; 281 weight[i ]=c*weight[i]-s*f; 282 } 283 zero[l]-=p; 284 work[l]=g; 285 work[m]=0.; 286 } while (iter < MAX_GAUS_ITER); 287 if (iter >= MAX_GAUS_ITER) { 288 xfree((void **)&work); 289 ISSMERROR("%s%i"," Max iterations exceeded for l=",MAX_GAUS_ITER); 290 } 291 } 292 293 /* Order eigenvalues and eigenvectors. */ 294 for (i=0;i<n-1;i++) { 295 k=i; 296 p=zero[i]; 297 for (j=i+1;j<n;j++){ 298 if (zero[j] < p){ 299 k=j; 300 p=zero[j]; 301 } 302 } 303 if (k > i){ 304 p=zero[i]; 305 zero[i]=zero[k]; 306 zero[k]=p; 307 p=weight[i]; 308 weight[i]=weight[k]; 309 weight[k]=p; 310 } 311 } 312 for (i=0;i<n;i++){ 313 weight[i]=beta[0]*weight[i]*weight[i]; 314 } 315 316 /*Cleanup*/ 317 xfree((void **)&work); 318 319 }/*}}}1*/ 320 321 /*Element Gauss points*/ 322 /*FUNCTION GaussQuad{{{1*/ 323 void GaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ) { 324 /*Gauss quadrature points for the quadrilaterial.*/ 325 326 /*get the gauss points using the product of two line rules */ 327 GaussLegendre(pxgaus, pxwgt, nigaus); 328 GaussLegendre(pegaus, pewgt, njgaus); 329 }/*}}}1*/ 330 /*FUNCTION GaussTria{{{1*/ 331 void GaussTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ) { 90 /*FUNCTION GaussLegendreTria{{{1*/ 91 void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ) { 332 92 /*Gauss quadrature points for the triangle. 333 93 … … 1379 1139 sizeof(wgt20)/sizeof(double)}; 1380 1140 1381 // _printf_("Gauss Tria: iord=%d\n",iord);1141 // _printf_("GaussLegendreTria: iord=%d\n",iord); 1382 1142 1383 1143 /* check to see if Gauss points need to be calculated */ … … 1414 1174 1415 1175 /* get the gauss points in each direction */ 1416 GaussLegendre (&xgaus, &xwgt, nigaus);1176 GaussLegendreLinear(&xgaus, &xwgt, nigaus); 1417 1177 1418 1178 egaus=xgaus; … … 1439 1199 } 1440 1200 1441 // _printf_("Gauss Tria - ngaus=%d\n",*pngaus);1201 // _printf_("GaussLegendreTria - ngaus=%d\n",*pngaus); 1442 1202 // for (i=0; i<*pngaus; i++) 1443 1203 // _printf_("i=%d: l1gaus=%f,l2gaus=%f,l3gaus=%f,wgt=%f\n", … … 1446 1206 return; 1447 1207 }/*}}}1*/ 1448 /*FUNCTION GaussHexa{{{1*/ 1449 void GaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ) { 1450 /*Gauss quadrature points for the hexahedron.*/ 1451 1452 /* get the gauss points using the product of three line rules */ 1453 GaussLegendre(pxgaus, pxwgt, nigaus); 1454 GaussLegendre(pegaus, pewgt, njgaus); 1455 GaussLegendre(pzgaus, pzwgt, nkgaus); 1456 }/*}}}1*/ 1457 /*FUNCTION GaussPenta{{{1*/ 1458 void GaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ) { 1459 /*Gauss quadrature points for the pentahedron.*/ 1460 1461 /* get the gauss points using the product of triangular and line rules */ 1462 GaussTria(pngaus, pl1, pl2, pl3, pwgt, iord); 1463 GaussLegendre(pzgaus, pzwgt, nkgaus); 1464 1465 }/*}}}1*/ 1466 /*FUNCTION GaussTetra{{{1*/ 1467 void GaussTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ) { 1208 /*FUNCTION GaussLegendreTetra{{{1*/ 1209 void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ) { 1468 1210 /* Gauss quadrature points for the tetrahedron. 1469 1211 … … 1656 1398 sizeof(wgt6 )/sizeof(double)}; 1657 1399 1658 // _printf_("Gauss Tetra: iord=%d\n",iord);1400 // _printf_("GaussLegendreTetra: iord=%d\n",iord); 1659 1401 1660 1402 /* check to see if Gauss points need to be calculated */ … … 1695 1437 1696 1438 /* get the gauss points in each direction */ 1697 GaussLegendre (&xgaus, &xwgt, nigaus);1439 GaussLegendreLinear(&xgaus, &xwgt, nigaus); 1698 1440 1699 1441 egaus=xgaus; … … 1729 1471 } 1730 1472 }/*}}}1*/ 1731 /*FUNCTION GaussSegment{{{1*/ 1732 void GaussSegment(double** psegment_coord,double** pgauss_weights,int num_gauss){ 1733 /* GaussSegment: 1734 * This routine computes gaussian points on a reference segment from -1 to 1. 1735 * The order p of integration depends on the number of gaussian points and can be computed from the polynomial degree p that needs to be integrated. 1736 * numgauss= (p+1) /2 */ 1737 1738 /*WARNING: This is a copy of GaussLegendre: Merge the two!*/ 1739 1740 double* segment_coord=NULL; 1741 double* gauss_weights=NULL; 1473 /*FUNCTION GaussLobatto{{{1*/ 1474 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ) { 1475 /*Gauss-Lobatto quadrature points. 1476 1477 The recurrence coefficients for Legendre polynomials on (-1,1) 1478 are defined (from the ORTHPOL subroutine RECUR with ipoly=1) as: 1479 1480 alpha(i)=0. 1481 beta (i)=1./(4.-1./(i-1)^2)) 1482 1483 and then modified for the Gauss-Lobatto quadrature rule on (-1,1) 1484 (from the ORTHPOL subroutine LOB). 1485 1486 For degree p, the required number of Gauss-Lobatto points is 1487 n>=(p+1)/2+1 (one more than Gauss-Legendre).*/ 1488 1489 int i; 1490 double *alpha,*beta; 1491 double left=-1.,right= 1.; 1492 double p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det; 1493 1494 /*p= 1, npoint= 1 (Gauss-Legendre)*/ 1495 static double wgt1[]={2.000000000000000}; 1496 static double xi1[]={0.000000000000000}; 1497 1498 /*p= 1, npoint= 2*/ 1499 static double wgt2[]={1.000000000000000, 1.000000000000000}; 1500 static double xi2[]={-1.000000000000000, 1.000000000000000}; 1501 1502 /*p= 3, npoint= 3*/ 1503 static double wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333}; 1504 static double xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000}; 1505 1506 /*p= 5, npoint= 4*/ 1507 static double wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667}; 1508 static double xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000}; 1509 1510 /*p= 7, npoint= 5*/ 1511 static double wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000}; 1512 static double xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000}; 1513 1514 static double* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 }; 1515 static double* xip [MAX_LINE_GLOB_PTS]={xi1 ,xi2 ,xi3 ,xi4 ,xi5 }; 1516 1517 static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(double), 1518 sizeof(wgt2 )/sizeof(double), 1519 sizeof(wgt3 )/sizeof(double), 1520 sizeof(wgt4 )/sizeof(double), 1521 sizeof(wgt5 )/sizeof(double)}; 1522 1523 // _printf_("Gauss-Lobatto recurrence coefficients ngaus=%d\n",ngaus); 1524 *pxgaus = (double *) xmalloc(ngaus*sizeof(double)); 1525 *pxwgt = (double *) xmalloc(ngaus*sizeof(double)); 1526 1527 /* check to see if Gauss points need to be calculated */ 1528 if (ngaus <= MAX_LINE_GLOB_PTS) { 1529 1530 /* copy the points from the static arrays (noting that the pointers 1531 could be returned directly, but then the calling function would 1532 have to know to not free them) */ 1533 for (i=0; i<ngaus; i++) { 1534 (*pxgaus)[i]=xip [ngaus-1][i]; 1535 (*pxwgt )[i]=wgtp[ngaus-1][i]; 1536 } 1537 } 1538 else { 1539 1540 /* calculate the Gauss points using recurrence relations */ 1541 alpha=(double *) xmalloc(ngaus*sizeof(double)); 1542 beta =(double *) xmalloc(ngaus*sizeof(double)); 1543 1544 /* calculate the Legendre recurrence coefficients */ 1545 alpha[0]=0.; 1546 beta [0]=2.; 1547 1548 for (i=1; i<ngaus; i++) { 1549 alpha[i]=0.; 1550 beta [i]=1./(4.-1./(i*i)); 1551 } 1552 1553 /* calculate the Gauss-Lobatto quadrature formula */ 1554 for (i=0; i<ngaus-1; i++) { 1555 pm1l=p0l; 1556 p0l=p1l; 1557 pm1r=p0r; 1558 p0r=p1r; 1559 p1l=(left -alpha[i])*p0l-beta[i]*pm1l; 1560 p1r=(right-alpha[i])*p0r-beta[i]*pm1r; 1561 } 1562 1563 /* Normalize system to prevent underflow: 1564 [ p1l p0l ]{ a } = {left *p1l} 1565 [ p1r p0r ]{ b } {right*p1r} 1566 dividing by p1l in the first equation and p1r in the second. */ 1567 1568 // det=p1l*p0r-p1r*p0l; 1569 det=p0r/p1r-p0l/p1l; 1570 // alpha[ngaus-1]=(left*p1l*p0r-right*p1r*p0l)/det; 1571 // beta [ngaus-1]=(right-left)*p1l*p1r/det; 1572 alpha[ngaus-1]=(left *(p0r/p1r)-right*(p0l/p1l))/det; 1573 beta [ngaus-1]=(right -left )/det; 1574 1575 /* calculate the Gauss points */ 1576 GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta ); 1577 xfree((void **)&beta ); 1578 xfree((void **)&alpha); 1579 } 1580 1581 }/*}}}1*/ 1582 /*FUNCTION GaussRecur{{{1*/ 1583 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ) { 1584 /*Gauss quadrature points from recursion coefficients. 1585 * 1586 *The routine uses the algorithm from the ORTHPOL routine GAUSS, which 1587 *finds the eigenvalues of a tridiagonal matrix.*/ 1588 1589 /*Intermediaries*/ 1590 int i,j,k,l,m,ii,mml,iter; 1591 double p,g,r,s,c,f,b; 1592 double* work; 1593 1594 if (n==1){ 1595 zero[0] =alpha[0]; 1596 weight[0]=beta[0]; 1597 return; 1598 } 1599 1600 work=(double*)xmalloc(n*sizeof(double)); 1601 1602 zero[0] =alpha[0]; 1603 weight[0]=1.; 1604 work[n-1]=0.; 1605 for (i=1; i<=n-1; i++){ 1606 zero[i]=alpha[i]; 1607 work[i-1]=sqrt(beta[i]); 1608 weight[i]=0; 1609 } 1610 1611 for (l=0; l<=n-1; l++){ 1612 iter=0; 1613 do { 1614 1615 /* Look for a small subdiagonal element. */ 1616 for (m=l; m<=n-1; m++) { 1617 if (m == n-1) break; 1618 if (fabs(work[m]) 1619 <= DBL_EPSILON*(fabs(zero[m])+fabs(zero[m+1]))) 1620 break; 1621 } 1622 p=zero[l]; 1623 if (m==l) break; 1624 ++iter; 1625 1626 /* Form shift. */ 1627 g=(zero[l+1]-p)/(2.*work[l]); 1628 r=sqrt(g*g+1.); 1629 // g=zero[m]-p+work[l]/(g+FortranSign(r,g)); 1630 g=zero[m]-p+work[l]/(g+(g>=0 ? fabs(r) : -fabs(r))); 1631 s=1.; 1632 c=1.; 1633 p=0.; 1634 mml=m-l; 1635 1636 /* For i=m-1 step -1 until l do ... */ 1637 for (ii=1; ii<=mml; ii++) { 1638 i=m-ii; 1639 f=s*work[i]; 1640 b=c*work[i]; 1641 if (fabs(f) >= fabs(g)) { 1642 c=g/f; 1643 r=sqrt(c*c+1.); 1644 work[i+1]=f*r; 1645 s=1./r; 1646 c*=s; 1647 } 1648 else { 1649 s=f/g; 1650 r=sqrt(s*s+1.); 1651 work[i+1]=g*r; 1652 c=1./r; 1653 s*=c; 1654 } 1655 g=zero[i+1]-p; 1656 r=(zero[i]-g)*s+2.*c*b; 1657 p=s*r; 1658 zero[i+1]=g+p; 1659 g=c*r-b; 1660 1661 /* Form first component of vector. */ 1662 f=weight[i+1]; 1663 weight[i+1]=s*weight[i]+c*f; 1664 weight[i ]=c*weight[i]-s*f; 1665 } 1666 zero[l]-=p; 1667 work[l]=g; 1668 work[m]=0.; 1669 } while (iter < MAX_GAUS_ITER); 1670 if (iter >= MAX_GAUS_ITER) { 1671 xfree((void **)&work); 1672 ISSMERROR("%s%i"," Max iterations exceeded for l=",MAX_GAUS_ITER); 1673 } 1674 } 1675 1676 /* Order eigenvalues and eigenvectors. */ 1677 for (i=0;i<n-1;i++) { 1678 k=i; 1679 p=zero[i]; 1680 for (j=i+1;j<n;j++){ 1681 if (zero[j] < p){ 1682 k=j; 1683 p=zero[j]; 1684 } 1685 } 1686 if (k > i){ 1687 p=zero[i]; 1688 zero[i]=zero[k]; 1689 zero[k]=p; 1690 p=weight[i]; 1691 weight[i]=weight[k]; 1692 weight[k]=p; 1693 } 1694 } 1695 for (i=0;i<n;i++){ 1696 weight[i]=beta[0]*weight[i]*weight[i]; 1697 } 1698 1699 /*Cleanup*/ 1700 xfree((void **)&work); 1701 1702 }/*}}}1*/ 1703 1704 /*Element Gauss points TO BE REMOVED*/ 1705 /*FUNCTION gaussQuad{{{1*/ 1706 void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ) { 1707 /*Gauss quadrature points for the quadrilaterial.*/ 1708 1709 /*get the gauss points using the product of two line rules */ 1710 GaussLegendreLinear(pxgaus, pxwgt, nigaus); 1711 GaussLegendreLinear(pegaus, pewgt, njgaus); 1712 }/*}}}1*/ 1713 /*FUNCTION gaussHexa{{{1*/ 1714 void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ) { 1715 /*Gauss quadrature points for the hexahedron.*/ 1716 1717 /* get the gauss points using the product of three line rules */ 1718 GaussLegendreLinear(pxgaus, pxwgt, nigaus); 1719 GaussLegendreLinear(pegaus, pewgt, njgaus); 1720 GaussLegendreLinear(pzgaus, pzwgt, nkgaus); 1721 }/*}}}1*/ 1722 /*FUNCTION gaussPenta{{{1*/ 1723 void gaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ) { 1724 /*Gauss quadrature points for the pentahedron.*/ 1725 1726 /* get the gauss points using the product of triangular and line rules */ 1727 GaussLegendreTria(pngaus, pl1, pl2, pl3, pwgt, iord); 1728 GaussLegendreLinear(pzgaus, pzwgt, nkgaus); 1742 1729 1743 1744 if (num_gauss==1){1745 //order=1, num_gauss=1. Can integrate polynomials of degree 0 to 11746 1747 gauss_weights=(double*)xmalloc(sizeof(double));1748 gauss_weights[0]= 2.0;1749 1750 segment_coord=(double*)xmalloc(sizeof(double));1751 segment_coord[0]= 0.0;1752 1753 }1754 else if (num_gauss==2){1755 //order=2, num_gauss=3. Can integrate polynomials of degree 0 to 31756 1757 gauss_weights=(double*)xmalloc(num_gauss*sizeof(double));1758 gauss_weights[0]=1.0;1759 gauss_weights[1]=1.0;1760 1761 segment_coord=(double*)xmalloc(num_gauss*sizeof(double));1762 segment_coord[0]=-0.577350269189626;1763 segment_coord[1]=0.577350269189626;1764 1765 }1766 else if (num_gauss==3){1767 //order=3, num_gauss=4. Can integrate polynomials of degree 0 to 51768 1769 gauss_weights=(double*)xmalloc(num_gauss*sizeof(double));1770 gauss_weights[0]=0.555555555555555556;1771 gauss_weights[1]=0.88888888888889;1772 gauss_weights[2]=0.555555555555555556;1773 1774 segment_coord=(double*)xmalloc(num_gauss*sizeof(double));1775 segment_coord[0]=-0.774596669241483;1776 segment_coord[1]=0.0;1777 segment_coord[2]=0.774596669241483;1778 1779 }1780 else if (num_gauss==4){1781 //order=3, num_gauss=4. Can integrate polynomials of degree 0 to 51782 1783 gauss_weights=(double*)xmalloc(num_gauss*sizeof(double));1784 gauss_weights[0]=0.347854845137454;1785 gauss_weights[1]=0.652145154862546;1786 gauss_weights[2]=0.652145154862546;1787 gauss_weights[3]=0.347854845137454;1788 1789 segment_coord=(double*)xmalloc(num_gauss*sizeof(double));1790 segment_coord[0]=-0.861136311594053;1791 segment_coord[1]=-0.339981043584856;1792 segment_coord[2]=0.339981043584856;1793 segment_coord[3]=0.861136311594053;1794 1795 }1796 else if (num_gauss==5){1797 //order=3, num_gauss=4. Can integrate polynomials of degree 0 to 51798 1799 gauss_weights=(double*)xmalloc(num_gauss*sizeof(double));1800 gauss_weights[0]=0.236926885056189;1801 gauss_weights[1]=0.478628670499366;1802 gauss_weights[2]=0.568888888888889;1803 gauss_weights[3]=0.478628670499366;1804 gauss_weights[4]=0.236926885056189;1805 1806 segment_coord=(double*)xmalloc(num_gauss*sizeof(double));1807 segment_coord[0]=-0.906179845938664;1808 segment_coord[1]=-0.538469310105683;1809 segment_coord[2]=0.0;1810 segment_coord[3]=0.538469310105683;1811 segment_coord[4]=0.906179845938664;1812 1813 }1814 else{1815 _printf_("GaussSegment error message: order not supported yet");1816 }1817 1818 /*Assign output pointers: */1819 *pgauss_weights=gauss_weights;1820 *psegment_coord=segment_coord;1821 return;1822 1730 }/*}}}1*/ 1731 /*FUNCTION gaussSegment{{{1*/ 1732 void gaussSegment(double** psegment_coord,double** pgauss_weights,int num_gauss){ 1733 /* gaussSegment*/ 1734 1735 GaussLegendreLinear(psegment_coord,pgauss_weights,num_gauss); 1736 }/*}}}1*/ -
issm/trunk/src/c/shared/Numerics/GaussPoints.h
r4417 r5624 7 7 8 8 #define MAX_LINE_GAUS_PTS 4 9 void GaussLegendre( double** pxgaus, double** pxwgt, int ngaus ); 10 9 void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus ); 10 #define MAX_TRIA_SYM_ORD 20 11 void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ); 12 #define MAX_TETRA_SYM_ORD 6 13 void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ); 11 14 #define MAX_LINE_GLOB_PTS 5 12 15 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ); 13 14 16 #define MAX_GAUS_ITER 30 15 17 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ); 16 18 17 void GaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ); 18 19 #define MAX_TRIA_SYM_ORD 20 20 void GaussTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ); 21 22 void GaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ); 23 24 void GaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ); 25 26 #define MAX_TETRA_SYM_ORD 6 27 void GaussTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ); 28 29 void GaussSegment(double** psegment_coord,double** pgauss_weights,int num_gauss); 19 void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ); 20 void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ); 21 void gaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ); 22 void gaussSegment(double** psegment_coord,double** pgauss_weights,int num_gauss); 30 23 31 24 #endif
Note:
See TracChangeset
for help on using the changeset viewer.