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

Conversion to fvscalar matrix equation

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

Like Tree2Likes
  • 2 Post By mkraposhin

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 11, 2013, 11:06
Unhappy Conversion to fvscalar matrix equation
  #1
Member
 
AJ
Join Date: Sep 2013
Posts: 30
Rep Power: 12
Aj Nair is on a distinguished road
Dear Fomers
Can you guys help me to convert this energy equation to fvscalar matrix equation, i am getting frequent errors in this part of program.


formula.JPG
Aj Nair is offline   Reply With Quote

Old   December 11, 2013, 11:43
Default
  #2
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Code:
forAll(A,i)
                {
                    A[i][i] = pEqn.diag()[i];                // inserting diagonal elements in A
                    b[i]    = pEqn.source()[i];                // and in b
                }
                
                const lduAddressing& addr = pEqn.lduAddr();
                const labelList& lowerAddr = addr.lowerAddr();
                const labelList& upperAddr = addr.upperAddr();                
                
                forAll(lowerAddr, i)
                {
                    A[lowerAddr[i]][upperAddr[i]] = pEqn.upper()[i];
                    A[upperAddr[i]][lowerAddr[i]] = pEqn.lower()[i];                                       
                }
                
                forAll(p.boundaryField(),I)
                {
                    const fvPatch &ptch=p.boundaryField()[I].patch();
                    forAll(ptch,J)
                    {
                    int w=ptch.faceCells()[J];
                    A[w][w]+=pEqn.internalCoeffs()[I][J];
                    b[w]   +=pEqn.boundaryCoeffs()[I][J];                    
                    }
                
                }
mkraposhin is offline   Reply With Quote

Old   December 11, 2013, 18:36
Default
  #3
Member
 
AJ
Join Date: Sep 2013
Posts: 30
Rep Power: 12
Aj Nair is on a distinguished road
But Matvej, i have attached an equation below.I had changed that equation as

fvm::ddt(T)+ ((fvc::grad(U))*T)-(lambda\(Cp*rho))*fvm::laplacian(T)

ignoring the epsilon. Is the above equation equivalent to which i attached .Because i get errors when i use this in TEqn
Aj Nair is offline   Reply With Quote

Old   December 12, 2013, 03:56
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
Uhm, which errors?

Normally you would discretize the convective term with fvm::div(phi,T).

Have a look in the, for example, buoyantPimpleFoam solver. The h-equation is very similar to your T-equation.
Bernhard is offline   Reply With Quote

Old   December 12, 2013, 09:32
Default
  #5
Member
 
AJ
Join Date: Sep 2013
Posts: 30
Rep Power: 12
Aj Nair is on a distinguished road
Bernhard, i have uploaded a formula pic in my first post.I got that from a journal.I wanted a fvscalar matrix equation equivalent to that.can u please go through tat equation and give me some suggestions.
Aj Nair is offline   Reply With Quote

Old   December 13, 2013, 11:17
Default
  #6
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Hi, Aj Nair!

My last post was about how to convert from your OF matrix format to 2D array. Now i see, that You are missing some basics of OF.

The problem that you are experiencing, is that OF uses conservative integral solution. Let's think you have equation

fig1.jpg

Then, You must convert this equation to conservative form:

fig2.jpg

But, OF works with integral equations, thus, you have to convert to integral balance:

fig3.jpg

If you will use mean theorem, without second order terms you can write:

fig4.jpg

By splitting terms at the r.h.s You will get:
fig5.jpg
mkraposhin is offline   Reply With Quote

Old   December 13, 2013, 11:28
Default
  #7
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Now, if lambda, rho and Cp are constant, You convert Your equation to:

fig6.jpg

You can find all equations here:
T-equation-from-cfd-online.pdf

Last equation can be discretized with OF:

Code:
volScalarField kappa = lambda / rho / Cp;
fvScalarMatrix TEqn
(
    fvm::ddt(T)
    +
    fvm::div(phi,T)
    -
    fvm::Sp(fvc::div(phi), T)
    ==
    fvm::laplacian(kappa, T)
    + (gamma / Cp) * dEpsilonOverDt
);
Please, remember, that we used second order approximations to get this equation, so You don't need schemes with order, higher then 2. You can use my first post in this thread to analyze resuling matrix TEqn (like pEqn)
smraniaki and daire6 like this.

Last edited by mkraposhin; December 15, 2013 at 06:10.
mkraposhin is offline   Reply With Quote

Old   December 15, 2013, 02:11
Default
  #8
Member
 
AJ
Join Date: Sep 2013
Posts: 30
Rep Power: 12
Aj Nair is on a distinguished road
Thanks a lot Matvej, i will come back to you, if i have any doubt
Aj Nair is offline   Reply With Quote

Old   December 15, 2013, 02:25
Default
  #9
Member
 
AJ
Join Date: Sep 2013
Posts: 30
Rep Power: 12
Aj Nair is on a distinguished road
Sorry for the delay in reply, thanks again Matvej
Aj Nair 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
inverse of a matrix or solution of implicit equation romant OpenFOAM Programming & Development 4 August 6, 2013 09:02
About theory:how to get the pressure equation when solving u-p simultaneously? lzw2003 Main CFD Forum 8 April 8, 2012 22:13
continuity equation Rafal Main CFD Forum 4 November 29, 2006 09:27
Poisson equation vs continuity equation DJ Main CFD Forum 1 August 5, 2004 20:01
Boundary conditions in a Poisson's equation? vincent Main CFD Forum 4 April 16, 1999 02:19


All times are GMT -4. The time now is 11:33.