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

How to add a source term for parallel computing?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 13, 2014, 23:06
Default How to add a source term for parallel computing?
  #1
New Member
 
Zhao An
Join Date: Jul 2014
Posts: 5
Rep Power: 12
8cold8hot is on a distinguished road
My aim is to modify the epsilon equation in the realizable k-epsilon turbulence model.

This is my UDF code:
Code:
#include "udf.h"
#include<math.h>

#define C2 1.9	/* The original value of coefficient  */

DEFINE_SOURCE(source_realizable_e, c, t, dS, eqn)
{
#if !RP_NODE
	real fk = 0.5;	/* The fraction of unresolved kenetic energy to the total */
	real fe = 1.0;	/* The fraction of unresolved rate of dissiptation to the total */
	real source;
	
	real k_temp = C_K(c,t);
	real e_temp = C_D(c,t);
	
	source = -(fk/fe-1)*C2*e_temp*e_temp/(k_temp+sqrt(0.001003/998.2*e_temp));
	dS[eqn] = 0.0;
	
	return source;
#endif	
#if RP_NODE
	dS[eqn] = 0.0;
	return 0.0;
#endif
}

DEFINE_PRANDTL_D(Prandtl_realizable_e, c, t)
{
#if !RP_NODE
	real fk = 0.5;	/* The fraction of unresolved kenetic energy to the total */
	real fe = 1.0;	/* The fraction of unresolved rate of dissiptation to the total */
	
	return 1.2*fk*fk/fe;
#endif

#if RP_NODE
	return 1.2;
#endif
}
May someone tells me that if I uses the right compilation directive? I think the source term shall be added in the host process, is that right?


Thank you in advance!
8cold8hot is offline   Reply With Quote

Old   November 14, 2014, 09:54
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
I don't really know what do you want to do, but try something like this

#include "udf.h"
#include<math.h>

#define C2 1.9 /* The original value of coefficient */

DEFINE_SOURCE(source_realizable_e, c, t, dS, eqn)
{
#if !RP_HOST
real fk = 0.5; /* The fraction of unresolved kenetic energy to the total */
real fe = 1.0; /* The fraction of unresolved rate of dissiptation to the total */
real source;

real k_temp = C_K(c,t);
real e_temp = C_D(c,t);

source = -(fk/fe-1)*C2*e_temp*e_temp/(k_temp+sqrt(0.001003/998.2*e_temp));
dS[eqn] = 0.0;

return source;

#endif
}

DEFINE_PRANDTL_D(Prandtl_realizable_e, c, t)
{
#if !RP_HOST
real fk = 0.5; /* The fraction of unresolved kenetic energy to the total */
real fe = 1.0; /* The fraction of unresolved rate of dissiptation to the total */

return 1.2*fk*fk/fe;
#endif
}

I think that the host process has nothing to do with your code.

Cheers
upeksa 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
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 14:14
add source term in energy equation chaolian OpenFOAM Programming & Development 4 November 8, 2012 23:22
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18
Add time dependent Source term libe OpenFOAM Running, Solving & CFD 13 September 23, 2010 10:12


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