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

Runge-Kutta method for incompressible fluid

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2013, 23:15
Default Runge-Kutta method for incompressible fluid
  #1
New Member
 
reza
Join Date: Apr 2013
Posts: 16
Rep Power: 13
haghgoo_reza is on a distinguished road
Hello All

I'm trying to implement an explicit Runge-Kutta 4 method to an incompressible fluid inside a 2-D cavity. I have already modified icoFoam.C but it does not work.

could anybody advise me how to do it or refer me to a suitable tutorial?

my modified icoFoam gives out the following error:
[Make/linux64GccDPOpt/myicoFoam.o] Error 1


modified icoFoam.C


int main(int argc, char *argv[])
{
#include "setRootCase.H"

#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

volVectorField H("H", U);
H = -fvc::div(phi, U)+fvc::laplacian(nu, U);
surfaceScalarField phitilta
(
"phitilta",
(fvc::interpolate(H) & mesh.Sf())
);

adjustPhi(phitilta, U, p);


fvScalarMatrix pEqn
(
fvc::laplacian(p) == fvc::div(phitilta)
);

pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();



#include "continuityErrs.H"

volVectorField k1("k1", U);
k1 = runTime.deltaT()*[-fvc::div(phi, U)-fvc::grad(p)+fvc::laplacian(nu, U)];

volVectorField k2("k2", U);
k2 = runTime.deltaT()*[-fvc::div(phi, U+0.5*k1)-fvc::grad(p)+fvc::laplacian(nu, U+0.5*k1)];

volVectorField k3("k3", U);
k3 = runTime.deltaT()*[-fvc::div(phi, U+0.5*k2)-fvc::grad(p)+fvc::laplacian(nu, U+0.5*k2)];

volVectorField k4("k4", U);
k4 = runTime.deltaT()*[-fvc::div(phi, U+k3)-fvc::grad(p)+fvc::laplacian(nu, U+k3)];

U = U+(k1+2.0*k2+2.0*k3+k4)/6.0;
U.correctBoundaryConditions();

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}

Last edited by haghgoo_reza; May 26, 2013 at 01:29.
haghgoo_reza is offline   Reply With Quote

Old   May 30, 2013, 18:28
Default
  #2
Member
 
Thomas Boucheres
Join Date: May 2013
Posts: 41
Rep Power: 12
thomasArk47 is on a distinguished road
Hi,

many misunderstanding I think.

First, your equation on the laplacian(p) cannot work since you use fvc namespace which is the namespace for explicit discretisation. For building a matrix as in a implicit scheme, you need to use fvm namespace.

Second, and much more drastic, your algorithm for solving NS cannot work.
Recall that incompressible NS system is constraint by div(u)=0 and this constraint is reflected at numerical level by the fact that one cannot use just a "consistant" algorithm to solve equation. Well defined predictor/corrector is the simplest scheme that can work. Roughly speaking, 3 phases:
a- solve equation on U (with/without p)
b- solve laplacian on p
c- correct U
The order and the phase 3 is fundamental. Note also that since you are working with collocated shceme (velocity and pressure are defined both at the cell centers), you need a well defined stabilisation on the velocity flux field (so-called Rhie-Chow stabilisation).

I think you should review your algorithm before of all.

Good luck.
thomasArk47 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
Main advantage of using Runge Kutta of higher order? jakubstary Main CFD Forum 14 August 20, 2019 16:15
Runge Kutta 4th Order Source Code sugu Main CFD Forum 4 October 26, 2012 03:15
1D Burgers euqation with 4th Runge Kutta dokeun Main CFD Forum 3 August 8, 2011 06:34
Level Set Method and Ghost Fluid Method alvin11 Main CFD Forum 0 October 24, 2010 09:46
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


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