CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF Parse Error - Initializing VOF for Multiphase Simulation

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 25, 2018, 02:07
Angry UDF Parse Error - Initializing VOF for Multiphase Simulation
  #1
New Member
 
Brandon Johnson
Join Date: Jul 2017
Posts: 6
Rep Power: 8
denbjornen is on a distinguished road
I'm having a hard time writing a UDF for patching the volume fraction for a phase in my domain at the start of a solution.

Big picture: I am running a 2-way coupled transient FSI simulation that has a transient frame motion angular velocity UDF. To make things more complex, the simulation is also multiphase (water & air).

Ordinarily, I'd just patch the air region using by marking the cells; but this does not seem to save the initialization state for system coupling and I get errors. I've been looking into solving this problem that initializes the VOF from a UDF at the start of the solution process. But if somebody has a more elegant solution, I'm all ears. I have little experience in C (I prefer python) so I'm quite irritated by what I think is probably a very simple error. The following UDF is taken from:
https://www.sharcnet.ca/Software/Flu...udf/node98.htm

Code:
/*****************************************************************
   UDF for initializing phase volume fraction                    
******************************************************************/

#include "udf.h"
/* domain pointer that is passed by INIT function is mixture domain  */
DEFINE_INIT(patch_vof, mixture_domain)
{
	 int phase_domain_index;
	 cell_t cell; 
	 Thread *cell_thread;
	 Domain *subdomain;
	 real xc[ND_ND];
  /* loop over all subdomains (phases) in the superdomain (mixture) */
  sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
  {
     /* loop if secondary phase  */
     if (DOMAIN_ID(subdomain) == 3)      

     /* loop over all cell threads in the secondary phase domain  */
     thread_loop_c (cell_thread,subdomain)
     {
         /* loop over all cells in secondary phase cell threads  */
         begin_c_loop_all (cell,cell_thread)
         {
             C_CENTROID(xc,cell,cell_thread);
			 
             if -0.35<NODE_X(xc[0])<0.35 && 0.0<NODE_Y(xc[1])<0.2 && -0.05<NODE_Z(xc[2])<0.05
				 C_VOF(cell,cell_thread) = 1.;
             else
				 C_VOF(cell,cell_thread) = 0.;
         }
         end_c_loop_all (cell,cell_thread)
     }

   }
}
When trying to interpret this UDF in Fluent, I get "parse error" for the if and else lines. I'm really not sure if the structure of the "if" statement is correct, regarding "xc" and the NODE functions (I really don't know what they do). I just need to initialize the volume fraction to 1 inside of the bounds, to 0 outside of the bounds.

I found a thread:
patch region with UDF

That claims to have a working UDF, but I've tested it and it does not work. It makes use of ND_SUM and sqrt, but the "if" statement doesn't seem to be evaluating anything (just a sqrt of a sum). I really don't know what to do; but I feel that it should be extremely simple to an experienced UDF programmer.

Thanks
denbjornen is offline   Reply With Quote

Reply

Tags
initialization, multiphase, user defined functions, volume of fluid

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Huge file sizes when Running VOF simulation aarratia FLUENT 0 May 8, 2014 12:27
Simulation with UDF for species mass fraction and velocity profile virgy Fluent UDF and Scheme Programming 8 February 7, 2012 04:30
parse error with interpreting UDF ivanbuz Fluent UDF and Scheme Programming 2 August 13, 2009 18:29
UDF parse error at profile function line Wiggy Fluent UDF and Scheme Programming 1 July 27, 2009 15:59
Difficult BCs about Freesurface Simulation by VOF Yongguang Cheng FLUENT 0 September 19, 2003 07:39


All times are GMT -4. The time now is 21:11.