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

How can I get the number of elements per row form the matrix?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2018, 08:26
Default How can I get the number of elements per row form the matrix?
  #1
Senior Member
 
Klaus
Join Date: Mar 2009
Posts: 250
Rep Power: 22
klausb will become famous soon enough
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 18:57.
klausb is offline   Reply With Quote

Old   April 16, 2018, 19:10
Default 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: 250
Rep Power: 22
klausb will become famous soon enough
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];
    }
It produces something like this (example):
Code:
   0  1  2  3
0  D  U  U  .
1  L  D  .  U
2  L  .  D  U
3  .  L  L  D
But I couldn't work out how to count the number of nonzero values (the L,D,Us) per row?
klausb is offline   Reply With Quote

Old   December 30, 2018, 15:27
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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...
Daniel_Khazaei likes this.
__________________
wyldckat is offline   Reply With Quote

Reply


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
[Other] Can't Shake Erros: patch type 'patch' not constraint type 'empty' BrendaEM OpenFOAM Meshing & Mesh Conversion 12 April 3, 2022 18:32
SigFpe when running ANY application in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 23, 2015 14:53
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 13:38
AMI interDyMFoam for mixer danny123 OpenFOAM Running, Solving & CFD 4 June 19, 2013 04:49
Stable boundaries marcoymarc CFX 33 March 13, 2013 06:39


All times are GMT -4. The time now is 22:40.