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

Pressure Function Object Crashes When Set To Output Static Pressure

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

Like Tree11Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 3, 2021, 17:10
Default Pressure Function Object Crashes When Set To Output Static Pressure
  #1
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 5
Ship Designer is on a distinguished road
I'm attempting to obtain a pressure result field with the hydrostatic pressure for a two-phase case. I'm using OpenFOAM v8. According to the documentation, for that both calcTotal and calcCoeff have to be set to no. When I start interFoam, it crashes right after the time loop starts and I get the following error message:

Code:
--> FOAM FATAL ERROR: 
Attempt to acquire non-const reference to const object from a tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE>

    From function T& Foam::tmp<T>::ref() const [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/tmpI.H at line 187.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >::ref() const in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
#3  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, bool) at ??:?
#4  Foam::functionObjects::pressure::calc() at ??:?
#5  Foam::functionObjects::fieldExpression::execute() at ??:?
#6  Foam::functionObjects::timeControl::execute() at ??:?
#7  Foam::functionObjectList::start() at ??:?
#8  Foam::Time::run() const at ??:?
#9  Foam::pimpleControl::run(Foam::Time&) at ??:?
#10  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
#11  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#12  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
Aborted
This is the code I'm using in controlDict for the Function Object:

Code:
HydrostaticPressure {
  // Mandatory entries (unmodifiable)
          type  pressure;
          libs  ("libfieldFunctionObjects.so");

  // Mandatory entries (runtime modifiable)
     calcTotal  no;
     calcCoeff  no;
           log  on;
          pInf  0;
          pRef  0;
          UInf  (-4.992 0 0);
        rhoInf  1025;  // Water phase
  writeControl  outputTime;

  // Optional entries (runtime modifiable)
         field  p;
             U  U;
           rho  rho;        
             g  (0 0 -9.81);
          hRef  0;
        result  p_hs;
}
If I set calcCoeff to yes, it doesn't crash. Am I missing something here? I've tried commenting out some of the optional entries and tried with both p and p_rgh fields. I've checked the source files pressure.H and pressure.C and couldn't find any dictionary entries I missed. I tried both in single core and parallel mode, as well as starting at time = 0 and later on during the simulation. I've also checked the forum here for similar threads but couldn't find any reports of crashes related to static pressure output.

See combinations with these settings:
Code:
Mode                        calcTotal  calcCoeff  Crashing
Static pressure             no         no         yes
Total pressure              yes        no         no
Pressure coefficient        no         yes        no
Total pressure coefficient  yes        yes        no
Any hints are greatly appreciated, thanks!

Cheers, Claudio
Ship Designer is offline   Reply With Quote

Old   June 24, 2021, 11:49
Default
  #2
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
I am having the same issue with v8 and a case solved with interFoam.
When I try to postprocess the static pressure I get:

Code:
$ postProcess -func "hydrostaticPressure(p)"
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 8-1c9b5879390b
Exec   : postProcess -func hydrostaticPressure(p)
Date   : Jun 24 2021
Time   : 17:47:20
Host   : "katara"
PID    : 24752
I/O    : uncollated
Case   : XXX
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0

Reading fields:


Executing functionObjects
--> FOAM Warning :     functionObjects::pressure hydrostaticPressure(p) cannot find required object p of type volScalarField
--> FOAM Warning :     functionObjects::pressure hydrostaticPressure(p) failed to execute.

Time = 0.5

Reading fields:
    volScalarFields: p


Executing functionObjects


--> FOAM FATAL ERROR: 
Attempt to acquire non-const reference to const object from a tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE>

    From function T& Foam::tmp<T>::ref() const [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/tmpI.H at line 187.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >::ref() const at ??:?
#3  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, bool) at ??:?
#4  Foam::functionObjects::pressure::calc() at ??:?
#5  Foam::functionObjects::fieldExpression::execute() at ??:?
#6  Foam::functionObjectList::execute() at ??:?
#7  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
#8  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
Aborted (core dumped)
The failure at time 0 is expected because there is no pressure field (only p_rgh) at that time. However that failure is non-fatal. Can be avoided with

Code:
postProcess -time 0.5: -func "hydrostaticPressure(p)
But I get the same fatal error.

The contents of the function file system/hydrostaticPressure is

Code:
$ cat system/hydrostaticPressure 
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
-------------------------------------------------------------------------------
Description
    Writes out values of the hydrostatic pressure field.

\*---------------------------------------------------------------------------*/

type  pressure;
libs  ("libfieldFunctionObjects.so");
calcTotal  no;
calcCoeff  no;

Any help is highly appreciated

Regards,
kakila is offline   Reply With Quote

Old   June 24, 2021, 12:21
Default
  #3
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 11
HPE is on a distinguished road
Hi,

Any chance for you to reproduce the matter by a standard tutorial, so that we can try to reproduce the issue?
HPE is offline   Reply With Quote

Old   June 24, 2021, 14:22
Default
  #4
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
The error is reproduced using the damBreak tutorial


Code:
$ cd ~/OpenFOAM/juanpi-8/run
$ cp -r ${FOAM_TUTORIALS}/multiphase/interFoam/laminar/damBreak .
$ cd damBreak
$ ./Allrun
$ cd damBreak
$ postProcess -func "staticPressure(p)"
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 8-1c9b5879390b
Exec   : postProcess -func staticPressure(p)
Date   : Jun 24 2021
Time   : 19:20:16
Host   : "katara"
PID    : 28589
I/O    : uncollated
Case   : /home/juanpi/OpenFOAM/juanpi-8/run/damBreak/damBreak
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0

Reading fields:


Executing functionObjects
--> FOAM Warning :     functionObjects::pressure staticPressure(p) cannot find required object p of type volScalarField
--> FOAM Warning :     functionObjects::pressure staticPressure(p) failed to execute.

Time = 0.05

Reading fields:
    volScalarFields: p


Executing functionObjects


--> FOAM FATAL ERROR:
Attempt to acquire non-const reference to const object from a tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE>

    From function T& Foam::tmp<T>::ref() const [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/tmpI.H at line 187.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >::ref() const at ??:?
#3  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, bool) at ??:?
#4  Foam::functionObjects::pressure::calc() at ??:?
#5  Foam::functionObjects::fieldExpression::execute() at ??:?
#6  Foam::functionObjects::timeControl::execute() at ??:?
#7  Foam::functionObjectList::execute() at ??:?
#8  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
#9  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
#10  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#11  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/postProcess"
Aborted (core dumped)
kakila is offline   Reply With Quote

Old   June 24, 2021, 17:42
Default
  #5
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Sometimes you need to run postProcess from within the solver, eg if the data you are dealing with is created within the solver and is not just one of the standard fields. Maybe try running:

Code:
interFoam -postProcess -time 0.5 -func "hydrostaticPressure(p)"
Tobermory is offline   Reply With Quote

Old   June 25, 2021, 07:19
Default
  #6
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Hi,


My answers are not being posted. It says a moderator needs to look at them.
I have posted the reproduction of the error in the damBreak tutorial



@Tobermory: it makes no difference, I get the same error
kakila is offline   Reply With Quote

Old   June 25, 2021, 07:23
Default
  #7
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Code:
$ interFoam -postProcess -time 0.5 -func "staticPressure(p)"
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 8-1c9b5879390b
Exec   : interFoam -postProcess -time 0.5 -func staticPressure(p)
Date   : Jun 25 2021
Time   : 13:22:57
Host   : "katara"
PID    : 28654
I/O    : uncollated
Case   : /home/juanpi/OpenFOAM/juanpi-8/run/damBreak/damBreak
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0.5


PIMPLE: No convergence criteria found


PIMPLE: Operating solver in transient mode with 1 outer corrector
PIMPLE: Operating solver in PISO mode


Time = 0.5
Reading field p_rgh

Reading field U

Reading/calculating face flux field phi

Reading transportProperties

Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
Selecting turbulence model type laminar
Selecting laminar stress model Stokes

Reading g

Reading hRef
Calculating field g.h

No MRF models present

No finite volume options present


--> FOAM FATAL ERROR: 
Attempt to acquire non-const reference to const object from a tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE>

    From function T& Foam::tmp<T>::ref() const [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/tmpI.H at line 187.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >::ref() const in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
#3  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, bool) at ??:?
#4  Foam::functionObjects::pressure::calc() at ??:?
#5  Foam::functionObjects::fieldExpression::execute() at ??:?
#6  Foam::functionObjects::timeControl::execute() at ??:?
#7  Foam::functionObjectList::execute() at ??:?
#8  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/interFoam"
Aborted (core dumped)
kakila is offline   Reply With Quote

Old   June 25, 2021, 09:49
Default
  #8
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Help me out here - you want the static pressure from your interFoam run, right? What's wrong with the static pressure in the time folder, ie p? Why do you want to calculate it? What am I missing?
Tobermory is offline   Reply With Quote

Old   June 25, 2021, 14:32
Default
  #9
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
As far as I had understood p in the time folders is total pressure. Isn't it the case?
Anyways why is this postprocessing failing. It shouldn't.
kakila is offline   Reply With Quote

Old   June 25, 2021, 17:00
Default
  #10
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Aah, okay. No, p is the static pressure (although sometimes it is kinematic, i.e. p/rho). If you want convincing, take a look at the pEqn.H in any of the solvers and you'll see that that must be the case.

What's the point of the function? Well, the incompressible solvers solve for the kinematic pressure, and so this is a way I guess of converting that to a true static pressure. Otherwise, I agree it's probably not very useful.
kakila likes this.
Tobermory is offline   Reply With Quote

Old   June 28, 2021, 10:18
Default
  #11
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 5
Ship Designer is on a distinguished road
Hello all,

@Tobermory, I disagree with your statement about p in interFoam. @kakila is right, in interFoam, p is the total pressure according to the source code in
applications/solvers/multiphase/interFoam/pEqn.H, line 72:
Code:
 p == p_rgh + rho*gh;  // rho*gh is the hydrostatic component
In addition, this is repeated in

applications/solvers/multiphase/interFoam/createFields.H, lines 86-97:
Code:
volScalarField p
(
    IOobject
    (
        "p",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    p_rgh + rho*gh
);
p is only an output field and not required for the computation, but that's the situation for interFoam. With other solvers, the p field can have a different meaning.

I've attached a modified controlDict below for the DTC Hull Tutorial (tutorials/multiphase/interFoam/RAS/DTCHull). I've added two Function Objects, one for hydrostatic pressure and one for pressure coefficient. The latter works fine, the former doesn't. Comment out as required to test. Just replace the controlDict with this one, generate the grid and then let it run.

P.S.: I'm not familiar with the damBreak case and wouldn't know what the pressure coefficients would have to look like there…
Attached Files
File Type: txt controlDict.txt (2.2 KB, 5 views)

Last edited by Ship Designer; June 28, 2021 at 10:21. Reason: Typos
Ship Designer is offline   Reply With Quote

Old   June 28, 2021, 10:44
Default
  #12
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Dear Claudio ... I don't want to be confrontational, but I am afraid that you are mistaken.

The coding in pEqn.H, that I pointed kakila to, is the pressure-correction coding that is widely used across "incompressible" type solvers, and the "p" in that coding is static pressure. It would make absolutely no sense to use total pressure.

As for the line that you are referring to:
Code:
 p == p_rgh + rho*gh;  // rho*gh is the hydrostatic component
what you need to realise is that:
1. Quantity p_rgh is defined as the static pressure (p) minus rho*gh (take a look at line 118 in createFields.H for interFoam or check out https://www.openfoam.com/documentati...orm-p-rgh.html)
2. Therefore: p_rgh + rho*gh = (p - rho*gh) + rho*gh = p! In other words, the code you are quoting is not calculating a "total pressure", but is just recovering the static pressure!

Finally, when you refer to "total pressure", I think you probably mean piezometric pressure since total pressure includes the dynamic pressure as well as the static and gravitational head. For constant density flows p_rgh is piezometric pressure, but just be careful since this is not the case for varying density flows since piezometric pressure is usually defined with a constant density.
Tobermory is offline   Reply With Quote

Old   June 28, 2021, 20:04
Default
  #13
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 5
Ship Designer is on a distinguished road
Hi Tobermory, the code portion you are referring to in createFields.H on line 118 is a correction applied to p_rgh after it was solved if a pressure reference is necessary in the case (pRefCell and pRefValue in fvSolution PIMPLE dictionary), e.g. if all p_rgh boundary conditions would be set to zeroGradient. The very same code is present in pEqn.H as well on lines 74-83, almost at the end of the PIMPLE corrector.

I seriously doubt that p is the static pressure, at least with interFoam. If it were, your statement

Quote:
Quantity p_rgh is defined as the static pressure (p) minus rho*gh
to me makes no sense because rho*gh is the (hydro)static pressure and p_rgh would be equal to 0. I'm not familiar with the term piezometric pressure. What I mean by total pressure is the sum of hydrostatic pressure and dynamic pressure (p_rgh). How could adding something to the static pressure, yield the static pressure? Do you agree that p_rgh is the dynamic pressure (which was called p_d I believe in the earliest versions of interFoam)?

I have attached screenshots from a case I'm currently working on. It's a profile view from a ship hull with the field p and it's contours. I left the same contours in place for reference in the other pictures. In the one with p_rgh it is clear that p is highly distorted where p_rgh is large, which should not have this effect if p were static pressure. The last picture shows the two phases and the wave profile more clearly.

To get back to the question at hand, regardless of what p is, why would a Function Object crash a solver despite valid input in accordance with the documentation?

Cheers, Claudio
Attached Images
File Type: jpg p Profile with Contours.jpg (68.6 KB, 8 views)
File Type: jpg p_rgh Profile with p Contours.jpg (76.1 KB, 8 views)
File Type: jpg alpha Profile with p Contours.jpg (58.5 KB, 4 views)
kakila likes this.
Ship Designer is offline   Reply With Quote

Old   June 29, 2021, 04:35
Default
  #14
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Dear Claudio

Can I ask - did you look at this link: https://www.openfoam.com/documentati...rm-p-rgh.html? The quantity p_rgh is used across a wide variety of solvers in OpenFOAM ... it's not just an interFoam thing. The definition is:
Code:
p_rgh = p - rho*gh
where g is a vector (i.e. (0,0,-9.81) if z is the vertical axis). This is universal. The benefit of quantity p_rgh - especially in a constant density problem e.g. water flow past a ship hull, is that this strips out the hydrostatic variation in pressure with height.

I wonder whether your confusion is over terminology? Let's explore this, looking at your pictures that you included, and ignoring the distortion around the hull for the moment - just look at the far field - you can clearly see a strong vertical variation in p. This is as expected in the static pressure, since this static pressure gradient is required to counter the weight of the water. In static conditions, the only terms that remain in the momentum equation are the vertical pressure gradient and the gravity term, viz
0 = -\frac{\partial p}{\partial z} + \rho gz
where p here is the "static pressure" and g=-9.81. So far, so good hopefully.

This variation in height of p is a nuisance, however, when trying to fix a vertical boundary condition, or when trying to review pressure results. So the quantity p_rgh is defined as the static pressure minus rho*gh, ie p_rgh = p - rho*g*z. In a constant density field, like the example above, you can see that this strips out the vertical variation in pressure - take the derivative and you get:
\frac{\partial p_{rgh}}{\partial z} =  \frac{\partial p}{\partial z} - \rho g = 0 here
where rho is assumed constant here. And indeed p_rgh is also zero in this case, which is an easy BC to apply! And that's what we see in your second plot. In fact, p_rgh uses a datum (hRef), and so the farfield value of p_rgh may not be zero, but could be some other constant value depending on your choice of hRef. The idea is the same though.

In your earlier post, you referred to p_rgh as a "dynamic pressure". I think most Fluid Mechanics practitioners would be confused by this label, since that term is almost universally used for the measure of the kinetic energy in the flow, 1/2 rho U^2 (eg https://en.wikipedia.org/wiki/Dynami...nation%20point). In an earlier post, I used the term piezometric pressure - that's something that is used by some of the Commercial CFD solvers, eg starccm+, and is defined as p_piez = p + rho_0 * g * z - i.e. similar to p_rgh but with a constant, reference density rather than the local, variable density. In a case like your water flow, p_rgh and piezometric pressure are the same thing.

Finally - why does the functionObject crash when it is run? Well, I suspect that it's because it is being used incorrectly. The documentation says that when it is called for static pressure, it should convert a kinematic static pressure to ordinary static pressure, i.e. multiplies by density. In your case, your pressure variable p is not kinematic (check the units in the p or p_rgh boundary file), and so it makes no sense to run the functionObject on the pressure field. You could try raise a bug report, since it would be better if the code came back with a message "no - I can't do that" rather than just crashing, but I think the simpler answer is just don't run it! It's not necessary. You already have the static pressure, p (or p_rgh if you want to remove the hydrostatic variation) so you do not need to convert from a kinematic pressure.

I hope that the above is helpful. I think that we have probably exhausted the subject! All the best.
Ship Designer likes this.
Tobermory is offline   Reply With Quote

Old   June 29, 2021, 09:26
Default
  #15
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 5
Ship Designer is on a distinguished road
Hello all,

Tonight I looked at the source code again and I agree that this function object is not suitable for what we are trying to do. More on this later.

@kakila, you can try this and see if this is what you need:

1. Add this Function Object to output the fields rho and gh, which are created internally by interFoam:
Code:
rgh  {
          type  writeObjects;
          libs  ("libutilityFunctionObjects.so");
       objects  (rho gh);
   writeOption  anyWrite;
  writeControl  outputTime;
}
2. In ParaView, add a Calculator filter with the following formula:
Code:
rho*gh
See attached pictures for the output, where I've included the p field for comparison. Is this what you are trying to obtain?


I'll post some more on this later, got to be productive now. Cheers
Attached Images
File Type: jpg rgh Profile with Contours 2700.jpg (65.2 KB, 8 views)
File Type: jpg p Profile with Contours 2700.jpg (67.6 KB, 8 views)
Ship Designer is offline   Reply With Quote

Old   June 29, 2021, 16:20
Default
  #16
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Hi people,


Thank you for the time to answer and all the insights. I made a small test: a Venturi meter.

The image venturi_meter_p_gauge shows the values of the two pressures under discussion (p and p_rgh) along the black line shown in the image, starting on the left. The values are gauge (reference pressure 101325 Pa), and in mbar (to ease comparison with the ruler in the image)



I do not see any difference between the two pressures, besides the lower quality of the p data. The pressure difference from one side to the other coincides with the vertical difference in water level (about 0.3 cm, i.e. ~0.3 mbar). It seems as both p and p_rgh are the static pressure = Pref + rho * g * h



After the discussion I was expecting p_rgh to be lower than p. Why it isn't the case?

I was expecting:

p = pref + rho * g * h [what's oberseved]

p_rgh = p - rho * g * h =(?) pref [not waht's observed]



Also, as mentioned, p is not kinematic
Attached Images
File Type: jpg venturi_meter_p_gauge.jpg (47.8 KB, 9 views)
Ship Designer likes this.
kakila is offline   Reply With Quote

Old   June 29, 2021, 16:51
Default
  #17
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 456
Rep Power: 11
Tobermory will become famous soon enough
Hey - I like the test case - what a great idea!

Where is the origin in your model? If the origin (z=0) is on the black line, then it makes total sense that p and p_rgh are identical along the line, since the reference height hRef defaults to zero and (h - hRef) is therefore zero. If you want to force a difference between p and p_rgh then set the value for hRef by dropping the following dictionary (file) into the constant folder:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       uniformDimensionedScalarField;
    location    "constant";
    object      hRef;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 0 0 0 0 0];
value           -10.0;

// ************************************************************************* //
Otherwise, you should see differences between the two fields from contour plots - the magnitude of the differences will be small, since your model is small (the venturi is around 10cm tall I think ... make it 10m tall and the differences will be magnified ... or make gravity 100 times larger and you'll get the same effect), but you should find that p_rgh is constant (constant rho) while p reduces with height.
Ship Designer and kakila like this.
Tobermory is offline   Reply With Quote

Old   June 29, 2021, 17:30
Default
  #18
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Thanks for the clarification. So the actual formulas are then


p = pref + rho * g * (water_elevation - z)


where the parenthesis is the difference between the current z coordinate and the water elevation. While


p_rgh = p - rho * g * (water_elevation + hRef) = pref - rho * g * (z + hRef)



I believe the source of all confusion is the difficulty to find a careful mathematical definition of the two fields in the documentation (it might be hidden somewhere! By careful I mean not with inconsistent notation as in the links to the docs given).


As you correctly guessed, in my model the black line is on z = 0, so the formulas coincide.


I moved the line 0.2 cm up and, as you explained, the difference became obvious (p is lower by ~ 0.2 mbar). Image attached.



I also tested the with the file hRef in the constant and also works (I used hRef value -1.0, not -10.0). However the quality of the solution was horribly affected! I do not understand why, as the value of h does not participate in the constant density equations (https://www.openfoam.com/documentati...orm-p-rgh.html) (I will leave that Pandora's box closed for now ...)



Thanks for the clarification!


I will file a bug regarding the misleading crash of staticPressure, asap.


PS: I am using v8 (from .org)
Attached Images
File Type: jpg venturi_meter_p_gauge_zup.jpg (45.8 KB, 5 views)
Tobermory likes this.

Last edited by kakila; June 29, 2021 at 18:01. Reason: improve equations
kakila is offline   Reply With Quote

Old   June 29, 2021, 17:48
Default
  #19
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Quote:
Originally Posted by kakila View Post

p_rgh = p - rho * g * (water_elevation + hRef) = pref - rho * g * (z + hRef)

Wait... that can't be right, because I should see a constant p_rgh. That's not what I get.


So it should be either


p_rgh = p - rho * g * hRef = pref + rho * g * (water_elevation - z - hRef)


or


p_rgh = p - rho * g * (z + hRef) = pref + rho * g * (water_elevation - hRef)


The observation that p has less quality than p_rgh supports the second equation. That's because p has two source of coarseness in water_level and z, while p_rhg only has the coarseness of water_elevation.

Also, it the one that makes more sense to have.
kakila is offline   Reply With Quote

Old   June 29, 2021, 17:50
Default
  #20
New Member
 
Juan Pablo Carbajal
Join Date: Jun 2021
Posts: 9
Rep Power: 3
kakila is on a distinguished road
Quote:
Originally Posted by kakila View Post
I also tested the with the file hRef in the constant and also works (I used hRef value -1.0, not -10.0). However the quality of the solution was horribly affected! I do not understand why, as the value of h does not participate in the constant density equations (https://www.openfoam.com/documentati...orm-p-rgh.html) (I will leave that Pandora's box closed for now ...)

But I can't.. I guess the term where h multiplies the gradient of rho is not always zero for two phases. The gradient has a huge contribution on the free surface, so I guess it is expected that for large hRef that term might introduce issues.
kakila is offline   Reply With Quote

Reply

Tags
crash, function object, interfoam, static pressure

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 fields in FOAM, p field, total pressure, etc. Tobi OpenFOAM Post-Processing 9 March 25, 2022 01:33
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 03:23
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 14:11
How to show the transient case? H.P.LIU Phoenics 7 July 13, 2010 04:31
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 04:37


All times are GMT -4. The time now is 12:42.