|
[Sponsors] |
June 28, 2021, 11:09 |
UDF reading files from a directory
|
#1 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hi,
I have written a udf using "dirent.h" header to read a bunch of text files from an specified directory and import them into Ansys Fluent. However after building the code in Fluent, it gives me this error: ..\..\src\data_import.c(2) : fatal error C1083: Cannot open include file: 'dirent.h': Invalid argument What can I do now? It seems like Ansys does not support "dirent.h" header? Is there any way to read a directory using Ansys UDFs? Thank you! |
|
June 29, 2021, 02:02 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
We can't see how you tried to use that header file, so it is impossible for us to say if you made a mistake and how to fix it...
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
June 29, 2021, 04:57 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 1, 2021, 10:17 |
|
#4 | |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hello and thank you for your responses.
Quote:
Anyhow, I solved my issue by using my code to read the data outside fluent and write them into 2 new files which can be read easier using a fluent UDF with standard C headers (no "dirent.h"). But now I have another question: How can I use this data in other UDFs with different source files? In other words how to share variables between different UDFs? |
||
July 1, 2021, 22:22 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you may use UDMs (user-defined memory) to do that,
however, UDMs contains the variable value on each cell/face of the domain. It is array. So it could be not efficient to use UDM to store single values, but it's the simplest approach. also you may write/read variable to file. the third option is rpvars. These are variable created in fluent cortex (not UDF) using scheme language. rpvars could be read/written in UDF as well. rpvars could be of different typres: integer, double, array, strings, so on. Read Ansys Fluent Customization manual.
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 2, 2021, 07:32 |
|
#6 | |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Quote:
Also as you said, UDMs store variables of Cells/Faces or nodes but the data that I'm trying to store do not belong to any of these and I'm reading them from text files. So what should i do with the input arguments of F_UDMI macro (i.e. face and thread identifiers) ? Thanks for assistance! |
||
July 3, 2021, 15:44 |
|
#7 | |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Quote:
Hello, So thanks to Ansys UDF manual, I managed to share my desired variables between different UDF source codes in a much simpler way than the methods mentioned above. Sharing it here so others might find it helpful: Lets say you want to use the values of 2 matrices like: a[5][5] and b[5][5] that you have defined in a UDF called "Code1.c", in the UDF called "Code2.c". 1.First you must define these two matrices in one of the source codes as Global Variables which means they have to be defined outside the macro definition: Code:
#include "udf.h" real a[5][5] , b[5][5] ; DEFINE_WHATEVER_MACRO(arg1,arg2,...) { // Your macro code that uses a and b goes here. } Code:
extern real a[5][5] , b[5][5] ; Code:
#include "udf.h" #include "Extvar.h" DEFINE_WHATEVER_MACRO(arg1,arg2,...) { // Your code that uses a and b goes here. } I tested this and it worked just fine. |
||
Tags |
udf and programming, udf code, udf compilation |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[openSmoke] LaminarSMOKE compilation error | mdhfiz | OpenFOAM Community Contributions | 8 | July 2, 2024 11:32 |
SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? | EternalSeekerX | SU2 | 3 | October 9, 2020 19:28 |
1.7.x Environment Variables on Linux 10.04 | rasma | OpenFOAM Installation | 9 | July 30, 2010 05:43 |
critical error during installation of openfoam | Fabio88 | OpenFOAM Installation | 21 | June 2, 2010 04:01 |
Problems in compiling paraview in Suse 10.3 platform | chiven | OpenFOAM Installation | 3 | December 1, 2009 08:21 |