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

Help! Delete the UDM codes in the UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2014, 12:08
Default Help! Delete the UDM codes in the UDF
  #1
New Member
 
Happy_weekend
Join Date: Jan 2014
Posts: 21
Rep Power: 12
Messi is on a distinguished road
Hi, everyone.

This problem really bothers me a lot.

I am using the Define_DPM_Erosion to extend processing for accretion computation in the DPM model.

However, the UDF codes provided by the fluent booklet contain lots of codes related to UDM (UDM check and UDM reset). I really don't know why do we need to contain them in the DPM_Erosion computation and what is their function.

Therefore, I delete the codes related UDM in the UDF. I find that the UDF can also be built and loaded. It can also be used for my erosion computation.

Therefore, could anyone tell me that why do we need the UDM in the Erosion coputation and if we delete it in the UDF, what will happen for the computation.

I provided the whole original code. The first one still contains the UDM codes. However, the second one don't contains the UDM codes. I also show where I delete the codes.

First UDF:
Code:
/***********************************************************************
   UDF*for*extending*postprocessing*of*wall*impacts
*************************************************************************/
*#include*"udf.h"
*
#define MIN_IMPACT_VELO -1000.
/* Minimum particle velocity normal to wall (m/s) to allow Accretion.*/
 
Domain *domain; /* Get the domain pointer and assign it later to domain*/
 
enum   /* Enumeration of used User-Defined Memory Locations. */
  {
    NUM_OF_HITS, /* Number of particle hits into wall face considered.*/
    AVG_DIAMETER, /* Average diameter of particles that hit the wall. */
    AVG_RADI_VELO, /* Average radial velocity of "" "" ------------ */
    NUM_OF_USED_UDM
  };
 
int UDM_checked = 0;  /* Availability of UDMLs checked? */
 
void reset_UDM_s(void); /* Function to follow below. */
 
int check_for_UDM(void)  /* Check for UDMLs availability... */
{
  Thread *t;
  if (UDM_checked)
    return UDM_checked;
 
  thread_loop_c(t,domain) /* We require all cell threads to */
  {       /* provide space in memory for UDML */
     if (FLUID_THREAD_P(t))   if (NULLP(THREAD_STORAGE(t,SV_UDM_I)))
        return 0;
  }
  UDM_checked = 1;  /* To make the following work properly... */
  reset_UDM_s();   /* This line will be executed only once, */
  return UDM_checked; /* because check_for_UDM checks for */
}      /* UDM_checked first. */
 
void reset_UDM_s(void)
{
  Thread *t;
  cell_t c;
  face_t f;
  int  i;
  if (!check_for_UDM()) /* Dont do it, if memory is not available. */
    return;
  Message("Resetting User Defined Memory...\n");
  thread_loop_f(t, domain)
    {
      if (NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
	{
          begin_f_loop(f,t)
	    {
	      for (i = 0; i < NUM_OF_USED_UDM; i++)
		F_UDMI(f,t,i) = 0.;
	    }
          end_f_loop(f, t)
        }
     else
       {
	 Message("Skipping FACE thread no. %d..\n", THREAD_ID(t));
       }
    }
  thread_loop_c(t,domain)
    {
      if (NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
	{
          begin_c_loop(c,t)
	    {
	      for (i = 0; i < NUM_OF_USED_UDM; i++)
		C_UDMI(c,t,i) = 0.;
	    }
          end_c_loop(c,t)
	}
      else
	{
          Message(" Skipping CELL thread no. %d..\n", THREAD_ID(t));
	}
    }    /* Skipping Cell Threads can happen if the user */
  /* uses reset_UDM prior to initializing. */
  Message(" --- Done.\n");
}
 
DEFINE_DPM_EROSION(dpm_accr, p, t, f, normal, alpha, Vmag, Mdot)
{
  real A[ND_ND], area;
  int num_in_data;
  Thread *t0;
  cell_t c0;
  real imp_vel[3], vel_ortho;

#if RP_2D  
  if (rp_axi) 
    {
      real radi_pos[3], radius;
      /* The following is ONLY valid for 2d-axisymmetric calculations!!! */
      /* Additional effort is necessary because DPM tracking is done in */
      /* THREE dimensions for TWO-dimensional axisymmetric calculations. */
      
      radi_pos[0] = P_POS(p)[1];  /* Radial location vector. */
      radi_pos[1] = P_POS(p)[2];  /* (Y and Z in 0 and 1...) */
      radius = NV_MAG(radi_pos);
      NV_VS(radi_pos, =, radi_pos, /, radius);
      /* Normalized radius direction vector.*/
      imp_vel[0] = P_VEL(p)[0]; /* Axial particle velocity component. */
      imp_vel[1] = NVD_DOT(radi_pos, P_VEL(p)[1], P_VEL(p)[2], 0.);
    }
  else
#endif
    NV_V(imp_vel, =, P_VEL(p));
  
  /* Dot product of normalized radius vector and y & z components */
  /* of particle velocity vector gives _radial_ particle velocity */
  /* component */
  vel_ortho = NV_DOT(imp_vel, normal); /*velocity orthogonal to wall */

  if (vel_ortho < MIN_IMPACT_VELO) /* See above, MIN_IMPACT_VELO */
    return;
  
  if (!UDM_checked)   /* We will need some UDMs, */
    if (!check_for_UDM()) /* so check for their availability.. */
      return;    /* (Using int variable for speed, could */
  /* even just call check_for UDFM().) */
  
  c0 = F_C0(f,t);
  t0 = THREAD_T0(t);
  
  F_AREA(A,f,t);
  area = NV_MAG(A);
  F_STORAGE_R(f,t,SV_DPMS_ACCRETION) += Mdot / area;
  
  MARK_PARTICLE(p, P_FL_REMOVED); /* Remove particle after accretion */

  /* F_UDMI not allocated for porous jumps */
  if (THREAD_TYPE(t) == THREAD_F_JUMP)
    return;

  num_in_data  = F_UDMI(f,t,NUM_OF_HITS);
  
  /* Average diameter of particles that hit the particular wall face:*/
  F_UDMI(f,t,AVG_DIAMETER) = (P_DIAM(p)
			      + num_in_data * F_UDMI(f,t,AVG_DIAMETER))
                              / (num_in_data + 1);
  C_UDMI(c0,t0,AVG_DIAMETER) = F_UDMI(f,t,AVG_DIAMETER);
 
  /* Average velocity normal to wall of particles hitting the wall:*/
  F_UDMI(f,t,AVG_RADI_VELO) = (vel_ortho
			       + num_in_data * F_UDMI(f,t,AVG_RADI_VELO))
                               / (num_in_data + 1);
  C_UDMI(c0,t0,AVG_RADI_VELO) = F_UDMI(f,t,AVG_RADI_VELO);
  
  F_UDMI(f, t, NUM_OF_HITS) = num_in_data + 1;
  C_UDMI(c0,t0,NUM_OF_HITS) = num_in_data + 1;

  
}
 
DEFINE_ON_DEMAND(reset_UDM)
{
  /* assign domain pointer with global domain */
  domain = Get_Domain(1);
  reset_UDM_s();
}
Second UDF:

Code:
 /***********************************************************************
   UDF for extending postprocessing of wall impacts
 ************************************************************************/
 
#include "udf.h"
 
#define MIN_IMPACT_VELO -1000.		
 
Domain *domain; 
DEFINE_DPM_EROSION(dpm_accr, p, t, f, normal, alpha, Vmag, Mdot)		
{
  real A[ND_ND], area;			
  int num_in_data;				
  Thread *t0;					
  cell_t c0;					
  real imp_vel[3], vel_ortho;	
  
  vel_ortho = NV_DOT(P_VEL(p), normal); 
   if (vel_ortho < MIN_IMPACT_VELO) 
    return;
  c0 = F_C0(f,t);															
  t0 = THREAD_T0(t);														
  
  F_AREA(A,f,t);															
  area = NV_MAG(A);															
  F_STORAGE_R(f,t,SV_DPMS_ACCRETION) += Mdot / area;
}
Messi is offline   Reply With Quote

Old   January 28, 2014, 06:11
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
The UDM's seem to contain extra information that you might use in post-processing.
There are three UDM's:

0=NUM_OF_HITS, /* Number of particle hits into wall face considered.*/
1=AVG_DIAMETER, /* Average diameter of particles that hit the wall. */
2=AVG_RADI_VELO, /* Average radial velocity of "" "" ------------ */

If you don't need this information, you can remove them, as you did. From a quick look at the code, I don't thing it influences the calculation. However, if you keep them, you get extra information.
pakk is offline   Reply With Quote

Old   January 28, 2014, 09:01
Default
  #3
New Member
 
Happy_weekend
Join Date: Jan 2014
Posts: 21
Rep Power: 12
Messi is on a distinguished road
Quote:
Originally Posted by pakk View Post
The UDM's seem to contain extra information that you might use in post-processing.
There are three UDM's:

0=NUM_OF_HITS, /* Number of particle hits into wall face considered.*/
1=AVG_DIAMETER, /* Average diameter of particles that hit the wall. */
2=AVG_RADI_VELO, /* Average radial velocity of "" "" ------------ */

If you don't need this information, you can remove them, as you did. From a quick look at the code, I don't thing it influences the calculation. However, if you keep them, you get extra information.
Many thanks for your consideration!
I also think that UDM will not affect the computation.
Messi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
Simulation with UDF for species mass fraction and velocity profile virgy Fluent UDF and Scheme Programming 8 February 7, 2012 04:30
Please check out my parallelized udf code aleisia Fluent UDF and Scheme Programming 0 June 10, 2011 16:16
DEFINE_ON_DEMAND UDF: How to declare A[ND_ND], etc jx FLUENT 1 November 6, 2003 17:23
DEFINE_GEOM UDF Problems Pat FLUENT 0 August 14, 2003 13:16


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