Matrix Assembly in OpenFOAM
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. |
Matrix Assembly in OpenFOAM
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 |
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:
|
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". http://www.cfd-online.com/Forums/ope...tml#post472905 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. |
All times are GMT -4. The time now is 14:51. |