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

OpenFOAM sum row with LDU addressing

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2021, 07:31
Default OpenFOAM sum row with LDU addressing
  #1
Member
 
Join Date: Feb 2020
Posts: 78
Rep Power: 3
Shibi is on a distinguished road
Hello to all,


I would like to know how to sum the value of a row in a OpenFOAM matrix through the LDU addressing.

Is there any already built in function to do this?

I have found for the upperTriangular part, the following:


Code:
const scalarField& diag = matrix_.diag();
const scalarField& lower = matrix_.lower();
const scalarField& upper = matrix_.upper();
 
const labelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const labelList& upperAddr = matrix_.lduAddr().upperAddr();
const labelList& ownStartAddr = matrix_.lduAddr().ownerStartAddr();
 
label fStart, fEnd;
 
sumRowElements = 0;
fStart = ownStartAddr[rowI];
fEnd = ownStartAddr[rowI + 1];
 
for (label j= fStart; j < fEnd; j++)
{
    sumRowElements  += upper[j]*x[upperAddr[j]];
}
Know I need to add the terms of the lower triangular part.





Can anyone give me a hand with this?


Best Regards
Shibi is offline   Reply With Quote

Old   October 7, 2021, 13:44
Default
  #2
Member
 
Join Date: Feb 2020
Posts: 78
Rep Power: 3
Shibi is on a distinguished road
So, I ended up checking Gauss Seidel, and it appears to send the lower adressing contributions to the right hand side vector.


So I did:


Code:
const scalarField& diag = matrix_.diag();
 const scalarField& lower = matrix_.lower();
const scalarField& upper = matrix_.upper();
 
const labelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const labelList& upperAddr = matrix_.lduAddr().upperAddr();
const labelList& ownStartAddr = matrix_.lduAddr().ownerStartAddr();
 
const label nRows = x.size();
 
scalarField store(x.size(), 0);
 
label fStart, fEnd;
 
for (label row = 0; row < nRows; row++)
{
    scalar sumRowElements = 0;
 
    // Start and end of this row
    fStart = ownStartAddr[row];
    fEnd = ownStartAddr[row + 1];
 
    // Sum terms in upper addressing

    for (label curCoeff = fStart; curCoeff < fEnd; curCoeff++)
    {
        sumRowElements  += upper[curCoeff]*x[upperAddr[curCoeff]];
    }
 
// Get row summation without diagonal element
    sumRowElements -= store[row];
 
    // Add lower addressing contributions to store vector for the next matrix row 
    for (label curCoeff = fStart; curCoeff < fEnd; curCoeff++)
    {
        store[upperAddr[curCoeff]] -= lower[curCoeff]*x[upperAddr[curCoeff]];
    }
}
Hopefully, this is correct.

Last edited by Shibi; October 12, 2021 at 08:01.
Shibi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 05:13
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 10:04
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 08:47
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 10:34
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 03:58


All times are GMT -4. The time now is 08:53.