CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Understanding matrix_.Amul(..) in PCG.C

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

LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2009, 11:37
Default Understanding matrix_.Amul(..) in PCG.C
New Member
Michael Wurst
Join Date: Mar 2009
Location: Munich, Germany
Posts: 6
Rep Power: 14
michi is on a distinguished road
Hallo everybody!

I am trying to understand the implementation of the linear solvers, for example the PCG solver. Most iterative methods have a matrix-vector multiplication which is performed in OpenFOAM by

matrix_.Amul(result, psi, interfaceBouCoeffs_, interfaces_, cmpt);

If we then have a further look in the implementation of Amul the following design can be found:
1. initMatrixInterfaces
2. Do the calculation: result = A*psi

3. updateMatrixInterfaces

I tried now to unterstand steps 1 and 3. As far as I see, steps 1 and 3 belong to some kind of correction of the final result. For example, if a case runs in parallel we have to transport some values of psi from one processor to the other. That are the values(cells) of psi which are close to the processor boundary. My question is now:
What exactly is the task of initMatrixInterfaces(....) and updateMatrixInterfaces(....)? Why is this correction of the result vector split into two steps and not just performed in one step?

It would be great if someone could help me!
michi is offline   Reply With Quote

Old   June 1, 2011, 10:52
Lukasz Miroslaw
Join Date: Dec 2009
Location: Poland
Posts: 66
Rep Power: 13
Lukasz is on a distinguished road
Send a message via Skype™ to Lukasz

Have you received the answer for this question? I know OF uses zero halo layer approach but still have to figure out how does it refers to updatematrixinterfaces().

Let me know if you know the answer.

Lukasz is offline   Reply With Quote

Old   June 1, 2011, 14:26
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 19
marupio is on a distinguished road
I haven't delved too deeply into this, but I'm pretty sure these interfaces are used only for boundary conditions that contribute to off-diagonal matrix terms - cyclic, processor, possibly GGI (?). The regular boundary conditions are absorbed into the diagonal and source term of the matrix before calling an ldu solver... but the off-diagonal ones cannot be, as different ldu solvers handle them differently. Ultimately, that is why boundary coefficients and interfaces are given to the solver.

I'm guessing the Amul function is one of the ldu solver's methods for handling these off-diagonal contributions.
marupio is offline   Reply With Quote

Old   August 27, 2013, 04:14
New Member
Join Date: Dec 2012
Posts: 2
Rep Power: 0
Amiin is on a distinguished road
Hope to find my answer in this old thread!

My question is about the second part. (result = A*psi)
I know that OpenFOAM uses LDU method (lower, upper and diagonal) to store a matrix.
Is it a simple matrix multiplication as I show below?
[ApsiPtr](vector) = [lowerPtr + upperPtr + diagPtr](matrix) * [psiPtr](vector)

It seems a little bit different!
//Quote from lduMatrixATmul.C in OpenFOAM 2.2.0
for (register label cell=0; cell<nCells; cell++)
ApsiPtr[cell] = diagPtr[cell]*psiPtr[cell];

for (register label face=0; face<nFaces; face++)
ApsiPtr[uPtr[face]] += lowerPtr[face]*psiPtr[lPtr[face]];
ApsiPtr[lPtr[face]] += upperPtr[face]*psiPtr[uPtr[face]];

Best regards,

Amiin is offline   Reply With Quote

Old   September 23, 2013, 10:47
Join Date: Oct 2012
Location: Iran
Posts: 63
Rep Power: 10
luckycfd is on a distinguished road
Dear Amiin;
Are you find your question?
Is the second part(result = A*psi) refers to the matrix multiplication?

luckycfd is offline   Reply With Quote


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
Accessing the motionU matrix in OF ver 14 philippose OpenFOAM Running, Solving & CFD 2 April 16, 2007 18:16
Matrix solver Yang Main CFD Forum 5 May 13, 2006 22:20
convective stiffness matrix for FEM Juergen Kertz Main CFD Forum 5 December 23, 2005 05:55
A question about matrix eigenvalues. Demidov Main CFD Forum 0 November 14, 2004 04:51
Elemtary matrix to CSR global matrix xueying Main CFD Forum 2 September 24, 2002 09:44

All times are GMT -4. The time now is 14:49.