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

Symmetric and asymmetric matrices have always the same size

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2018, 13:50
Default Symmetric and asymmetric matrices have always the same size
  #1
Senior Member
 
Klaus
Join Date: Mar 2009
Posts: 265
Rep Power: 22
klausb will become famous soon enough
I am trying to analyze the matrix structure but my routine gives me the same size for both the symmetric p matrix and the asymmetric U matrix as if the latter was symmetric and of the same size as the p matrix.

The diagonal part is currently omitted.

Code:
  // allocate memory for row_NNZ[N+1], the number of nonzero values for each matrix row
  int * row_NNZ = (int *)calloc(N+1, sizeof(int));

  // initialize row_NNZ with 0s
  for (int i=0; i<N+1; i++) 
    row_NNZ[i] = 0;

  // count the nonzero values per row for lower and upper part

  Foam::UList<int>::const_iterator it_lower = matrix_.lduAddr().lowerAddr().begin();
  Foam::UList<int>::const_iterator it_upper = matrix_.lduAddr().upperAddr().begin();

  // compute NNZ per row for upper + lower part, excluding diagonal for a symmetric matrix
  for (int i=0; i<matrix_.upper().size(); i++) {
    row_NNZ[*it_lower + 1]++;
    row_NNZ[*it_upper + 1]++;
    it_lower++;
    it_upper++;
  }
   // check sum size of upper + lower part 
   int i, sum=0;
   for (i=0; i<N+1; i++)
   {
     sum = sum + row_NNZ[i];
   }
I want to develop a routine for an array containing the numbers (count) of nonzero values per matrix row. So far the above seems to work for the symmetric matrix (p) but not for asymmetric matrices (U).

How can I adjust it for the asymmetric matrices?

Klaus
klausb is offline   Reply With Quote

Old   May 13, 2018, 14:02
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
The asymmetric matrix is still symmetric IN ADDRESSING. The difference is that the symmetric matrix says that a_ij = a_ji and it only stores one.

Make sure you count both the upper and lower triangle. This is not the CR format.

Good luck, Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak 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
Asymmetric solution for bluff bodies symmetric tandem bud_el_lodituma Main CFD Forum 7 March 18, 2014 15:07
change symmetric lduMatrix into asymmetric marek88 OpenFOAM Programming & Development 2 August 24, 2011 09:02
Merits and Demerits of symmetric and asymmetric re Mukkarum Husain Main CFD Forum 0 January 7, 2009 08:46
asymmetric solution generated by symmetric problem Twiti CFX 7 October 16, 2004 19:12
Symmetric problem - Asymmetric prediction Mark Main CFD Forum 14 January 29, 2001 13:21


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