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

Eulerian-Eulerian Source Term

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By camilo_costa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 22, 2016, 21:00
Exclamation Eulerian-Eulerian Source Term
  #1
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Hi!!!

I am trying to simulate a 2D, transient and Eulerian-Eulerian problem. I want to create a source term in x-mon and y-mon directions for both gas and liquid phases.
The equation of source term is showed in the figure. My code for create the source term in gas for x-direction is:

Code:
DEFINE_SOURCE(intforcexg, c, tm, dS, eqn)
{
	real dotprot_CUG_CVOF_gas;
	real dotprot_CUG_CVOF_liq;
	real C_T = 1;
	real source;
	real A_i;
	real diam = 1e-5;

	Thread *t = THREAD_SUPER_THREAD(tm);
	Thread *tg = THREAD_SUB_THREAD(t, gas_zone);
	Thread *tl = THREAD_SUB_THREAD(t, liq_zone);

	if ((NULL != THREAD_STORAGE(tg, SV_VOF_G)) && (NULL != THREAD_STORAGE(tg,
		SV_U_G)) && (NULL != THREAD_STORAGE(tl, SV_VOF_G)) &&
		(NULL != THREAD_STORAGE(tl, SV_U_G))) {

		dotprot_CUG_CVOF_gas = NV_DOT(C_U_G(c, tg), C_VOF_G(c, tg));
		dotprot_CUG_CVOF_liq = NV_DOT(C_U_G(c, tl), C_VOF_G(c, tl));
		
		A_i = 6. * C_VOF(c, tg) * C_VOF(c, tl) / diam;

		source = (-C_T * C_VOF(c, tg) * C_MU_EFF(c, tg) * dotprot_CUG_CVOF_gas -
			C_T * C_VOF(c, tl) * C_MU_EFF(c, tl) * dotprot_CUG_CVOF_liq) * A_i;
			
		//C_UDMI(c, t, 0) = source;
		return source;
	}

	else {
		return 0;
	}
}
I able to store the gradients in memory like described in udf manual.
When I try to run with x-source force appears this msg:
Error: received a fatal signal (Segmentation fault).
Error Object: #f

I am lost, anyone could help me?

Best Regards!!!
Attached Images
File Type: png Equation.png (10.8 KB, 15 views)
camilo_costa is offline   Reply With Quote

Old   June 23, 2016, 10:05
Default
  #2
Member
 
Rajukiran Antham
Join Date: Dec 2012
Location: Sweden
Posts: 41
Rep Power: 13
RAJ KIRAN is on a distinguished road
You are missing dS[eqn] in your UDF.
RAJ KIRAN is offline   Reply With Quote

Old   June 23, 2016, 17:19
Default
  #3
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Thank you RAJ KIRAN.
But is really necessary declare
Code:
dS[eqn] = 0;
for all define_source problems?

Recentelly I discover that the fluent not disponibilize the C_VOF_G, and is necessary compute him. I find two ways for resolve this problem.
First:
Code:
DEFINE_ADJUST(adjust_gradient_g, gas_dom)
{
	Thread *t;
	cell_t c;
	face_t f;
	gas_dom = Get_Domain(gas_id);

	/* Fill UDS with the variable. */
	thread_loop_c(t, gas_dom) {
		begin_c_loop(c, t) {
			C_UDSI(c, t, 0) = C_VOF(c, t);
		}
		end_c_loop(c, t)
	}

	thread_loop_f(t, gas_dom) {
		if (THREAD_STORAGE(t, SV_UDS_I(0)) != NULL)
			begin_f_loop(f, t) {
			F_UDSI(f, t, 0) = F_VOF(f, t);
			}
		end_f_loop(f, t)
	}
}

DEFINE_ADJUST(adjust_gradient_l, liq_dom)
{
	Thread *t;
	cell_t c;
	face_t f;
	liq_dom = Get_Domain(liq_id);

	/* Fill UDS with the variable. */
	thread_loop_c(t, liq_dom) {
		begin_c_loop(c, t) {
			C_UDSI(c, t, 1) = C_VOF(c, t);
		}
		end_c_loop(c, t)
	}

	thread_loop_f(t, liq_dom) {
		if (THREAD_STORAGE(t, SV_UDS_I(1)) != NULL)
			begin_f_loop(f, t) {
			F_UDSI(f, t, 1) = F_VOF(f, t);
			}
		end_f_loop(f, t)
	}
}
Second:
Code:
DEFINE_ADJUST(store_gradient_g, domain)
{
	Thread *t;
	Thread **pt;
	cell_t c;
	int phase_domain_index = 0.;
	Domain *pDomain = DOMAIN_SUB_DOMAIN(domain, phase_domain_index);
	{
		Alloc_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
		Scalar_Reconstruction(pDomain, SV_VOF, -1, SV_VOF_RG, NULL);
		Scalar_Derivatives(pDomain, SV_VOF, -1, SV_VOF_G, SV_VOF_RG,
			Vof_Deriv_Accumulate);
	}

	mp_thread_loop_c(t, domain, pt)
	if (FLUID_THREAD_P(t)) {
		Thread *ppt = pt[phase_domain_index];

		begin_c_loop(c, t) {
			C_UDMI(c, t, 0) = C_VOF_G(c, ppt)[0];
			C_UDMI(c, t, 1) = C_VOF_G(c, ppt)[1];
			C_UDMI(c, t, 2) = C_VOF_G(c, ppt)[2];
		}
		end_c_loop(c, t)
	}
	Free_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
}

DEFINE_ADJUST(store_gradient_l, domain)
{
	Thread *t;
	Thread **st;
	cell_t c;
	int phase_domain_index = 1.;
	Domain *sDomain = DOMAIN_SUB_DOMAIN(domain, phase_domain_index); {
		Alloc_Storage_Vars(sDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
		Scalar_Reconstruction(sDomain, SV_VOF, -1, SV_VOF_RG, NULL);
		Scalar_Derivatives(sDomain, SV_VOF, -1, SV_VOF_G, SV_VOF_RG,
			Vof_Deriv_Accumulate);
	}

	mp_thread_loop_c(t, domain, st)
	if (FLUID_THREAD_P(t)) {
		Thread *ppt = st[phase_domain_index];

		begin_c_loop(c, t) {
			C_UDMI(c, t, 1) = C_VOF_G(c, ppt)[0];
			C_UDMI(c, t, 4) = C_VOF_G(c, ppt)[1];
			C_UDMI(c, t, 5) = C_VOF_G(c, ppt)[2];
		}
		end_c_loop(c, t)
	}
	Free_Storage_Vars(sDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
}
Both is good, but the second I think that is possible retrieve the C_UDSI_G direct.
Don't forget is possible to dissable the solution of uds in your flow. Just disable in Controls -> Equations.
Wang Changjun likes this.
camilo_costa is offline   Reply With Quote

Old   June 24, 2016, 06:36
Default
  #4
Member
 
Rajukiran Antham
Join Date: Dec 2012
Location: Sweden
Posts: 41
Rep Power: 13
RAJ KIRAN is on a distinguished road
Yes, it is necessary to declare dS[eqn]. By setting it to 0 you pass only the the explicit part of the source code. If you want you can also pass the implicit part of the source, this enhances the stability of the solution and will help convergence rates. (According to the manual, you can read more about this in manual)

I used the second code to calculate the volume fraction gradient. It worked without any problems. I think you can also get the same thing done by using UDS, but I did not try this before.
RAJ KIRAN is offline   Reply With Quote

Old   June 24, 2016, 08:57
Default
  #5
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Quote:
Originally Posted by raj kiran View Post
yes, it is necessary to declare ds[eqn]. By setting it to 0 you pass only the the explicit part of the source code. If you want you can also pass the implicit part of the source, this enhances the stability of the solution and will help convergence rates. (according to the manual, you can read more about this in manual)

i used the second code to calculate the volume fraction gradient. It worked without any problems. I think you can also get the same thing done by using uds, but i did not try this before.
Thx RAJ KIRAN!!!
camilo_costa is offline   Reply With Quote

Old   June 24, 2016, 10:03
Default
  #6
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Was observed a differences between the tow methods for obtain the gradient of VOF. See the figures!!!
What is the most correctely?
Attached Images
File Type: png C_VOF_G.png (29.1 KB, 25 views)
camilo_costa is offline   Reply With Quote

Old   June 28, 2016, 12:19
Default C_mu_eff
  #7
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Hi Guys!!
I resolved the almost problems, but I can't retrieve the value of C_MU_EFF!! What is wrong in the code?

Code:
DEFINE_ADJUST(intforcexg, d)
{
	cell_t c;
	Thread *t;
	Thread **pt = THREAD_SUB_THREADS(t);
	Thread *tg = pt[0];
	Thread *tl = pt[1];

	real source;
	real c_mu_eff_l;
	real C_T = 1;

	mp_thread_loop_c(t, d, tl) {
		if (FLUID_THREAD_P(t)) {
			begin_c_loop(c, t) {
				c_mu_eff_l = C_MU_EFF(c, t);
				C_UDMI(c, t, 5) = c_mu_eff_l;
			}
			end_c_loop(c, t)
		}

	}
}
camilo_costa is offline   Reply With Quote

Old   June 28, 2016, 14:05
Default
  #8
Member
 
Camilo Costa
Join Date: Jun 2009
Posts: 34
Rep Power: 16
camilo_costa is on a distinguished road
Quote:
Originally Posted by camilo_costa View Post
Hi Guys!!
I resolved the almost problems, but I can't retrieve the value of C_MU_EFF!! What is wrong in the code?

Code:
DEFINE_ADJUST(intforcexg, d)
{
	cell_t c;
	Thread *t;
	Thread **pt = THREAD_SUB_THREADS(t);
	Thread *tg = pt[0];
	Thread *tl = pt[1];

	real source;
	real c_mu_eff_l;
	real C_T = 1;

	mp_thread_loop_c(t, d, tl) {
		if (FLUID_THREAD_P(t)) {
			begin_c_loop(c, t) {
				c_mu_eff_l = C_MU_EFF(c, t);
				C_UDMI(c, t, 5) = c_mu_eff_l;
			}
			end_c_loop(c, t)
		}

	}
}
Resolved!!
Code:
DEFINE_ADJUST(intforcexg, domain)
{
	real mu_eff_g;
	real mu_eff_l;
	Thread *t;
	Thread **pt;
	cell_t c;

	mp_thread_loop_c(t, domain, pt)
	if (FLUID_THREAD_P(t)) {
		Thread *tp = pt[P_PHASE];
		begin_c_loop(c, t) {
			mu_eff_g = C_MU_EFF(c, tp);
			C_UDMI(c, t, 5) = mu_eff_g;
		}
		end_c_loop(c, t)
	}
	mp_thread_loop_c(t, domain, pt)
	if (FLUID_THREAD_P(t)) {
		Thread *tp = pt[S_PHASE];
		begin_c_loop(c, t) {
			mu_eff_l = C_MU_EFF(c, tp);
			C_UDMI(c, t, 6) = mu_eff_l;
		}
		end_c_loop(c, t)
	}
}
camilo_costa is offline   Reply With Quote

Reply

Tags
c_u_g, c_vof, define_source, eurelian

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Source Term due to evaporation in energy transport equation styleworker OpenFOAM Programming & Development 3 September 7, 2022 04:09
[OpenFOAM.org] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 18:25
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 02:41
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41


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