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

Fluent crashes on running simulation.

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 2, 2021, 02:38
Default Fluent crashes on running simulation.
  #1
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
Hello all!! I am new to writing UDFs and am trying to model Selective Laser Melting making use of UDF for moving laser as a source term in the energy equation. I am using volume of fluid for this. I have written a UDF for this. The UDF compiles without any error and initializes also without any error. It's just that when I try to run the simulation, FLUENT crashes. I have attached the equation which I am trying to add as a source term, the screenshot of the error and my UDF also. I think there is some issue with the DEFINE_ADJUST which I am using to get gradient of volume fraction.
I request you all to please help me. I would be really grateful as I am facing a lot of difficulty and running out of time.
Thanks in advance.

#include "udf.h"
#include "sg_mphase.h"
#include "mem.h"
#include "sg_mem.h"
#include "math.h"
#include "flow.h"
#include "unsteady.h"
#include "metric.h"

#define A 0.4 // Absorption coefficient
#define P 200 // Laser power
#define R 80e-6 // spot radius
#define v 0.1 // scan speed of laser
#define h 25 // Heat transfer coefficient
#define Ta 298 // Ambient air temperature
#define s 5.67e-8 // Stefan Boltzmann constant
#define e 0.5 // Emmisivity
#define Pi 3.1415926535
#define Ts 1658 // Solidus temperature
#define Tl 1723 // Liquidus temperature
#define x0 100e-6 // Initial x position of the laser
#define y0 0.0 // Intiial y position of the laser
#define domain_ID 3 // Domain ID of metal substrate


DEFINE_INIT(volume_fraction, mixture_domain)
{
int phase_domain_index = 1;
cell_t c;
Thread *t;
Domain *subdomain;
real xc[ND_ND];
sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
{
if(DOMAIN_ID(subdomain) == 3)
thread_loop_c(t,subdomain)
{
begin_c_loop_all(c,t)
{
C_CENTROID(xc,c,t);
if(xc[0] > -0.5e-3 && xc[0] < 0.5e-3 && xc[1] > -0.25e-3 && xc[1] < 0.25e-3 && xc[2] < 0 && xc[2] > -0.3e-3)
C_VOF(c,t) = 1.0;
else
C_VOF(c,t) = 0.0;
}
end_c_loop_all(c,t)
}
}
}




DEFINE_ADJUST(adjust_gradient, mixture_domain)
{
int phase_domain_index = 1;
Thread *t;
cell_t c;
Domain *subdomain = DOMAIN_SUB_DOMAIN(mixture_domain,phase_domain_inde x);

sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
{
if(DOMAIN_ID(subdomain) == 3)
thread_loop_c(t, subdomain)
{
begin_c_loop(c,t)
{
C_UDSI(c,t,0) = C_VOF(c,t);
C_UDMI(c,t,1) = C_UDSI_G(c,t,0)[0];
C_UDMI(c,t,2) = C_UDSI_G(c,t,0)[1];
C_UDMI(c,t,3) = C_UDSI_G(c,t,0)[2];
C_UDMI(c,t,4) = sqrt(C_UDMI(c,t,1)*C_UDMI(c,t,1) + C_UDMI(c,t,2)*C_UDMI(c,t,2) + C_UDMI(c,t,3)*C_UDMI(c,t,3));
}
end_c_loop(c,t)
}
}
}



DEFINE_SOURCE(heat_source, c, t, dS, eqn) // The name of the UDF is heat_source
{
Thread *pri_th;
Thread *sec_th;
real source;
real x[ND_ND], time; // Define face centroid vector, distance, time, exponential for laser and volume to get cell volume
time = RP_Get_Real("flow-time"); // Acquire time from Fluent solver
C_CENTROID(x, c, t); // Acquire the cell centroid location
real T = C_T(c,t);
pri_th = THREAD_SUB_THREAD(t, 0);
sec_th = THREAD_SUB_THREAD(t, 1);

if(C_VOF(c,t)>0.05 && C_VOF(c,t)<1)
{
source = (((2*A*P)/(Pi*R*R))*exp((-2*(pow(x[0]-x0-v*time,2.0) + pow(x[1]-y0,2.0)))/(R*R)) - h*(T-Ta) - s*e*(pow(T,4) - pow(Ta,4)))*C_UDMI(c,t,4);
dS[eqn] = 0.0;
}
else
{
source = 0.0;
dS[eqn] = 0.0;
}
return source;
}
Attached Images
File Type: jpg Untitled4.jpg (108.1 KB, 14 views)
File Type: jpg Untitled3.jpg (107.9 KB, 13 views)
Cooper24 is offline   Reply With Quote

Old   July 2, 2021, 04:07
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I've received an error while compiling your code,
try to use following
Code:
DEFINE_SOURCE(heat_source, c, t, dS, eqn) // The name of the UDF is heat_source
{
Thread *pri_th;
Thread *sec_th;
real source;
real x[ND_ND], time, T; // Define face centroid vector, distance, time, exponential for laser and volume to get cell volume
time = RP_Get_Real("flow-time"); // Acquire time from Fluent solver
C_CENTROID(x, c, t); // Acquire the cell centroid location
T = C_T(c,t);
pri_th = THREAD_SUB_THREAD(t, 0);
sec_th = THREAD_SUB_THREAD(t, 1);

if(C_VOF(c,t)>0.05 && C_VOF(c,t)<1)
{
source = (((2*A*P)/(Pi*R*R))*exp((-2*(pow(x[0]-x0-v*time,2.0) + pow(x[1]-y0,2.0)))/(R*R)) - h*(T-Ta) - s*e*(pow(T,4) - pow(Ta,4)))*C_UDMI(c,t,4);
dS[eqn] = 0.0;
}
else
{
source = 0.0;
dS[eqn] = 0.0;
}
return source;
}
__________________
best regards


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

Old   July 2, 2021, 04:42
Default
  #3
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
Thanks for your reply. Actually I want to multiply tha heat equation term with magnitude of gradient of volume of fraction, as you can see in the attached image in which equation is shown. That is why I have used UDMI for storing the gradient and magnitude of gradient. When I am compiling, it compiles without any error. FLUENT just crashes when I run the simulation. Can you tell if it is the right way to use and multiply with volume fraction gradient??

Thanks
Cooper24 is offline   Reply With Quote

Reply

Tags
sifsegv, udf, volume of fluid

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
Fluent running increadibly slow MayTheFlowBeWithYou FLUENT 12 May 22, 2018 02:04
Error while running a Fluent Simulation in Hpc cluster averageindianjoe FLUENT 0 February 7, 2017 05:10
Having problems running transient fluent simulation in batch mode obylong FLUENT 1 August 14, 2014 23:58
Huge file sizes when Running VOF simulation aarratia FLUENT 0 May 8, 2014 12:27
Replacing mesh while running a simulation akultane CFX 1 November 15, 2009 13:46


All times are GMT -4. The time now is 21:48.