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

Problems to acces VOF gradients in a Source UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 23, 2017, 15:13
Default Problems to acces VOF gradients in a Source UDF
  #1
New Member
 
Ruben Garcia
Join Date: Oct 2017
Location: Castelló de la Plana, Spain
Posts: 4
Rep Power: 9
Rufohead is on a distinguished road
Hello,

I'm a new user in ANSYS-FLUENT and I'm working in a quite simple Eulerian Multiphase model with 2 phases: liquid as main phase and solid as the secondary dispersed one.

I'm trying to implement an UDF in order to define a mass source for the solid phase but, in order to define the source equation I need to acces to the Liquid Volume Fraction Gradient. I've been trying it in different ways and I have realised that it's is possible for me to acces to the gradient of other variables (like velocity of primary phase) but when include the Solids VOF gradient in my UDF the program generates me an error (find atteched file) when I try to initialize my simulation.

The UDF Script is written as follow:

#include "stdio.h"
#include "math.h"
#include "udf.h"

DEFINE_SOURCE(secondary_source2, cell, t, dS, eqn)
{
Thread *tm = THREAD_SUPER_THREAD(t);
Thread **pt = THREAD_SUB_THREADS(tm);
real U_primary = C_U(cell, pt[0]); //Just for checking the variable is accesible
real VOF_primary = C_VOF(cell, pt[0]); //Just for checking the variable is accesible
real VOF_secondary = C_VOF(cell, pt[1]); //Just for checking the variable is accesible
real GRADX_U_primary = C_U_G(cell, pt[0])[0]; //Just for checking the variable is accesible
real GRADX_VOF_primary = C_VOF_G(cell, pt[0])[0]; // This is the part that generates the error
Message("VOF_secondary= %f \n", VOF_secondary);
Message("VOF_primary= %f \n", VOF_primary);
Message("U_primary= %f \n", U_primary);
Message("GRADX_U_primary= %f \n", GRADX_U_primary);

real Source = 100 * GRADX_VOF_primary;
return Source;
}

I have tryed using previously the command solve/set/expert and answering “yes” to the question “Keep temporary solver memory from being freed?” in order to keep all the data (specially gradients) in the memory but it doesn't work.

I would really appreciate whether someone could tell me what am I doing wrong or suggest any other approach to do that.

Thank you in advance
Attached Images
File Type: jpg UDF error.JPG (110.9 KB, 34 views)
Rufohead is offline   Reply With Quote

Old   November 24, 2017, 09:16
Default
  #2
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 16
Sun is on a distinguished road
I don't think there is macro called C_VOF_G(c,t), are you sure about it?
Sun is offline   Reply With Quote

Old   November 24, 2017, 13:52
Default
  #3
New Member
 
Ruben Garcia
Join Date: Oct 2017
Location: Castelló de la Plana, Spain
Posts: 4
Rep Power: 9
Rufohead is on a distinguished road
Hello Sun, thank you for answering.

I have to say I'm quite new in UDF programming and It's possible I've made some silly mistake. I've just guessed there must exist the C_VOF_G(c,t) macro since its has the same nomenclature as the other macros to call any of the other variables gradients (like C_P_G(c,t), C_U_G(c,t), and so on). In fact I would say I have seen this macro in one example in the UDF Guide v18 (find attached file) but I'm not completly sure they are using it in the same context.

My intention is, as I tryed to explain, to acces to the value of the Volume Fraction Gragient of the different phases in order to operate with it to deffine my Mass Source function. Maybe it's not possible though a direct macro but, could anyone suggest any different approach to achieve it?

Thank you very much
Rufohead is offline   Reply With Quote

Old   November 24, 2017, 13:53
Default
  #4
New Member
 
Ruben Garcia
Join Date: Oct 2017
Location: Castelló de la Plana, Spain
Posts: 4
Rep Power: 9
Rufohead is on a distinguished road
Here I attach the file, sorry
Attached Images
File Type: jpg UDF Guide C_VOF_G sample.JPG (59.6 KB, 64 views)
Rufohead is offline   Reply With Quote

Old   November 25, 2017, 04:54
Default
  #5
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 16
Sun is on a distinguished road
Hi Ruben, I didn't know that there is actually a macro for it. I have done a bit of googling and came across with this link. It's a bit different than your application, as you want to compute a source time every time-step. It might give you some ideas though!
hope it helps
cheers!
Sun is offline   Reply With Quote

Old   November 28, 2017, 07:54
Default
  #6
New Member
 
Ruben Garcia
Join Date: Oct 2017
Location: Castelló de la Plana, Spain
Posts: 4
Rep Power: 9
Rufohead is on a distinguished road
Hello Sun,

thank you for the link. As you have said it's a bit different but I think it will really help me to figue out a solution for my case. I'll post it if I success .
Rufohead is offline   Reply With Quote

Old   December 6, 2017, 12:43
Default
  #7
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
Thread *tm = THREAD_SUPER_THREAD(t);

Does it work when you delete this line or does it give you the same error ?

because i believe t is already the mixture level thread.

Just "pt = THREAD_SUB_THREADS(t);" should be enough.
doruk is offline   Reply With Quote

Reply


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
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44


All times are GMT -4. The time now is 16:50.