CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   how to obtain the total number of cells (http://www.cfd-online.com/Forums/fluent/84262-how-obtain-total-number-cells.html)

coiby January 24, 2011 22:24

how to obtain the total number of cells
 
I know we can see the number when importing mesh file. But does Fluent provide API? Thanks!

gearboy January 24, 2011 22:50

Quote:

Originally Posted by coiby (Post 291995)
I know you can see the number when importing mesh file. But does Fluent provide API? Thanks!

You can use UDF to loop all the cells and count the total cell number.

coiby January 25, 2011 00:54

Quote:

Originally Posted by gearboy (Post 291998)
You can use UDF to loop all the cells and count the total cell number.

Thank you, gearboy.
If Fluent doesn't provide API, that's the only way. I'll try this through it's a bit of a waste of CPU.

vig January 26, 2011 00:47

Could you try thread->nelements, where thread is a cell thread.
In that case, you have to loop over all cell threads using therad_loop_c.

Or

Try domain-> cell_count

It should help.

coiby January 27, 2011 04:46

Quote:

Originally Posted by vig (Post 292185)
Could you try thread->nelements, where thread is a cell thread.
In that case, you have to loop over all cell threads using therad_loop_c.

Or

Try domain-> cell_count

It should help.

Thank you, vig!
I've tried "domain-> cell_count" :

Code:


DEFINE_INIT(my_init_function, domain)
{
 cell_t c;
 Thread *t;
 int i; //loop control
 int j; //loop control
 int cnum = domain->cell_count; // the total number of cells
 float *radius[cnum][K];
 j=0;
 thread_loop_c(t,domain)
 {
  for(i=0;i<K;i++)
  *radius[j][i]=gauss();
  j++;
 }
}

When compling it, Fluent gives out the following message:
"error C2039: 'cell_count' : is not a member of 'domain_struct'"?

And I check mem.h, find these lines:
Code:

#if RP_HOST
  int cell_count, face_count;
#endif

For the first method " thread->nelements", nelements doesn't seem to be a member of struct thread i thread.h.
Thanks!

vig January 27, 2011 14:07

which version of fluent are you using.

coiby January 27, 2011 20:58

Hi, vig. I'm using Fluent_v6.3.26, 32bit, Win7.
I first compile it under Linux, but there are extra errors(see http://www.cfd-online.com/Forums/flu...tters-why.html).


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