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

ANSYS UDF on GPU

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

Like Tree1Likes
  • 1 Post By plotr

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 3, 2025, 09:54
Default ANSYS UDF on GPU
  #1
New Member
 
Join Date: Oct 2023
Posts: 7
Rep Power: 3
plotr is on a distinguished road
Hi there,

So, currently, we are running some PyFluent simulations on an HPC platform, but to speed up our computations vastly, we would like to use GPU instead of CPU.

We have the following UDF to generate a parabolic time-dependent velocity at the inlet:

/* UDF for time-dependent coronary inflow with a paraboloid inflow profile
Units according to SI Standards */

#include "udf.h"

#define a 0.0015 /* radius inlet in m */
#define bpm 65.0
#define pi 3.141592654

DEFINE_PROFILE(inlet_velocity,thread,position)
{
/* "Parallelized" Sections */
#if PARALLEL
face_t f;
double Va; /* Velocity profile */
double t; /* transient flow time/phase in cycle */
double r; /* radius */
double Qt; /* Flow profile */
double Iv; /* Shape(function) of velocity profile */
int ncf = 20;
/* Fourier coefficients describing transient velocity profile */
double FC[20][2] = {
{7.771158879065718e-07, 0.0},
{-1.9137987527226527e-07, -1.791911369679127e-09},
{1.0845217682621154e-08, -8.480206194017801e-08},
{1.7684953869140035e-08, -1.7029291957063344e-08},
{2.137056864166352e-08, -2.3711687251689842e-08},
{3.626328105441136e-08, 5.085415716967635e-09},
{1.1312674519145852e-08, 2.563164635736455e-08},
{-7.96671055698641e-09, 1.5020549999536426e-08},
{-8.326548245953747e-09, 2.9831718662924694e-09},
{-4.124528495204487e-09, -2.3493417624601775e-10},
{-3.538249905026171e-09, -8.004106638204953e-11},
{-3.8635323280883435e-09, -2.88857991468041e-09},
{2.480966807062465e-10, -5.23914605261328e-09},
{3.997335176893913e-09, -2.07716227670381e-09},
{2.64013476254159e-09, 1.4056024177653453e-09},
{7.079805292876343e-10, 1.167137448080335e-09},
{1.2368603689937795e-09, 1.0370616260206528e-09},
{2.3038933499127694e-10, 2.8560702934490556e-09},
{-2.773198988875632e-09, 1.7076844087473355e-09},
{-2.137746293389916e-09, -1.4757223448181385e-09},
};

t = (CURRENT_TIME * (bpm / 60.0) - floor(CURRENT_TIME * (bpm / 60.0))) / (bpm / 60.0); /*t is the local time within each period*/
Message("CURRENT_TIME = %g, t = %g\n", CURRENT_TIME, t);

begin_f_loop(f, thread)
double w0 = (2.0 * pi) / (60.0 / bpm);
int i;
float x[ND_ND];
float xx, yy, zz;
F_CENTROID(x,f,thread);
xx = x[0]; /* x-coordinate */
yy = x[1]; /* y-coordinate */
zz = x[2]; /* z-coordinate */
r = sqrt((xx*xx) + (yy*yy) + (zz*zz)); /* Distance to centroid */
{
Qt = FC[0][0];
for (i = 1 ; i <= (ncf - 1) ; i++)
{
Qt = Qt + FC[i][0] * cos(i * w0 * t) + FC[i][1] * sin(i * w0 * t);
}
Iv = (1. - pow(r,2)/(a*a));
Va = (2.0 * Qt)/(pi*(a*a));
Message("Va = %g\n", Va);

F_PROFILE(f,thread,position) = (Va * Iv);
}
end_f_loop(f,thread);
#endif /* !RP_HOST */
}

The problem here is that when we switch to GPU, the inlet boundary condition is no longer a time-dependent value but becomes the same value (the mean value of our Fourier series) throughout the entire simulations. I am assuming the time is not processed correctly within the UDF anymore due to using GPUs instead of CPUs. Still, I cannot find any (recent) information about the compatibility of ANSYS Fluent on GPU with UDFs.

Has anyone encountered a similar problem? If anyone has tips to solve this, please let us know. Thanks in advance!
Milan2013 likes this.
plotr is offline   Reply With Quote

Old   March 7, 2025, 06:22
Default Python UDF
  #2
New Member
 
Join Date: Oct 2023
Posts: 7
Rep Power: 3
plotr is on a distinguished road
Update: I started working with Python UDFs and discovered that they are currently the only UDFs that support GPU computing. However, since Python UDFs are still in beta, there is limited documentation and support available. Additionally, the examples provided did not produce the expected results. If anyone has further insights or resources on using these UDFs, please let me know.
plotr is offline   Reply With Quote

Old   March 14, 2025, 10:20
Default
  #3
New Member
 
Hector Maldonado
Join Date: Feb 2024
Location: Rotterdam
Posts: 8
Rep Power: 3
DigiHctrGT is on a distinguished road
Quote:
Originally Posted by plotr View Post
Update: I started working with Python UDFs and discovered that they are currently the only UDFs that support GPU computing. However, since Python UDFs are still in beta, there is limited documentation and support available. Additionally, the examples provided did not produce the expected results. If anyone has further insights or resources on using these UDFs, please let me know.
I was confronted with a similar situation. I asked in the Ansys Forum and a representative told me that some developments are going on to expand the capabilities of the GPU-based solver. So, as far as I know, there is no alternative. You could check if a named expression (with some limitations) might suit your purposes.
DigiHctrGT is offline   Reply With Quote

Reply

Tags
cpu, fluent, gpu, inlet bc, udf

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
Ansys Installation on Docker Container mohsen.shiea ANSYS 11 March 14, 2024 11:18
Radially varying heatflux UDF - Ansys Fluent farhanjaved Fluent UDF and Scheme Programming 1 October 25, 2020 02:38
UDF for coding CFD ANSYS FLUENT zuraidah rasep FLUENT 2 September 5, 2020 22:22
Error in UDF calling parameters from ANSYS WorkBench anand32 Fluent UDF and Scheme Programming 0 April 6, 2018 19:52
Ansys SIG$ILL error loth ANSYS 3 December 24, 2015 05:31


All times are GMT -4. The time now is 13:35.