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 Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools 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: 131
Rep Power: 11
klausb is on a distinguished road
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: 131
Rep Power: 11
klausb is on a distinguished road
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

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
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
Can't Shake Erros: patch type 'patch' not constraint type 'empty' BrendaEM OpenFOAM Meshing & Mesh Conversion 10 November 5, 2014 21:14
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 04:32.