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

define shear stress=d2u/dx2

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By zobekenobe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2018, 00:27
Default define shear stress=d2u/dx2
  #1
New Member
 
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8
runyu is on a distinguished road
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)
}
after hook the ajust,change my shear stress I only get my taux=0,and I found my UDS=0 also.
can anybody help me?
runyu is offline   Reply With Quote

Old   May 23, 2018, 08:35
Default
  #2
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
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)
}
runyu likes this.
zobekenobe is offline   Reply With Quote

Old   May 24, 2018, 07:52
Default
  #3
New Member
 
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8
runyu is on a distinguished road
Thank you for your help.And I have tried your code,but I got the segmentation fault when I calculated it.
runyu is offline   Reply With Quote

Old   May 24, 2018, 08:53
Default
  #4
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Did you allocate memory for the UDMI??
zobekenobe is offline   Reply With Quote

Old   May 24, 2018, 09:02
Default
  #5
New Member
 
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8
runyu is on a distinguished road
Quote:
Originally Posted by zobekenobe View Post
Did you allocate memory for the UDMI??
I defined UDM=1,UDS=1
runyu is offline   Reply With Quote

Old   May 24, 2018, 09:26
Default
  #6
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
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
zobekenobe is offline   Reply With Quote

Old   May 24, 2018, 22:40
Default
  #7
New Member
 
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8
runyu is on a distinguished road
Quote:
Originally Posted by zobekenobe View Post
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
hi,zobekennobe,
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?
runyu is offline   Reply With Quote

Old   June 11, 2018, 22:03
Default
  #8
New Member
 
zhangrunyu
Join Date: May 2018
Posts: 5
Rep Power: 8
runyu is on a distinguished road
Dear friend,
I'm extremely grateful to you,and my udf is working now.
runyu is offline   Reply With Quote

Old   June 11, 2018, 22:33
Default
  #9
New Member
 
Peter Parker
Join Date: Oct 2016
Location: Busan, Korea
Posts: 5
Rep Power: 10
letsroll is on a distinguished road
Dear Runyu
May you share the modified code here?
Thank you for your kindness.
letsroll is offline   Reply With Quote

Reply

Tags
c_udsi_g;shear stress


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
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


All times are GMT -4. The time now is 16:39.