CFD Online Logo CFD Online URL
Home > Forums > Fluent UDF and Scheme Programming

How to access only one phase in multiphase model by UDF

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

LinkBack Thread Tools Display Modes
Old   September 23, 2009, 07:57
Default How to access only one phase in multiphase model by UDF
New Member
Soeren Werner
Join Date: Mar 2009
Location: Wädenswil, Switzerland
Posts: 27
Rep Power: 8
wersoe is on a distinguished road
Hello guys,

I am trying to write an UDF to write data (cell volume, spec diss rate) only for one phase in multiphase (vof) model.
However, either I get all cells or a segmentation violation error.
I tried different methods to access only primary_phase by threads or domains, but I do not have any success.

Could you help me please...
For checking, used a quader with 8000 cells, patched to water in 4000 cells.
I did and didnt run some iterations, nothing helps...

This UDF writes cell volume of all cells, not only primary phase
If I switch C_VOLUME to C_D for spec diss rate, a seg viol error aoccurs.

#include "udf.h"

  cell_t c;
  int ID = 2; 
       /* Zone ID for wall-1 zone from Boundary Conditions panel */
  Domain *mixture_domain = Get_Domain(1);
  Domain *subdomain = DOMAIN_SUB_DOMAIN(mixture_domain,0);
  Thread *thread = Lookup_Thread(subdomain, ID);

  FILE *output=fopen ("epsilon.out","w");

  begin_c_loop(c, thread)
        fprintf(output,"\nvof=%e", C_VOLUME(c,thread)); 
  end_c_loop(c, thread)

This UDF writes C_VOF for all cells, not only primary phase
eventhough C_VOF(c,pt[1])

#include "udf.h"


Domain *mix_domain = Get_Domain(1);
Thread *mix_thread;
Thread **pt;

mp_thread_loop_c(mix_thread, mix_domain, pt)
cell_t c;
begin_c_loop(c, pt[1])

Message("cell volume fraction = %f\n",C_VOF(c,pt[1]));

end_c_loop(c, pt[1])

This UDF writes values for all cells too.
Eventhough if(C_VOF(cell,subthread) = 1)
#include "udf.h"

Domain *mixture_domain = Get_Domain(1);
Domain *s_d = DOMAIN_SUB_DOMAIN(mixture_domain,0);		/*subdomain pointer, locally defined*/
Thread *mixture_thread;
cell_t cell;

int p_d; 		/* loop counter for phase_domain_index, locally defined*/
int p_d_id;		 /* mix_domain is available*/

FILE *output=fopen ("epsilon.out","w");
fprintf (output, "energy dissipation rate distriubtion\n");
fprintf (output, "epsilon,volume\n");
int phase_domain_index=0;

sub_domain_loop(s_d, mixture_domain, phase_domain_index)
	/* loop over all cell threads in the primary phase domain  */
        		/*Thread *st = THREAD_SUB_THREAD(cell_thread, 0);*/
			/* loop over all cells in primary phase cell threads  */
			/*if(C_VOF(cell,mixture_thread) = 1)*/
			Message("\nDone... %g", C_VOF(cell,mixture_thread));
fclose (output);

Eventhough I have 3 examples here, I would like to go to the first one, since I need Lookup_Thread for determining the size of an array to parallelize the udf.
Examplers for parallelizing are here:
I do not know how I can to this when using a loop over domains or threads, since the size of the array needs to be send from nodes to host...
If I check the udf, it seems very clear to me: I define a domain, then a subdomain, then I define a thread by using subdomain for lookup...
That means, in thread it is supposed to point to thread in subdomian, or better to thread in domain with phase index 0...
However, C_VOLUME can be written, but C_D or C_VOF causes a seg viol error...

Actually, the task seems very easy to me.
Write cell values from cells which are associated with primary phase.
I have tried different methods to access one phase only.
However, I am at one's wit' end...
Any help is much appreaciated.

Thanks, Sören

Last edited by wersoe; September 23, 2009 at 08:22.
wersoe is offline   Reply With Quote


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modified k-e turbulence model UDF Travis Fluent UDF and Scheme Programming 6 October 7, 2015 13:54
Discrete phase or two phase model in Fluent? andrea panizza FLUENT 14 September 6, 2015 16:18
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
UDF problem in multiphase model Amir Khodabandeh FLUENT 1 March 13, 2009 09:43
air and water vapour mixture - multiphase model Saba FLUENT 0 February 10, 2009 13:05

All times are GMT -4. The time now is 03:24.