CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   c_udmi solver (https://www.cfd-online.com/Forums/fluent-udf/158572-c_udmi-solver.html)

zahraorveh August 28, 2015 15:32

c_udmi solver
 
2 Attachment(s)
i write this udf

#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
#include "unsteady.h"

#define K 3.65e-4
#define gama 0.146
#define sigma 4.796e-4
#define alpha 1.935e-3
#define beta 5.7848e-7
#define kx 0.27318
#define kw 0.2
DEFINE_ADJUST(adjust_for_force, domain)
{
Thread **pt;
Thread *t;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,1);
real x,D;
real xc[ND_ND];
begin_c_loop(c,t)
C_CENTROID(xc,c,t);
C_UDMI(c,t,0)=500*exp(-1*(kx*(C_UDSI(c,t,0))+kw)*(0.04-xc[1]));
D=alpha*beta*pow(C_UDMI(c,t,0),2)+(alpha+beta)*sig ma*C_UDMI(c,t,0)+sigma*gama;
C_UDMI(c,t,1)=(sigma*gama+C_UDMI(c,t,0)*beta*sigma )/D;
C_UDMI(c,t,2)=alpha*sigma*C_UDMI(c,t,0)/D;
C_UDMI(c,t,3)=(alpha*beta*pow(C_UDMI(c,t,0),2))/D;
C_UDMI(c,t,4)=K*gama*C_UDMI(c,t,2);

end_c_loop(c,t)

}



it has to calculate 5 c_udmi for each cell of cfd computational cell. but it doesn't work :(

`e` August 28, 2015 18:58

Is this DEFINE_ADJUST macro being called by the solver; have you hooked it?

zahraorveh August 28, 2015 20:19

Quote:

Originally Posted by `e` (Post 561539)
Is this DEFINE_ADJUST macro being called by the solver; have you hooked it?

Yes,i hooked it and i defined memory location!!!

`e` August 28, 2015 22:00

Check which value is being assigned to the UDM with:

Code:

Message("udm-0 = %e\n",500*exp(-1*(kx*(C_UDSI(c,t,0))+kw)*(0.04-xc[1])));

zahraorveh August 29, 2015 00:21

Quote:

Originally Posted by `e` (Post 561544)
Check which value is being assigned to the UDM with:

Code:

Message("udm-0 = %e\n",500*exp(-1*(kx*(C_UDSI(c,t,0))+kw)*(0.04-xc[1])));

Value below 500 has to be assigned to udmi_0!!!!!
But udmi isnt calculated!!!!

Bruno Machado September 1, 2015 04:17

I think you need to add a " thread_loop_c " to your code.

pakk September 2, 2015 04:13

Quote:

Originally Posted by Bruno Machado (Post 561900)
I think you need to add a " thread_loop_c " to your code.

Good observation.
Zahraorveh, didn't you see any compilation warnings/errors? Similar to "warning: variable t undefined"?

zahraorveh September 2, 2015 04:51

Quote:

Originally Posted by pakk (Post 562110)
good observation.
Zahraorveh, didn't you see any compilation warnings/errors? Similar to "warning: Variable t undefined"?

when i compiled it no error i saw!!!!
Can you send me your email to i send my case and data to you???
Have you free time?

pakk September 2, 2015 05:23

No, please don't send me case and data. That will not help anybody.

When I compile it, I see the following:
Quote:

test.c: In function adjust_for_force:
test.c:27: error: sig undeclared (first use in this function)
test.c:27: error: (Each undeclared identifier is reported only once
test.c:27: error: for each function it appears in.)
test.c:27: error: expected ; before ma
test.c:22: warning: unused variable x
test.c:21: warning: unused variable pDomain
test.c:18: warning: unused variable pt
So, no warning/error about t. The biggest problem from here is that you wrote "sig ma" in stead of "sigma".

But that does not change that t is never defined, it only means that the compiler did not catch this problem. Bruno Machado already gave you the solution.


All times are GMT -4. The time now is 23:51.