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

udf-assign a set of data to the corresponding cell center and calculate gradient

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 31, 2021, 06:22
Default udf-assign a set of data to the corresponding cell center and calculate gradient
  #1
New Member
 
Lanting li
Join Date: Nov 2019
Posts: 10
Rep Power: 6
by1704116 is on a distinguished road
Hello, my dears.
Here is my problem in detail.I have a set of values,and each of it corresponds to its specific cell. I want to assign each of them to the corresponding cell center, and calculate the gradient of these value to form a mass source in the right hand side of the continuity equation.
In one paper,it says that one could save data in a txt file,and use DEFINE_ON_DEMOND to read it, assign values to the cell center ,store into an array,and use a second order reconstruction technique to calculate the gradient.
However, the Fluent udf manual just mentions the inherent variables,such as C_U(c,t),C_R(c,t), to use Gradient or Reconstruction Gradient macro.
I could store data into an array, but I don't know how to assign it to specific cell, and how could I use udf marco to calculate gradient?
Could someone give me some suggestions on my problem?
Thanks a lot for reading my post.
by1704116 is offline   Reply With Quote

Old   October 31, 2021, 19:13
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
to assign value to specific cell you should decide how you are going to recognize if that is a cell you are looking for.

usually people are using coordinates to do that.

to apply specific values you may use both UDF or just profile.

as far as I understand, to get a gradient you should apply you values as a source of user defined scalar (C_UDSI). set proper boundary condition for it (usually specific value, for instance 0), turn on that scalar equation and calculate.
Also you will need to change solver settings:
Code:
In order to retain the
gradient data (when you want to set up user-defined scalar transport equations, for example), you can
prevent the solver from freeing up memory by issuing the text command solve/set/expert and
then answering yes to the question, “Keep temporary solver memory from being freed?”
for more information look into Ansys Fluent Customization manual

macro to get gradient of scalar is C_UDSI_G(c,t,i)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 31, 2021, 20:27
Default
  #3
New Member
 
Lanting li
Join Date: Nov 2019
Posts: 10
Rep Power: 6
by1704116 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
to assign value to specific cell you should decide how you are going to recognize if that is a cell you are looking for.

usually people are using coordinates to do that.

to apply specific values you may use both UDF or just profile.

as far as I understand, to get a gradient you should apply you values as a source of user defined scalar (C_UDSI). set proper boundary condition for it (usually specific value, for instance 0), turn on that scalar equation and calculate.
Also you will need to change solver settings:
Code:
In order to retain the
gradient data (when you want to set up user-defined scalar transport equations, for example), you can
prevent the solver from freeing up memory by issuing the text command solve/set/expert and
then answering yes to the question, “Keep temporary solver memory from being freed?”
for more information look into Ansys Fluent Customization manual

macro to get gradient of scalar is C_UDSI_G(c,t,i)
Dear Alexander,
Thanks for your quick reply. I've read your suggestions, but I still have some questions about how to realize it.
1、use coordinates to assign values to cells.
I may have not expressed exactlly. There is a zone full of cells, and I want to assign these valus to this zone. If use coordinates, I could only thinkof these steps. First output cell center coordinates from mesh, and then make a txt file with these coordinates and corresponding value that I've had. If I read the txt file to an array, how could I recognize which cell corresponds to its specific value? Loop over all the cells,and use 'if' statement to decide whether one cell coordinate matches with the array or not? Could you give me one example code on this kind of problem if it is possible?
2、use UDS
According to the udf manual, as if when I need to calculate an equation formed with the usteady, flux or diffusivity of a variable,then I use it?
Don't know why I can't upload pictures. I can just describe my problem in words. I just need to sole ordinary Euler equations with mass source in the right hand side of continuity equation. and values I've mentioned all through this post is a set of constant data and its gradient is constant too.So, what do you think about my new description of the question. Should I still use UDS or other method?

Look foward to your reply, Alexander.


I could attach a picture to describe the equations I need to deal with, please read the post below.
by1704116 is offline   Reply With Quote

Old   October 31, 2021, 20:38
Smile
  #4
New Member
 
Lanting li
Join Date: Nov 2019
Posts: 10
Rep Power: 6
by1704116 is on a distinguished road
Fortunately, I could attach a picture. there is a set of Euler equations with source terms on the right hand of them. The variable 'b' is what I want to assign to the cell center, and the one to be solved graident.
Attached Images
File Type: png equations.png (19.2 KB, 8 views)
by1704116 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
How to implement a TVD scheme? Jaydi_21 Main CFD Forum 10 May 17, 2019 16:11
How to get cell data like center, volume/mass, velocity julianschl OpenFOAM Post-Processing 3 June 13, 2014 03:10
Prediction of gradient at the cell center for cell-centered finite volume method openfoammaofnepo Main CFD Forum 4 March 23, 2014 15:07
gradient calculation of cell centered finite volume method zhengjg Main CFD Forum 10 November 11, 2012 23:13
calculate cell volume, center...? Paul Main CFD Forum 5 June 21, 2003 12:55


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