|
[Sponsors] |
How can I get the number of elements per row form the matrix? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 16, 2018, 09:26 |
How can I get the number of elements per row form the matrix?
|
#1 |
Senior Member
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22 |
Hi,
how can I compute the number of elements of a particular row of the coefficient matrix? I know how to compute the totals of the lower, upper and diagonal part e.g. int elements_lower_triangle = matrix.lower().size() + matrix.diag().size(); int elements_upper_triangle = matrix.upper().size() + matrix.diag().size(); Klaus Last edited by klausb; April 16, 2018 at 19:57. |
|
April 16, 2018, 20:10 |
I have been thinking of modifying the following code which is used to print a matrix
|
#2 |
Senior Member
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22 |
Code:
for(int i = 0; i < matrix_.lower().size(); i++){ int r = matrix_.lduAddr().upperAddr()[i]; int c = matrix_.lduAddr().lowerAddr()[i]; a[r*n + c] = matrix_.lower()[i]; } for(int i = 0; i < matrix_.diag().size(); i++){ a[i*n + i] = matrix_.diag()[i]; } for(int i = 0; i < matrix_.upper().size(); i++){ int r = matrix_.lduAddr().lowerAddr()[i]; int c = matrix_.lduAddr().upperAddr()[i]; a[r*n + c] = matrix_.upper()[i]; } Code:
0 1 2 3 0 D U U . 1 L D . U 2 L . D U 3 . L L D |
|
December 30, 2018, 16:27 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Quick note: I was looking into answering another thread of yours and while deducing how to do things, I remembered that gdbOF does what you're looking for: https://openfoamwiki.net/index.php/Contrib_gdbOF
If you look into the manual they provide, in the appendices are the pseudo-code blocks that tell how the matrices are reconstructed... which is what you're looking for here...
__________________
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Can't Shake Erros: patch type 'patch' not constraint type 'empty' | BrendaEM | OpenFOAM Meshing & Mesh Conversion | 12 | April 3, 2022 19:32 |
SigFpe when running ANY application in parallel | Pj. | OpenFOAM Running, Solving & CFD | 3 | April 23, 2015 15:53 |
Compressor Simulation using rhoPimpleDyMFoam | Jetfire | OpenFOAM Running, Solving & CFD | 107 | December 9, 2014 14:38 |
AMI interDyMFoam for mixer | danny123 | OpenFOAM Running, Solving & CFD | 4 | June 19, 2013 05:49 |
Stable boundaries | marcoymarc | CFX | 33 | March 13, 2013 07:39 |