|
[Sponsors] |
September 1, 2018, 15:36 |
UDF should be written in C or C++ standard?
|
#1 |
Senior Member
Join Date: Sep 2017
Posts: 130
Rep Power: 9 |
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? |
|
September 2, 2018, 00:30 |
|
#2 |
Senior Member
|
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.
|
|
September 3, 2018, 05:41 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
September 10, 2018, 02:26 |
|
#4 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
It writes udf in C++ language, so OOP is of course allowed. https://vcudfstudio.bitbucket.io/ |
||
December 30, 2020, 08:13 |
|
#5 |
New Member
Join Date: Jun 2011
Posts: 11
Rep Power: 15 |
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:..." |
|
December 30, 2020, 09:14 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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.) |
|
December 31, 2020, 09:09 |
|
#7 |
New Member
Join Date: Jun 2011
Posts: 11
Rep Power: 15 |
I will try a simple C++ udf both as interpreted and compiled and see..
|
|
December 31, 2020, 11:36 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Nice idea, can you share the results? (and the simple C++ udf?)
|
|
|
|
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 |