sonicLiquidFoam can Run With Time-Dependent Pressure

sonicLiquidFoam is a compressible sonic laminar liquid flow code in OpenFOAM, which is an open-source CFD toolkit.

Early, sonicLiquidFoam could not be running with time-dependent pressure. When you set a boundary with timeVaryingUniformFixedValue in the case which could be computed with sonicLiquidFoam, the boundary style is like:

type timeVaryingUniformFixedValue;
timeDataFileName "inlet.dat";
value uniform 1e+5;

it would interrupt with these words which states the error:

--> FOAM FATAL IO ERROR : file "" does not exist

file: at line 1.

From function IFstream::operator()
in file db/IOstreams/Fstreams/IFstream.C at line 171.

FOAM exiting

However, If a boundary which is set as time-dependent velocity rather than time-dependent pressure, in other words, the pressure boundary condition is set as fixedValue, sonicLiquidFoam will run without any error.

I googled this problem, but there was not any effective method to make it run. I must do it myself. Finally, I find the cause, so it will run if a correction is made:

Please enter the folder $WM_PROJECT_DIR/applications/solvers/compressible/sonicLiquidFoam/, and edit the file createFields.H, then delete the line 41:

30    volScalarField rho
31    (
32        IOobject
33        (
34            "rho",
35            runTime.timeName(),
36            mesh,
37            IOobject::NO_READ,
38            IOobject::AUTO_WRITE
39        ),
40       rho0 + psi*(p-p0),
41       p.boundaryField().types()
42    );

and also delete the comma at the end of the previous line (line 40).

In addition, in file sonicLiquidFoam.C, I think rho0 + psi*p in line 105 should corrected as rho0 + psi*(p-p0) in order to compute the density rightly.
For consistency, rhoO + psi*p , which is on the line 105 of sonicLiquidFoam.C, should be used on line 40 of createFields.H, since rhoO = rho0 - psi*p0.

Then you should run wmake in this directory to update the application code, sonicLiquidFoam.

Ok, That's all. It can run with time-dependent pressure as a boundary condition.

Nishant Singh also reported another application code in OpenFOAM has the same problem after I reported this problem on the discussion board of OpenFOAM,, I also checked rhoSonicFoam. The field "rho" is just like this in the createFields.H of the rhoSonicFoam. So I made the same change, the rhoSonicFoam can also run.


p.boundaryField().types() run in the program means the variable "rho" use the same boundary types as pressure in the case. However, the density, "rho", is computed according to the pressure and the continuity equation on lthe boundary, so it cannot be used with the pressure boundary type.

But the fatal error is not caused by it, but by the system, because we cannot open the same file two times at the same time.

But, if we use the velocity boundary as time-dependent variable, it will run without errors, because the pressure boundary type is set as fixedValue.


   Send article as PDF   

One Reply to “sonicLiquidFoam can Run With Time-Dependent Pressure”

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.