# Matrix Assembly in OpenFOAM

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

 October 13, 2014, 08:49 Matrix Assembly in OpenFOAM #1 Senior Member   Join Date: Sep 2010 Location: France Posts: 194 Rep Power: 7 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.

 October 14, 2014, 03:12 Matrix Assembly in OpenFOAM #2 Member   Manjunath Reddy Join Date: Jun 2013 Posts: 38 Rep Power: 4 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

October 14, 2014, 04:21
#3
Senior Member

Join Date: Sep 2010
Location: France
Posts: 194
Rep Power: 7
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 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

 November 4, 2014, 11:16 #4 Member   Avdeev Evgeniy Join Date: Jan 2011 Location: Togliatty, Russia Posts: 52 Blog Entries: 1 Rep Power: 12 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.

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post rosswin Open Source Meshers: Gmsh, Netgen, CGNS, ... 0 March 5, 2013 08:34 botp OpenFOAM Programming & Development 1 February 6, 2013 05:26 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 May 31, 2012 09:07 linnemann OpenFOAM Installation 7 July 30, 2009 03:14 masb OpenFOAM 3 May 25, 2009 11:32

All times are GMT -4. The time now is 13:18.