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

Matrix Assembly in OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 13, 2014, 08:49
Smile Matrix Assembly in OpenFOAM
  #1
Senior Member
 
Join Date: Sep 2010
Location: France
Posts: 193
Rep Power: 6
T.D. is on a distinguished road
Hi FOAMers,

We know that in OpenFOAM the matrix coefficients are split into diag, lower and upper ones with an attention for boundary cells in the .diag() coefficients.
For example:
Taking any problem after discretizaton it becomes: KU=F , and we need to find i.e. the U field. OpenFoam classes split the matrices into: (A+H')U=F <=> AU = (F-H'U) for special treatments like sparse matrices.

We know that we can access diag(),lower(), upper(), source(), .A(), .H1(), .H(), and .psi() in OpenFOAM.

My Question is:

How can we re-Assemble-Back correctly the problem to get the two whole matrices: K and F from all what is available in the OpenFOAM classes like diag(),lower(), upper(), source(), .A(), .H1(), .H(), and .psi(), etc.. ?
Any ideas ?

Thanks

Best regards,

T.D.
T.D. is offline   Reply With Quote

Old   October 14, 2014, 03:12
Default Matrix Assembly in OpenFOAM
  #2
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 34
Rep Power: 4
manju819 is on a distinguished road
Hiiii,
Whole Matrix can be build using the owner Cell indices and neighbour cell indcies. For example in 2D, owner cell is surrounded by 4 neighbour cells.
If we know neighbour cell indcies then we can place the coefficients in their respective places.


For example to place diagonal elements
I've created one matrix with the size of mesh.
and
forAll(pEqn.diag(),i)
{

AMatrix[mesh.C().size()+i][i] = pEqn.diag()[i];

}

forAll(pEqn.lower(),i)
{

AMatrix[mesh.C().size()+i+1][mesh.C().size()+i] = pEqn.lower()[i];

}

to place the lower triangular matrix in AMatrix.


Regards,
Manjunath
manju819 is offline   Reply With Quote

Old   October 14, 2014, 04:21
Question
  #3
Senior Member
 
Join Date: Sep 2010
Location: France
Posts: 193
Rep Power: 6
T.D. is on a distinguished road
Dear Manjunath,

Thanks, but this is not what i want.
I know well how to place the lower(), upper(), and diag() coefficients in a Matrix form.
You should be aware ! This should be done by using the lduAddressing functions: lowerAddr() and upperAddr() and not just as simply as you did, because the coefficients may be not in order. look at:
http://openfoamwiki.net/index.php/Matrices_in_OpenFOAM

For what i want, I think you should read well again my question above precisely !

I will explain again: I want to recover the original matrices (K and F) so when i have the solution vector U, it satisfies well K*U=F.

Unfortunately, This is not in OpenFOAM, since OpenFOAM knows AMatrix as you called it, but this Matrix is such that AMatrix*U=H with AMatrix and H being completely different from K and F, respectively.

I hope it is more clear now 4 u.

Regards,

T.D.

Quote:
Originally Posted by manju819 View Post
Hiiii,
Whole Matrix can be build using the owner Cell indices and neighbour cell indcies. For example in 2D, owner cell is surrounded by 4 neighbour cells.
If we know neighbour cell indcies then we can place the coefficients in their respective places.


For example to place diagonal elements
I've created one matrix with the size of mesh.
and
forAll(pEqn.diag(),i)
{

AMatrix[mesh.C().size()+i][i] = pEqn.diag()[i];

}

forAll(pEqn.lower(),i)
{

AMatrix[mesh.C().size()+i+1][mesh.C().size()+i] = pEqn.lower()[i];

}

to place the lower triangular matrix in AMatrix.


Regards,
Manjunath
T.D. is offline   Reply With Quote

Old   November 4, 2014, 11:16
Default
  #4
Member
 
Avdeev Evgeniy
Join Date: Jan 2011
Location: Togliatty, Russia
Posts: 52
Blog Entries: 1
Rep Power: 12
j-avdeev will become famous soon enough
Send a message via Skype™ to j-avdeev
Hello.

If I understand your problem right - for small size matrices you can use matricoFoam approach. It creates zero dense matrix and grab coefficients from matrixes threw "addressing".
Dumping matrices from OpenFOAM

But if you need "production solution", probably you will need to add your own scalar field to solver and grab coefficients to this scalar field.
j-avdeev is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
gmsh 2.6.0 conversion to OpenFoam 160 rosswin Open Source Meshers: Gmsh, Netgen, CGNS, ... 0 March 5, 2013 08:34
Memory protection in OpenFOAM / combinig with FORTRAN botp OpenFOAM Programming & Development 1 February 6, 2013 05:26
OpenFOAM Foundation Releases OpenFOAMŪ Version 2.1.1 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 May 31, 2012 09:07
OpenFOAM 1.5.x package - CentOS 5.3 x86_64 linnemann OpenFOAM Installation 7 July 30, 2009 03:14
OpenFOAM Install problem masb OpenFOAM 3 May 25, 2009 11:32


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