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

urgent! Help! Define mass source on boundary cells used UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2021, 03:22
Exclamation urgent! Help! Define mass source on boundary cells used UDF
  #1
New Member
 
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6
ssetay is on a distinguished road
Hi, friends

I am using UDF to define a mass source on the boundary cells,here's my code.
My case is this: particles and water flow in a pipe, and I want to define a mass source for the particle phase in the pipe wall cells.
When I compile this UDF, it works normally, but the volume fraction of particles at the wall has not changed. According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced. I don't know where the error is, but the UDF can work well after compilation. Can anyone help me? Any suggestions will be appreciated!

code:


Code:
//* You are storing source in User defined memory under DEFINE_ON_DEMAND. Then you are using UDMI(c0,t0,0) in DEFINE_SOURCE *//
#include "udf.h"
//get the boundary cells
DEFINE_ON_DEMAND(selecting_the_cells)
{
#if !RP_HOST
	Domain *d;
	Thread *t, *tc, *t0;
	face_t f;
	cell_t c, c0;
	d = Get_Domain(1);
	tc = Lookup_Thread(d, 9); //Get boundary thread, wall zone ID is 9
	//Loop through all the cell threads in the domain
	thread_loop_c(t, d)
	{
		//Loop through the cells in each cell thread
		begin_c_loop(c, t)
		{
			C_UDMI(c, t, 0) = 0;
		}
		end_c_loop(c, t)
	}

	begin_f_loop(f, tc)
	{
		c0 = F_C0(f, tc);
		t0 = THREAD_T0(tc);
		C_UDMI(c0, t0, 0) = 1;
	}
	end_f_loop(f, tc)
#endif
}

DEFINE_SOURCE(mass_source, c, t, dS, eqn)
{
	real source;
	if (C_UDMI(c, t, 0) > 0.)
	{
		source = -1000.;
		dS[eqn] = 0.;
	}
	else
	{
		source = 0.;
		dS[eqn] = 0.;
	}
	return source;
}
Attached Files
File Type: c mass_rouce0.c (1,004 Bytes, 18 views)
ssetay is offline   Reply With Quote

Old   March 14, 2021, 05:29
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
"According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced."

I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work?

Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   March 14, 2021, 21:06
Default
  #3
New Member
 
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6
ssetay is on a distinguished road
Thanks for your suggestion, and sorry for my late reply.

"I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work?"
To be honest, I want to use UDM0 to distinguish wall cells. As you just said, UDM0 is 1 in the wall cells and 0 in other cells; In this way, I can specify the source in the wall cell in the following if statement (if (C_UDMI(c, t, 0)> 0.)). Is there anything wrong with this? please give me some advice.

"Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model."
I'm sorry I didn't understand you. I am a UDF rookie... Do you mean there is a problem with my UDF0 usage method?


Any suggestions will be appreciated.
best wishes
ssetay is offline   Reply With Quote

Old   March 15, 2021, 02:30
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I hadn't noticed the second UDF.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   March 17, 2021, 22:46
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you code seems to be correct,
do you see what you want, when making contour of C_UDMI_0 ?
are you sure, that -1000 is value which you want? check units
__________________
best regards


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

Old   March 18, 2021, 06:27
Default
  #6
New Member
 
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6
ssetay is on a distinguished road
Thanks Reply! Now it works great because I forgot to load it...
ssetay is offline   Reply With Quote

Reply

Tags
fluent, udf and programming


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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 10:17
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 18:44


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