CFD Online Discussion Forums

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

coiby January 24, 2011 21: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 21: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 24, 2011 23: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 25, 2011 23: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 03: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 13:07

which version of fluent are you using.

coiby January 27, 2011 19: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 05:27.