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

UDF in case with DPM modle

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 3, 2021, 07:21
Default UDF in case with DPM modle
  #1
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Hi, all

I am trying to get the particle numbers in each cell and then calculate the particle concentration in each cell. I have used a UDF, which contains the loop(I, Ilist), loop(p,I->p), C_UDMI, and so on.

After the calculation, I have check the contour of C_UDMI_0 and C_UDMI_1, they are similar to the contour of the DPM parcels or particles. However, when I want to write the C_UDMI of each cell to a exernal txt file, there are some problems.

In my case, the whole flow field is consisted by two zones, i.e., fluid 1 and fluid 2. There are 124800 cells in each fluid zone.

In the outputed txt file, only the cells in fluid 1 were considered, and the UDF outputs these cells again and again. I wonder what happened and what should I do to get a right way to output these data.

Thanks a lot.

My UDF file is attached.

Code:
 #include "udf.h"

DEFINE_ADJUST(particle_cells_count,d)
{
	if ((CURRENT_TIME==0)||(CURRENT_TIME==0.01))
	{
	Thread *t;
	char filename[256];

	Injection *Ilist;
	Injection *I;
	Particle *p;


	cell_t c;
	Thread *c_t;

	int parcel_trapped = 0;
	real num_particles=0.;
	real num_particles_in_total=0.;
	real number_in_parcel=0.;


	Ilist = Get_dpm_injections();

	loop(I, Ilist)
	{
		loop(p, I->p)
		{
			c = P_CELL(p);
			c_t = P_CELL_THREAD(p);
			parcel_trapped+=1;
			num_particles=p->number_in_parcel;
			C_UDMI(c,c_t,0)=C_UDMI(c,c_t,0)+1.;
			C_UDMI(c,c_t,1)=C_UDMI(c,c_t,1)+num_particles;
			num_particles_in_total=num_particles_in_total+num_particles;
			num_particles=0.;
			Message("num_particles_in_total: %f",num_particles_in_total);
			Message("parcel_trapped: %d",parcel_trapped);
			//Message("pacel %d is in cell %d\n",parcel_trapped,c);
			//Message("There are %f particles in parcel %d\n",num_particles,parcel_trapped);
		}
	}
	FILE *fpwrite;

	thread_loop_c(t,d)
	{
		begin_c_loop(c,c_t)
		{
			sprintf(filename,"parcelsconcenincells%f.txt",CURRENT_TIME);
			fpwrite= fopen(filename,"a+");
			if (fpwrite == NULL)
			{
			return 0;
			}
			fprintf(fpwrite,"There are %f parcels in cell %d \n",C_UDMI(c,c_t,0),c);
			fclose(fpwrite);
			char filename[256];

			sprintf(filename,"particlesconcenincells%f.txt",CURRENT_TIME);
			fpwrite=fopen(filename,"a+");
			if (fpwrite == NULL)
			{
			return 0;
			}
			fprintf(fpwrite,"There are %f particles in cell %d \n",C_UDMI(c,c_t,1),c);
			fclose(fpwrite);
		}
		end_c_loop(c,c_t)
	}
}
}
Some of the outputed txt file is shown bellow.

There are 19.414102 particles in cell 0
There are 26.287837 particles in cell 1
There are 29.934247 particles in cell 2
There are 26.287837 particles in cell 3
There are 19.414102 particles in cell 4
There are 23.331015 particles in cell 5
There are 30.204750 particles in cell 6
There are 33.851161 particles in cell 7
......
There are 36.954978 particles in cell 124790
There are 53.476081 particles in cell 124791
There are 62.240273 particles in cell 124792
There are 53.476081 particles in cell 124793
There are 23.331016 particles in cell 124794
There are 19.414101 particles in cell 124795
There are 26.287835 particles in cell 124796
There are 29.934246 particles in cell 124797
There are 26.287835 particles in cell 124798
There are 9.707051 particles in cell 124799
There are 19.414102 particles in cell 0
There are 26.287837 particles in cell 1
There are 29.934247 particles in cell 2
There are 26.287837 particles in cell 3
There are 19.414102 particles in cell 4
There are 23.331015 particles in cell 5
There are 30.204750 particles in cell 6
There are 33.851161 particles in cell 7
There are 30.204750 particles in cell 8
There are 23.331015 particles in cell 9
There are 27.152663 particles in cell 10
There are 34.026397 particles in cell 11
There are 37.672808 particles in cell 12
......

My flow field is shown in the attached picture.

Thanks a lot!
Attached Images
File Type: png QQ图片20210303202040.png (53.7 KB, 6 views)
POSTHU is offline   Reply With Quote

Reply


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
The udf of specific heat can load but leading the case divergence Kobe Peng Fluent UDF and Scheme Programming 2 July 8, 2018 19:11
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT subhankar_bhandari Main CFD Forum 0 August 19, 2010 03:01
please help me. i have question about the UDF at the DPM motallebi FLUENT 0 July 6, 2009 11:27
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 01:29
So many questions in DPM & UDF - Help! URGENT! Prashanth FLUENT 0 March 3, 2009 22:26


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