CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Accessing Coefficient Matrix (http://www.cfd-online.com/Forums/openfoam/111748-accessing-coefficient-matrix.html)

hawkeye321 January 14, 2013 15:41

Accessing Coefficient Matrix
 
Hi FOAMERS

I am trying to access to elements of the coefficient matrix of an equation using lduAddresing

Foloowing the procedure in "OpenFOAM guide/Matrices in OpenFOAM" http://openfoamwiki.net/index.php/Matrices_in_OpenFOAM

I use

scalarField *lowerPtr_;
scalarField *diagPtr_;
scalarField *upperPtr_;

for (register label face=0; face<l.size(); face++)
{
Diag[l[face]] -= Lower[face];
Diag[u[face]] -= Upper[face];
}

But I get the following errors

error: ‘l’ was not declared in this scope
error: ‘Diag’ was not declared in this scope
error: ‘Lower’ was not declared in this scope
error: ‘u’ was not declared in this scope
error: ‘Upper’ was not declared in this scope

Do you have any idea what these errors are?
PS: I have included these header files

#include "fvCFD.H"
#include "wallFvPatch.H"
#include <fstream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <iostream>

fumiya January 14, 2013 18:58

Hi,

If your equation is UEqn, you can access the diag, upper and lower
coefficients of UEqn in the following manner:

Code:

    label Nc = mesh.nCells(); //Total number of cells

    //Diagonal coefficients
    for(label i=0; i<Nc; i++)
    {
        Info<< UEqn.diag()[i] << endl;
    }

    //Off-diagonal coefficients
    for(label faceI=0; faceI<UEqn.lduAddr().lowerAddr().size(); faceI++)
    {
        Info<< UEqn.upper()[faceI] << endl; //Lower coefficients
        Info<< UEqn.lower()[faceI] << endl; //Upper coefficients
    }

Hope that helps,
Fumiya

hawkeye321 January 14, 2013 19:11

Fumiya Thanks for the answer

Would you please also let me know what does "lduAddr()" and "lowerAddr()" mean here?

fumiya January 15, 2013 00:28

Hi mahdiiowa,

I don't understand what exactly "lduAddr()" means,
but you can access the "owner" cell label by UEqn.lduAddr().lowerAddr()[faceI]
and the "neighbour" cell label by UEqn.lduAddr().upperAddr()[faceI], respectively.

Hope that helps,
Fumiya

Yahoo March 6, 2013 17:35

Thanks for the comment.

EmadTandis June 1, 2013 07:11

Quote:

Originally Posted by mahdiiowa (Post 401816)
Hi FOAMERS

I am trying to access to elements of the coefficient matrix of an equation using lduAddresing

Foloowing the procedure in "OpenFOAM guide/Matrices in OpenFOAM" http://openfoamwiki.net/index.php/Matrices_in_OpenFOAM

I use

scalarField *lowerPtr_;
scalarField *diagPtr_;
scalarField *upperPtr_;

for (register label face=0; face<l.size(); face++)
{
Diag[l[face]] -= Lower[face];
Diag[u[face]] -= Upper[face];
}

But I get the following errors

error: ‘l’ was not declared in this scope
error: ‘Diag’ was not declared in this scope
error: ‘Lower’ was not declared in this scope
error: ‘u’ was not declared in this scope
error: ‘Upper’ was not declared in this scope

Do you have any idea what these errors are?
PS: I have included these header files

#include "fvCFD.H"
#include "wallFvPatch.H"
#include <fstream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <iostream>


Thanks mahdiiowa for your good link
this error is because the Diag, upper, ... is defined as a function in special class (I think lduMatrix or fvMatrix). If you want to call this function, you have to construct object from those class. example:
ldumatrix A
... (Defenition A)
now, you can call A.diag() and A.upper() , ...
I Hope this help you.
best Regards
Emad Tandis

santiagomarquezd June 4, 2013 07:53

Hi, you can use gdbOF to access the matrix coefficients at debugging time.

Regards.


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