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

Segmentation error with F_PROFILE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2018, 06:53
Default Segmentation error with F_PROFILE
  #1
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Code:
DEFINE_ADJUST(functionName, domain_pointer)
{
    Thread* thread_pointer = Lookup_Thread(domain_pointer, zone_index);
    face_t facet;
    cell_t c0; 
    Thread* t0 = thread_pointer->t0; 
    
    begin_f_loop(facet, thread_pointer)
    {
        c0 = F_C0(facet, thread_pointer);
        F_PROFILE(facet, thread_pointer, zone_index) = -1.0 * C_UDMI(c0, thread_pointer, var);
    }
    end_f_loop(facet, thread_pointer)
}
I get a segmentation error when I try and run this UDF. It compiles without any warnings and initializes as well.

I get the zone_index from another UDF which represents the boundary at which I want to use this BC (using THREAD_ID). It retrieves the correct boundary (checked).

Only on commenting or negating any assignment in the highlighted line does the error not persist.

Any insight would be really appreciated. Thanks
zobekenobe is offline   Reply With Quote

Old   April 24, 2018, 09:03
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Let's start with the obvious: you should have a user defined memory (UDM) activated, do you?

Secondly: first you use "thread_pointer" as a pointer to a face-thread, but later it is a pointer to a cell-thread. That will give you problems...

And finally: what are you actually doing with F_PROFILE here? The third variable that you give is the zone-index, but it should be an integer index to a variable. I have never seen a F_PROFILE used in a DEFINE_ADJUST, normally you use a DEFINE_PROFILE for that.

From your code, I can not guess what you are trying to do, so I can not give a suggestion on what to do.
pakk is offline   Reply With Quote

Old   April 24, 2018, 09:44
Default
  #3
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Thanks Pakk for your answer

(1) Yes, the UDM has been activated and the values successfully stored.

(2) I'm not very sure where this is happening (could you let me know on which line of the code this happens). c0 is the pointer to the cell immediate to the boundary face.

(3) the variable zone_index, is a global integer variable taken from another boundary UDF. The value has been checked and is unaltered. Also, when passing the boundary ID directly, the problem did persist.

(4) DEFINE_ADJUST is also used to specify alternate/ conditional boundary conditions (Fluent UDF documentation)

What I am trying to do is specify a flux through a boundary; which is supposed to replicate a membrane wall.
zobekenobe is offline   Reply With Quote

Old   April 24, 2018, 09:53
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
(2) I was talking about "thread_pointer", not about "c0". You use it two times in the line that you made bold-faced, and it has two different meanings.

(3) I believe that "zone_index" is the correct integer for the zone that you want to have. But in F_PROFILE, you should not give the integer for the zone that you want to have, the third integer should be an integer index to a variable.

(4) It might be possible to use DEFINE_ADJUST for that, but it is a lot more complicated. Just use DEFINE_PROFILE... Then you almost automatically also solve the two problems above.
pakk is offline   Reply With Quote

Old   April 24, 2018, 10:06
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
This might already work:
Code:
/* var defined somewhere above */
DEFINE_PROFILE(functionName, t, i)
{
    face_t facet;
    begin_f_loop(facet, t)
    {
        F_PROFILE(facet, t, i) = -1.0 * F_UDMI(facet, t, var);
    }
    end_f_loop(facet, t)
}
pakk is offline   Reply With Quote

Old   May 14, 2018, 07:59
Default
  #6
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Thanks Pakk,

the suggested code did work.

But I wonder if you could suggest how to get around the complete problem I have at hand.

I'm simulating a 2D rectangular channel. The bottom surface is the membrane through which a fixed amount of the fluid is allowed to flow.

Initially I was defining the membrane surface as a wall and hence was trying to use define_adjust to specify the flux on the boundary.

However if I have to use DEFINE_PROFILE, I have to define the bottom membrane surface as a velocity inlet.

This results in reversed flow and over prediction of the calculated flux coming into the channel rather than flowing out.

Any suggestion as how to approach the problem assuming the UDF is correct?

Thanks
zobekenobe is offline   Reply With Quote

Old   May 14, 2018, 11:35
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Check if you missed a minus sign.
pakk is offline   Reply With Quote

Old   May 17, 2018, 07:52
Default
  #8
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Hi Pakk,

Thanks for your reply. I have checked with the signs and they seem all good.

Any suggestions on how to apply two boundary conditions on one boundary surface.

(1) I need to set the flux at the surface
(2) I need to calculate/ predict the solute concentration on the same surface (analytical solution available that I have used in the UDF)

thanks
zobekenobe is offline   Reply With Quote

Old   May 17, 2018, 21:16
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
use two DEFINE_PROFILE macro in your UDF, one for flux, another for concentration

best regards
AlexanderZ is offline   Reply With Quote

Old   May 18, 2018, 07:02
Default
  #10
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Hi Alexander,

Thanks for the reply.

The boundary I am applying these conditions to is suppose to be a membrane through which there is an outflow. The objective is that I would want to know the effective flux and polarization layer on the membrane surface (both affect each other)

The solute transport is solved by user defined scalar transport.

if I have to use 2 DEFINE_PROFILE macros on the same boundary (for velocity out and scalar concentration) then I will need to define membrane as a velocity inlet : (1) to define a negative flux (2) define the UDS flux/value at the boundary

using mass outlet/ pressure outlet only allows one to define the scalar BC and the gauge pressure

Would defining the boundary (outflow) as an inlet with negative velocity be logically correct.

Many at times I have had reversed flow when I have done this
zobekenobe is offline   Reply With Quote

Reply

Tags
boundary conditions, define_adjust, f_profile, segmentation error


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
sigSegv error, segmentation error? ollebapur OpenFOAM Running, Solving & CFD 1 June 11, 2018 07:54
Segmentation fault when running dieselFoam or dieselEngineFoam in parallel francesco OpenFOAM Bugs 4 May 2, 2017 21:59
Segmentation fault in SU2 V5.0 ygd SU2 2 March 1, 2017 04:38
segmentation fault when installing OF-2.1.1 on a cluster Rebecca513 OpenFOAM Installation 9 July 31, 2012 15:06
Segmentation Violation Corentin FLUENT 1 February 13, 2011 01:07


All times are GMT -4. The time now is 00:07.