TAGGED: #fluent-#ansys, udf, udferror
-
-
December 7, 2023 at 6:23 pm
brandon.hager.63
SubscriberHello,Â
I am writing a UDF as DEFINE_SOURCE that will perform some calculations within a singular cell zone. I want to write the result of those calculations in a text file. Currently, I can write the data using the following code. However, I run into issues where I get duplicates of many values. Additionally, some of those duplicates contain values that aren't sensible. I have confirmed that these are duplicate values by having the UDF write the cell coordinates and unique cell ID numbers. Because the DEFINE_SOURCE macro loops over all of the cells in a cell zone I expect that the amount of data written is equal to the total number of cells. This is often not the case as I usually have more data than cells. I think my issue is that my current code is not parallelized for writing the data.
I have found the Ansys documentation on how to write files in parallel here: https://www.afs.enea.it/project/neptunius/docs/fluent/html/udf/node231.htm
I have tried to implement it within the source term by removing the DEFINE_ON_DEMAND, but I either receive a segmentation fault error or the simulation will hang on the iteration that the data is supposed to be written on. Currently, I am only testing by writing each cell's temperature instead of all of the data I require. I've included the new code below.
I'm not sure what is causing the segmentation fault or the hanging behavior. Any help would be greatly appreciated.
Thanks.
-
January 2, 2024 at 4:47 pm
Luca B.
Forum ModeratorHi, in the Ansys Fluent Documentation you can find very good indication how to best write an UDF in parallel.
When you run an UDF in parallel and you want to print ( or write to file ) a data, you have to be be sure to loop only on nodes and skip the host. There are some "Neighborhood"Â cells that you want to skip in the count. ( see chapter 7.2)Â
I have seen you are trying to use this raccomandation in your UDF. It is quite hard to debug your code to understand what generate the segmentation fault.Â
I suggest you to create a simpler case, to test how writing in parallel works and then to increse the complexity to identify the critical lines that generate the error.
You can first print the results on screen and then save to file.Â
You wrote you are not using DEFINE_ON_DEMAND macro. What type of macro are you using?Â
Hope my suggestions help you.
Luca
-
- The topic ‘Writing UDF data to a file in parallel’ is closed to new replies.
- air flow in and out of computer case
- Varying Bond model parameters to mimic soil particle cohesion/stiction
- Eroded Mass due to Erosion of Soil Particles by Fluids
- I am doing a corona simulation. But particles are not spreading.
- Centrifugal Fan Analysis for Determination of Characteristic Curve
- Guidance needed for Conjugate Heat Transfer Analysis for a 3s3p Li-ion Battery
- Issue to compile a UDF in ANSYS Fluent
- JACOBI Convergence Issue in ANSYS AQWA
- affinity not set
- Resuming SAG Mill Simulation with New Particle Batch in Rocky
-
4047
-
1467
-
1308
-
1156
-
1021
© 2025 Copyright ANSYS, Inc. All rights reserved.