## Fluids

#### obtaining total pressure from UDF

• atulsingh92
Subscriber
How do we get the total pressure at a surface? I tried something like followsnvoid dynamic_pressure()nnt = Lookup_Thread(domain, id);? //outlet edge (for a 2D case) is at id=6;nbegin_f_loop(f,t)n{n Amag = NV_MAG(area);n vsquared = pow(C_U(f,t), 2)+ pow(C_V(f,t),2) + pow(C_W(f,t),2);n velocity_squared += vsquared * Amag;n d = C_R(f,t);n density += d * Amag;n}nend_f_loop(f,t)nreturn dynamic_component;nafter the PRF_GRSUM() command on these values, I divide with global area values to get the area averaged quantities as shwon in the examples of the manual.nI then add this to the C_P(f,t), however it did not give the correct result. (the one that area averaged results in fluent console is obtained from the results section)nCould you recommend something else, on how can I obtain the total pressure. I require this via udf to print to an external file, because I want to assign this pressure to another inlet with perhaps the F_PROFILE command, after some other calculations.n
• DrAmine
Ansys Employee
What about defining a report definition for it and then accessing that report definition elsewhere in UDF?n
• DrAmine
Ansys Employee
Moreover the dynamic pressure is calculated for each facet and not as average over all facets. Density is not available on boundary just refer to cell next to the facet.n
• atulsingh92
Subscriber
The customization manual has one example n 3.8.3, but it gives the following errornc(12):error C2099:initializer is not a constantnhere line 12 is the first declaration ofnint rv = Get_Report_Definition_Values(pressure_outlet, 0, &nrOfvalues, NULL, NULL,NULL);ncould you help, how can I solve this error?nThe example was used as it is, with just the name of the report-definition changed.n
• YasserSelima
Subscriber
make itint rv;nrv = Get_Report_Definition_Values(pressure_outlet, 0, &nrOfvalues, NULL, NULL,NULL);nn
• YasserSelima
Subscriber
but is it integer ??n
• atulsingh92
Subscriber
So, the pressure_outlet report definition is defined so that I could obtain the total pressure at my outlet, after convergence, so no it is not an integer.nhence I tried with the below, and get the errornfloat rv;nn..\..\src\reportdef.c(12): warning C4142: 'rv:benign redefinition of typen..\..\src\reportdef.c(10): note: see declaration of 'rv'n..\..\src\reportdef.c(12): error C2099: initializer is not a constantnnso help is appreciated.n
• YasserSelima
Subscriber
it seems that you declared it twice ... once as integer and once as floatremove the line nint rv;nhave only the original declaration nfloat rv;nand the line nrv = Get_Report_Definition_Values(pressure_outlet, 0, &nrOfvalues, NULL, NULL,NULL);nn
• atulsingh92
Subscriber
Thank you for your response, Yasser.nThat is not the case, I have run the example as it is from the 3.8.3 example in fluent customization manual shown as followsnn﻿#include udf.hnn  int nrOfvalues=0;n  real *values;n  int *ids;n  int index;n  int counter;n  float rv;nn  rv = Get_Report_Definition_Values(pressure_outlet, 0, &nrOfvalues, NULL, NULL,NULL);nn  if (rv==0 && nrOfvalues)n{n  Message(Report definition evaluated at iteration has %d values, nrOfvalues);n n  values = (real*) malloc(sizeof(real)* nrOfvalues);n  ids = (int*) malloc(sizeof(int)* nrOfvalues);n n  rv = Get_Report_Definition_Values(pressure_outlet, 0, NULL, values, ids, &index);n n  Message(Values correspond to iteration index:%d, index);n n  for ( counter = 0; counter < nrOfvalues; counter++ )n    {n      Message(report definition values: %d, %f, ids[counter], values[counter]);n    }n  free(values);n  free(ids);nn  elsen{n  if (rv == 1)n    {n      Message(report definition: %s does not exist, pressure_outlet);n    }n  else if ( nrOfvalues == 0 )n    {n      Message(report definition: %s not evaluated at iteration level, pressure_outlet);n    }nThe error is the same.ninitializer is not a constantn
• YasserSelima
Subscriber
initializer is not a constant means that you declare variable and put it in equation on the same step ... I can not see you doing this in this coden
• atulsingh92
Subscriber

What about defining a report definition for it and then accessing that report definition elsewhere in UDF?https://forum.ansys.com/discussion/comment/107260#Comment_107260

Could you suggest how can I do this?.
• Surya Deb
Ansys Employee
Hello, nI think you will need to include this API within the DEFINE_REPORT_DEFINITION_FN UDF. Also keep the int rv = .. definition from the API example. nSomething like this should work. n#include udf.hnDEFINE_REPORT_DEFINITION_FN(UDF_name)n{ n...(include the rest of the API structure here)nn}nGive this a try. nRegards,nSDn