|
[Sponsors] |
Pressure Function Object Crashes When Set To Output Static Pressure |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 30, 2021, 06:08 |
|
#21 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14 |
Dear Juan
to unpick how hRef is used, you need to dig into the interFoam coding a little. In createFields.H there are the lines: Code:
#include "readhRef.H" #include "gh.H" Code:
Info<< "Calculating field g.h\n" << endl; dimensionedScalar ghRef(- mag(g)*hRef); volScalarField gh("gh", (g & mesh.C()) - ghRef); surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef); Code:
p_rgh = p - rho * gh = p - rho*g(z - hRef) p_rgh is only used to set boundaries, I think, since it has no real physical meaning. So you'll see in createFields.H that p_rgh is read in and then used to calculate the static pressure p; the static pressure is updated in pEqn.H with reference to the momentum equation, as part of the pressure-momentum coupling, and then p_rgh is updated straight afterwards. That seemed to be confusing Claudio. The messy part is that the gradient of p_rgh is not just simply the gradient of p minus rho*g; it also introduces a density gradient term: which is why there are some special boundary conditions (eg fixedFluxPressure) for p_rgh. Anyway, it seems like you are all sorted now. All the best. |
|
July 1, 2021, 19:34 |
|
#22 | ||||
Senior Member
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 7 |
Hello all again,
@Tobermory, first of all, thank you for your time. I agree that some confusion is due indeed to terminology. From the book "Ship Resistance and Flow", by Lars Larsson & Hoyte C. Raven, Section 2.5 "Hydrodynamic and Hydrostatic Pressure", p. 9: Quote:
In your post you asked to ignore those distortions in the p field. Those distortions however, are the hydrodynamic component of p, which is p_rgh. That's why I disagree with the statement: Quote:
Quote:
Further down the book says: Quote:
*** @Juan Pablo: I'm not sure why the results get inaccurate if the hRef has a relatively large value. One thing I have noticed though, is that p_rgh gets a fixed bias if hRef is not 0 at the still free surface. This is a problem if p_rgh is used as the pressure field for the forces Function Object, because the forces will be off as well (the lower p_rgh, the lower the forces and vice versa). This also happens, if due to inappropriate boundary conditions the overall water level changes during the course of the computation, in which case the (still) water level starts to deviate from the hRef coordinate. Just to be sure, I took the DTC Hull Tutorial case, which has z = 0 at the keel level and both z at the free surface and hRef as 0.244. If I let it run after it has converged with p as the field for Forces, the x pressure force is about -2.7 N. If I replace the field with p_rgh instead, this value drops immediately to about -2.4 N and remains stable there. This doesn't happen in cases where hRef = 0, where using either p or p_rgh as field for the forces Function Object results in almost the same forces. I've noticed that there is a very small difference though, but haven't discovered the reason. My take away from this is:
*** Coming back to the pressure Function Object, if both calcTotal and calcCoeffs are set to no, the first thing it does, is it checks whether the passed pressure field is kinematic or not and if it is, it multiplies it with rho, according to pressure.C, lines 66-79: Code:
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale ( const volScalarField& p ) const { if (p.dimensions() == dimPressure) { return p; } else { return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*p; } } Quote:
Cheers, Claudio |
|||||
July 2, 2021, 04:41 |
|
#23 | |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14 |
Great post Claudio - thanks for taking the time to write all of the above. One of the things that I love about this forum is that you get to discuss topics with Engineers from different backgrounds and get a different perspective ... I always end up learning something!
The above makes total sense now - and yes, we were being trapped by terminology. Two quick points - first, I agree that when working with a constant density fluid (eg water, for most scenarios) then p_rgh does have meaning - and is far more convenient to use not only for boundary conditions, but also for looking at dynamic effects. My statement: Quote:
Secondly - p is indeed vestigial here, since there is no equation of state for your case. Again, I was mistaken in replying. In fact, it's pretty obvious when I think clearly about it - in pEqn.H the solver is creating and then solving an equation for p_rgh, not p! On hRef - another possible approach is to consider choosing the value to remove as much of the hydrostatic pressure as you can, so for example if you were studying conditions on the sea bed you'd could set hRef to sea-bed level. In this case, you'd have to add on the neglected hydrostatic force manually to p_rgh, if you were using absolute values - that's the difference that you see Claudio between the forces calculated from p and p_rgh in your test. For my atmospheric work I set it to ground level, so that p_rgh is 0 at ground level and close to zero across the domain - it's a lot easier dealing with small deviations in pressures that are around zero compared to smalldeviations in pressure values of around 10^5. All the best. |
||
July 3, 2021, 07:58 |
|
#24 |
Senior Member
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 7 |
Hi Tobermory,
I'm glad you could learn something and I share the thought, we are all here to learn! Yes, it is amazing how many uses CFD has, it's really incredible. I thank you for taking the time and I appreciate your willingness to help. interFoam is the solver I work by far the most with and understanding how it works is essential to me. So if I'm told that I might have misunderstood something, I'm glad to investigate. I've never dealt with compressible flows and I imagine that those are more difficult to post process and to interpret. For using p_rgh to set the boundary conditions, I guess it has to be used because there's no other way, since p is not an input field read by interFoam. That's why there are pressure boundary conditions applied to p_rgh that set total pressure et al.,which I personally find very confusing at times. Their descriptions are sometimes very vague and I wish they were more clearly documented with what the face values at the boundary would be, at the nearest cell centre and the opposing internal faces. This would provide a better understanding of what values the boundary cells assume. I'm sure there's a justification and meaningful applications for hRef and pRef, although I think that it should be well understood to ensure correct interpretation of the results. Knowing where p_rgh is larger than 0 and smaller is detrimental, as it translates directly to forces acting on the hull. By analizing the p_rgh field one can make judgements on a hull and with the proper modifications reduce its resistance. Making that judgement if p_rgh were not zero-based would be impractical and that's why my alarm bells ring if I notice that p_rgh is far from zero far away from the hull for example, since a non-zero value implies change in velocity. Just out of curiosity, are you a meteorologist or climate researcher? Have a nice weekend, Claudio |
|
July 3, 2021, 10:16 |
|
#25 |
Senior Member
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 7 |
I've just tried the pressure Function Object with the tutorials/incompressible/simpleFoam/airFoil2D case. Although it doesn't crash, the output p_static field with both flags calcTotal and calcCoeff set to no, is exactly the same as p, with only one difference. The p_static field's dimensions are being changed from
Code:
[0 2 -2 0 0 0 0] Code:
[1 -1 -2 0 0 0 0] I've also tried the Function Object with the tutorials/compressible/rhoSimpleFoam/aeroFoilNACA0012 case and with the same settings it crashes as it does with interFoam giving the same error message. At this point I'm not sure what this Function Object is supposed to do and I'll just leave it be. I can't file a bug report if I don't understand what the intended behaviour is. Maybe it is still based on a very old code base and simply doesn't work properly anymore. |
|
July 6, 2021, 08:22 |
|
#26 |
Senior Member
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 7 |
I just run a case with pisoFoam where the p field is kinematic and I wanted to convert it to pressure in order to be able to compare the pressure field to results previously calculated with interFoam. So I gave the pressure Function Object another shot. I discovered that the rho entry needs to be present and set to rhoInf, then the multiplication of p by rho works. If it's not set, the Function Object won't issue any errors or warnings and just assume it to be 1.
Here's the working dictionary for static pressure: Code:
p_static { type pressure; libs ("libfieldFunctionObjects.so"); calcTotal no; calcCoeff no; UInf (-5.144 0 0); pInf 0; pRef 0; rhoInf 1025; // Density of seawater rho rhoInf; // Set this to rhoInf, otherwise it will default to rho = 1 result p_static; writeControl outputTime; } |
|
July 6, 2021, 10:11 |
|
#27 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14 |
That makes sense Claudio, and from your experiences above it seems to reinforce the idea that it is only useful for kinematic solvers., i.e. principally the incompressible solvers, to convert from kinematic to ordinary pressure.
|
|
Tags |
crash, function object, interfoam, static pressure |
|
|
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 02:33 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 04:23 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
How to show the transient case? | H.P.LIU | Phoenics | 7 | July 13, 2010 05:31 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 05:37 |