|
[Sponsors] |
March 12, 2015, 10:45 |
|
#21 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thank you very much. that is indeed helpful..
|
|
March 18, 2015, 04:57 |
.....Error while compiling....
|
#22 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
I am getting error like this. Is this because of declaration? Not getting properly. Any help would be appreciated.
.\..\src\Untitled1.c(58) : error C2440: 'function' : cannot convert from 'real [2]' to 'double' ..\..\src\Untitled1.c(58) : warning C4024: 'fabs' : different types for formal and actual parameter 1 |
|
March 18, 2015, 05:10 |
|
#23 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
This is because of this part in your code:
Code:
fabs(C_P_G(c,t)) 1. What does C_P_G give as output? (Look up in the Fluent manual, because this is a Fluent macro.) 2. What does fabs expect as input? (Look up in a c-reference, for example this one.) You will see that they don't match. But look it up anyway, it is useful to see these things. How to fix this: think about what you want. What should that part of code do? If you would explain it to a human, how would you describe it? |
|
March 18, 2015, 05:39 |
|
#24 | |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Quote:
Thank you for the reply. Those are good examples for beginners like me, thank u... I used the same code but still getting the same error Code:
f_shock=((C_U(c,t)*C_P_G(c,t)[0]) + (C_V(c,t)*C_P_G(c,t)[1]) + (C_W(c,t)*C_P_G(c,t)[2]))/(a*fabs(C_P_G(c,t))); |
||
March 18, 2015, 05:47 |
|
#25 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You forgot to actually read my post. It has some questions that you should try to answer. Let me repeat them:
1. What does C_P_G give as output? (Look up in the Fluent manual, because this is a Fluent macro.) 2. What does fabs expect as input? (Look up in a c-reference, for example this one.) How to fix this: think about what you want. What should that part of code do? If you would explain it to a human, how would you describe it? |
|
March 20, 2015, 00:44 |
|
#26 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
C_P_G it gives the pressure gradient vector, and its components can be accessed by specifying it as an argument in the gradient vector call (0 for the x component; 1 for y; and 2 for z).
Even I did the same but why this error is occurring?? The fabs yields the absolute value of some quantity, which is in the header file #include "math.h" This one also I included.. Still the error is same. Please help. |
|
March 20, 2015, 03:53 |
|
#28 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
That is right. "fabs" calculates the absolute value of a number.
So fabs(1) will give 1. And fabs(-2) will give 2. And fabs("test") will give an error, because "test" is not a number. And fabs(C_P_G(c,t)) will give an error, because C_P_G(c,t) is not a number. Honestly, I know exactly what you have to do. But I want to teach you the approach to solve these problems. So again I ask you: What should that part of code do? If you would explain it to a human, how would you describe it? |
|
March 20, 2015, 04:00 |
|
#29 | |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Quote:
Thank you very much. |
||
March 20, 2015, 04:09 |
|
#30 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Too bad you went for the complicated approach.
If you would have just said: "I want the magnitude of the vector", I would have told you "Then you should use NV_MAG". But it looks like you are not interested in understanding what your code does, and are only interested in getting rid of compilation errors. Good for the short term, bad for the longer term. |
|
March 20, 2015, 04:22 |
|
#31 | |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Quote:
That part of the code contains dot product of velocity vector and del p. velocity vector is (ui+vj+wk) and del p is expanded as dp/dx i +dp/dy j +dp/dy k. This product yields a scalar but when it comes to the denominator fabs(del p), the output of del p normally gives a vector. correct?. How it is possible to divide scalar by vector?. I am just confused.. |
||
March 20, 2015, 04:28 |
|
#32 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Pakk
I am interested in understanding all the concepts and codes. |
|
March 20, 2015, 05:09 |
|
#33 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Let's be sure you have the terminology correct. The pressure, , is a scalar field and the vector derivative of this scalar field is called the gradient; namely .
The denominator of your equation (11) includes ; the vertical lines represent the norm of the pressure gradient. pakk has mentioned you could use the vector operation macro NV_MAG to compute . Code:
NV_MAG(C_P_G(c,t)) |
|
March 20, 2015, 05:18 |
|
#34 | |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Quote:
|
||
March 23, 2015, 02:37 |
|
#35 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Hi,
Is it possible to obtain the freesteam laminar and turbulent viscosity from the fluent udf? The below code is compiling well but I am not sure about the freestream laminar and turbulent viscosities. Is there any other way to compute the freestream viscosities.? any help would be appriciated. Code:
#include "udf.h" #include "mem.h" DEFINE_ON_DEMAND(viscous_sen) { Domain *d; Thread *t; cell_t c; real f_viscous; real viscous_sensor; d=Get_Domain(1); thread_loop_c(t,d) { f_viscous = (C_MU_L(c,t)+C_MU_T(c,t))/C_MU_L(c,t); if(f_viscous>=(1.1 * f_viscous)) begin_c_loop(c,t) { C_UDMI(c,t,0) = viscous_sensor; } end_c_loop(c,t) } } Thanks shivakumar |
|
March 23, 2015, 02:47 |
|
#36 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
I got error like this while executing the above code..
FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. |
|
March 23, 2015, 03:23 |
|
#37 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You haven't yet set a value for the cell ID, c, when you call the C_MU_L(c,t) macro. Specifically, Fluent uses the number previously allocated in memory (most likely an irrelevant number; "garbage") at the location where you've declared it with "cell_t c". There'd be a similar problem with the viscous_sensor variable (it's declared but no value has been added).
Move the f_viscous line to within the cell loop. Similarly, either set a value for viscous_sensor in the loops or where you've declared this variable. |
|
March 23, 2015, 04:26 |
|
#38 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thank you for the reply. I made changes and is compiled. Its going well..
Is that correct formula for finding the freestream laminar and turbulant viscosity? Thanks |
|
March 23, 2015, 05:00 |
|
#39 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Yes, your code looks correct according to equation (12) of your attached file.
|
|
March 23, 2015, 05:13 |
|
#40 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thanks for the reply
Ok. Is there any other formula to calculate the freestream values of those two.? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |