CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

c++ for fluent

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 18, 2010, 09:47
Default c++ for fluent
  #1
New Member
 
marie
Join Date: May 2010
Posts: 21
Rep Power: 8
marye is on a distinguished road
Hi,
I have another problem...
Just to try, I wanted to put different viscosities to the pair cells and impair cells...

#include"udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
cell_t c;
int i;
for (i=1, i<200, i++)
if ((cell_t ci %2)==0)
mu_lam = 2.;
else
mu_lam = 1.;
return mu_lam;
}

But it doesn't work... I'm new with both Fluent and C++...

If anyone could help..
Thanks!!

marye is offline   Reply With Quote

Old   May 18, 2010, 10:57
Default
  #2
Senior Member
 
Chris
Join Date: Jul 2009
Location: Ohio, USA
Posts: 169
Rep Power: 9
Chris D is on a distinguished road
One thing that I noticed is that the for loop should be

for (i = 1; i < 200; i++)

Use a semicolon to separate arguments, not a comma. Also, I don't think that

if ((cell_t ci %2)==0)

will do what you think it will do. ci is a new variable of type cell_t, it's not cell_t c at index i. Are you trying to loop over the cells in a domain? I think there are macros to do that for you. (I have some c++ experience, but not really any experience writing UDFs, so I'm exactly sure how to do that.) One final thing is that UDF's are supposed to be written in c, not c++.
Chris D is offline   Reply With Quote

Old   May 18, 2010, 11:09
Default
  #3
New Member
 
marie
Join Date: May 2010
Posts: 21
Rep Power: 8
marye is on a distinguished road
thank you for your answer!

ok then, C and not C++

I'll try ";" instead of ","

I'm trying to do : All the cells at index i pair have viscosity1
All the cells at index i impair have viscosity 2

I have no experience both in writting C and UDFs so I donīt know very well the macros...
marye is offline   Reply With Quote

Old   May 18, 2010, 11:13
Default
  #4
Senior Member
 
Chris
Join Date: Jul 2009
Location: Ohio, USA
Posts: 169
Rep Power: 9
Chris D is on a distinguished road
Section 3.3 in the UDF manual is about looping macros.
Chris D is offline   Reply With Quote

Old   May 18, 2010, 11:19
Default
  #5
New Member
 
marie
Join Date: May 2010
Posts: 21
Rep Power: 8
marye is on a distinguished road
Yes, I will see that again... I must have forgotten something...

Thank you for your help!
marye is offline   Reply With Quote

Reply

Tags
c++, fluent

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 16:00.