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

HEEELP!! Laplacian temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 23, 2014, 10:24
Default HEEELP!! Laplacian temperature
  #1
New Member
 
Join Date: Jul 2014
Posts: 6
Rep Power: 12
stef_pasc is on a distinguished road
Hi everyone!!
I'm trying to calculate the laplacian of temperature field in order to introduce it into the source terme of energy equation. Here there is a simplification of my C code.

DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;

if (! Data_Valid_P())
return;

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0)=C_T_RG(c,t)[0];
C_UDSI(c,t,1)=C_T_RG(c,t)[1];
C_UDSI(c,t,2)=C_T_RG(c,t)[2];
}
end_c_loop (c,t)
}

}

DEFINE_SOURCE(energy_source,c,t,ds,eqn)
{

real source;

source=20*C_UDSI(c,t,0);

C_UDMI(c,t,0)=C_UDSI(c,t,0);
C_UDMI(c,t,1)=source;
C_UDMI(c,t,2)=C_UDSI_G(c,t,0)[0]; /*some calculus for testing the data*/
C_UDMI(c,t,3)=1/C_UDSI_G(c,t,0)[0];
C_UDMI(c,t,4)=100*C_UDSI_G(c,t,0)[0];

ds[eqn]=0;
return source;

}

The operations I make are:
Add User Scalars and memory
Inactivate UDS equations
Tape solver/set/expert---> yes for "keep temporary solver memory ...."
Launch the computation

SO I have 2 principal problems:
Sometimes, I receive a "segmentation fault" error message: this is due to the lines
C_UDSI(c,t,0)=C_T_G(c,t)[0];
C_UDSI(c,t,1)=C_T_G(c,t)[1];
C_UDSI(c,t,2)=C_T_G(c,t)[2];

If I use C_T(c,t), there's no more problems...whyyy??;
In this case, if I plot "Reconstruction dT/dx", Scalar 0 and Memory 0, they should coincide but there some little differences.

Is there someone who can help me, pleeease???

Thank you guys!!!
Stefano
stef_pasc is offline   Reply With Quote

Old   July 24, 2014, 23:09
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
To the first question, you need to ensure that the pointer is non-null before accessing it. You can disable your udf for first few iterations then enable it, or you can check the pointer of C_T_G in your udf.

To the second question, the UDSIs are governed by the convection-diffusion equation. For each iteration/time step, they are set with the value of temperature gradient but they will change according to their governing equations.

Dr Bill Wangard provided a solution for gradients calculation in this forum. You can search his threads for the solution.
blackmask is offline   Reply With Quote

Old   August 5, 2014, 05:29
Default
  #3
New Member
 
Join Date: Jul 2014
Posts: 6
Rep Power: 12
stef_pasc is on a distinguished road
Thank you blackmask for your answer!
I added an If statement with a condition on storage and it works. But I have a doubt. Indeed, if I try to verify iterations in the cells, and I found out that iterations are less than the real number of cells.
For example, I have 2048 cells while I got 1040 iterations. It means that UDS for some cells qre not allocated. How can I solve this?

Thank you very much for your help!!!

thread_loop_c (t,d)
{
if (NULL != THREAD_STORAGE(t,SV_UDS_I(0))&&
NULL != THREAD_STORAGE(t,SV_UDS_I(1))&&
NULL != THREAD_STORAGE(t,SV_UDS_I(2)))
{ k=0;
begin_c_loop (c,t)
{
C_UDSI(c,t,0)=C_T_G(c,t)[0];
C_UDSI(c,t,1)=C_T_G(c,t)[1];
C_UDSI(c,t,2)=C_T_G(c,t)[2];

k+=1;
printf("cell number%d \n", k);
}
end_c_loop (c,t)
}
}
stef_pasc 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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 08:15
Static Temperature / Opening Temperature JulianP CFX 12 April 10, 2019 19:00
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 02:27
laplacian of temperature seyed Farid hosseinizadeh FLUENT 0 December 17, 2006 22:56


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