CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   how to change code in channelFoam for RAS (

conceptone December 12, 2012 14:47

how to change code in channelFoam for RAS
Hi everyone, I wanna use channelFoam with RAS model. However, the solver seems to be designed specially for LES, which leads to incredible large Courant number and pressure, pressure gradient and velocity as below then OpenFoam crashes, so I hope someone can tell me how to change the code in solver for RAS, thanks!

Time = 0.18


Courant Number mean: 3.02935e+63 max: 4.12859e+67
DILUPBiCG: Solving for epsilon, Initial residual = 1, Final residual = 19.3092, No Iterations 1001
bounding epsilon, min: -2.73732e+98 max: 8.22502e+99 average: 1.61408e+95
DILUPBiCG: Solving for k, Initial residual = 1, Final residual = 758720, No Iterations 1001
bounding k, min: -3.0437e+89 max: 3.58778e+97 average: 5.9839e+92
#0 Foam::error::printStack(Foam::Ostream&) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#1 Foam::sigFpe::sigHandler(int) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#2 __restore_rt at sigaction.c:0
#3 Foam::DILUPreconditioner::calcReciprocalD(Foam::Fi eld<double>&, Foam::lduMatrix const&) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#4 Foam::DILUPreconditioner::DILUPreconditioner(Foam: :lduMatrix::solver const&, Foam::dictionary const&) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#5 Foam::lduMatrix::preconditioner::addasymMatrixCons tructorToTable<Foam::DILUPreconditioner>::New(Foam ::lduMatrix::solver const&, Foam::dictionary const&) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#6 Foam::lduMatrix::preconditioner::New(Foam::lduMatr ix::solver const&, Foam::dictionary const&) in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#7 Foam::PBiCG::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const in "/usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/platforms/linux64Gcc44DPOpt/lib/"
#8 Foam::fvMatrix<Foam::Vector<double> >::solve(Foam::dictionary const&) in "/usr/erc/people/liao23/OpenFOAM/liao23-2.1.1/platforms/linux64Gcc44DPOpt/bin/mychannelFoam_RAS"
#9 Foam::fvMatrix<Foam::Vector<double> >::solve() in "/usr/erc/people/liao23/OpenFOAM/liao23-2.1.1/platforms/linux64Gcc44DPOpt/bin/mychannelFoam_RAS"
#10 main in "/usr/erc/people/liao23/OpenFOAM/liao23-2.1.1/platforms/linux64Gcc44DPOpt/bin/mychannelFoam_RAS"
#11 __libc_start_main in "/lib64/"
#12 Foam::UOPstream::write(char) in "/usr/erc/people/liao23/OpenFOAM/liao23-2.1.1/platforms/linux64Gcc44DPOpt/bin/mychannelFoam_RAS"

Lieven December 12, 2012 15:49

Hi conceptone,

channelFoam is in the end an extension of pisoFoam. So just have a look at how the turbulence is implemented in pisoFoam and modify it accordingly in the channelFoam solver.

In summary, you need to modify createFields.H, the include statements in channelFoam.C, and of course the momentum equation. To compile it afterwards, have a look at the Make/option file of pisoFoam as well...



conceptone December 12, 2012 16:41

Thanks Lieven, I guess what you mentioned is the declaration of that pointer in createFields.H, which I have done below and in solver. If I didn't do this modification, the solver even can't be compiled well. However, my issue is that channelFoam returns the very large Courant No. and pressure and velocities, which exceeds the extent of C++ calculation capability so openfoam crashed after runs some time...I don't know whether there are bugs here or other codes need to be changed..

Modified Coding:
autoPtr<incompressible::turbulenceModel> sgsModel
incompressible::turbulenceModel::New(U, phi, laminarTransport)

#include "RASModel.H"
#include "turbulenceModel.H"
(I've already deleted #include "LESModel.H" in solver.C)

fvVectorMatrix UEqn
+ fvm::div(phi, U)
+ sgsModel->divDevReff(U)


Lieven December 13, 2012 06:09

That's indeed how you needed to change it.

The problem with the courant number is not related to the solver but to your time step. You can try two things to solve it:
1. Use a small, constant time step such that the max courant number < 1 at all times
2. Enable variable time stepping based on courant number control as explained in . This way you can use the maximal "allowable" time step.
Both approaches work with RANS and LES



conceptone December 13, 2012 16:25

Hi Lieven, yep, the problem is done, it turns out the time step leads to this. I tried small time step before, but not small enough. This time I try really small one, which works. This may turn out LES's advantage in time step compared with RAS.
Thanks so much!

All times are GMT -4. The time now is 04:08.