Kanak BUET19
Bbp_participant

 

I have no idea sir :)) But I have worked something out :

I have run the code ( added below) and the heat source part perfectly worked out ( i.e its being applied to where 0

Code : 

 

#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”

// Constants
#define A 0.4 // Absorption coefficient
#define P 200 // Laser power (W)
#define R 40e-6 // Spot radius (m)
#define v 0.5 // Scan speed of laser (m/s)
#define Pi 3.1415926535 // Pi constant
#define x0 0.2e-3 // Initial x position of the laser (m)
#define y0 0.1e-3 // Initial y position of the laser (m)

#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”

// UDF for adjusting the gradient heat
DEFINE_ADJUST(adjust_gradient_heat, domain)
{
Thread *t;
Thread **pt;
cell_t c;
int phase_domain_index = 3.0; // thjats my metal domain
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];
    C_UDMI(c, t, 3) = sqrt(C_UDMI(c, t, 0) * C_UDMI(c, t, 0) + C_UDMI(c, t, 1) * C_UDMI(c, t, 1) + C_UDMI(c, t, 2) * C_UDMI(c, t, 2)); // Magnitude of gradient of volume fraction



    }
    end_c_loop(c, t)
    }

    Free_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
}


// UDF for defining the heat source
DEFINE_SOURCE(heat_source, c, t, dS, eqn)
{
Thread *pri_th; // Gas phase
Thread *sec_th; // solid phase
real source = 0.0 ;
real x[ND_ND], time;
time = CURRENT_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);





real rho = C_R(c,t);
real Cp = C_CP(c,t);

real rhom = C_R(c,sec_th);
real Cpm = C_CP(c,sec_th);

real rhog = C_R(c,pri_th);
real Cpg = C_CP(c,pri_th);
real factor = (2 * rho * Cp) / (rhom * Cpm + rhog * Cpg);
Message(“Factor = %f\n”,factor);

real r = sqrt(pow(x[0] – x0 – v * time, 2.0) + pow(x[1] – y0, 2.0));



if (C_VOF(c, sec_th) > 0.05 && C_VOF(c, sec_th) < 1)
{


source = ((2 * A * P) / (Pi * R * R)) * exp((-2 * (r * r)) / (R * R))*factor ;
dS[eqn] = 0.0;
}
else
{
source = 0.0;
dS[eqn] = 0.0;
}

return source;
}