# Artificial compressibility in open foam

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

 November 18, 2010, 16:00 Artificial compressibility in open foam #1 Senior Member   Join Date: Nov 2009 Location: Michigan Posts: 135 Rep Power: 16 Is there Artificial Compressibility solver in openfoam first introduced by Chorin?

 November 19, 2010, 01:27 #2 Senior Member   Nakul Join Date: Apr 2010 Location: India Posts: 147 Rep Power: 16 Hi The description of the available solvers can be found in User'd Guide and in the source code locate in "\$/applications/solvers/". You may find suitable solver four your specific problem. If you just elaborate exactly what you want to do then it would be easier to suggest some perticular solver.

 November 19, 2010, 08:06 #3 Senior Member   David Boger Join Date: Mar 2009 Location: Penn State Applied Research Laboratory Posts: 146 Rep Power: 17 Artificial compressibility is a method used in time-marching algorithms to solve for incompressible flows. All of the solvers in OpenFOAM so far have been pressure-based solvers, so artificial compressibility is not used. __________________ David A. Boger

 November 19, 2010, 14:08 #4 Member   M. Mahdi Salehi Join Date: Mar 2009 Location: Vancouver, BC, Canada Posts: 50 Rep Power: 17 It's not hard to implement the artificial compressibility method. I wrote one long time ago, just as a CFD fun ! It's not in a coupled way though ! The time loop looks like this: do { runTime++; counter++; Info<< "Time = " << runTime.timeName() << nl << endl; fvScalarMatrix pEqn ( fvm::ddt(p) + (1/beta)*fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); volScalarField p_old = p; pEqn.solve(); p_residual = max(mag(p_old - p)).value(); fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); volVectorField U_old = U; solve(UEqn == -fvc::grad(p)); u_residual = max(mag(U_old - U)).value(); Info << "Residual in U: " << u_residual << " Residual in P: " << p_residual << endl; max_residual = max(u_residual, p_residual); //solve(UEqn == -fvc::grad(p)); phi = linearInterpolate(U) & mesh.Sf(); }while (max_residual > epsilon); scleakey likes this.

 November 28, 2010, 02:35 #5 Senior Member   Join Date: Nov 2009 Location: Michigan Posts: 135 Rep Power: 16 Thank you all!

December 19, 2010, 23:19
to edit SIMPLE solver
#6
Member

nsreddy
Join Date: Sep 2010
Posts: 40
Rep Power: 15
Quote:
 Originally Posted by boger Artificial compressibility is a method used in time-marching algorithms to solve for incompressible flows. All of the solvers in OpenFOAM so far have been pressure-based solvers, so artificial compressibility is not used.
Dear David A. Boger,
Is it possible to write a code for the artificial compressibility method or manipulating the given solvers (like SIMPLE) in OpenFOAM.

With Regargs
N.S. Reddy,
DS college of Engg,
Bangalore

 December 20, 2010, 07:47 #7 Senior Member   David Boger Join Date: Mar 2009 Location: Penn State Applied Research Laboratory Posts: 146 Rep Power: 17 I'm sure it's possible, but it's not clear to me what you're trying to achieve. My interpretation of the artificial compressibility method is that it is a method to extend an efficient compressible solver to incompressible flows through pre-conditioning. If you simply want to solve for incompressible flow, you already have solvers here to choose from. If you simply want to add an artificial compressibility term to simpleFoam, you can read how to do that in one of the posts above, although I'm not sure what exactly it buys you. If you're determined to write an artificial compressibility code and want it to be block coupled, then I would look at the new block coupling methods that were released in the 1.6-extend version. __________________ David A. Boger

December 20, 2010, 23:52
Artificial Compressibility method
#8
Member

nsreddy
Join Date: Sep 2010
Posts: 40
Rep Power: 15
Quote:
 Originally Posted by boger I'm sure it's possible, but it's not clear to me what you're trying to achieve. My interpretation of the artificial compressibility method is that it is a method to extend an efficient compressible solver to incompressible flows through pre-conditioning. If you simply want to solve for incompressible flow, you already have solvers here to choose from. If you simply want to add an artificial compressibility term to simpleFoam, you can read how to do that in one of the posts above, although I'm not sure what exactly it buys you. If you're determined to write an artificial compressibility code and want it to be block coupled, then I would look at the new block coupling methods that were released in the 1.6-extend version.
Dear David A. Boger,
Thanks a lot for your kind information, actually I am trying to use compressible solvers ( like Roe Scheme and Riemann solver based schemes ) for solving incompressible flows. My Problem is how to write a code for the above problem in OpenFOAM. can u please send me a format of the code. My email id is "nsreddysrsit@gmail.com". Once again thanks.

With Regards
N.S. Reddy,
DS college of Engg,
Bangalore

 February 23, 2011, 00:21 #9 Member   nsreddy Join Date: Sep 2010 Posts: 40 Rep Power: 15 dear M. Mahdi Salehi, the above code is applicable for which solver for example, for icoFoam or SimpleFoam.

 February 23, 2011, 01:41 #10 Member   M. Mahdi Salehi Join Date: Mar 2009 Location: Vancouver, BC, Canada Posts: 50 Rep Power: 17 It's a stand-alone solver.

 February 23, 2011, 19:32 what is the difference between time preconditioning in openfoam and the artificial co #11 Member   nsreddy Join Date: Sep 2010 Posts: 40 Rep Power: 15 thank you Mr. M. Mahdi Salehi, I understood, my doubt is, is it possible to modify icoFoam, simpleFoam or rhoCentralFoam to Artificial Compressibility Method. and one More question what is the difference between time preconditioning in openfoam and the artificial compressibility method. Regards N.S.Reddy

 February 24, 2011, 13:29 #12 Member   M. Mahdi Salehi Join Date: Mar 2009 Location: Vancouver, BC, Canada Posts: 50 Rep Power: 17 Hi, Yes, you can modify them to get the artificial compressibility method. However, your new solver is just the artificial compressibility solver. I do not think you can easily make this to be an "all-speed" method so that you can run both the compressible and incompressible flows with the same solver. (I am not quit sure though) About your second question, basically both the artificial compressibility method and preconditioning methods remove the stiffness of the system of equations in low-Mach number regimes caused by the spread in wave speed. In the artificial compressibility method you tweak your governing equations to remove the stiffness. In the preconditioning method the stiffness is removed mathematically by multiplying the equations by a matrix. Cheers Mahdi

 February 24, 2011, 19:58 #13 Member   nsreddy Join Date: Sep 2010 Posts: 40 Rep Power: 15 Hi, thank you for your reply, You are exactly correct, one more issue if I want to implement convection schemes like Lax-Friedrich Method or Roe scheme, is there any suitable scheme to edit or I should write a new code.

 September 5, 2011, 20:50 Acm #14 Member   venkat Join Date: Mar 2011 Location: Bangalore,india Posts: 47 Rep Power: 15 hi, anybody working on artificial Compressibility method in openFoam, any comments on this method are welcome, if anybody working on this please provide the information about it. thanks in advance, Best Regards,

 September 5, 2011, 22:34 #15 New Member   G. D. McBain Join Date: Apr 2010 Posts: 3 Rep Power: 16 I've been thinking about writing an artificial compressibility solver for OpenFOAM, partly because I noticed that all the existing viscous incompressible solvers (that I'm aware of) ignore the viscous term in the boundary condition for the pressure Poisson equation at solid walls. Actually that boundary condition is not strictly the job of the solver, but in the case files, a zero Neumann condition is applied, and I'm not too sure how one would go about specifying the correct viscous condition there, since they involve the velocity's second derivative (Peyret & Taylor 1983, eqs. 6.2.29, 6.3.8a; Anderson, Tannehill, & Pletcher 1984, eq. 9-171, p. 514). The point is that with artificial compressibility or similar, e.g. the "conjugate gradient" algorithms introduced to finite element methods by Glowinski & Pironneau (1979), one doesn't formulate a Poisson equation for pressure and so doesn't need to formulate boundary conditions for it. It's often argued that the viscous term is negligible because it's of order of 1/Re; this is true: it's proportional to the viscosity, but if the Reynolds number is small, that's not a good argument. Anderson, D. A., J. C. Tannehill, & R. H. Pletcher (1984). Computational Fluid Mechanics and Heat Transfer. Series in Computational Methods in Mechanics and Thermal Sciences. Washington: Hemisphere Glowinski, R., & O. Pironneau (1979). On numerical methods for the Stokes problem. In R. Glowinksi, E. Y. Rodin, & O. C. Zienkiewicz (Eds.), Energy Methods in Finite Element Analysis, Numerical Methods in Engineering, pp. 243-264. Chichester:John Wiley & Sons Peyret, R., & T. D. Taylor (1983). Computational Methods for Fluid Flow. Springer Series in Computational Physics. New York: Springer

 September 6, 2011, 02:01 Acm #16 Member   venkat Join Date: Mar 2011 Location: Bangalore,india Posts: 47 Rep Power: 15 Dear G. D. McBain, thank you for the information given, I would like to create a new solver using Artificial Compressibility Method in openFoam, How to Start writing a code,any suggestions, comments are welcome. I wanted to use compressible solver Schemes for incompressible flows using Artificial Compressibility Method. Thanks in advance,

 September 6, 2011, 02:33 #17 New Member   G. D. McBain Join Date: Apr 2010 Posts: 3 Rep Power: 16 Dear venkataramana: Doesn't the code posted by smehdi609 work? It looks right. As to `how to start writing a code', I suggest reading http://openfoam.com/docs/user/compil...plications.php and then inspecting and tinkering with some of the simpler solvers provided, e.g. potentialFoam.C. For the background on the method, try Chorin's original paper, or the book by Peyet & Taylor that I cited before. The basic idea is to locally decrease the pressure wherever the velocity is divergent (this is what smehdi609's pEqn does), and to keep iterating on that until the velocity isn't divergent anywhere. The smehdi609 code tests for the pressures no longer changing rather than testing divergence directly, but given the directness of the pressure update in the artificial compressibility method, it amounts to much the same thing. Best of luck.

 September 6, 2011, 05:13 hi #18 Member   venkat Join Date: Mar 2011 Location: Bangalore,india Posts: 47 Rep Power: 15 Dear G. D. McBain, Thank you very much for your valuable suggestions, I will try it Regards,

 January 7, 2012, 13:02 #19 Member   nsreddy Join Date: Sep 2010 Posts: 40 Rep Power: 15 dear foamers, anybody can help me where the code is available for the the following method. http://openfoamwiki.net/index.php/TestLucaG Regards, Last edited by nsreddysrsit; January 7, 2012 at 20:01.

 April 2, 2012, 10:17 #20 New Member   Gilles De Neyer Join Date: Nov 2011 Posts: 18 Rep Power: 14 hello, I would like to improve the code of M. Mahdi Salehi for unsteady problems, which is possible by using a certain amount of pseudo-timesteps at each "real timestep" of the case. My problem is that I don't know how I could modelize a time derivative for these pseudo time-steps in OpenFoam. Any idea ?