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

Writing a UDF to get the coordinates of the center of mass of a rising bubble

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2023, 06:14
Default Writing a UDF to get the coordinates of the center of mass of a rising bubble
  #1
New Member
 
Elliott
Join Date: Jul 2022
Posts: 4
Rep Power: 4
edems86 is on a distinguished road
Hello, I am using fluent to simulate a rising bubble in a column of water. The bubble is an oil bubble and the simulations are made in 2D axisym.

I would like to get the terminal velocity of the bubble and have decided to use a UDF to get the center of mass of the bubble. However this is my first UDF and the results I get is always 0 and I do not know where the problem comes from. I hope somebody will be able to help me out here. Thank you very much

The udf I wrote :
Code:
#include "udf.h"
#include <math.h>


DEFINE_EXECUTE_AT_END(execute_at_end)
{  
  int phase_domain_index;

  Domain *subdomain;

  Domain *mixture_domain;
  mixture_domain = Get_Domain(1);

  double num;
  num = 0.0;

  double denom;
  denom = 0.0;

  double bar;

  double vol;
  vol = 6.25e-8;

  double rho;
  rho = 974.5;
  
  #if !RP_HOST

  FILE *file = fopen("data.txt", "a");
  if(!file)
    {
        Message("Cannot open the file");
    }
  else
    {
    /*loop over all subdomain(phases) in the superdomain(mixture)*/
    sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
        {
	    Thread *cell_thread;
	    cell_t cell;
	    real xc[ND_ND];
         /*loop over all cell threads in the domain*/
	    thread_loop_c(cell_thread, subdomain)
	        {
		    /*loop over all cells in the thread*/
		    begin_c_loop_all(cell, cell_thread)
		        {
		    	/*get the cell centroid*/
			    C_CENTROID(xc, cell, cell_thread);

                            num = num + C_VOF(cell, cell_thread)*xc[0]*rho*vol;
                            denom = denom + C_VOF(cell, cell_thread)*rho*vol;
		        }
		    end_c_loop_all(cell, cell_thread)
            }
        }
    }
    bar = num/denom;
    fprintf(file,"Resultats: %g\n",bar);
    fclose(file);
    #endif
}

Last edited by edems86; January 18, 2023 at 10:55.
edems86 is offline   Reply With Quote

Reply

Tags
rising bubble, udf


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
Defining UDF function for Time-dependent mass flow cfdstudent12 FLUENT 0 June 27, 2022 04:09
Bubble expansion due to mass transfer from liquid richard222 Fluent Multiphase 1 July 2, 2018 08:34
UDF for mass and heat source with heat transfer rajendra1 Fluent UDF and Scheme Programming 35 October 13, 2017 05:04
bubble rising problem swamysrikanth ANSYS Meshing & Geometry 3 May 31, 2016 12:09
Mass source UDF epc1 Fluent UDF and Scheme Programming 1 January 24, 2013 10:24


All times are GMT -4. The time now is 14:58.