-
-
August 29, 2023 at 7:54 pm
Silversea
SubscriberHi,
I wrote a simple UDF to get the previous time step values in a transient model in Ansys Fluent V2022. It worked fine when I used current time macros, e.g., C_R(c,t) or previous time step macros, e.g., C_R_M1(c,t). However, when I tried to get the second previous time step macros, no matter which one, e.g., C_R_M2(c,t), C_U_M2(c,t), or C_T_M2(c,t), I always get Segmentation fault error.
Does fluent store the second previous time step values by default?
Should I do something in fluent before accessing the second previous time step (_M2) macros?
-
August 30, 2023 at 12:56 pm
Atharva Nagarkar
SubscriberHello,
A segementation error is usually related to incorrect allocation of memory or errors in writing the UDF.
Can you please share your UDF?
Thanks!
-
August 31, 2023 at 12:25 am
Silversea
SubscriberHi,
Thanks for the reply.
This is the code I tested:
======================================================================
/*Calculate the average velocity at outlet and print it.*/#include "udf.h"DEFINE_EXECUTE_AT_END(pre_time){Domain *d;Thread *t, *t_f;cell_t c;face_t f;real V, sum = 0., sum_V = 0.;real ave;int zone_ID = 7; // outlet IDd = Get_Domain(1);t_f = Lookup_Thread(d,zone_ID);begin_f_loop(f,t_f){t = THREAD_T0(t_f); // get cell threadc = F_C0(f,t_f); // get corresponding cellV = C_VOLUME(c,t);sum_V += V;sum += V*C_U_M2(c,t);}end_f_loop(f,t_f)ave = PRF_GRSUM1(sum/sum_V);if I_AM_NODE_ZERO_P{Message("ave = %g\n",ave);}}======================================================================It is a simple code that calculates and prints the average velocity at a boundary. I used it on both 2D and 3D models (very simple models such as 2D laminar flow in a pipe).First, I run the model for a few time steps, e.g. time steps =10. Then I apply the UDF, and continue the simulation.When I change the line "sum += V*C_U_M2(c,t);" to "sum += V*C_U_M1(c,t);" or "sum += V*C_U(c,t);" it perfectly works without error and prints the average velocity. But with C_U_M2(c,t) (or any other _M2 macros) it encounters the segmentation error. -
September 1, 2023 at 6:25 pm
Silversea
SubscriberUpdate:
I tried it on older versions of Ansys, such as 18 and 19, with the same outcome.
I also used THREAD_STORAGE(t, SV_...))) to test whether the memory has already been allocated as follows:
if (THREAD_STORAGE(t,SV_U_M2) == NULL)
{
Error("error THREAD_STORAGE SV_U_M2");
}and it produced the error. So, it means that memory is not allocated for this macro.
A question, Am I the only one that gets this problem? Would somebody please confirm that any _M2 macros work?
-
September 14, 2023 at 6:42 pm
Selawe97
SubscriberHello
I am getting the same problem also, But i read in the documentaion that data from C_T_M1 is available only if user-defined scalars are defined. and i did not understand what that mea!
-
September 15, 2023 at 9:33 am
Rob
Ansys EmployeeIt means you'll need some scalars (look in User Defined tab in the solver). They're extra scalar fields we can use to solve "stuff" as required.
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Difference between K-epsilon and K-omega Turbulence Model
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Suppress Fluent to open with GUI while performing in journal file
- Mesh Interfaces in ANSYS FLUENT
- Time Step Size and Courant Number
- error: Received signal SIGSEGV
-
7672
-
4476
-
2957
-
1433
-
1322
© 2023 Copyright ANSYS, Inc. All rights reserved.