CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Auto-compile error (https://www.cfd-online.com/Forums/fluent-udf/182675-auto-compile-error.html)

twcp0104 January 16, 2017 07:56

Auto-compile error
 
Hi everybody,

So I have this annoying error that pops up every day:

when I save a case with a UDF library attached to it and then go to reopen it, fluent tries to do this auto-compile thing. It would be very useful, but it keeps throwing segmentation errors that don't happen when I compile the normal way. Specifically these segmentation errors happen when I use F_AREA or F_CENTROID in the DEFINE_ON_LOAD macro. From that I imagine that fluent hasn't fully loaded the mesh from the saved case yet, but I could be wrong.

Anybody has an idea of how to fix this?

I can give more information including the code. I'm using ANSYS Fluent 16.0 with Visual Studio 13 for compiling.

kirmaks January 24, 2017 02:32

Hallo,

it may happen if Your UDF is using some data which is generated during the solver run like gradients of the variables. You may check Your code and comment out such places and see if UDF is loaded without errors afterwards. Then You may try to check if the data are present with constructions similar to
Code:

if (NULL != THREAD_STORAGE(t,SV_U_G) )
in Your UDF. Best regards Maksim

twcp0104 January 24, 2017 05:45

Quote:

Originally Posted by kirmaks (Post 634475)
Hallo,

it may happen if Your UDF is using some data which is generated during the solver run like gradients of the variables. You may check Your code and comment out such places and see if UDF is loaded without errors afterwards. Then You may try to check if the data are present with constructions similar to
Code:

if (NULL != THREAD_STORAGE(t,SV_U_G) )
in Your UDF. Best regards Maksim

Thanks for the reply.

So, yes, I've been doing that. The code seems to reject the F_AREA, F_CENTROID, THREAD_ID macros present on the EXECUTE_ON_LOADING macro, which led me to believe that the mesh was not available during loading. Is that true?

kirmaks January 25, 2017 02:31

Hallo,

You may try to replace EXECUTE_ON_LOADING with EXECUTE_ON_DEMAND and call the second macro before starting the iterations. Then You will be sure that the mesh and data are loaded.

Regards, Maksim

twcp0104 January 25, 2017 13:44

Quote:

Originally Posted by kirmaks (Post 634628)
Hallo,

You may try to replace EXECUTE_ON_LOADING with EXECUTE_ON_DEMAND and call the second macro before starting the iterations. Then You will be sure that the mesh and data are loaded.

Regards, Maksim

Hi, thanks for the reply.

So... yeah... what I have been doing (to preserve my sanity) is including everything that was in the EXECUTE_ON_LOADING in the DEFINE_INIT so that it would load after the mesh was loaded. I'd still really like to have it in the EXECUTE_LOADING macro though, but what are you gonna do.

I am right in thinking that that the loading phase for the EXECUTE_ON_LOADING happens before the mesh is loaded? because that doesn't seem to make sense to me

twcp0104 February 2, 2017 13:50

Just to close the thread: the conclusion was that when using the DEFINE_ON_LOADING macro, you dont always have access to the macros that access the mesh variables like F_AREA and F_CENTROID. long story short, if you use these macros and fluent tries to auto-compile, you'll get a segmentation fault.

The solution was to move the problematic code to the DEFINE_INIT macro. The initialization is run after the mesh has been loaded and I haven't had a problem since.


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