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

Define_source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 23, 2020, 04:55
Smile Define_source
  #1
New Member
 
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6
yingjie.li is on a distinguished road
Hi,all

I want to include an absorption on a wall. So I stored the area in DEFINE_ON_DEMAND, as below. Is there anything wrong? Thank you for your time!

begin_f_loop(f, tc)
{
c0 = F_C0(f, tc);
t0 = THREAD_T0(tc);
C_UDMI(c0, t0, 0) = 1;
BOUNDARY_FACE_GEOMETRY(f, tc, A, ds, es, A_by_es, dr0);
area = NV_MAG(A);
C_UDMI(c0, t0, 1) = area;
}
end_f_loop(f, tc)
yingjie.li is offline   Reply With Quote

Old   December 23, 2020, 05:21
Default
  #2
New Member
 
amine
Join Date: Dec 2020
Posts: 7
Rep Power: 6
djendara is on a distinguished road
Hi , i think that you d'ont need to use BOUNDARY_FACE_GEOMETRY(f, tc, A, ds, es, A_by_es, dr0); since you are not computing flux in skewed mesh region inside boundaries
djendara is offline   Reply With Quote

Old   December 23, 2020, 06:47
Default
  #3
New Member
 
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6
yingjie.li is on a distinguished road
Quote:
Originally Posted by djendara View Post
Hi , i think that you d'ont need to use BOUNDARY_FACE_GEOMETRY(f, tc, A, ds, es, A_by_es, dr0); since you are not computing flux in skewed mesh region inside boundaries
Dear Sir,

I have a curve that fits from the test data with units kg/m²-s. Although I'm not computing flux, but i need its area and volume to change its unit to kg/m³-s. For use in DEFINE_SOURCE. Or do I distort 'Flux in skewed mesh' in your reply?

Thank you for your time!
yingjie.li is offline   Reply With Quote

Old   December 24, 2020, 02:16
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
DEFINE_ON_DEMAND(get_face_area)
{
	Domain *d;
	Thread *t; 
	face_t f;
	int i,thread_id;
	real area = 0.0;
	real A[ND_ND];
	d = Get_Domain(1); 
	area = 0.0;
	thread_id = *** put here ID of face ***;
	t = Lookup_Thread(d, thread_id);
	begin_f_loop(f,t)
		if PRINCIPAL_FACE_P(f,t)
		{
			F_AREA(A,f,t);
			area+=NV_MAG(A);
		}
	end_f_loop(f,t)
	# if RP_NODE /* Perform node synchronized actions here; Does nothing in Serial */
		area = PRF_GRSUM1(area);
	# endif /* RP_NODE */
	Message0("Area of face %d is %e\n",thread_id,area);
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 28, 2020, 00:43
Default
  #5
New Member
 
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6
yingjie.li is on a distinguished road
Dear AlexanderZ,

First of all, Thank you very much for the code you provided, which is very useful. Then I added some other code in it, but it doesn't work. I don't know whether it is a mistake in principle or a mistake in logic. Could you please help me have a look, this has been bothering me for several days.

Thank you for your time!

Quote:
Originally Posted by AlexanderZ View Post
Code:
begin_f_loop(f, tc)
		if PRINCIPAL_FACE_P(f, tc)
		{
			c0 = F_C0(f, tc); 
			t0 = THREAD_T0(tc);
			C_UDMI(c0, t0, 0) = 1;
			F_AREA(A, f, tc);
			area = NV_MAG(A);
			F_UDMI(c0, t0, 1) = area;
			volume = C_VOLUME(c0, t0);
			C_UDMI(c0, t0, 2) = volume;
			/********/
			mixture_species_loop(mix_mat, sp, i)
			{
				Mw = MATERIAL_PROP(sp, PROP_mwi);
				total_mole += C_YI(c0, t0, i) / Mw;
		        }
			co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole;
			P_total = ABS_P(C_P(c0, t0), op_pres);
			P_co2 = P_total * co2_mole_fract;
			C_UDMI(c0, t0, 3) = P_co2;
                        /********/
			Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(c0, t0, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3));
		}
end_f_loop(f, t)
Node 4: Process 20420: Received signal SIGSEGV.

================================================== ============================
errsignal.c:CX_Signal_monitor_system_propagate_err or: 722==> myid 1: Failure to print error message in async signal safe manner.
yingjie.li is offline   Reply With Quote

Old   December 28, 2020, 01:23
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try this code:
Code:
	begin_f_loop(f, t)
		if PRINCIPAL_FACE_P(f, t)
		{
			c0 = F_C0(f, t); 
			t0 = THREAD_T0(t);
			C_UDMI(c0, t0, 0) = 1;
			F_AREA(A, f, t);
			area = NV_MAG(A);
			F_UDMI(f, t, 1) = area;
			volume = C_VOLUME(c0, t0);
			C_UDMI(c0, t0, 2) = volume;
			/********/
			mixture_species_loop(mix_mat, sp, i)
			{
				total_mole += C_YI(c0, t0, i) / MATERIAL_PROP(sp, PROP_mwi);
		    }
			co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole;
			P_total = ABS_P(C_P(c0, t0), op_pres);
			P_co2 = P_total * co2_mole_fract;
			C_UDMI(c0, t0, 3) = P_co2;
                        /********/
			Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(f, t, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3));
		}
	end_f_loop(f, t)
allocate 4 user defined location in Fluent graphical interface
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 28, 2020, 02:52
Default
  #7
New Member
 
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6
yingjie.li is on a distinguished road
Dear AlexanderZ,

I tried the code, but still 'Received signal SIGSEGV'. So allow me to post the entire code. According to your code, everything works fine, but problems arise with the addition of my 'mixture_species_loop'. By the way, allocated 4 user defined location.

Thank you for your time!

Quote:
Originally Posted by AlexanderZ View Post
try this code:
Code:
	DEFINE_ON_DEMAND(get_face_are)
{
#if !RP_HOST
	cell_t c, c0;
	Domain *d;
	Thread *tc, *t0, *t;
	face_t f;
	int i, thread_id;
	real area, volume, P_co2, total_mole, co2_mole_fract, P_total;
	real A[ND_ND];
	d = Get_Domain(1);
	area = 0.0;
	volume = 0.0;
	thread_id = 10;
	P_co2 = 0.0;
	total_mole = 0.0;
	co2_mole_fract = 0.0;
	real mw_co2 = 44.0095;
	tc = Lookup_Thread(d, thread_id);
	Material *mix_mat, *sp;
	mix_mat = mixture_material(d);
	thread_loop_c(t, d)
	{
		begin_c_loop(c, t)
		{
			C_UDMI(c, t, 0) = 0;
		}
		end_c_loop(c,t)
	}
	begin_f_loop(f, tc)
		if PRINCIPAL_FACE_P(f, tc)
		{
			c0 = F_C0(f, tc); 
			t0 = THREAD_T0(tc);
			C_UDMI(c0, t0, 0) = 1;
			F_AREA(A, f, tc);
			area = NV_MAG(A);
			F_UDMI(f, t, 1) = area;
			volume = C_VOLUME(c0, t0);
			C_UDMI(c0, t0, 2) = volume;
			/**/
			mixture_species_loop(mix_mat, sp, i)
			{
				total_mole += C_YI(c0, t0, i) / MATERIAL_PROP(sp, PROP_mwi);
		    }
			co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole;
			P_total = ABS_P(C_P(c0, t0), op_pres);
			P_co2 = P_total * co2_mole_fract;
			C_UDMI(c0, t0, 3) = P_co2;
			Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(f, t0, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3));
		}
	end_f_loop(f, t)
#endif
}
allocate 4 user defined location in Fluent graphical interface
yingjie.li is offline   Reply With Quote

Old   December 31, 2020, 05:34
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
FIRST of all, compile your code and read log! Code which you've put above has a lot of problems.
Try this one

Code:
#include "udf.h"

DEFINE_ON_DEMAND(get_face_are)
{
#if !RP_HOST
	cell_t c, c0;
	Domain *d;
	Thread *tc, *t0, *t;
	face_t f;
	int i, thread_id;
	real area, volume, P_co2, total_mole, co2_mole_fract, P_total,mw_co2;
	real A[ND_ND];
	Material *mix_mat, *sp;
	d = Get_Domain(1);
	area = 0.0;
	volume = 0.0;
	thread_id = 10;
	P_co2 = 0.0;
	total_mole = 0.0;
	co2_mole_fract = 0.0;
	mw_co2 = 44.0095;
	tc = Lookup_Thread(d, thread_id);
	mix_mat = THREAD_MATERIAL(t);
	thread_loop_c(t, d)
	{
		begin_c_loop(c, t)
		{
			C_UDMI(c, t, 0) = 0;
		}
		end_c_loop(c,t)
	}
	begin_f_loop(f, tc)
		if PRINCIPAL_FACE_P(f, tc)
		{
			c0 = F_C0(f, tc); 
			t0 = THREAD_T0(tc);
			C_UDMI(c0, t0, 0) = 1;
			F_AREA(A, f, tc);
			area = NV_MAG(A);
			F_UDMI(f, t, 1) = area;
			volume = C_VOLUME(c0, t0);
			C_UDMI(c0, t0, 2) = volume;
			/**/
			mixture_species_loop(mix_mat, sp, i)
			{
				total_mole += C_YI(c0, t0, i) / MATERIAL_PROP(sp, PROP_mwi);
		    }
			co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole;
			P_total = ABS_P(C_P(c0, t0), op_pres);
			P_co2 = P_total * co2_mole_fract;
			C_UDMI(c0, t0, 3) = P_co2;
			Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(f, t0, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3));
		}
	end_f_loop(f, t)
#endif
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 3, 2021, 22:02
Default
  #9
New Member
 
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6
yingjie.li is on a distinguished road
Dear AlexanderZ,

Thank you very much for your patient answers and professional code. Based on your code, I updated some variables and it's working properly!

Quote:
Originally Posted by AlexanderZ View Post
FIRST of all, compile your code and read log! Code which you've put above has a lot of problems.
Try this one
yingjie.li is offline   Reply With Quote

Reply

Tags
area, source, udmi


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



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