|
[Sponsors] |
May 22, 2018, 00:27 |
define shear stress=d2u/dx2
|
#1 |
New Member
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8 |
Dear all,
I want to define my shear stressx=a*d2u/dx2,and this is my code Code:
# include "udf.h" # include "mem.h" # include "math.h" # define domain_ID 1 DEFINE_ADJUST(adjust_gradient, domain) { Thread *t; cell_t c; face_t f; domain = Get_Domain(domain_ID); /* Fill UDS with the variable. */ thread_loop_c(t,domain) begin_c_loop (c,t) { C_UDSI(c,t,0) = C_DUDX(c,t); } end_c_loop (c,t) } DEFINE_ON_DEMAND(store_gradient) { Domain *domain; face_t f; cell_t c; Thread *t; domain=Get_Domain(1); /* Fill the UDM with magnitude of gradient. */ thread_loop_c(t,domain) begin_c_loop (c,t) { C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0)); } end_c_loop (c,t) } DEFINE_PROFILE(shear_stressx, t,i) { face_t f; cell_t c; real xw[ND_ND],xc[ND_ND],taux; real a = 0.00012; Thread *t0 =THREAD_T0(t); begin_f_loop(f,t) { cell_t c0 = F_C0(f,t); taux = -a*C_UDMI(c0,t0,0); F_PROFILE(f,t,i) =taux; } end_f_loop(f,t) } can anybody help me? |
|
May 23, 2018, 08:35 |
|
#2 |
Member
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17 |
Hi, you can try the code posted below.
I have defined and calculated the UDMI in the define_adjust macro. In the code you posted domain was already passed by fluent in define_adjust so you were overriding it Get_Domain(Domain_ID) also DEFINE_ON_DEMAND doesnt calculate before or after every iteration but only when activated that's one reason why the UDMI was empty and hence giving zeros. Anyway try this and see if there is any difference Code:
DEFINE_ADJUST(adjust_scalar, domain_pointer) { Thread* thread_pointer; cell_t cellt; thread_loop_c(thread_pointer, domain_pointer) { begin_c_loop(cellt, thread_pointer) { C_UDSI(cellt, thread_pointer, 0) = C_DUDX(cellt, thread_pointer); C_UDMI(cellt, thread_pointer, 0) = NV_MAG(C_UDSI_G(cellt, thread_pointer, 0)); } end_c_loop(cellt, thread_pointer) } } DEFINE_PROFILE(shear_stress, thread_pointer, position_index) { face_t facet; cell_t c0; real a = 0.00012; Thread *t0 = thread_pointer->t0; begin_f_loop(facet, thread_pointer) { c0 = F_C0(facet,thread_pointer); F_PROFILE(facet, thread_pointer, position_index) = -a * C_UDMI(c0, t0, position_index); } end_f_loop(facet, thread_pointer) } |
|
May 24, 2018, 07:52 |
|
#3 |
New Member
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8 |
Thank you for your help.And I have tried your code,but I got the segmentation fault when I calculated it.
|
|
May 24, 2018, 08:53 |
|
#4 |
Member
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17 |
Did you allocate memory for the UDMI??
|
|
May 24, 2018, 09:02 |
|
#5 |
New Member
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8 |
||
May 24, 2018, 09:26 |
|
#6 |
Member
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17 |
hey runyu,
I ran the code for a rough geometry I have and it didn't give a segmentation error. Did you allocate memory as Define -> user-defined ->Memory-> Number of user-defined-memory locations = 1 ?? Usually a segmentation error occurs when something goes wrong with the memory allocated |
|
May 24, 2018, 22:40 |
|
#7 | |
New Member
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8 |
Quote:
Thank you for your careful help,I tried it again,and I found it can be calculated,maybe I did something wrong yesterday.But my shear tress still=0.Could it be something wrong with my Settings? |
||
June 11, 2018, 22:03 |
|
#8 |
New Member
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8 |
Dear friend,
I'm extremely grateful to you,and my udf is working now. |
|
June 11, 2018, 22:33 |
|
#9 |
New Member
Peter Parker
Join Date: Oct 2016
Location: Busan, Korea
Posts: 5
Rep Power: 10 |
Dear Runyu
May you share the modified code here? Thank you for your kindness. |
|
Tags |
c_udsi_g;shear stress |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF unit conversion | yeongjia | Fluent UDF and Scheme Programming | 3 | November 5, 2019 06:22 |
metal hydride reactor simulation | srj007 | Fluent UDF and Scheme Programming | 0 | August 28, 2017 03:28 |
udf problem | eb.nabizadeh | Fluent UDF and Scheme Programming | 2 | March 1, 2013 01:28 |
Robin B.C. | Yu | FLUENT | 3 | May 27, 2012 05:19 |
Free surface boudary conditions with SOLA-VOF | Fan | Main CFD Forum | 10 | September 9, 2006 13:24 |