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

Gradient of UDM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 28, 2023, 10:27
Post Gradient of UDM
  #1
Member
 
Chris
Join Date: Dec 2020
Posts: 45
Rep Power: 5
Pyrokrates is on a distinguished road
Hi,


I would like to calculate the gradient of some scalar value, stored in UDMI.


The way I found (User guide + forum posts) is some kind of transformation to UDSI and saving UDSI_G afterwards to UDMI.


I tried this but it didnt work for me... Do I require face values also?


First I use some DEFINE_ADJUST to initialize my UDSI:



Code:
DEFINE_ADJUST(DA_UDSI, d)
{
    Thread *t;
    cell_t c;
    face_t f;

    thread_loop_c (t,d)
    {
        begin_c_loop (c,t)
        {
            C_UDSI(c,t,0) = C_UDMI(c,t,0);
        }
        end_c_loop (c,t)
    }
}
In the next step, I would like to set the gradient values to UDMI:



Code:
DEFINE_ON_DEMAND(DOD_UDMI)
{
    Thread *t;
    cell_t c;
    Domain *d = Get_Domain(1);

    thread_loop_c (t,d)
    {
        begin_c_loop (c,t)
        {
            C_UDMI(c,t,1) = C_UDSI_G(c,t,0)[0];
            C_UDMI(c,t,2) = C_UDSI_G(c,t,0)[1];
            C_UDMI(c,t,3) = C_UDSI_G(c,t,0)[2];

        }
        end_c_loop (c,t)
    }
 }
For using UDS, I disable the calculation of UDS in solver menu.


In CFD-Post, I use some contour on plane for visualization. While C_UDMI(c,t,1) shows me some results, I get "holes" inside my plane for C_UDMI(c,t,2) and C_UDMI(c,t,3), as there are some cells where I get no value.




Thanks in advance for any help


Pyro
Pyrokrates is offline   Reply With Quote

Old   March 2, 2023, 02:46
Default
  #2
Member
 
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6
Siba11 is on a distinguished road
Can you try this instead:

Switch on the UDS equation, and allocate 3 memory locations (since you'll be using C_UDMI thrice)

Code:
#include "udf.h"

DEFINE_ADJUST (name,d)
{
#if !RP_HOST  
Thread *t;
cell_t c;
face_t f;

thread_loop_c (t,d)
    {
        begin_c_loop (c,t)
        {
            C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0];
            C_UDMI(c,t,1) = C_UDSI_G(c,t,0)[1];
            C_UDMI(c,t,2) = C_UDSI_G(c,t,0)[2];

        }
        end_c_loop (c,t)
    }
#endif
}
This will save your x,y,z gradients in the 3 memory locations. Now you can plot the C_UDMI contours.
Siba11 is offline   Reply With Quote

Old   March 3, 2023, 08:19
Default
  #3
Member
 
Chris
Join Date: Dec 2020
Posts: 45
Rep Power: 5
Pyrokrates is on a distinguished road
Hi and thank you for the answer.


I donīt understand the benefit or change, for doing this...


If I turn on the claculation of UDS, than my value changes over time as I have unsteady term and flux, ...


I already allocate enough memories and scalars.
My data are stored in UDMI 0, I write them to UDSI 0 and than I save them in UDMI 1, UDMI 2 and UDMI 3. So I use 4 UDMI and 1 UDSI.


Thanks in advance


Pyro
Pyrokrates is offline   Reply With Quote

Old   March 3, 2023, 13:00
Default
  #4
Member
 
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6
Siba11 is on a distinguished road
C_UDSI is a solver macro that fetches you the value of your scalar variable. You cannot alter or change the value of C_UDSI by assigning it some value.
Code:
C_UDSI(c,t,0) = C_UDMI(c,t,0) 

//the above statement is wrong. It's no better than:

int a;
2 = a;
The correct assignment would be :

Code:
C_UDMI(c,t,0) = C_UDSI(c,t,0);
Siba11 is offline   Reply With Quote

Reply

Tags
gradient, udmi, udsi


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
Question about C_UDMI and F_UDMI and How to define the gradient of a UDM? aestas Fluent UDF and Scheme Programming 4 May 14, 2018 11:50
pisoFOAM (LES) - internal pipe flow - convergence gu1 OpenFOAM Running, Solving & CFD 0 January 11, 2018 17:39
question regarding LES of pipe flow - pimpleFoam Dan1788 OpenFOAM Running, Solving & CFD 37 December 26, 2017 15:42
Periodic flow using Cyclic - comparison with Fluent nusivares OpenFOAM Running, Solving & CFD 30 December 12, 2017 06:35
How could I get the gradient of UDM? fireman FLUENT 2 February 8, 2011 06:36


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