CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Adjusting UDM to UDS (https://www.cfd-online.com/Forums/fluent-udf/118031-adjusting-udm-uds.html)

mvee May 20, 2013 00:50

Adjusting UDM to UDS
 
Hi

I have define adjusted UDM to UDS and for this UDS I am not solving any transport equation, hence default BC i.e flux zero and solution UDS equation in off mode.

Now in the contours of UDM and UDS, there is mismatch at on the boundaries. Because I have used, C_UDMI() = C_UDSI(). This assigns the cell centroid values only. Now in order to assign face centroid values I followed below mentioned ways but it did not work.

(1) define_profile condition on boundaries.
(2) similar to cell centroid adjustment, face centroid adjustment

If any one have tried on this issue. According to you which option should work.

Thanks in advance for your reply
Mvee

mvee May 21, 2013 00:29

any response?

blackmask May 21, 2013 22:48

Have you tried to loop all the face threads and cell threads?
The UDM is not associated with certain type of boundaries.

mvee May 22, 2013 04:27

I opted the second the way i.e adjusted the face centroid values also. This is only possible by Lookup_Thread on defined face thread.

blackmask May 22, 2013 05:18

I speculate that the difference appeared in the contour is due to different interpolation schemes for UDM and UDS. Is the mismatch most apparent at the edge of your b.c.? For two-faced b.c. like interface, the UDM is not defined but I think UDS would be defined there.

mvee May 22, 2013 07:51

I got the solution.
As I told you that for C_UDMI to C_UDSI , the cell centroid values are transfered; while it is considering the BC values on the face which is not the actual physics. Values of the algebraic expression that is stored in memory should transferred everywhere which in turn overwrite the BC. To achieve this in addition to cell centroid values, face centroid values are also incorporated through additional face loop.

blackmask May 22, 2013 08:37

So what is the difference between you final solution and your first post in this thread?

mvee May 23, 2013 02:02

Both the ways are correct. First option you can utilize on the face for which transport equation is required to be solved while second option can be utilized when there is no need of solution of scalar transport equation. Second option requires proper looping macros where I was doing mistake.

gaza January 26, 2016 12:06

Hi mvee,
I assigned C_T to UDS however values are not equall at the boundary.
So I did face looping as you suggested. But it still does not work.
Can you tell me where I do mistake:

Code:

# include "udf.h"
# define domain_ID 1

DEFINE_ADJUST(adjust_gradient, domain)
{
  Thread *t;
  Thread *tf;
  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_T(c,t);
        }
      end_c_loop (c,t)
    }
  tf = Lookup_Thread(domain,11);
  thread_loop_f (tf,domain)
    {
      if (THREAD_STORAGE(tf,SV_UDS_I(0))!=NULL)
      begin_f_loop (f,tf)
        {
          F_UDSI(f,tf,0) = F_T(f,tf);
        }
      end_f_loop (f,tf)
    }
}

DEFINE_ON_DEMAND(store_gradient)
{
  Domain *domain;
  cell_t c;
  face_t f;
  Thread *t;
  Thread *tf;

  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));
          C_UDMI(c,t,0) = C_UDSI(c,t,0);
        }
      end_c_loop (c,t)
    }

    tf = Lookup_Thread(domain,11);
  thread_loop_f (tf,domain)
    {
      if (THREAD_STORAGE(tf,SV_UDS_I(0))!=NULL)
      begin_f_loop (f,tf)
        {
          F_UDMI(f,tf,0) = F_UDSI(f,tf,0);
        }
      end_f_loop (f,tf)
    }
 
 }


mvee January 26, 2016 20:35

I do not see any mistake in UDF. You plot the face centered value of C-T and C-UDS and check its consistency. Keep in mind that node values will differ.

gaza January 27, 2016 02:32

1 Attachment(s)
Quote:

Originally Posted by mvee (Post 582554)
I do not see any mistake in UDF. You plot the face centered value of C-T and C-UDS and check its consistency. Keep in mind that node values will differ.

Hi mvee,

I used this code (the previous one I posted where you did not find any mistake):
Code:

# include "udf.h"
# define domain_ID 1

DEFINE_ADJUST(adjust_gradient, domain)
{
  Thread *t;
  Thread *tf;
  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_T(c,t);
        }
      end_c_loop (c,t)
    }
  tf = Lookup_Thread(domain,11);
  thread_loop_f (tf,domain)
    {
      if (THREAD_STORAGE(tf,SV_UDS_I(0))!=NULL)
      begin_f_loop (f,tf)
        {
          F_UDSI(f,tf,0) = F_T(f,tf);
        }
      end_f_loop (f,tf)
    }
}

DEFINE_ON_DEMAND(store_gradient)
{
  Domain *domain;
  cell_t c;
  face_t f;
  Thread *t;
  Thread *tf;

  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));
          C_UDMI(c,t,0) = C_UDSI(c,t,0);
        }
      end_c_loop (c,t)
    }

    tf = Lookup_Thread(domain,11);
  thread_loop_f (tf,domain)
    {
      if (THREAD_STORAGE(tf,SV_UDS_I(0))!=NULL)
      begin_f_loop (f,tf)
        {
          F_UDMI(f,tf,0) = F_UDSI(f,tf,0);
        }
      end_f_loop (f,tf)
    }
 
 }

In the attachment there is a file with comparison of static temperature (C_T), UDS and UDM values (both cell values and node values).

It is very strange because I only assigned the values and in the file one can see
a lot of differences in resulting values???

Does anybody know how to do it correctly?

mvee January 27, 2016 04:14

thats true!

Values would differ. I donot know reason. You check %age error and if it allowable according to you physics you go ahead with it. You only compare cell values not node values because it follows different method to calculate node value of UDS/UDM and T.

gaza January 27, 2016 05:51

Yes but my really purpose is to calculate gradient on the wall so it can influence on the results. I cannot find any piece of code how to properly assign UDS to UDM. I found only how to assign C_T to UDS:

http://aerojet.engr.ucdavis.edu/flue...df/node235.htm

mvee January 27, 2016 05:55

use first order scheme on wall to calculate grad T and assign it to F-UDS/F-UDM.

gaza January 27, 2016 06:39

it does not work :(
I think that macro for UDM works strange or I coded it in a wrong way??

sumagaji June 26, 2018 04:03

copy UDS to UDM
 
Hello, I have a problem to copy uds to udm using the following code.

Code:

#include "udf.h"
#include"sg.h"
DEFINE_ON_DEMAND(copy_uds_to_udm)
{
Domain*d=Get_Domain(1);
Thread*t;
cell_t c;
thread_loop_c(t,d)
  {
  begin_c_loop(c,t)
  {
  C_UDMI(c,t,0)=C_UDSI(c,t,0);
  }
  end_c_loop(c,t)
  }
  return;
  }

the data was successfully interpolated to uds in Ansys fluent. But the data was not copy to udm. after using the code above.
please anyone help me with this.
Thanks
Umar Sadik

AlexanderZ June 26, 2018 04:30

delete
Code:

return;
best regards


All times are GMT -4. The time now is 14:47.