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

Foam::correction() function

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By sharonyue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 29, 2015, 09:39
Default Foam::correction() function
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 849
Rep Power: 18
sharonyue is on a distinguished road
Hello guys

I was trying to figure out this function:

Code:
tmp<fvMatrix<Type> > Foam::correction	(	const fvMatrix< Type > & 		)	
Return the correction form of the given matrix.
by subtracting the matrix multiplied by the current field
I checked out the code in fvMatrix.H. its:
Code:
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::correction
(
    const fvMatrix<Type>& A
)
{
    tmp<Foam::fvMatrix<Type> > tAcorr = A - (A & A.psi());

    if
    (
        (A.hasUpper() || A.hasLower())
     && A.psi().mesh().fluxRequired(A.psi().name())
    )
    {
        tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr();
    }

    return tAcorr;
}
But I did grasp its meaning. Is it substantial derivative?

Thanks
sharonyue is offline   Reply With Quote

Old   May 23, 2015, 13:02
Default
  #2
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 849
Rep Power: 18
sharonyue is on a distinguished road
Yeah, from mathematical equations. it should be substantial derivative, but it does not look like.
sharonyue is offline   Reply With Quote

Old   July 2, 2015, 03:43
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 849
Rep Power: 18
sharonyue is on a distinguished road
Okay, I figured it out finally,

correction(fvm::ddt(p)) means d(p)/d(t) - d(pold)/d(t)

/handshake
xpqiu and Huibo like this.
__________________
My OpenFOAM algorithm website: http://dyfluid.com
By far the largest Chinese CFD-based forum: http://www.cfd-china.com/category/6/openfoam
We provide lots of clusters to Chinese customers, and we are considering to do business overseas: http://dyfluid.com/DMCmodel.html
sharonyue is offline   Reply With Quote

Old   July 9, 2015, 14:06
Default
  #4
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 16
kaifu is on a distinguished road
Quote:
Originally Posted by sharonyue View Post
correction(fvm::ddt(p)) means d(p)/d(t) - d(pold)/d(t)
What does pold here refer to? A temporary value during iteration or the solution from previous time step (usually in the transient solver)? In case of former circumstance, the correction term should disappear when the equation is converged. I'd rather treat this term in favor of mathematics than physics.
__________________
Kai
kaifu is offline   Reply With Quote

Old   January 12, 2023, 09:01
Default Some links to help others discern the meaning of Foam::correction()
  #5
New Member
 
Corbin G
Join Date: Oct 2022
Location: Midwest, USA
Posts: 11
Rep Power: 4
CorbinMG is on a distinguished road
Dear FOAMers,

I have been struggling to understand the correction() function as well. Particularly as it is implemented in the compressibleInterFoam pEqn.H. I don't have a perfect answer, but I at least wanted to put in the information I have found here. It would be nice if an OpenFOAM expert could tell us once and for all the meaning and purpose of correction().

First, the definition of the correction() function is found in fvMatrix.C. For OpenFOAM v2112, this looks like:
Code:
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::correction
(
    const fvMatrix<Type>& A
)
{
    tmp<Foam::fvMatrix<Type>> tAcorr = A - (A & A.psi());
 
    // Delete the faceFluxCorrection from the correction matrix
    // as it does not have a clear meaning or purpose
    deleteDemandDrivenData(tAcorr.ref().faceFluxCorrectionPtr());
 
    return tAcorr;
}
 
 
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::correction
(
    const tmp<fvMatrix<Type>>& tA
)
{
    tmp<Foam::fvMatrix<Type>> tAcorr = tA - (tA() & tA().psi());
 
    // Delete the faceFluxCorrection from the correction matrix
    // as it does not have a clear meaning or purpose
    deleteDemandDrivenData(tAcorr.ref().faceFluxCorrectionPtr());
 
    return tAcorr;
}
Then the question is what does the A.psi() mean? Well, from the CFD Direct book Chapter 3.5, OpenFOAM constructs the matrix for each equation as: \left[A\right] \left[{\Psi} \right] = \left[ b \right]. So I guess psi refers to the solved field variable.

What does correction() actually do? Well, as mentioned at the beginning of this post, "Return the correction form of the given matrix by subtracting the matrix multiplied by the current field".

Henry gave us another hint here: https://bugs.openfoam.org/view.php?id=1772
"The correction(fvm::ddt(p_rgh)) term is a correction to fvc::ddt(rho) due to changes in pressure and the converged result will be the same irrespective of how this correction is formulated, i.e. the correction will converge to 0 and the results will be fvc::ddt(rho)."

So I guess the correction term goes to 0 at convergence and it is meant for improving solver robustness?

More insights into the functionality of the correction() function are welcomed.

Best regards,
Corbin

Edit: this thread also contains come interesting ideas on what correction() might do: Understanding Terms in Compressible pEqn

Edit2: this wiki has some good info on OpenFOAM matrices which may also help: https://openfoamwiki.net/index.php/O...es_in_OpenFOAM

Last edited by CorbinMG; January 12, 2023 at 14:01.
CorbinMG 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
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 10:56
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 07:42
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 21:50
Please help about the VTKFoam liugx212 OpenFOAM Running, Solving & CFD 0 November 18, 2005 19:27


All times are GMT -4. The time now is 09:38.