CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Matrix addressing

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 13, 2017, 14:50
Default Matrix addressing
  #1
New Member
 
Basel Abu-sinni
Join Date: Mar 2017
Posts: 6
Rep Power: 9
BaselAS is on a distinguished road
Hi,
I'm very new to OpenFOAM, and I've been tasked in exporting a certain matrix's data from the solver on each time-step.
I've read Matrices_in_OpenFOAM but unfortunately I didn't fully understand lduaddressing... where can I find more examples on the subject?

as I mentioned, I need to export the matrix's data, meaning I need to loop over all non-zero entries and output the value along with its row-col index. any tips are very much welcomed.

Thanks in advance,
Basel
BaselAS is offline   Reply With Quote

Old   March 14, 2017, 10:23
Default
  #2
New Member
 
Hasan Shetabivash
Join Date: Jan 2017
Location: Montreal
Posts: 17
Rep Power: 12
hasan_shetabivash is on a distinguished road
Dear BaselAS,

LduAddressing keeps the addressing of related cells. In lduMatrix coefficients are stored in three list named diagonal, upper and lower. If you just want to export the fvMatrix data you can simply use << operator for those list. And if you want to have indexing of all the lists you need to loop over all faces. The following example may help you.
Code:
  fvScalarMatrix TEqn
    (
        fvm::ddt(T)+
        fvm::laplacian(dimensionedScalar("D", dimensionSet(0,2,-1,0,0,0,0), 1), T)
    );
//Printing diagonal lower and upper lists   
    Info<<TEqn.diag()<<endl;
    Info<<TEqn.lower()<<endl;
    Info<<TEqn.upper()<<endl;
    const labelUList& owner = mesh.owner();
    const labelUList& neighbour = mesh.neighbour();
    Info<<owner<<endl;
    Info<<neighbour<<endl;
    const labelUList& lowerAdd = TEqn.lduAddr().lowerAddr();
    const labelUList& upperAdd = TEqn.lduAddr().upperAddr();
    for(int index=0;index<mesh.cells().size();index++)
    {
        Info<<"Diagonal value"<<TEqn.diag()[index]<<"\tDiagonal index: "<<index<<","<<index<<endl;
    }
    forAll(neighbour, facei)
    {
        Info<<"Lower value: "<<TEqn.lower()[facei]<<"\tLower index: "<<upperAdd[facei]<<","<<lowerAdd[facei]<<endl;
    }
    forAll(neighbour, facei)
    {
        Info<<"Upper value: "<<TEqn.upper()[facei]<<"\tUpper index: "<<lowerAdd[facei]<<","<<upperAdd[facei]<<endl;
    }
Cheers,

Last edited by hasan_shetabivash; March 14, 2017 at 13:28.
hasan_shetabivash is offline   Reply With Quote

Old   March 14, 2017, 12:11
Default
  #3
New Member
 
Basel Abu-sinni
Join Date: Mar 2017
Posts: 6
Rep Power: 9
BaselAS is on a distinguished road
Quote:
Originally Posted by hasan_shetabivash View Post
Dear BaselAS,

LduAddressing keeps the addressing of related cells. In lduMatrix coefficients are stored in three list named diagonal, upper and lower. If you just want to export the fvMatrix data you can simply use << operator for those list. And if you want to have indexing of all the lists you need to loop over all faces. The following example may help you.
Code:
  fvScalarMatrix TEqn
    (
        fvm::ddt(T)+
        fvm::laplacian(dimensionedScalar("D", dimensionSet(0,2,-1,0,0,0,0), 1), T)
    );
//Printing diagonal lower and upper lists   
    Info<<TEqn.diag()<<endl;
    Info<<TEqn.lower()<<endl;
    Info<<TEqn.upper()<<endl;
    const labelUList& owner = mesh.owner();
    const labelUList& neighbour = mesh.neighbour();
    Info<<owner<<endl;
    Info<<neighbour<<endl;
    const labelUList& lowerAdd = TEqn.lduAddr().lowerAddr();
    const labelUList& upperAdd = TEqn.lduAddr().upperAddr();
    for(int index=0;index<=neighbour.size();index++)
    {
        Info<<"Diagonal value"<<TEqn.diag()[index]<<"\tDiagonal index: "<<index<<","<<index<<endl;
    }
    forAll(neighbour, facei)
    {
        Info<<"Lower value: "<<TEqn.lower()[facei]<<"\tLower index: "<<upperAdd[facei]<<","<<lowerAdd[facei]<<endl;
    }
    forAll(neighbour, facei)
    {
        Info<<"Upper value: "<<TEqn.upper()[facei]<<"\tUpper index: "<<lowerAdd[facei]<<","<<upperAdd[facei]<<endl;
    }
Cheers,
That's fantastic, exactly what I needed!
Thank you very much!
BaselAS is offline   Reply With Quote

Reply

Tags
addressing, export data, matrix


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matrix addressing maybee OpenFOAM Programming & Development 10 August 1, 2020 07:55
ldu matrix, ldu addressing maybee OpenFOAM Programming & Development 0 December 7, 2013 12:40
Force can not converge colopolo CFX 13 October 4, 2011 22:03
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 21:47
Addressing matrix element and reuse of system matrix marziolettich OpenFOAM Running, Solving & CFD 2 February 19, 2008 05:04


All times are GMT -4. The time now is 10:21.