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

UDF should be written in C or C++ standard?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By blackmask
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 1, 2018, 15:36
Question UDF should be written in C or C++ standard?
  #1
Roh
Senior Member
 
Join Date: Sep 2017
Posts: 130
Rep Power: 9
Roh is on a distinguished road
Guys,
UDF should be written in C or C++ standard? in some places I've heared that it should be written in C and another places heared that should be written in C++? if C++, so can we use OOP?
Roh is offline   Reply With Quote

Old   September 2, 2018, 00:30
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
It does not matter if you use compiled UDF. You can do a major part of your work using C/C++/FORTRAN as you please. However you need to wrap it with a C interface. You should stick to C if mixed language programming sounds foreign to you.
Roh and THA SEANGHAI like this.
blackmask is offline   Reply With Quote

Old   September 3, 2018, 05:41
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The simple answer: C.
Everything in the manual is written in C. All examples that you will encounter: C.


Now, it is possible to set C up such that it accepts functions from Fortran or C++. For 99.999% of all cases, this is needlessly complicated, and should not be done. Just do it in C.
Roh likes this.
pakk is offline   Reply With Quote

Old   September 10, 2018, 02:26
Default
  #4
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by Roh View Post
Guys,
UDF should be written in C or C++ standard? in some places I've heared that it should be written in C and another places heared that should be written in C++? if C++, so can we use OOP?
See the UDF debugging tool using VC++.
It writes udf in C++ language, so OOP is of course allowed.

https://vcudfstudio.bitbucket.io/
gearboy is offline   Reply With Quote

Old   December 30, 2020, 08:13
Default
  #5
New Member
 
Join Date: Jun 2011
Posts: 11
Rep Power: 15
elochana is on a distinguished road
Ansys Fluent UDF manual 2019 R2 says
"A user-defined function, or UDF, is a C or C++ function that can be dynamically loaded with the ANSYS Fluent solver to enhance its standard features. For example, you can use a UDF to:..."
elochana is offline   Reply With Quote

Old   December 30, 2020, 09:14
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Interesting find.
As far as I am aware, Fluent compiles with the c-compiler. C and C++ are not the same, but share syntax, so many C++ functions are also valid C. But not all.

So, unless there is an option that I am not aware of to change the compiler, this is just marketing. They can claim to support a popular language, and they are misleading, but just enough correct to defend it.

My advice remains: use C.
(Exception for experienced C++ programmers, but they wouldn't ask this question.)
pakk is offline   Reply With Quote

Old   December 31, 2020, 09:09
Default
  #7
New Member
 
Join Date: Jun 2011
Posts: 11
Rep Power: 15
elochana is on a distinguished road
I will try a simple C++ udf both as interpreted and compiled and see..
elochana is offline   Reply With Quote

Old   December 31, 2020, 11:36
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Nice idea, can you share the results? (and the simple C++ udf?)
pakk 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
Want help regarding the UDF that is been written in VS code related to weber number saratunni07 CFD Freelancers 0 May 20, 2017 03:30
Help with unsteady calculation with source/sink UDF RobV FLUENT 1 November 13, 2016 06:44
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 08:26
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12


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