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

Write a UDF script For FLUENT!!

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2015, 10:27
Default Mean vorticity field
  #1
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Hello,

I am new to UDF scripts and I have tried to make a script using UDF manual, and FLUENT does not complain when I interpret but I don't know if the script is correct. I have a LES simulation and want to make a contour plot of mean vorticity and I don't have any velocity fields from time steps. So I have to make a UDF script in order to get mean vorticity field of velocity fields. The script is as follows

#include "udf.h"

enum{
VORT
};

DEFINE_ON_DEMAND(vorticity_on_demand)
{
Thread*t;
cell_t c;
face_t f;

Domain *domain;
domain = Get_Domain(1);

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
C_UDSI(c,t,VORT) = (C_DWDY(c,t)-C_DVDY(c,t)) + (C_DWDX(c,t)-C_DUDZ(c,t)) + (C_DVDX(c,t)-C_DWDY(c,t));
}
end_c_loop(c,t)
}
}

When I interpret, I can't see the vorticity in the contour list and don't know how to make it.

Last edited by Martin1; June 18, 2015 at 14:54.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 03:35
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
First of all: you want to put the data in a User Defined Memory (UDM), not a User Defined Scalar.

So:
1. Change the code (replace UDSI by UDMI).
2. Add a user defined memory. (In the menu Define->User Defined->Memory)
3. Run your udf (Define->User Defined->Execute on Demand)
4. Plot User Defined Memory 1.


And please don't open four threads for the same problem, that does not really help...
pakk is offline   Reply With Quote

Old   June 19, 2015, 03:54
Default
  #3
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Thank you for your reply. What about the mean value of vorticity? Right now I am integrating over time but I don't have a velocity field of time steps. And when I run without t it complains. Also is define_on_demand appropriate to use
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:09
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Martin1 View Post
Thank you for your reply. What about the mean value of vorticity?
What does "mean value" mean? Time-averaged? Volume-averaged? The LES-filtered?
Quote:
Right now I am integrating over time but I don't have a velocity field of time steps.
I don't see how you can integrate over time without a velocity field on different time steps. What are you doing?
Quote:
And when I run without t it complains.
Are you suggesting that "t" in the UDF corresponds to time? If so, you are wrong, it refers to "threads". If not, I don't understand what you say.
Quote:
Also is define_on_demand appropriate to use
With "define_on_demand" you have to manually click the button every time you want the calculation done. If this is what you want, it is appropriate. If this is not what you want, you maybe should use something else. So it all depends on what you want, I can not judge that.
pakk is offline   Reply With Quote

Old   June 19, 2015, 04:16
Default
  #5
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
I have run my simulations in LES but I only have instantaneous values of vorticity, I want average values instead.

regarding t, if it is not time, then I don't understand what it is, it says that it is pointer threads, but what does that mean?

Also right now I loop over cells, do I have to loop over faces as well?

Sorry for not being clear, I am very new to this.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:24
Default
  #6
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Maybe there is an easier way to show the average value of vorticity but I don't know what.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:25
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Martin1 View Post
I have run my simulations in LES but I only have instantaneous values of vorticity, I want average values instead.
Unless you know which kind of average you want, I can not help you. (Or actually, I don't want to explain how to get every possible type of average, while you only need one. I have only limited time to spend.)
Quote:
regarding t, if it is not time, then I don't understand what it is, it says that it is pointer threads, but what does that mean?
A thread is a group of cells.
Quote:
Also right now I loop over cells, do I have to loop over faces as well?
Again this totally depends on what you want. If you loop over cells, you get information in cells, so in your internal volume. If you loop over faces, you get information in faces, so on your boundaries. Probably you want to know vorticity in you internal volume, so then cells are appropriate. But maybe you want to know vorticity only on your boundaries (inlets/outlets). In that case, faces might be better.
pakk is offline   Reply With Quote

Old   June 19, 2015, 04:29
Default
  #8
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Ok that explained a lot, then cells are definitely appropriate.

Then I only have the averaging left, but is there different macros to use for different averaging? Am i not averaging now?
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:30
Default
  #9
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Thank you so much pakk for your time, it cleared things up
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:32
Default
  #10
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
I think I need surface averaging
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:38
Default
  #11
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Or I am not sure, I mean I just want the average value, mean value. I don't know which types it exist or which one to use.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 04:49
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Do you know what the difference is between time-averaged, volume-averaged and LES-averaged?
pakk is offline   Reply With Quote

Old   June 19, 2015, 04:52
Default
  #13
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Yes I know that and LES-averaged is what I want.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 05:09
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
OK, good that you know it now.

In that case, probably, you don't need to do anything special. As far as I know, if you use LES in fluent, your 'normal' flow properties are actually the 'LES-averaged' flow properties. (I have never done LES in Fluent, so don't take my word for it, but search the Manual to be sure.)

Instead of writing this UDF, you could have just plotted the contours of "vorticity magnitude". Actually, this is better, because what you are calculating in the UDF is actually the divergence of the vorticity, (which should always be zero), because you entered the equation wrong, I had not noticed that before.
pakk is offline   Reply With Quote

Old   June 19, 2015, 05:13
Default
  #15
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
No the vorticity magnitude in LES is not averaged, its instantaneous.
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 05:14
Default
  #16
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
How is that equation wrong?
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 05:20
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Martin1 View Post
No the vorticity magnitude in LES is not averaged, its instantaneous.
It is instantaneous LES-averaged. Otherwise you are talking about DNS simulations. I get again the feeling that you are confusing LES-averaging with time-averaging...

Quote:
Originally Posted by Martin1 View Post
How is that equation wrong?
I believe I already said that. You wrote the divergence of the vorticity, while you want the magnitude.
pakk is offline   Reply With Quote

Old   June 19, 2015, 05:24
Default
  #18
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
Yes you are probably right. But the vorticity magnitude shows instantaneous values and that is not what I want. I want to compare the LES solutions to RANS solutions, so I can't compare RANS against instantaneous solutions

Ok How do I get the magnitude?
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 05:27
Default
  #19
Member
 
Martin
Join Date: May 2015
Posts: 30
Rep Power: 11
Martin1 is on a distinguished road
I don't see how that is divergence
Martin1 is offline   Reply With Quote

Old   June 19, 2015, 05:37
Default
  #20
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Martin1 View Post
Yes you are probably right. But the vorticity magnitude shows instantaneous values and that is not what I want. I want to compare the LES solutions to RANS solutions, so I can't compare RANS against instantaneous solutions
So, if I summarize, you want to do a steady-state LES simulation, but you did a transient LES simulation? If that is the case, then the solution is obvious: do a steady-state LES simulation.

Quote:
Originally Posted by Martin1 View Post
I don't see how that is divergence
You are correct: it is not divergence, I was wrong. As far as I know, the thing you wrote down does not have a proper name.

Why don't you just write down what vorticity is, and what the magnitude of vorticity therefore is? That should make it immediately clear.
pakk 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
write a UDF to give a velocity boundary condition at an interior face Tharanga Fluent UDF and Scheme Programming 19 August 5, 2018 04:29
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 07:26
fluent udf problem: write specific data for every iteration in a file. nnvoro Fluent UDF and Scheme Programming 1 May 27, 2013 15:26
How to write UDF to achieve phase chang dunga82 Fluent UDF and Scheme Programming 0 May 6, 2013 08:50
how to write a 3D linear temperature of UDF venus FLUENT 1 October 28, 2008 02:46


All times are GMT -4. The time now is 07:26.