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

Cleaning UDM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 6, 2014, 04:49
Default Cleaning UDM
  #1
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
Hi all,

I wrote a small DPM_SCALAR_UPDATE script which stores some stuff in a UDM(c,t,0). These UDM variables are needed in the next timestep, but they should be reset to 0 before the next particle update. Since not every cell contains a particle at every timestep, I do this in a loop inside the DPM_SCALAR_UPDATE script. Furthermore I use a secondary UDM(c,t,1) as a boolean to indicate if a cell has been reset or not. This happens in another UDF during a downstream processing step. In practice, this looks like:

Code:
if (C_UDMI(c,t,1) > 0)
{

domain=Get_Domain(1);

  thread_loop_c (tr,domain)
    {
       begin_c_loop (cell,tr)
         {

C_UDMI(cell,tr,0) = 0;
C_UDMI(cell,tr,1) = 0;

         }
       end_c_loop (cell,tr)
    }
}
In serial mode, this works fine; the complete UDM field gets cleaned as soon as DPM iterations start and afterwards the UDM can be filled again without problems.

If I run in parallel however, the routine only resets the UDM in the partitions that contain a particle. Although in practice there are nearly always particles in every partition, this could theoretically lead to improper memory cleaning and thereby mass imbalances in other UDFs linked to this UDM.

Does anyone have a suggestion to properly clean the memory, by not just looping over all cells in this partition, but by all cells in the entire mesh?

Thanks!
Cees
CeesH is offline   Reply With Quote

Old   August 6, 2014, 06:01
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I used something like this (I removed some lines from my code that you don't need, I did not test this version but I think it should still work).

I used it in serial mode, but probably it should work in parallel too.

Code:
DEFINE_ON_DEMAND(cleanUDM)
  {
	Domain *domain = Get_Domain(ROOT_DOMAIN_ID);
	Thread *t;
	cell_t c;

	Alloc_Storage_Vars(domain, SV_RTMP_0, SV_NULL);

	thread_loop_c(t,domain) {
		if (THREAD_ID(t)!=0) {
			begin_c_loop(c,t) {
				C_UDMI(c,t,0)=0
			}
		}
	end_c_loop(c,t)
	}
  }
pakk is offline   Reply With Quote

Old   August 6, 2014, 06:07
Default
  #3
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
Thanks Pakk, I'll give it a try.
CeesH is offline   Reply With Quote

Old   August 6, 2014, 10:32
Default
  #4
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
I implemented the piece of code in my DPM_SCALAR_UPDATE UDF (can't use execute at end or define on demand as I need the values in the next timestep).

Unfortunately, it didn't work. Like before only the cells in the partition that contained a particle got cleaned out, while the others were not..

EDIT:
Also using both a c_loop_int and c_loop_ext in the routine did not work..
CeesH is offline   Reply With Quote

Old   August 7, 2014, 04:33
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I think that is because the DPM_SCALAR_UPDATE UDf is only called if DPM particles are found. You might have better luck with a DEFINE_ADJUST UDF.
pakk is offline   Reply With Quote

Old   August 7, 2014, 05:28
Default
  #6
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
That might be the case indeed; problem is that the define_adjust routine is called before species and energy equation update, and I need the UDM values during those updates.

If I'm correct, the DPM routine is called after the scalar fields have been treated, and at that point the memory is to be erased. So far this approach has been working well, provided indeed there is a particle in the partition domain.
CeesH is offline   Reply With Quote

Old   August 7, 2014, 06:11
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
One problem with your original code is that it is evaluated for every cell where there is a particle.
If there are 10000 particles, the domain will be 'cleaned' 10000 times. This is not necessarily wrong, but inefficient.
More ideally, you need one flag per domain. You can do that be defining a global variable (assuming there is one domain, otherwise make it an array):
Code:
int domainisclean=1;
Every time you change the UDM, update this variable:
Code:
domainisclean=-1;
Then you can change your code to
Code:
if (domainisclean < 0)
{

domain=Get_Domain(1);

  thread_loop_c (tr,domain)
    {
       begin_c_loop (cell,tr)
         {
            C_UDMI(cell,tr,0) = 0;
         }
       end_c_loop (cell,tr)
    }
domainisclean=1;
}
But this does not answer your question... I don't know the answer to that question. Maybe this is a good time to involve the Ansys support!
pakk is offline   Reply With Quote

Old   August 7, 2014, 06:38
Default
  #8
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
Hi Pakk,

The loop is only executed if there the boolean UDM is 1; so once per partition. But in terms of memory it is indeed not efficient, 1 boolean per partition would be sufficient, rather than 1 per cell..

Indeed, time to contact ansys support. Thanks for your help anyway!

Best
cees
CeesH is offline   Reply With Quote

Old   August 7, 2014, 07:17
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by CeesH View Post
The loop is only executed if there the boolean UDM is 1; so once per partition. But in terms of memory it is indeed not efficient, 1 boolean per partition would be sufficient, rather than 1 per cell..
You are right, I forgot about that.
pakk is offline   Reply With Quote

Reply

Tags
dpm, reset, scalar, transient, udm


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
Segmentation violation louiza FLUENT 16 June 27, 2017 15:41
Help! Delete the UDM codes in the UDF Messi Fluent UDF and Scheme Programming 2 January 28, 2014 09:01
Udm nasser FLUENT 0 April 7, 2013 09:19
UDS stored to UDM do not show the same values swati_mohanty FLUENT 0 December 3, 2010 03:46
No data is written into UDM ivanbuz Fluent UDF and Scheme Programming 1 August 13, 2009 18:49


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