CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Syntaxproblem LU decomposition of a matrix (

kathrin_kissling January 20, 2009 05:40

Hello! I am having a proble

I am having a problem with the the syntax used to decompose a matrix with LU decomposition.

I found two makros:
scalarMatrix::LUsolve declared as:
static void LUsolve (Matrix<scalar> &matrix, Field<t> &source)

and simpleMatrix:LUsolve declared as:
Foam::Field<t> LUsolve ( ) const

Here is the snippet from my code:

volTensorField D = fvc::grad(U);
volTensorField Wtr = 0.5 * (D.T() + D);

volTensorField WtrLambda = Wtr - test * I;
volVectorField solution = WtrLambda.LUsolve();

The compiler gives me the following error:
error: 'struct Foam::volTensorField' has no member named LUsolve.

I understand, that LUsolve is obviously not a member function of volTensorField.

Can anybody tell me the correct syntax to use the LUsolve macro? What is the difference between the two macros?
I searched the forum, but I couldn't find anything regarding this topic.

Thank you a lot!


henrik January 20, 2009 11:57

Dear Kathrin, I am not exac
Dear Kathrin,

I am not exactly sure what exactly you are trying to do. There are many ways to assemble and solve a linear system in OF depending whether you seek a solution for a standalone linear system, a discretised PDE or a pointwise solution.

simpleMatrix is a NxN matrix & solver. It doesn't know about geometric Fields. It is used, for example, in the ODE solvers - where you can also find examples how to use it.

scalarMatrix is used to solve discretised PDEs, but you would normally go solve(ffm::div(s)) or similar.

However, my feeling is that you a looking for a pointwise solution of a 3x3 matrix (or tensor). If this is the case, you want to check out Tensor::cofactors and Tensor::inv (see $FOAM_SRC/src/OpenFOAM/lnInclude/TensorI.H).

BTW, symm(D) is faster than 0.5 * (D.T() + D) and can also be found in $FOAM_SRC/src/OpenFOAM/lnInclude/TensorI.H.


kathrin_kissling January 20, 2009 12:46

Dear Henrik, thank you a lo
Dear Henrik,

thank you a lot for your answer. That helps me a lot!



All times are GMT -4. The time now is 17:00.