
[Sponsors] 
July 23, 2014, 09:24 
HEEELP!! Laplacian temperature

#1 
New Member
Join Date: Jul 2014
Posts: 6
Rep Power: 3 
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 

July 24, 2014, 22:09 

#2 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
To the first question, you need to ensure that the pointer is nonnull 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 convectiondiffusion 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. 

August 5, 2014, 04:29 

#3 
New Member
Join Date: Jul 2014
Posts: 6
Rep Power: 3 
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) } } 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Calculation of the Governing Equations  Mihail  CFX  7  September 7, 2014 06:27 
whats the cause of error?  immortality  OpenFOAM Running, Solving & CFD  11  April 22, 2014 12:32 
is internalField(U) equivalent to zeroGradient?  immortality  OpenFOAM Running, Solving & CFD  7  March 29, 2013 02:27 
Static Temperature / Opening Temperature  JulianP  CFX  6  March 23, 2013 17:03 
laplacian of temperature  seyed Farid hosseinizadeh  FLUENT  0  December 17, 2006 22:56 