|
[Sponsors] |
May 12, 2011, 11:03 |
Problems with biCGSTAB
|
#1 |
New Member
Felipe Hernandez
Join Date: Apr 2011
Posts: 13
Rep Power: 14 |
I wrote a biconjugate gradient method in C for my FEM solver, but it does not work. (I can tell because when I use a different method, the results are correct). Can you see if there is an obvious problem with the code below?
Code:
r = addVectors(b, multiplyR(A, x0), n, -1); copyVector(r, rtilde, n); int i; for(i=0;i<n;i++) { rho_1 = dotProduct(rtilde, r, n); if(i==0) { copyVector(r, p, n); } else { beta = (rho_1/rho_2) * (alpha/omega); double * tempA = addVectors(p, v, n, -omega); p = addVectors(r, tempA, n, beta); free(tempA); } v = multiplyR(A, p); alpha = rho_1 / (dotProduct(rtilde, v, n)); s = addVectors(r, v, n, (-1)*alpha); t = multiplyR(A, s); omega = (dotProduct(t, s, n))/dotProduct(t, t, n); double* temp = addVectors(x, p, n, alpha); x = addVectors(temp, s, n, omega); free(temp); r = addVectors(s, t, n, -omega); rho_2 = rho_1; } multiplyR(matrix, vector) is a function that multiplies a matrix on the left with a vector on the right. addVectors(vector A, vector B, int n, double k) returns A+kB. (The n is length of each vector). As you can see, I'm not using a pre-conditioner. Any help would be much appreciated!! :::UPDATE::: I have recently tried using a gauss-siedel preconditioner. The results did not improve at all, but they did change. Does that mean that I should try more sophisticated preconditioners, that there something wrong with the algorithm above, or that I should move on to gmres or some other method? (I think I'm just going to try gaussian elimination until I feel like tackling this problem again. I've spent far too long on it!!!) Last edited by Petrov; May 12, 2011 at 17:14. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Needed Benchmark Problems for FSI | Mechstud | Main CFD Forum | 4 | July 26, 2011 12:13 |
TurbDyMFoam-Ggi | JulytoNovember | OpenFOAM Running, Solving & CFD | 2 | January 31, 2011 01:36 |
Some problems with Star CD | Micha | Siemens | 0 | August 6, 2003 13:55 |
Airpak: Problems with heat flow contour conditions | Ivan de Miguel Urain | FLUENT | 1 | November 16, 2001 09:36 |
unstructured grid | sreekanth | Main CFD Forum | 1 | August 6, 2001 15:09 |