CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Computation of total pressure drop based on integral definition

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By palarcon

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 4, 2018, 08:00
Default Computation of total pressure drop based on integral definition
  #1
Member
 
Pablo Alarcón
Join Date: Mar 2018
Location: Liège
Posts: 59
Rep Power: 8
palarcon is on a distinguished road
Hello everybody

I'm working on topology optimization with OpenFOAM and I'm using and adapting the solver adjointShapeOptimizationFoam.
In order to do that, I need to compute and print the objective function used on that solver (which is not the same used on the paper which is based on).
The real objective function used in this solver is the total pressure drop, which mathematically is

J=\int_{\Gamma_i}d\Gamma_i\left( p+\frac{1}{2}v^{2} \right) - \int_{\Gamma_o}d\Gamma_o \left( p+\frac{1}{2}v^{2} \right)

which is the total pressure at the inlet minus the total pressure at the outlet.
I'm not sure about the implementation into my solver, mainly for the differential part d\Gamma.

My current implementation is

Code:
objective_inlet  = sum((p.boundaryField()[objPatchList[0]] + 0.5*magSqr(U.boundaryField()[objPatchList[0]])));
objective_outlet = sum((p.boundaryField()[objPatchList[1]] + 0.5*magSqr(U.boundaryField()[objPatchList[1]])));
objective = objective_outlet - objective_inlet;
where objPatchList[0] is the inlet and objPatchList[1] is the oulet.

My question is, should I multiply objective_inlet and objective_outlet by mesh.magSf()[objPatchList[X]] in order to account for the differential d\Gamma in the analytical expression?

PS: I know that I posted a similar question some time ago, but my knowledge of the problem was different at that time.
FlyBob91 likes this.
palarcon is offline   Reply With Quote

Old   September 26, 2018, 12:50
Default
  #2
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
You should multiply for the cell face area, sum all the contributes and finally divide for the area of the boundary. If you multiply only one time the area you change the dimension of your cost function.
If you need help I can post my code.

Best regards
FlyBob91 is offline   Reply With Quote

Old   September 27, 2018, 07:50
Default
  #3
Member
 
Pablo Alarcón
Join Date: Mar 2018
Location: Liège
Posts: 59
Rep Power: 8
palarcon is on a distinguished road
Hello FlyBob

Finally I did (a few days ago) something similar to what you suggest. Nevertheless, given that OpenFOAM coding per se is not my strong point, I would be really grateful if you could post your code.

Thank you in advance

Quote:
Originally Posted by FlyBob91 View Post
You should multiply for the cell face area, sum all the contributes and finally divide for the area of the boundary. If you multiply only one time the area you change the dimension of your cost function.
If you need help I can post my code.

Best regards
palarcon is offline   Reply With Quote

Old   September 27, 2018, 08:10
Default
  #4
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Code:
scalar jDissTotalOutlet(0);
scalar jDissTotalInlet(0);

label PatchIDInlet = mesh.boundaryMesh().findPatchID("inlet");
scalar areaInlet = gSum(mesh.magSf().boundaryField()[PatchIDInlet]);

label PatchIDOutlet = mesh.boundaryMesh().findPatchID("outlet");
scalar areaOutlet = gSum(mesh.magSf().boundaryField()[PatchIDOutlet]);


jDissTotalOutlet = 

sum(mesh.magSf().boundaryField()[PatchIDOutlet]* (p.boundaryField()[PatchIDOutlet] + 0.5 * rho.boundaryField()[PatchIDOutlet] * magSqr(U.boundaryField()[PatchIDOutlet]))) / areaOutlet;	


jDissTotalInlet = 
sum(mesh.magSf().boundaryField()[PatchIDInlet] * (p.boundaryField()[PatchIDInlet] + 0.5 * rho.boundaryField()[PatchIDInlet] * magSqr(U.boundaryField()[PatchIDInlet]))) / areaInlet;	

scalar diff = jDissTotalInlet - jDissTotalOutlet;

Info<<"Total Pressure at the inlet: "<<jDissTotalInlet<<endl;
Info<<"Total Pressure at the outlet: "<<jDissTotalOutlet<<endl;
Info<<"The total difference is: "<<diff<<endl;
Since my formulation is compressible, while I imagine your is incompressible, you don't need the density (rho) so you can delete that term.
Hope it helps

Best regards

Last edited by FlyBob91; September 27, 2018 at 09:49.
FlyBob91 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
Total pressure in rel frame and total pressure Salut CFX 14 May 8, 2023 03:29
How to get the total pressure in the UDF? zgzhai Fluent UDF and Scheme Programming 3 September 24, 2018 17:12
Orifice-Pipe Problem CFXMUFFIN CFX 3 July 16, 2015 19:57
Error in run Batch file saba1366 CFX 4 February 10, 2013 02:15
Hydrostatic pressure in 2-phase flow modeling (long) DS & HB Main CFD Forum 0 January 8, 2000 16:00


All times are GMT -4. The time now is 17:22.