# second derivation of temperature

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

 June 13, 2014, 03:43 #2 Senior Member   Join Date: Nov 2013 Posts: 1,074 Rep Power: 14 Do you get the same error if you replace the line Code: `source=-0.000143472*(C_UDSI_G(c,t,1)[0]+C_UDSI_G(c,t,2)[1]+C_UDSI_G(c,t,3)[2]);` by the following line? Code: `source=-0.000143472*(C_UDSI(c,t,1)[0]+C_UDSI(c,t,2)[1]+C_UDSI(c,t,3)[2]);` If you get the same problems without the gradient, the problem is that the UDS is not defined; if you do not get the same problems, the problem is related to the gradient. Having this information might bring you one small step closer to the solution...

 June 13, 2014, 08:27 #3 New Member   Join Date: Jun 2014 Posts: 16 Rep Power: 5 Hi, pakk. Thank you for your reply. I replace the line CODE: source=-0.000143472*(C_UDSI_G(c,t,1)[0]+C_UDSI_G(c,t,2)[1]+C_UDSI_G(c,t,3)[2]); with the following line CODE: source=-0.000143472*(C_UDSI(c,t,1)+C_UDSI(c,t,2)+C_UDSI(c, t,3)); Then I get the same error. You said maybe the uds is not defined. But what can I do to solve this problem? Is there something wrong in DEFINE_ADJUST?

 June 13, 2014, 09:52 #4 Senior Member   Join Date: Nov 2013 Posts: 1,074 Rep Power: 14 Try to plot the UDS. Is it zero on some parts of your domain? Then something is wrong in the adjust-part, maybe it did not hook to all cell zones. Otherwise, I would have to think really hard.

 June 15, 2014, 05:23 #5 New Member   Join Date: Jun 2014 Posts: 16 Rep Power: 5 Hi, pakk. It's very nice of you to reply. Thank you again. I tried to iterated with hooking the adjust-part and without including UDS transport equation 0 (I need to obtain User Scalar 0 in this equation) because as long as I include UDS transport equation 0, I will get the error access_violation. And I found that User Scalar 1, User Scalar 2 and User Scalar 3 were mostly not zero, though in some parts they might be zero (most of the values were near zero). On this occasion, is something wrong in the adjust-part?

 June 18, 2014, 03:16 #7 Senior Member   Join Date: Nov 2013 Posts: 1,074 Rep Power: 14 Simplify your uds_source until it works. In that way you might identify in which step the problem occurs. Some suggestions: Code: ```DEFINE_SOURCE(uds_source, c, t, dS, eqn) { real source; source=-0.000143472*(C_UDSI_G(c,t,1)[0]); dS[eqn]=0; return source; }``` Code: ```DEFINE_SOURCE(uds_source, c, t, dS, eqn) { real source; source=-0.000143472*(C_UDSI(c,t,1)[0]); dS[eqn]=0; return source; }``` Code: ```DEFINE_SOURCE(uds_source, c, t, dS, eqn) { real source; source=-0.000143472; dS[eqn]=0; return source; }```

 June 19, 2014, 04:06 #8 New Member   Join Date: Jun 2014 Posts: 16 Rep Power: 5 Hi, pakk. Thank you for your help! I've found where the error happens. In my UDF, I also define a UDS flux for UDS transport equation 0. I want to obtain the flux that equals the negative product of density and velocity. I use the code below firstly: DEFINE_UDS_FLUX(A_flux, f, t, i) { real NV_VEC(vec), NV_VEC(A),dens,flux; F_AREA(A, f, t); dens=F_R(f,t); NV_DS(vec,=,F_U(f,t),F_V(f,t),F_W(f,t),*,dens); flux=NV_DOT(vec,A); return - flux; } The error access_violation always occurs. Then I try the code below: DEFINE_UDS_FLUX(A_flux, f, t, i) { return - F_FLUX(f,t); } It can iterate now. Both of the codes can be compiled without any error. Do you know what the mistake is in the first code? Best regards.

 June 19, 2014, 05:04 #9 Senior Member   Join Date: Nov 2013 Posts: 1,074 Rep Power: 14 You should look at the example in the manual for DEFINE_UDS_FLUX. It has a comment about the density not being available for all BCs, and how to solve it. I don't know if this is causing the problem, but you could try it.

 June 23, 2014, 05:32 #10 New Member   Join Date: Jun 2014 Posts: 16 Rep Power: 5 Hi, pakk. I have another question about the outlet boundary condition. I simulate the heat transfer in duct. For the inlet, I set the velocity-inlet condition and the user scalar 0 is set constant value 0. Here's no question. But for the fully-developed flow, I set the outflow condition and the BC should be (A*)inlet = (A*)outlet, where A is user scalar 0. For BC like this, how can I define it? I couldn't find a similar example in UDF manual. Could you help me with some clue? Thank you very much.

June 23, 2014, 05:55
#11
Senior Member

Join Date: Nov 2013
Posts: 1,074
Rep Power: 14
Quote:
 Originally Posted by sunjian Hi, pakk. I have another question about the outlet boundary condition. I simulate the heat transfer in duct. For the inlet, I set the velocity-inlet condition and the user scalar 0 is set constant value 0. Here's no question. But for the fully-developed flow, I set the outflow condition and the BC should be (A*)inlet = (A*)outlet, where A is user scalar 0. For BC like this, how can I define it? I couldn't find a similar example in UDF manual. Could you help me with some clue? Thank you very much.
If A at the inlet is set at the constant value 0, then (A*)inlet=0, isn't it?

 June 23, 2014, 10:25 #12 New Member   Join Date: Jun 2014 Posts: 16 Rep Power: 5 Yes, you are right. So I just need to define (A*)outlet = 0. Is it right? I'll have a try and see what I will get. Thank you very much.

 July 18, 2014, 08:53 #13 New Member   Join Date: Jul 2014 Posts: 6 Rep Power: 5 Hi everyone!! I have a similar problem. 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mihail CFX 7 September 7, 2014 06:27 immortality OpenFOAM Running, Solving & CFD 11 April 22, 2014 12:32 immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 02:27 JulianP CFX 6 March 23, 2013 17:03 shenying0710 CFX 8 January 4, 2013 05:03