CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Fourth Order Runge Kutta time integration (http://www.cfd-online.com/Forums/openfoam-solving/60452-fourth-order-runge-kutta-time-integration.html)

lr103476 October 26, 2005 10:07

Hello, Has someone implemen
 
Hello,

Has someone implemented 4th order Runge Kutta time integration. I think this method will be more efficient than the 2nd order CrankNickolson.

Maybe someone tried it and could give me some hints in order to develop it myself.

Regards, Frank

misakagan December 16, 2009 09:19

I'm also wondering if someone has runge-kutta implementation for incompressible turbulent flows (LES or DNS). Apparently the only application dealing such flows is Pisofoam and it uses implicit time stepping, which is very slow.

theory37 June 14, 2010 13:07

I too am wondering about this. I am attempting to implement a 3rd order (low storage) RK scheme for an RSTM I am working on. Any ideas?

ville September 19, 2010 17:56

Runge-Kutta 4 to top-level OpenFOAM
 
Hi! I am currently working on compressible flows and writing a RK4 method to OpenFOAM. I am currently learning many things about top-level programming
(mostly from the codes written by other people) but would like to share a simple example of one way to program
RK4 in the top-level code. The following code (that can be put inside the main for-loop of any existing solver to test it) solves the simple advection equation for a variable rho (that can represent of course anything).
Here, we btw can assume for the moment being that
U is a constant field i.e. the velocity.

rhoOld = rho;
phiv = fvc::interpolate(U)& mesh.Sf();
k1 = -runTime.deltaT()*fvc::div(phiv, rhoOld);
k2 = -runTime.deltaT()*fvc::div(phiv, rhoOld + 0.5*k1);
k3 = -runTime.deltaT()*fvc::div(phiv, rhoOld + 0.5*k2);
k4 = -runTime.deltaT()*fvc::div(phiv, rhoOld + k3);

rho = rhoOld + a1*k1 + a2*k2 + a3*k3 + a4*k4;

// ai are the RK4 coefficients

Of the following I would like to hear some further comments about and hopefully the more experienced people could further comment on
these issues (or point out a proper link to a discussion).

When programming explicit code as above the correctBoundaryConditions() function should be used after each update because otherwise there might be
inconsistencies in BC's and also in the processor
BC's. I guess the reason for this is that field operations
such as the ones above have no influence on what
is happening on the boundary; right ?
One can also explicitly update the BC's for a certain
quantity (say e.g. rhoE that is often solved for in
compressible computations) by typing

rhoE.boundaryField() =
rho.boundaryField()*
(
e.boundaryField() + 0.5*magSqr(U.boundaryField())
);

Of course, it remains as user's responsibility
that everything stays consistent when doing
top-level OF solvers.

Regarding the previous question about an incompressible RK4 solver I do not see any problem
of why the above-presented approach for advection
equation would not work also for the
incompressible NS-equations .

Best regards,
Ville

alberto September 20, 2010 03:47

Quote:

Originally Posted by ville (Post 275756)
When programming explicit code as above the correctBoundaryConditions() function should be used after each update because otherwise there might be
inconsistencies in BC's and also in the processor
BC's. I guess the reason for this is that field operations
such as the ones above have no influence on what
is happening on the boundary; right ?

Yes and no :D
Yes, you have to do something to update the boundaries, if you need that. No, what you have to do is not necessarily an explicit call to correctBoundaryConditions().

If you update the value of a field, and you also want to update the corresponding boundaryField, all you have to do is to replace

=

with

==

in the assignment. For example:

k1 == ...;

This should work in OF 1.6 and following. I am not sure about the previous versions, since I noticed this syntax for the first time in 1.6.

Of course, if you do not have an assignment, but a sum with +=, like in the velocity corrector step, you have to call correctBoundaryConditions().

Best,

juho September 20, 2010 05:54

Quote:

Originally Posted by alberto (Post 275776)
Yes and no :D
This should work in OF 1.6 and following. I am not sure about the previous versions, since I noticed this syntax for the first time in 1.6.

I've used it in 1.4.1, so I would assume it also works in all the following versions.

alberto September 20, 2010 11:26

OK. Thanks for the info :)

ville September 20, 2010 11:46

Hi and thanks for the comments!
As said, I am currently considering how to nicely implement the boundary conditions for a fully explicit, density based RK4 solver (say the hardest case of subsonic inflow, outflow for the time being).
Currently, in the prototype version, I define the BC's for p, T and U as they are rather convenient to give. The variables that are solved for are rho, rhoU and rhoE. Now, the BC's for rho, rhoU and rhoE would be needed. In e.g. subsonic inflow the BC for rho would need to be determined by the solution. Thus, p and
T may be used for determining the boundary value of rho.
After this the boundary fields of rhoU and rhoE may be constructed. Any ideas of how to conveniently do this?
How would the more experienced OF-people consider simply
updating the boundary field in the top-level code as is done in
e.g. rhoCentralFoam? Another option would be
defining a new BC type for rho, rhoU and rhoE that is constructed from p, T and U.
Best,
Ville

ville October 31, 2012 13:00

Runge-Kutta 4 density based LES solver implemented
 
Hi,
to get a closure: I have now implemented into OpenFOAM a RK4 based
fully explicit compressible solver. Works as smoothly as it only can :)
I've also written RK4 solvers for incompressible flows based on the projection method
which allows us to get rid of the PISO solvers if so desired.
Work based on the incompressible solver was published recently in Computers & Fluids
and can be found currently in the "Articles in Press" section of the journal.

Vuorinen V., Schlatter P., Boersma B., Larmi M., and Fuchs L., A Scale-Selective, Low-
Dissipative Discretization Scheme for the Navier-Stokes Equation, (to appear in Computers and Fluids)

Best,
Ville

ville February 27, 2014 03:29

Publication: Runge-Kutta 4 method for compressible and incompressible flows
 
Hi,
probably the first published paper on the topic including practical instructions
on how to implement, theory, numerical validation
On the implementation of low-dissipative Runge–Kutta projection methods for time dependent flows using OpenFOAM

Vuorinen et al.
http://www.sciencedirect.com/science...45793014000334

Best,
Ville

ville November 11, 2014 09:27

Fluid dynamical part of the code shown herein
 
Large-eddy simulation in a complex hill terrain enabled by a compact fractional step OpenFOAM® solver


http://www.sciencedirect.com/science...65997814001513

Best wishes,
Ville


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