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

Cannot Validate Fluent Gradient

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2023, 13:57
Default Cannot Validate Fluent Gradient
  #1
New Member
 
EmmaKate
Join Date: Aug 2023
Posts: 11
Rep Power: 3
emmakateh is on a distinguished road
Hi all, I am working on a code that calculates the gradient of a UDSI in fluent using udf. When I use this code and export the gradients on nodes and cell centers, I cannot figure out how fluent is determining the gradient so I cannot validate and verify the gradient. I have looked in the manual at the three ways it calculates the gradients, but when I try to mimic those, I get different results.

I am using a simple 3x3x3 cube to try to validate the results. Can anyone explain if my code is wrong or how fluent is extrapolating points outside the mesh?

#include "udf.h"
#include "sg.h"
#include <math.h>

enum
{
HMAG,
N_REQUIRED_UDS
};

enum
{
GHX,
GHY,
GHZ,
N_REQUIRED_UDM
};

DEFINE_INIT(HFIELD, domain)
{
Thread *t;
cell_t c;
face_t f;

//Calculating T for Cell Centers
thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
C_UDSI(c,t,HMAG) = 9.5;
}
end_c_loop(c,t);
}

thread_loop_f(t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(HMAG))!=NULL)
begin_f_loop(f,t)
{
F_UDSI(f,t,HMAG) = 20;
}
end_f_loop(f,t);
}

//Calculating T Derivatives
int p;
for (p=0; p<n_uds; p++)
{
uds_derivatives(domain,p);
}


thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_UDSI_G(c,t,HMAG)[0];
C_UDMI(c,t,1) = C_UDSI_G(c,t,HMAG)[1];
C_UDMI(c,t,2) = C_UDSI_G(c,t,HMAG)[2];
}
end_c_loop (c,t)
}

thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(HMAG))!=NULL &&
T_STORAGE_R_NV(t->t0,SV_UDSI_G(HMAG))!=NULL)
{
begin_f_loop (f,t)
{
F_UDMI(f,t,0) = C_UDMI(F_C0(f,t),t->t0,0);
F_UDMI(f,t,1) = C_UDMI(F_C0(f,t),t->t0,1);
F_UDMI(f,t,2) = C_UDMI(F_C0(f,t),t->t0,2);
}
end_f_loop (f,t)
}
}
}



void uds_derivatives(Domain *domain, int n)
{
MD_Alloc_Storage_Vars(domain, SV_UDSI_RG(n), SV_UDSI_G(n), SV_NULL);
Scalar_Reconstruction(domain, SV_UDS_I(n), -1, SV_UDSI_RG(n), NULL);
Scalar_Derivatives(domain, SV_UDS_I(n), -1, SV_UDSI_G(n), SV_UDSI_RG(n), NULL);
return;
}
emmakateh is offline   Reply With Quote

Old   October 5, 2023, 04:38
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
shouldn't you get data after computation?
DEFINE_INIT(HFIELD, domain) is a macro to initialize case, gradients are not calculated at that moment, however, I could be wrong
__________________
best regards


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

Old   October 6, 2023, 18:30
Default
  #3
New Member
 
EmmaKate
Join Date: Aug 2023
Posts: 11
Rep Power: 3
emmakateh is on a distinguished road
once I validate the gradient it will be used in a DEFINE_SOURCE loop as I need the magnetic field established to run my simulation to see how the fluid reacts with the magnetic field. This is how I have seen other udfs calculate the gradient of a scalar
emmakateh is offline   Reply With Quote

Reply

Tags
gradient, udf, udmi, udsi, validation


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
Is there a way to access the gradient limiter in Fluent ? CFDYourself FLUENT 1 February 16, 2016 06:49
gradient in fluent maziar FLUENT 0 June 6, 2015 19:49
few quesions on ANSYS ICEMCFD and FLUENT Prakash.Paudel ANSYS 0 August 12, 2010 13:07
Fluent: Mesh Adaption based on Gradient enigma FLUENT 4 July 15, 2010 18:36
FLUENT - velocity gradient Sue Main CFD Forum 1 May 8, 2006 16:09


All times are GMT -4. The time now is 13:10.