Changeset 99
- Timestamp:
- 04/28/09 15:26:17 (16 years ago)
- Location:
- issm/trunk/src/c/shared/Numerics
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/shared/Numerics/GaussPoints.cpp
r1 r99 41 41 #undef __FUNCT__ 42 42 #define __FUNCT__ "GaussLegendre" 43 int GaussLegendre( double** pxgaus, 44 double** pxwgt, 45 int ngaus ) 46 { 47 int i,ierr=0; 43 void GaussLegendre( double** pxgaus, double** pxwgt, int ngaus ) { 44 45 int i; 48 46 double *alpha,*beta; 49 47 … … 124 122 /* calculate the Gauss points */ 125 123 126 if ((ierr=GaussRecur(*pxgaus, 127 *pxwgt, 128 ngaus, 129 alpha, 130 beta ))) 131 _printf_("%s -- Error %d from GaussRecur for ngaus=%d.\n", 132 __FUNCT__,ierr,ngaus); 133 124 GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta ); 134 125 xfree((void **)&beta ); 135 126 xfree((void **)&alpha); 136 127 } 137 128 138 // for (i=0; i<ngaus; i++)139 // _printf_("i=%d: xgaus=%f,xwgt=%f\n",i,(*pxgaus)[i],(*pxwgt)[i]);140 141 return(ierr);142 129 } 143 130 … … 179 166 #define __FUNCT__ "GaussLobatto" 180 167 181 int GaussLobatto( double** pxgaus, 182 double** pxwgt, 183 int ngaus ) 184 { 185 int i,ierr=0; 168 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ) { 169 170 int i; 186 171 double *alpha,*beta; 187 172 double left=-1.,right= 1.; … … 297 282 /* calculate the Gauss points */ 298 283 299 if ((ierr=GaussRecur(*pxgaus, 300 *pxwgt, 301 ngaus, 302 alpha, 303 beta ))) 304 _printf_("%s -- Error %d from GaussRecur for ngaus=%d.\n", 305 __FUNCT__,ierr,ngaus); 306 284 GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta ); 307 285 xfree((void **)&beta ); 308 286 xfree((void **)&alpha); 309 287 } 310 288 311 // for (i=0; i<ngaus; i++)312 // _printf_("i=%d: xgaus=%f,xwgt=%f\n",i,(*pxgaus)[i],(*pxwgt)[i]);313 314 return(ierr);315 289 } 316 290 … … 339 313 #define __FUNCT__ "GaussRecur" 340 314 341 int GaussRecur( double* zero, 342 double* weight, 343 int n, 344 double* alpha, 345 double* beta ) 346 { 315 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ) { 347 316 int i,j,k,l,m,ii,mml,iter; 348 317 double p,g,r,s,c,f,b; 349 318 double* work; 350 319 351 // _printf_("Gauss abscissas and weights n=%d\n",n);352 353 320 if ( n == 1 ) { 354 321 zero[0] =alpha[0]; 355 322 weight[0]=beta[0]; 356 return 1;323 return ; 357 324 } 358 325 … … 463 430 xfree((void **)&work); 464 431 465 return 1;466 432 } 467 433 … … 492 458 #define __FUNCT__ "GaussQuad" 493 459 494 int GaussQuad( double** pxgaus, 495 double** pxwgt, 496 double** pegaus, 497 double** pewgt, 498 int nigaus, 499 int njgaus ) 500 { 501 int i,ierr=0; 502 503 // _printf_("GaussQuad: nigaus=%d,njgaus=%d\n", 504 // nigaus,njgaus); 460 void GaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ) { 505 461 506 462 /* get the gauss points using the product of two line rules */ 507 463 508 if ((ierr=GaussLegendre(pxgaus, 509 pxwgt, 510 nigaus))) { 511 _printf_("%s -- Error %d from GaussLegendre for nigaus=%d.\n", 512 __FUNCT__,ierr,nigaus); 513 return(ierr); 514 } 515 // for (i=0; i<nigaus; i++) 516 // _printf_("i=%d: xgaus=%f,xwgt=%f\n",i,(*pxgaus)[i],(*pxwgt)[i]); 517 518 if ((ierr=GaussLegendre(pegaus, 519 pewgt, 520 njgaus))) { 521 _printf_("%s -- Error %d from GaussLegendre for njgaus=%d.\n", 522 __FUNCT__,ierr,njgaus); 523 return(ierr); 524 } 525 // for (i=0; i<njgaus; i++) 526 // _printf_("j=%d: egaus=%f,ewgt=%f\n",i,(*pegaus)[i],(*pewgt)[i]); 527 528 return 1; 464 GaussLegendre(pxgaus, pxwgt, nigaus); 465 466 GaussLegendre(pegaus, pewgt, njgaus); 529 467 } 530 468 … … 559 497 #undef __FUNCT__ 560 498 #define __FUNCT__ "GaussTria" 561 int GaussTria( int* pngaus, 562 double** pl1, 563 double** pl2, 564 double** pl3, 565 double** pwgt, 566 int iord ) 567 { 568 int i,j,ipt,nigaus,ierr=0; 499 void GaussTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ) { 500 501 int i,j,ipt,nigaus; 569 502 double xi,eta; 570 503 double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt; … … 1659 1592 /* get the gauss points in each direction */ 1660 1593 1661 if ((ierr=GaussLegendre(&xgaus, 1662 &xwgt, 1663 nigaus))) { 1664 _printf_("%s -- Error %d from GaussLegendre for nigaus=%d.\n", 1665 __FUNCT__,ierr,nigaus); 1666 return(ierr); 1667 } 1594 GaussLegendre(&xgaus, &xwgt, nigaus); 1668 1595 1669 1596 egaus=xgaus; … … 1697 1624 // i,(*pl1 )[i],(*pl2 )[i],(*pl3 )[i],(*pwgt)[i]); 1698 1625 1699 return 1;1626 return ; 1700 1627 } 1701 1628 … … 1730 1657 #undef __FUNCT__ 1731 1658 #define __FUNCT__ "GaussHexa" 1732 int GaussHexa( double** pxgaus, 1733 double** pxwgt, 1734 double** pegaus, 1735 double** pewgt, 1736 double** pzgaus, 1737 double** pzwgt, 1738 int nigaus, 1739 int njgaus, 1740 int nkgaus ) 1741 { 1742 int i,ierr=0; 1743 1744 // _printf_("GaussHexa: nigaus=%d,njgaus=%d,nkgaus=%d\n", 1745 // nigaus,njgaus,nkgaus); 1746 1747 /* get the gauss points using the product of three line rules */ 1748 1749 if ((ierr=GaussLegendre(pxgaus, 1750 pxwgt, 1751 nigaus))) { 1752 _printf_("%s -- Error %d from GaussLegendre for nigaus=%d.\n", 1753 __FUNCT__,ierr,nigaus); 1754 return(ierr); 1755 } 1756 // for (i=0; i<nigaus; i++) 1757 // _printf_("i=%d: xgaus=%f,xwgt=%f\n",i,(*pxgaus)[i],(*pxwgt)[i]); 1758 1759 if ((ierr=GaussLegendre(pegaus, 1760 pewgt, 1761 njgaus))) { 1762 _printf_("%s -- Error %d from GaussLegendre for njgaus=%d.\n", 1763 __FUNCT__,ierr,njgaus); 1764 return(ierr); 1765 } 1766 // for (i=0; i<njgaus; i++) 1767 // _printf_("j=%d: egaus=%f,ewgt=%f\n",i,(*pegaus)[i],(*pewgt)[i]); 1768 1769 if ((ierr=GaussLegendre(pzgaus, 1770 pzwgt, 1771 nkgaus))) { 1772 _printf_("%s -- Error %d from GaussLegendre for nkgaus=%d.\n", 1773 __FUNCT__,ierr,nkgaus); 1774 return(ierr); 1775 } 1776 // for (i=0; i<nkgaus; i++) 1777 // _printf_("k=%d: zgaus=%f,zwgt=%f\n",i,(*pzgaus)[i],(*pzwgt)[i]); 1778 1779 return 1; 1659 void GaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ) { 1660 1661 /* get the gauss points using the product of three line rules */ 1662 1663 GaussLegendre(pxgaus, pxwgt, nigaus); 1664 1665 GaussLegendre(pegaus, pewgt, njgaus); 1666 1667 GaussLegendre(pzgaus, pzwgt, nkgaus); 1780 1668 } 1781 1669 … … 1811 1699 #define __FUNCT__ "GaussPenta" 1812 1700 1813 int GaussPenta( int* pngaus, 1814 double** pl1, 1815 double** pl2, 1816 double** pl3, 1817 double** pwgt, 1818 double** pzgaus, 1819 double** pzwgt, 1820 int iord, 1821 int nkgaus ) 1822 { 1823 int i,ierr=0; 1824 1825 // _printf_("GaussPenta: iord=%d,nkgaus=%d\n", 1826 // iord,nkgaus); 1701 void GaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ) { 1827 1702 1828 1703 /* get the gauss points using the product of triangular and line rules */ 1829 1704 1830 if ((ierr=GaussTria(pngaus, 1831 pl1, 1832 pl2, 1833 pl3, 1834 pwgt, 1835 iord))) { 1836 _printf_("%s -- Error %d from GaussTria for iord=%d.\n", 1837 __FUNCT__,ierr,iord); 1838 return(ierr); 1839 } 1840 // for (i=0; i<*pngaus; i++) 1841 // _printf_("i=%d: l1gaus=%f,l2gaus=%f,l3gaus=%f,wgt=%f\n", 1842 // i,(*pl1 )[i],(*pl2 )[i],(*pl3 )[i],(*pwgt)[i]); 1843 1844 if ((ierr=GaussLegendre(pzgaus, 1845 pzwgt, 1846 nkgaus))) { 1847 _printf_("%s -- Error %d from GaussLegendre for nkgaus=%d.\n", 1848 __FUNCT__,ierr,nkgaus); 1849 return(ierr); 1850 } 1851 // for (i=0; i<nkgaus; i++) 1852 // _printf_("k=%d: zgaus=%f,zwgt=%f\n",i,(*pzgaus)[i],(*pzwgt)[i]); 1853 1854 return 1; 1705 GaussTria(pngaus, pl1, pl2, pl3, pwgt, iord); 1706 1707 GaussLegendre(pzgaus, pzwgt, nkgaus); 1708 1855 1709 } 1856 1710 … … 1891 1745 #define __FUNCT__ "GaussTetra" 1892 1746 1893 int GaussTetra( int* pngaus, 1894 double** pl1, 1895 double** pl2, 1896 double** pl3, 1897 double** pl4, 1898 double** pwgt, 1899 int iord ) 1900 { 1901 int i,j,k,ipt,nigaus,ierr=0; 1747 void GaussTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ) { 1748 int i,j,k,ipt,nigaus; 1902 1749 double xi,eta,zeta; 1903 1750 double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt,*zgaus,*zwgt; … … 2126 1973 /* get the gauss points in each direction */ 2127 1974 2128 if ((ierr=GaussLegendre(&xgaus, 2129 &xwgt, 2130 nigaus))) { 2131 _printf_("%s -- Error %d from GaussLegendre for nigaus=%d.\n", 2132 __FUNCT__,ierr,nigaus); 2133 return(ierr); 2134 } 1975 GaussLegendre(&xgaus, &xwgt, nigaus); 2135 1976 2136 1977 egaus=xgaus; … … 2168 2009 } 2169 2010 2170 // _printf_("GaussTetra - ngaus=%d\n",*pngaus);2171 // for (i=0; i<*pngaus; i++)2172 // _printf_("i=%d: l1gaus=%f,l2gaus=%f,l3gaus=%f,l4gaus=%f,wgt=%f\n",2173 // i,(*pl1 )[i],(*pl2 )[i],(*pl3 )[i],(*pl4 )[i],(*pwgt)[i]);2174 2175 return 1;2176 2011 } 2177 2012 -
issm/trunk/src/c/shared/Numerics/GaussPoints.h
r1 r99 8 8 9 9 #define MAX_LINE_GAUS_PTS 4 10 11 int GaussLegendre( double** pxgaus, 12 double** pxwgt, 13 int ngaus ); 10 void GaussLegendre( double** pxgaus, double** pxwgt, int ngaus ); 14 11 15 12 #define MAX_LINE_GLOB_PTS 5 16 17 int GaussLobatto( double** pxgaus, 18 double** pxwgt, 19 int ngaus ); 13 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ); 20 14 21 15 #define MAX_GAUS_ITER 30 16 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ); 22 17 23 int GaussRecur( double* zero, 24 double* weight, 25 int n, 26 double* alpha, 27 double* beta ); 28 29 int GaussQuad( double** pxgaus, 30 double** pxwgt, 31 double** pegaus, 32 double** pewgt, 33 int nigaus, 34 int njgaus ); 18 void GaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ); 35 19 36 20 #define MAX_TRIA_SYM_ORD 20 21 void GaussTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ); 37 22 38 int GaussTria( int* pngaus, 39 double** pl1, 40 double** pl2, 41 double** pl3, 42 double** pwgt, 43 int iord ); 23 void GaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ); 44 24 45 int GaussHexa( double** pxgaus, 46 double** pxwgt, 47 double** pegaus, 48 double** pewgt, 49 double** pzgaus, 50 double** pzwgt, 51 int nigaus, 52 int njgaus, 53 int nkgaus ); 54 55 int GaussPenta( int* pngaus, 56 double** pl1, 57 double** pl2, 58 double** pl3, 59 double** pwgt, 60 double** pzgaus, 61 double** pzwgt, 62 int iord, 63 int nkgaus ); 25 void GaussPenta( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, double** pzgaus, double** pzwgt, int iord, int nkgaus ); 64 26 65 27 #define MAX_TETRA_SYM_ORD 6 28 void GaussTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ); 66 29 67 int GaussTetra( int* pngaus,68 double** pl1,69 double** pl2,70 double** pl3,71 double** pl4,72 double** pwgt,73 int iord );74 30 void GaussSegment(double** psegment_coord,double** pgauss_weights,int num_gauss); 75 31 -
issm/trunk/src/c/shared/Numerics/numerics.h
r8 r99 13 13 double OptFunc(double scalar, OptArgs* optargs); 14 14 void BrentSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs); 15 void cross(double* result,double* vector1,double* vector2); 16 double norm(double* vector); 15 17 16 18 #endif //ifndef _NUMERICS_H_
Note:
See TracChangeset
for help on using the changeset viewer.