CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

how to set up Hydrostatic pressure distribution in interFoam?

Register Blogs Community New Posts Updated Threads Search

Like Tree34Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 12, 2017, 09:01
Default
  #21
JFM
Member
 
JFM's Avatar
 
John Anonymous
Join Date: Jan 2011
Location: Melbourne Australia
Posts: 37
Rep Power: 15
JFM is on a distinguished road
Send a message via Skype™ to JFM
Hi there Max,

seems to me that you may have solved a problem around specifying outlet phase (water) levels that I have been wrestling with for months (and months). Is there any chance you could provide a copy of the modified .H & .C files (and any other modified files) plus some detail about the new BC that you have created and a generic copy respective controlDict files for implementation?

Any assistance / guidance on this would be greatly appreciated and would end months of turmoil.
(For information I am using OpenFOAM 4.1 and foam-extend-4.0)

All the best - JFM
JFM is offline   Reply With Quote

Old   May 15, 2017, 03:53
Default
  #22
New Member
 
maxonline's Avatar
 
Max
Join Date: May 2011
Location: Nuremberg
Posts: 17
Rep Power: 15
maxonline is on a distinguished road
Hey,
I named the bc "totalPressureFreeSurfaceP_rgh" since it is only useful for calculations with p_rgh as bc.

Save the unziped directory in your OpenFOAM directory ("user-OFversion"). Change directory to totalPressureFreeSurfaceP_rgh and run <wmake libso> command. There should be a totalPressureFreeSurfaceP_rgh.dep file now. In controlDict add "libiwwnBCs.so" at libs (...); and thats it.

In the header of the .H file you will find an example how to use the bc in your 0/p_rgh file.
I am not sure if it works with OF 4.1.

Max

totalPressureFreeSurfaceP_rgh.zip
maxonline is offline   Reply With Quote

Old   August 24, 2018, 03:28
Default use hRef
  #23
New Member
 
Kate Bradbrook
Join Date: Nov 2015
Posts: 12
Rep Power: 10
KateBradbrook is on a distinguished road
Hi. To set free surface elevation at outlet in interfoam, I simply create file hRef in Constant directory and set value to my free-surface elevation at outlet. BC for pgrh is then fixedValue of 0. All other variables zeroGradient at outlet. This avoids having to translate mesh.

hRef:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedScalarField;
location "constant";
object hRef;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
value 17.87;
// ************************************************** *********************** //
RicardoLB and hydronico like this.
KateBradbrook is offline   Reply With Quote

Old   January 31, 2020, 15:36
Default
  #24
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 6
Bodo1993 is on a distinguished road
Hi,

I am simulating 2D vertical channel flow (flow between two plates). Fluid 1 is initially filling the channel and Fluid 2 is injected to the domain from below.

I am getting some troubles at the outlet; the fluids exist just from some portion of the outlet (not the whole patch).

The boundary conditions I use at the outlet are:

U -> pressureInletOutletVelocity
P_rgh -> totalPressure with p0 = 0
phase -> inletOutlet

I would be grateful for any advice. Please let me know if further information is required.

Thanks.
Bodo1993 is offline   Reply With Quote

Old   January 19, 2024, 10:07
Default
  #25
New Member
 
Joana
Join Date: Jul 2021
Posts: 2
Rep Power: 0
joanaCFD is on a distinguished road
Hello!

I am modeling a rectangular open channel (from an experimental study) with OpenFOAM v11, which uses incompressibleVOF solver instead of interFoam. I started from the tutorial waterChannel and I changed the geometry and the b.c.

The ideia is to give the inflow discharge (0.219 m3/s) and fix the water level at the outlet. The horizontal smooth channel has 41 m long, 2 m wide, and 1 m high. The water level downstream is 0.3 m.

I tried to follow the ideas mentioned in this thread.

I created two patches: the lower one for water, and the upper one for air. For alpha.water I used the same b.c. in the inlet and the outlet: fixedValue 1 in the lower patch, and 0 in the upper patch. For p_rgh, I used fixedFluxPressure in the inlet and, fixedValue in the outlet - for the patch with air I defined 0, for the patch with water I defined 2943 = rho*g*h = 1000*9.81*0.3. The bottom of the channel corresponds to z=0m. For U, I used inletOutlet at both outlet patches.

Code:
alpha
    inletWater
    {
        type            fixedValue;
        value           uniform 1;
    }
 
    inletAir
    {
        type            fixedValue;
        value           uniform 0;
    }
    
    outletWater
    {
        type            fixedValue;
        value           uniform 1;
    }
    
    outletAir
    {
        type            fixedValue;
        value           uniform 0;
    }


p_rgh
    inletWater
    {
        type            fixedFluxPressure;
        value           uniform 0;
    }
    
    inletAir
    {
        type            fixedFluxPressure;
        value           uniform 0;
    }

    outletWater
    {
        type            fixedValue;
        value           uniform 2943;
    }
    
    outletAir
    {
        type            fixedValue;
        value           uniform 0;
    }

U
   inletWater
    {
        type            flowRateInletVelocity;
        volumetricFlowRate constant 0.219;
    }

    inletAir
    {
        type            fixedValue;
        value           uniform (0.0 0 0);
    }
    
    outletWater
    {
        type            inletOutlet;
        inletValue      uniform (0 0 0);
        value           uniform (0 0 0);
    }
    
    outletAir
    {
        type            inletOutlet;
        inletValue      uniform (0 0 0);
        value           uniform (0 0 0);
    }
In these conditions the run eventually stops. From what appears in the cmd I think the error is related to the VOF solver; alpha gets negative! (picture attached)

So, I also tried, unsuccessfully, to use zeroGradient in alpha.water and p_rgh in the patch for air in the outlet.

I also tried, again unsuccessfully, to set at the outlet p_rgh as a fixedValue of 0 in both patches, maintaining alpha.water 1 for water and 0 for air, and translating the mesh, such that z=0 coincided with the free surface.

The simulations eventually stop, with high values of Co nº and fluxes and alpha negative!

Does anyone see a problem with what I did? Or does anyone have used another way to fix the water level at the outlet?

I'm sorry for the long text!

Thank you very much in advance for any assistance.
Attached Images
File Type: jpg error2.jpg (110.9 KB, 3 views)
joanaCFD is offline   Reply With Quote

Old   May 6, 2024, 21:10
Default not working for me
  #26
New Member
 
Steven Pells
Join Date: Apr 2024
Posts: 5
Rep Power: 2
Pellet_time is on a distinguished road
Quote:
Originally Posted by matejmuller View Post
The utility setFields only prescribes the initial values of the variables. When you change the boundary type calculated to fixedValue, you fix those values on the outlet boundary that setFields automatically prescribed. Don't bother with the dynamic pressure, the whole idea of p_rgh is that you don't have to define it, the solver calculates it from the velocities.


1. set boundary type on the outlet boundary patch of p_rgh to calculated

outlet
{
type calculated;
}

2. use setFields to prescribe the INITIAL VALUES of p_rgh in the internal field and on the boundaries (set the box coordinates in the file setFields only for the area with water)

For example if you have a channel with horizontal dimensions 10x1 m and with the initial water level 0,5m :

boxToCell
{
box (0 0 0) (10 1 0.5);
fieldValues
(
volScalarFieldValue p_rgh 5000
);
}


3. run setFields
4. change the boundary type calculated on the outlet boundary to fixedValue (you will see, that the setFields utility has prescribed the p_rgh values 5000 on the outlet boundary on every cell face that lies inside your box from setFields).

outlet
{
type fixedValue;

value nonuniform List<scalar>

1500 //number of cell faces//
(
5000
5000
5000
.
.
.
);

5. Do the same for alpha1
6. start simulation


matej

its a while since this post, Im using v2312, using interFoam, I followed the above, but running setFields doesnt populate the 0/p_rgh file - it only gets populated when I run (or try to run) the simulation. And then the p_rgh file gets populated with cell values, but it doesnt honour the 'calculated' bc. Not sure if this is because OF has changed since then ?
Pellet_time is offline   Reply With Quote

Old   May 6, 2024, 23:28
Default
  #27
New Member
 
Steven Pells
Join Date: Apr 2024
Posts: 5
Rep Power: 2
Pellet_time is on a distinguished road
Quote:
Originally Posted by KateBradbrook View Post
Hi. To set free surface elevation at outlet in interfoam, I simply create file hRef in Constant directory and set value to my free-surface elevation at outlet. BC for pgrh is then fixedValue of 0. All other variables zeroGradient at outlet. This avoids having to translate mesh.

hRef:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedScalarField;
location "constant";
object hRef;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
value 17.87;
// ************************************************** *********************** //

this works for me, but how would you set a different hRef if you also wanted to define a constant water level at the inflow boundary?
Pellet_time is offline   Reply With Quote

Old   May 7, 2024, 00:39
Default
  #28
New Member
 
Steven Pells
Join Date: Apr 2024
Posts: 5
Rep Power: 2
Pellet_time is on a distinguished road
Quote:
Originally Posted by Pellet_time View Post
its a while since this post, Im using v2312, using interFoam, I followed the above, but running setFields doesnt populate the 0/p_rgh file - it only gets populated when I run (or try to run) the simulation. And then the p_rgh file gets populated with cell values, but it doesnt honour the 'calculated' bc. Not sure if this is because OF has changed since then ?

Ok so if I do:


outlet
{
type calculated;
value uniform 0;
}


then I can follow the method and fix the boundary after setFields. However, Im finding the solution pretty unstable.
Pellet_time is offline   Reply With Quote

Old   May 7, 2024, 02:43
Default
  #29
New Member
 
Steven Pells
Join Date: Apr 2024
Posts: 5
Rep Power: 2
Pellet_time is on a distinguished road
Quote:
Originally Posted by maxonline View Post
Hey,
I named the bc "totalPressureFreeSurfaceP_rgh" since it is only useful for calculations with p_rgh as bc.

Save the unziped directory in your OpenFOAM directory ("user-OFversion"). Change directory to totalPressureFreeSurfaceP_rgh and run <wmake libso> command. There should be a totalPressureFreeSurfaceP_rgh.dep file now. In controlDict add "libiwwnBCs.so" at libs (...); and thats it.

In the header of the .H file you will find an example how to use the bc in your 0/p_rgh file.
I am not sure if it works with OF 4.1.

Max

Attachment 56020

I know its been a long time, but this bc fails wmake because writeEntryIfDifferent doesnt seem to get recognised anymore. so this section doesnt work:


void Foam::totalPressureFreeSurfaceP_rghFvPatchScalarFi eld::write(Ostream& os) const
{
fvPatchScalarField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
zFS_.writeEntry("zFS", os);
p0_.writeEntry("p0", os);
}


is there a work around?


Im kinda new to OF, surprised its so difficult to write a successful constant head boundary!!
Pellet_time 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
Pressure Outlet Guage pressure Mohsin FLUENT 36 April 29, 2016 17:16
Bad pressure distribution in pump oringo FLUENT 2 March 2, 2013 10:38
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 02:15
hydrostatic and static pressure pi CFX 3 May 26, 2004 10:35
Definition of pressure Ola Nordblom FLUENT 1 August 16, 2001 15:58


All times are GMT -4. The time now is 09:48.