CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Solving Linear System of Equations in UDF (https://www.cfd-online.com/Forums/fluent/75413-solving-linear-system-equations-udf.html)

mohsen zendehbad April 25, 2010 01:28

Solving Linear System of Equations in UDF
 
Somewhere in my UDF i should solve linear system of equations(Ax = b), where i have A matrix and b vector and i need to compute x vector,
Now do any one know if there is an internal linear solver in fluent udf that i can use to compute x vector?

REGARDS

DoHander April 25, 2010 09:05

I think I've seen in one of the *.h files of Fluent a declaration for a Gauss solver (I don't have a Fluent installed on this machine to give you an exact name).

However I'm sure you can find on Internet a simple Gauss solver in pure C, you can simply use this function in your UDF.

Do

DoHander April 26, 2010 14:56

Precisely the above mentioned code is in linalg.h in your Fluent directory, this is a piece of code from the file:

void Gauss_Elimination(const int n_rows, const int n_cols, real A[], real X[], real B[], int swap_rows)

This is what you need ! (I hope)

Do

arjun April 26, 2010 18:42

Quote:

Originally Posted by mohsen zendehbad (Post 256221)
Somewhere in my UDF i should solve linear system of equations(Ax = b), where i have A matrix and b vector and i need to compute x vector,
Now do any one know if there is an internal linear solver in fluent udf that i can use to compute x vector?

REGARDS


why you want to use fluent. Do you need this as a part of simulation.

if you do not need it as part of simultion than there are many libraries that would do it for you.

mohsen zendehbad May 8, 2010 07:48

Isn't there any iterative method (such as GMRES or conjugate gradient) since gauss elimination is not responding to huge matrices?

REGARDS
MZ

DoHander May 8, 2010 10:39

Hello,

I've found only Gauss, but you can search in all Fluent's *.h files from the udf's directory, maybe I've missed something (probably there are less then 100 *.h files so you can do a quick check).

If you want a more complex solver I'm sure you can link your udf with an open source math library (I said open source because you will need to compile this just like you compile your own UDF). Unfortunately you need a pure C library, I think GSL ( http://www.gnu.org/software/gsl/ ) may be a good choice, not sure how easy it will be for you to recompile it.

Or you can write a C wrapper for Lapack which is a state of the art linear algebra library, probably this will be more feasible for any operating system (Lapack is written in Fortran).

Do you use Linux or Windows ?

Do


All times are GMT -4. The time now is 19:45.