|
[Sponsors] |
patchAverage on totalPressure (both functionObjects) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 17, 2021, 15:48 |
patchAverage on totalPressure (both functionObjects)
|
#1 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Hey all,
we all know that we can use the patchAverage to calculate an averaged field that is stored in the registry of the OpenFOAM such as p, U, k, etc. However, I am more interested in the total-pressure (contribution from the velocity). Hence, I am wondering if we can simply calculate the patch average value of an function object such as the totalPressure? I don't want to save the totalPressure field on my hard disk and I want to calculate the data each iteration. Any idea? Code:
pressureField { // Mandatory entries (unmodifiable) type pressure; libs (fieldFunctionObjects); // Mandatory entries (runtime modifiable) mode total; // Optional entries (runtime modifiable) p p; U U; rho rhoInf; rhoInf 1.2; // enabled if rho=rhoInf pRef 0.0; hydroStaticMode none; writeControl adjustableRunTime; writeInterval 0.1; } // Now calculate the patchAverage of that field on any patch ....
__________________
Keep foaming, Tobias Holzmann |
|
February 18, 2021, 06:03 |
|
#2 |
Senior Member
|
Hi Tobi,
I have used this in the past for a total pressure difference. It did not write total(p) every timestep, but it did write the delta. Both use executeControl timeStep as default. For your case you may need to adapt it a bit, but I hope the general idea is clear. Code:
totalPressure { type pressure; writeControl writeTime; mode total; rho rhoInf; rhoInf 1.2; pRef 0; libs (fieldFunctionObjects); } deltaTotalPressure_inOutlet { type fieldValueDelta; libs (fieldFunctionObjects); operation subtract; region1 { type surfaceFieldValue; libs (fieldFunctionObjects); log false; writeControl timeStep; writeFields false; regionType patch; name tunnel_inlet; operation areaAverage; fields ( total(p) ); } region2 { type surfaceFieldValue; libs (fieldFunctionObjects); log false; writeControl timeStep; writeFields false; regionType patch; name tunnel_outlet; operation areaAverage; fields ( total(p) ); } } |
|
January 10, 2022, 13:30 |
|
#3 |
New Member
Join Date: Sep 2020
Posts: 6
Rep Power: 5 |
Hi guys, I tried the code but it doesn't work. I don't know where is the problem. This is the dictionary I called FOdeltaP
HTML Code:
totalPressure { type pressure; libs ("libfieldFunctionObjects.so"); mode total; pRef 0; /*p p; U U; rho 1.0;*/ calcTotal yes; calcCoeff no; } deltaTotalPressure_inOutlet { type fieldValueDelta; libs ("libfieldFunctionObjects.so"); operation subtract; region1 { type surfaceFieldValue; libs ("libfieldFunctionObjects.so"); log false; writeControl timeStep; writeFields false; regionType patch; name inlet; operation areaAverage; fields ( total(p) ); } region2 { type surfaceFieldValue; libs ("libfieldFunctionObjects.so"); log false; writeControl timeStep; writeFields false; regionType patch; name outlet; operation areaAverage; fields ( total(p) ); } } HTML Code:
postProcess The result is this error message: HTML Code:
ime = 0 Reading fields: Executing functionObjects --> FOAM Warning : functionObjects::pressure totalPressure cannot find required object p of type volScalarField --> FOAM Warning : functionObjects::pressure totalPressure failed to execute. surfaceFieldValue deltaTotalPressure_inOutlet.region1 write: total faces = 875 total area = 5.94739e-05 --> FOAM Warning : From Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll(const vectorField&, const Foam::Field<Type>&, const pointField&, const faceList&) [with WeightType = double; Foam::label = int; Foam::vectorField = Foam::Field<Foam::Vector<double> >; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>] in file fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C at line 345 Requested field total(p) not found in database and not processed surfaceFieldValue deltaTotalPressure_inOutlet.region2 write: total faces = 550 total area = 3.58576e-05 --> FOAM Warning : From Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll(const vectorField&, const Foam::Field<Type>&, const pointField&, const faceList&) [with WeightType = double; Foam::label = int; Foam::vectorField = Foam::Field<Foam::Vector<double> >; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>] in file fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C at line 345 Requested field total(p) not found in database and not processed fieldValueDelta deltaTotalPressure_inOutlet write: none |
|
January 10, 2022, 16:27 |
|
#4 |
Senior Member
|
Hi,
Maybe you can specify which fields to load when running postProcess: Code:
postProcess -fields '(U p)' Code:
simpleFoam -postProcess Hope this helps, Tom |
|
January 11, 2022, 06:11 |
|
#5 |
New Member
Join Date: Sep 2020
Posts: 6
Rep Power: 5 |
Hi, thank you for the fast response. It works!
Now I am trying to apply the same function object to a different field, "p_rgh". Every time I try calling this field: HTML Code:
totalPressure { type pressure; libs ("libfieldFunctionObjects.so"); mode total; p p_rgh; U U; rho rho; } deltaTotalPressure_inOutlet { type fieldValueDelta; libs ("libfieldFunctionObjects.so"); operation subtract; region1 { type surfaceFieldValue; libs ("libfieldFunctionObjects.so"); log false; writeControl timeStep; writeFields false; regionType patch; name inlet; operation areaAverage; fields ( total(p_rgh) ); } region2 { type surfaceFieldValue; libs ("libfieldFunctionObjects.so"); log false; writeControl timeStep; writeFields false; regionType patch; name outlet; operation areaAverage; fields ( total(p_rgh) ); } } I am passing p_rgh in the calling command, but the error is the same. |
|
January 11, 2022, 06:32 |
|
#6 |
Senior Member
|
Hi,
Not sure if the new variable would still be called total(p) or now total(p_rgh). You may be able to give another name by using: Code:
totalPressure { type pressure; libs "libfieldFunctionObjects.so"); mode total; p p_rgh; U U; rho rho; result totPrgh; } Last edited by tomf; January 11, 2022 at 06:35. Reason: alignment |
|
January 14, 2022, 12:13 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Good point using the keyword result. This name is used to construct the object inside the calc() function in the FO. However, the resultName_ by default is constructed by the resultName() function.
Code:
Foam::word Foam::functionObjects::pressure::resultName() const { word rName; if (mode_ & STATIC) { rName = "static(" + fieldName_ + ")"; } else if (mode_ & TOTAL) { rName = "total(" + fieldName_ + ")"; } else if (mode_ & ISENTROPIC) { rName = "isentropic(" + fieldName_ + ")"; } else { FatalErrorInFunction << "Unhandled calculation mode " << modeNames[mode_] << abort(FatalError); } switch (hydrostaticMode_) { case NONE: { break; } case ADD: { rName = rName + "+rgh"; break; } case SUBTRACT: { rName = rName + "-rgh"; break; } } if (mode_ & COEFF) { rName += "_coeff"; } return rName; }
So I guess with Tom's hint, you should be ready to go.
__________________
Keep foaming, Tobias Holzmann |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
totalPressure (why flux direction dependend) | Tobi | OpenFOAM Running, Solving & CFD | 3 | October 17, 2019 23:27 |
About the totalPressure BC | fmerk | OpenFOAM Running, Solving & CFD | 1 | September 25, 2017 18:53 |
totalPressure boundary :Performance Curve (constant RPM) | nash | OpenFOAM Running, Solving & CFD | 0 | September 6, 2013 12:34 |
OpenFOAM v1.6 & OpenMPI & functionObjects | bruce | OpenFOAM Bugs | 7 | December 16, 2011 15:37 |
OpenFOAM v1.6 & OpenMPI & functionObjects | bruce | OpenFOAM Running, Solving & CFD | 1 | August 7, 2009 14:15 |