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

How to build divergence of volume fraction gradient in UDF?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 1, 2017, 14:28
Default How to build divergence of volume fraction gradient in UDF?
  #1
bss
New Member
 
Bahador
Join Date: Jun 2016
Posts: 3
Rep Power: 10
bss is on a distinguished road
Hello,
I want to calculate 'curvature' in UDF. I have attached formulation of curvature.
'F' is volume fraction.
C_VOF_G(c,t) can calculate gradient of volume fraction
NV_MAG(C_VOF_G(c,t)) can calculate magnitude of volume fraction. I can calculate gradient of volume fraction but My problem is that I can't calculate divergence of volume fraction gradient in UDF.

Thank you in advance.
Attached Images
File Type: png Curvature.png (5.8 KB, 10 views)
bss is offline   Reply With Quote

Old   February 11, 2021, 14:53
Default
  #2
New Member
 
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9
anoop.k.unni is on a distinguished road
Quote:
Originally Posted by bss View Post
Hello,
I want to calculate 'curvature' in UDF. I have attached formulation of curvature.
'F' is volume fraction.
C_VOF_G(c,t) can calculate gradient of volume fraction
NV_MAG(C_VOF_G(c,t)) can calculate magnitude of volume fraction. I can calculate gradient of volume fraction but My problem is that I can't calculate divergence of volume fraction gradient in UDF.

Thank you in advance.
Hi did you solve?
anoop.k.unni is offline   Reply With Quote

Old   February 12, 2021, 01:47
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Going from the gradient to the divergence (in standard Cartesian coordinates) is super simple... Just sum them.

Maybe I don't understand the problem?
pakk is offline   Reply With Quote

Old   February 12, 2021, 02:14
Default
  #4
New Member
 
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9
anoop.k.unni is on a distinguished road
Quote:
Originally Posted by pakk View Post
Going from the gradient to the divergence (in standard Cartesian coordinates) is super simple... Just sum them.

Maybe I don't understand the problem?
I have written a UDF for a multiphase (of) problem dealing with recoil pressure which has to be added as momentum source term. i have attached a figure which shows a definition of my problem and also udf. can you please check whether i have written in the right way because i am not able to run the case.
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "unsteady.h"


DEFINE_ADJUST(vol_gradient, domain)
{
Thread *t;
cell_t c;
real DVOFNX,DVOFNY,DVOFDNZ;
domain = Get_Domain(6);

/* Fill UDS with the variable. */

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_VOF(c,t);

DVOFNX = C_UDSI_G(c,t,0)[0];
DVOFNY = C_UDSI_G(c,t,0)[1];
DVOFNZ = C_UDSI_G(c,t,0)[2];

C_UDMI(c,t,0) = DVOFNX;
C_UDMI(c,t,1) = DVOFNY;
C_UDMI(c,t,2) = DVOFNZ;

}
end_c_loop (c,t)
}

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,3) = NV_MAG(C_UDSI_G(c,t,0));
}
end_c_loop (c,t)
}

DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
domain = Get_Domain(6);

/* Fill the UDM with magnitude of gradient. */

*thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,4) = C_UDMI(c,t,0)/NV_MAG(C_UDSI_G(c,t,0));
C_UDMI(c,t,5) = C_UDMI(c,t,1)/NV_MAG(C_UDSI_G(c,t,0));
C_UDMI(c,t,6) = C_UDMI(c,t,2)/NV_MAG(C_UDSI_G(c,t,0));
}
end_c_loop (c,t)
}
}
}

DEFINE_SOURCE(x_recoil,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real time;
real temp;
time=RP_Get_Real("flow-time"); //Acquire time from FLUENT solver
C_CENTROID(x,c,t);
temp=C_T(c,t); //Acquire the face centroid location
if (C_T(c,t) >= 3201.)
{
source=(54715.5*exp(13.14*(temp-(3200)/temp)))*(C_UDMI(c,t,4));
C_UDMI(c,t,7) = source;
dS[eqn] = 0;
}
else
{
source = dS[eqn] = 0.;
}
return source;
}
//same for y and z
Attached Images
File Type: jpg deep.jpg (40.6 KB, 60 views)
File Type: jpg keyhole.jpg (129.6 KB, 52 views)
anoop.k.unni is offline   Reply With Quote

Old   February 12, 2021, 07:31
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by anoop.k.unni View Post
can you please check whether i have written in the right way because i am not able to run the case.
"not able to run the case" can mean 20 things. Please be more detailed, that makes it much easier to help you.
pakk is offline   Reply With Quote

Old   February 12, 2021, 08:39
Default
  #6
New Member
 
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9
anoop.k.unni is on a distinguished road
Quote:
Originally Posted by pakk View Post
Going from the gradient to the divergence (in standard Cartesian coordinates) is super simple... Just sum them.

Maybe I don't understand the problem?
Quote:
Originally Posted by pakk View Post
"not able to run the case" can mean 20 things. Please be more detailed, that makes it much easier to help you.
After initializing the case with adjust gradient hoking and it is showing' Received signal SIGSEGV. MPI Application rank 0 exited before MPI_Finalize()' So, I want to know whether is it because of any mistake in UDF or other (improper boundary conditions,patching issue)
anoop.k.unni is offline   Reply With Quote

Old   February 12, 2021, 12:22
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by anoop.k.unni View Post
After initializing the case with adjust gradient hoking and it is showing' Received signal SIGSEGV. MPI Application rank 0 exited before MPI_Finalize()' So, I want to know whether is it because of any mistake in UDF or other (improper boundary conditions,patching issue)
That is a good question. To find out if your error comes from the UDF or from somewhere else: run it without hooking the UDF! If you don't get an error, the problem was in your UDF.

If you do get a problem: debug! Simplify your UDF, and find out which line causes the error.
pakk is offline   Reply With Quote

Reply

Tags
curvature, gradients, udf and programming, vof method


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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 03:53
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 08:47
UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym. ksiegs2 Fluent UDF and Scheme Programming 0 February 27, 2011 13:55


All times are GMT -4. The time now is 01:48.