CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Calculation per iteration

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2011, 07:22
Default Calculation per iteration
  #1
Member
 
Join Date: Mar 2009
Posts: 85
Rep Power: 17
husker is on a distinguished road
Hi,

I would like to calculate some quantities from the pressure value of a surface, per iteration. I could'nt find a way (scheme of udf way) to do it.

Could anyone show me a way to do this example per iteration:

a = pressure_of_a_surface * 10
b = a / x_coordinate_of_cell
..
..
..

Regards
husker is offline   Reply With Quote

Old   October 26, 2011, 08:33
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Hi,

First define these variables for whole domain with custom field function. For data extraction over specific surfaces you have these options:
- if you want to calculate something like integrals or min or max and ..., simply use (solve->monitor->surface-> ...)
- if you want to have a contour for these surfaces you can use one of these procedures:
1) use transient export option (in later versions)
2) write a simple journal file to export desired data during iterations

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 24, 2012, 03:22
Default
  #3
Member
 
Join Date: Mar 2009
Posts: 85
Rep Power: 17
husker is on a distinguished road
I'm too late but thank you Amir.

However I still have problems about this. What I want to do is to monitor pressure difference of two boundary conditions iterationally.

I can't imagine why this kind of an execution is that hard to discover.
husker is offline   Reply With Quote

Old   January 24, 2012, 03:43
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Ok, you can do that with a UDF (define adjust macro); find your desired data over different planes and save the difference in a temporary memory. you can save it in a simple scalar variable and write it during iteration or save it in a UDM and plot it during iteration.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 24, 2012, 10:20
Default
  #5
Member
 
Join Date: Mar 2009
Posts: 85
Rep Power: 17
husker is on a distinguished road
Very fast response Amir, surprised, thanks again.

I am totally a newbie about UDF, please let me ask how to select inlet and outlet faces by UDF methods. As I understand from UDF manual, after selecting appropriate faces, you can do some calculations on them. However I need area-average-surface integrals for pressure values.

If it doesn't take too much time of yours, could you please guide me for this purpose. I think this post will be very helpful for any other UDF newbies because I've scanned almost all UDF posts on cfd-online and got nothing in my hands now.

Kind Regards
husker is offline   Reply With Quote

Old   January 24, 2012, 11:02
Default
  #6
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Quote:
Originally Posted by husker View Post
If it doesn't take too much time of yours, could you please guide me for this purpose. I think this post will be very helpful for any other UDF newbies because I've scanned almost all UDF posts on cfd-online and got nothing in my hands now.
It's really easy. you need to have loops over inlet and outlet boundaries, for this purpose, you have to know the thread IDs of these surface which can be found from BC panel, then you can use such commands:

Code:
Thread *t1 = Lookup_Thread(domain, ID1);
Thread *t2 = Lookup_Thread(domain, ID2);
then use the loops over them:
Code:
begin_f_loop(f,t1)
{
......
}
end_f_loop(f,t)
In these loops you need temporary memories for storing accumulated area and pressure*area. (for calculating area weighted integrals)
At last, as I said before, use a UDM or a simple scalar to monitor the differences.
Don't hesitate to ask if it's not clear.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 25, 2012, 03:18
Default
  #7
Member
 
Join Date: Mar 2009
Posts: 85
Rep Power: 17
husker is on a distinguished road
Hi,

My code is below:

I try to calculate and write area-weighted-average of pressure at inlet boundary (id=14). After this I will be monitoring different quantities of different surfaces.

#include "udf.h"
DEFINE_ON_DEMAND (HeadCalculation)
{
real A[3];
real total_area = 0;
real ap = 0;
real apsum = 0;
real pressure = 0;
FILE *fp=NULL;
Domain *d;
Thread *t1 = Lookup_Thread(d, 14);
face_t f;
d = Get_Domain(1);
begin_f_loop(f, t1)
{
F_AREA(A, f, t1);
total_area += NV_MAG(A);
ap = NV_MAG(A) * F_P(f, t1);
apsum += ap;
}
pressure = apsum / total_area;
end_f_loop(f, t1)
fp = fopen("kondi.out", "a");
fprintf(fp, "%.4f \n", total_area);
fclose(fp);
}

Regards
husker is offline   Reply With Quote

Old   January 25, 2012, 08:40
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Ok, it's better to have few modifications:

Quote:
#include "udf.h"
DEFINE_ON_DEMAND(HeadCalculation)
{
Domain *d=Get_Domain(1);
Thread *t1 = Lookup_Thread(d,14);
face_t f;
real A[3];
real total_area =0.0;
real ap=0.0;
real apsum=0.0;
real pressure=0.0;
FILE *fp=NULL;
begin_f_loop(f, t1)
{
F_AREA(A, f, t1);
total_area += NV_MAG(A);
ap = NV_MAG(A) * F_P(f, t1);
apsum += ap;
}
end_f_loop(f, t1)
pressure = apsum / total_area;
fp = fopen("kondi.out", "a");
fprintf(fp, "%.4f \n", total_area);
fclose(fp);
}
Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 25, 2012, 09:26
Default
  #9
Member
 
Join Date: Mar 2009
Posts: 85
Rep Power: 17
husker is on a distinguished road
Thank you much Amir. I hope this thread will be very useful to the newbies.
husker 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
[snappyHexMesh] snappyHexMesh aborting Tobi OpenFOAM Meshing & Mesh Conversion 0 November 10, 2010 03:23
Force report every iteration in unsteady flow calculation Friso Landstra FLUENT 0 October 23, 2009 07:13
Parallel runs slower with MTU=9000 than MTU=1500 Javier Larrondo FLUENT 0 October 28, 2007 22:30
Warning 097- AB Siemens 6 November 15, 2004 04:41
Heat exchanger problem chiseung FLUENT 16 October 20, 2001 04:36


All times are GMT -4. The time now is 03:15.