|
[Sponsors] |
Computation of total pressure drop based on integral definition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 4, 2018, 08:00 |
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 |
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 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 . 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; My question is, should I multiply objective_inlet and objective_outlet by mesh.magSf()[objPatchList[X]] in order to account for the differential 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. |
|
September 26, 2018, 12:50 |
|
#2 |
Senior Member
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10 |
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 |
|
September 27, 2018, 07:50 |
|
#3 |
Member
Pablo Alarcón
Join Date: Mar 2018
Location: Liège
Posts: 59
Rep Power: 8 |
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 |
|
September 27, 2018, 08:10 |
|
#4 |
Senior Member
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10 |
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; Hope it helps Best regards Last edited by FlyBob91; September 27, 2018 at 09:49. |
|
|
|
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 |