DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Applying heat flux on a tube surface (http://www.daniweb.com/forums/thread181273.html)

tendolm Mar 12th, 2009 11:41 pm
Applying heat flux on a tube surface
 
I want to apply heat on a tube surface (3D). The heat is to be applied on a straight line on the tube. The equation of line is
x= 87.5
y = 126.1620 + (-1*1004.0820)
z= 166.1620 + (-1*-1004.0880)

Since x is constant is given asposition holder, real x[ND_ND];
For this constant value of x, heat is appiled on the line with the equation above. (If y and z are satisfied.
I have created my code below and when I try to interprete it, there is an error report:
Error line 16: invalid type for &&: float && float.
This is the line 16
((y = 126.1620 + (-1*1004.0820)) && (z= 166.1620 + (-1*
-1004.0880)));
How do I correct the error?

#include "udf.h"

/* profile for heat flux*/
DEFINE_PROFILE(heatflux_profile, t, i)
{
    /* declaring variables */
real x[ND_ND];  /* this will hold the position vector */
real y;
real z;
face_t f;

begin_f_loop(f, t)
{
F_CENTROID(x, f,t);
if
((y = 126.1620 + (-1*1004.0820)) && (z= 166.1620 + (-1*
-1004.0880)));
F_PROFILE(f, t, i) =500;
else
F_PROFILE(f,t,i)=350;
}
end_f_loop(f, t)
}

r.stiltskin Mar 13th, 2009 1:31 am
Re: Applying heat flux on a tube surface
 
Is this supposed to be C++ or is it some other language?

nucleon Mar 13th, 2009 1:36 am
Re: Applying heat flux on a tube surface
 
He's using a special header.

You do not want the semicolon at the end of the parenthesized portion of the if statement.

Other than that, it seems weird to be assigning y and z a constant value and then testing whether or not either are zero, which is what your code is doing.

Rashakil Fol Mar 13th, 2009 1:49 am
Re: Applying heat flux on a tube surface
 
Your "line equation" is wrong -- you have defined a point.

r.stiltskin Mar 13th, 2009 1:51 am
Re: Applying heat flux on a tube surface
 
Perhaps you intended a test for equality (==), rather than assigment (=). And why the unnecessarily confusing multiplication by -1 in the first expression and double negative in the second?
This seems to make more sense:
if( (y == 126.1620 -1004.0820) && (z == 166.1620 + 1004.0880) ) {
      F_PROFILE(f, t, i) =500;
    else
      F_PROFILE(f,t,i)=350;
}

But
begin_f_loop(f, t)
and
end_f_loop(f, t)
don't look like any kind of C/C++ syntax I've ever seen. What is that supposed to be doing? How is it a loop?

tendolm Mar 13th, 2009 3:46 am
Re: Applying heat flux on a tube surface
 
This code is developed in C++ and used in a computational fluid dynamics model (CFD), Fluent, and these other fetures are part of Fluent. If I get correct the part of stating my if condition then everything else will work.
If I do not use the if condition and apply only heat to the surface decribed by my line equation. I am able to interprete the code into Fluent. I have writen it as
Quote:

begin_f_loop(f, t)
{
F_CENTROID(x, f,t);

y = 126.1620 + (-1*1004.0820);
z= 166.1620 + (-1*-1004.0880);
F_PROFILE(f, t, i) =500;

}
end_f_loop(f, t)
}
The oter part is teh same as the previous code. In C++ how do I set the condition if y and z are met.

tendolm Mar 13th, 2009 3:48 am
Re: Applying heat flux on a tube surface
 
How do I define a line in 3D

tendolm Mar 13th, 2009 4:01 am
Re: Applying heat flux on a tube surface
 
Please assist me form the equation of line. The staring point is (87.5, 126.162, 166.162) and the end point is (87.5, 877.97, 1170.25)

tendolm Mar 13th, 2009 5:13 am
Re: Applying heat flux on a tube surface
 
My equation of line is
x=87.5
y= 126.162-(1004.082)t
z=166.162-(-1004.088)t
and 0<=t<=1.
(0 is less or equal to t but t is less or equal to 1)

I want to develop a code that applies one value of heat on this line on a tube and another value on other parts of the tube
This code will then be intepreted in Fluent (computational fluid dynamics package) and used for numerical simulation of temperature change in the tube as a result of applied heat.
Please just assist develop this code in C ignoring parts involving Fluent language. If I get this correct in C then will make necessary changes to suit Fluent

r.stiltskin Mar 13th, 2009 10:40 am
Re: Applying heat flux on a tube surface
 
You want to apply one value using the F_PROFILE function to points on your line, and another value using that function "everyplace else", but in C you must define points in terms of discrete values for x, y and z. (Unless there is some way to deal with continuous values in Fluent, but in that case your question is really how to write that in Fluent, not in C.)

Therefore, before we can give you the C code, you must provide ranges for x, y, and z, and you must provide increment sizes for x, y and z in order to compute discrete points in xyz space.

Also, you gave an interval [0,1] for t, but is that really relevant? I don't think you want a 4-dimensional (xyzt) loop. Don't you really want to leave t as a variable in the conditional expression, to be assigned explicit values elsewhere in the code or possibly at runtime?


All times are GMT -4. The time now is 2:42 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC