CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

second previous time step Segmentation error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 29, 2023, 15:26
Exclamation second previous time step Segmentation error
  #1
New Member
 
silver
Join Date: May 2018
Posts: 7
Rep Power: 7
silversea12 is on a distinguished road
Hi,

I tried to get previous time step values in a UDF, but every time I call a 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 get Segmentation fault error.


================================================== ============================

Node 0: Process 11500: Received signal SIGSEGV.

================================================== ============================
The fl process could not be started.


It doesn't happen for the first ones (previous time step, _M1 macros). The _M1 macros work good.

Should I do something in Fluent before using the second previous time step macros (_M2)?
Does Fluent store these second previous time step values by default?
Any suggestion?
silversea12 is offline   Reply With Quote

Old   August 29, 2023, 20:39
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Make sure you've actually stepped forward before trying to call M2. There is no M2 field in the first time-step.
LuckyTran is offline   Reply With Quote

Old   August 29, 2023, 23:17
Default
  #3
New Member
 
silver
Join Date: May 2018
Posts: 7
Rep Power: 7
silversea12 is on a distinguished road
I don't think that is the problem. I tested it with the if condition and N_TIME (number of time steps) and also by first getting some time steps run and then activating the macro. But every time it runs the _M2 macros, it encounters the segmentation fault. As I mentioned before, there isn't any problem with _M1 macros, even at the beginning time step.

I use Ansys V2022; maybe this is a change in newer versions of Ansys. Or, something should be activated first in order for Fluent to store these second previous time steps.

Have you tested to get results from the _M2 macros?
I am wondering if it is just me or if it has happened to other people too. I searched, but I couldn't find anything about this.
silversea12 is offline   Reply With Quote

Old   August 29, 2023, 23:28
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
If you truly did multiple time-steps and M1 works but not M2, then the error is in your UDF and not the M2 macro

More specifically, C_T_M1 is the most restrictive of the allowed macros. If C_T_M1 works then there rest should work unless you call a disallowed one like C_uranus_M1. So you are confirming that C_T_M1 works but not C_T_M2?

The macros have not changed in a decade. It's not your Fluent version.
LuckyTran is offline   Reply With Quote

Old   August 30, 2023, 20:34
Default
  #5
New Member
 
silver
Join Date: May 2018
Posts: 7
Rep Power: 7
silversea12 is on a distinguished road
Thanks for the reply.

This is the code I tested:
================================================== ====================
/*
Calculate the average velocity at the 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 ID

d = Get_Domain(1);

t_f = Lookup_Thread(d,zone_ID);
begin_f_loop(f,t_f)
{
t = THREAD_T0(t_f); // get cell thread
c = F_C0(f,t_f); // get corresponding cell
V = 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 it encounters the segmentation error with C_U_M2(c,t) (or any other _M2 macros).

Update: I tested this UDF with older versions of Ansys, such as V19 and V18. It leads to the same outcome.
silversea12 is offline   Reply With Quote

Old   September 1, 2023, 14:27
Default
  #6
New Member
 
silver
Join Date: May 2018
Posts: 7
Rep Power: 7
silversea12 is on a distinguished road
Update:

I used THREAD_STORAGE(t, SV_...))) in the UDF 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.


Am I the only one that gets this problem with _M2 macros?
Would somebody please confirm that any _M2 macros work for them?
silversea12 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 05:28
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 18:44
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


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