CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Thomas Algorithm Testing (https://www.cfd-online.com/Forums/main/3107-thomas-algorithm-testing.html)

Out of Ideas February 8, 2001 02:05

Thomas Algorithm Testing
 
I need some advice on the C program i am working on. Currently i am using the ADI scheme to work on my problem. However, i seem to suspect that the thomas algorithm i wrote has some errors. Is there anyway i can test my thomas algorithm? Please advice.

andy February 8, 2001 06:00

Re: Thomas Algorithm Testing
 
Download routine from netlib.

Download routine from Numerical Recipes.

Solve a 3x3 matrix with your code and check it by hand.

yf yap February 8, 2001 10:13

Re: Thomas Algorithm Testing
 
please refer to Applied Numerical Methods in C by Shoichiro Nakamura. pg. 385. a subroutine for solving tridiagonal matrix, thomas algorithm, is given there. for ADI, you must have at least 2 sweeps in different directions, i suggest that instead of having one subroutine for solving all those tridiagonal matrices, try to code one subroutine for each sweeping direction in order to avoid unnecessary confusion. afterall, the thomas algorithm can be coded in few lines. as suggested by andy, do try a 3x3 matrix manually, it should be pretty easy to detect any possible errors with such small matrix. regards, yfyap

T. Matsuzawa February 8, 2001 22:45

Re: Thomas Algorithm Testing
 
hello

In order to check your Thomas Algorithm implementation, Make the check routines like this.

STEP1(Build problem) A x = b where A: (blocked? ) tridiagonal matrix (first some simple matrix, such as identitymatrix, then gradually augment complexitiy)

x_{exact}: any vector you want

then calculate the vector b STEP2(CHECK Tomas)

solve for x_{calc} by A x = b for given A & b in STEP1 using your Thomas. Then compare x_{exact} to x_{calc}.

STEP3 If OK, then change A to more complex matrix until you are confident to your implementation.

Good Luck!!


All times are GMT -4. The time now is 16:22.