Reading (interpolating) source term from point data input file not aligned with grid


Client has source terms (for energy eqn) that are not aligned with grid. How can this source term data be interpolated.
The solution is several steps and involves a UDF (that should be compiled).

-- Compile the UDF.
-- Read mesh or case
-- Add AT LEAST one User-Defined Scalar (UDS) and one User-Defined Memory (UDM)...
-- Set up your case as much as possible and Initialize the solution.
Do not iterate with the the UDS-0 yet!
-- Link UDF
* Define->User Defined->Functions->Compiled... Use "libudf"
-- Use File->Interpolate to interpolate the SOURCE data (source_data.ip) into UDS-0
-- Use Execute on demand (copy_uds_to_udm) to copy UDS-0 into the UDM-0
-- In B.C. panel, under source term, hook source UDF with "my_source"
This will then use the UDM value for the source term.
-- At this point, you may remove UDS-0, since it is no longer used. The data are in UDM-0.

WARNING:
-- If you initizlize the solution, the UDM0 will be zeroed and thes source term will be lost. You
will have to reinterpolate the UDS0 and execute the DEFINE_ON_DEMAND function (copy_uds_to_udm)
again to set the source term!

I would recomend saving the case/data file after you perform the DEFINE_ON_DEMAND(copy_uds_to_udm).



NOTE:
This function extrapolates linearly outside the defined domain of the data!


/***********************/
Data file input format
/**********************/
2 (for fluent 6.0)
3 (for 3d)
n (the number of points)
1 (the number of scalar functions)
uds-0 (the name of the function... not arbitrary!)
x1
x2
..
xn
y1
y2
..
yn
z1
z2
..
zn
s1
s2
..
sn

/************/


/**********/
/* UDF */
/**********/

#include "udf.h"

DEFINE_ON_DEMAND(copy_uds_to_udm)
{

Domain* d = Get_Domain(1);
Thread* t;
cell_t c;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = C_UDSI(c,t,0);
}
end_c_loop(c,t);
}

return;
}

DEFINE_SOURCE(my_source,c,t,dS,eqn)
{

real source;

dS[eqn] = 0.0;

source = C_UDMI(c,t,0);

return source;

}





Show Form
No comments yet. Be the first to add a comment!