Fluent UDF command C_VOF_G causing error/crash

  • 231 Views
  • Last Post 14 January 2019
  • Topic Is Solved
tallred11 posted this 08 January 2019

I'm trying to access the gradient of the volume fraction in a cell via UDF, but I'm consistently getting an error which crashes fluent (Node 0: Process xxxx: Received signal SIGSEGV). I'm able to access the volume fraction of the cell itself using C_VOF, so it seems I'm doing the cell thread and looping appropriately. 

I understand that the gradients aren't stored for the initial time step, but I have avoided this calculation in the initial time step so I know that isn't the issue. 

Let me know if you have any advice.

Thanks!

Order By: Standard | Newest | Votes
abenhadj posted this 08 January 2019

To use the documented way use the text command /solve/set/expert and answer yes to the question "Keep temporary solver memory from being freed?" 

Best regards,

Amine

tallred11 posted this 09 January 2019

Thanks for the response.

I had found this advice elsewhere on the internet, but don't quite understand the instructions. Where exactly do I put in these text commands? This isn't a part of the UDF, correct? I need to input this somewhere in the Fluent GUI? I initially thought it was an alternative for just selecting settings in the GUI, but couldn't find the appropriate settings. I'm working in Fluent through Ansys Workbench version 19. 

abenhadj posted this 09 January 2019

You put the in the Fluent Console Window. You type at first "solve" then "set" then "expert" and answer with "yes" whenever you are asked with "..Memory"

 

Best regards,

Amine

  • Liked by
  • tallred11
tallred11 posted this 09 January 2019

Alright, thanks. I did that - still running into the same error.

rwoolhou posted this 10 January 2019

Check you have both phases present: SIGSEV isn't overly diagnostic in itself. Are there any warnings/errors when you compile the code?

tallred11 posted this 10 January 2019

I think the only warning I have when compiling is that I have an unused variable. That doesn't lead to any issues without me calculating the gradients, so I don't believe that is the issue.

Do I need to have both phases present in every cell I try to calculate the gradient in? I figured that it would just say the gradient was [0,0] if only one phase was present in the cell. I do have both phases present in some cells of course.

abenhadj posted this 10 January 2019

Paste your UDF Here.

Best regards,

Amine

tallred11 posted this 10 January 2019

tallred11 posted this 10 January 2019

See the UDF above, it's not doing a whole lot now. I'm working on a bubble growth simulation and am playing around with how I can manipulate the interface near the surface. So, I'm messing with the face volume fractions at the boundary and see how the adjacent cell volume fraction and cell volume fraction gradient are influenced.

abenhadj posted this 11 January 2019

So can you now debug it line by line by eliminating some blocks: like the one where the face vof is assigned. Just limit it at first to accessing the gradient?. 

Best regards,

Amine

abenhadj posted this 11 January 2019

Moreover I will split the UDF into a DEFINE_PROFILE and DEFINE_ADJUST where in the profile the VOF is prescribed. DEFINE_PROFILE is executed two times before the DEFINE_ADJUST.

Best regards,

Amine

  • Liked by
  • tallred11
tallred11 posted this 11 January 2019

Alright, I commented out everything from the "if" statement that assign the F_VOF through to the end of the second set of messages and I still received the same error. If I change the C_VOF_G to C_P_G to look at the pressure gradient instead, it runs fine. So C_VOF works and other gradients work; so it seems to be an issue unique to C_VOF_G.

Regarding your other point, I had thought of implementing this in a DEFINE_PROFILE rather than a DEFINE_ADJUST, but wasn't sure where I could hook it up. If I hook this up to the wall adhesion BC for contact angle, can I control the contact angle and the F_VOF in the same DEFINE_PROFILE? I thought perhaps since there was no boundary condition for the phase fraction (since it is a solid wall), I couldn't set the volume fraction using DEFINE_PROFILE. But, can I simply do it the same way I'm doing it now and it will fix it throughout the iteration?

tallred11 posted this 11 January 2019

So, I changed the gradient to a reconstruction gradient (C_VOF_RG) and now it runs without giving the error. I don't fully understand the difference between the gradients and reconstruction gradients after reading the manual descriptions, but it still doesn't seem to be working properly. I get a gradient of [0,0] in every cell even at the interface cells which have a volume fraction between 0 and 1. It seems to me that these interface cells must have a non-zero volume fraction gradient. 

abenhadj posted this 11 January 2019

Through flag SV _ Allocated _ p (t, SVVOFG) you can check if gradients are available or not to avoid crashes. Contact angle can be controlled via Profile UDF.

Best regards,

Amine

  • Liked by
  • tallred11
tallred11 posted this 11 January 2019

I know that contact angle can be controlled via the DEFINE_PROFILE. I have done this successfully. I was wondering if in the same DEFINE_PROFILE macro I can fix the face volume fractions.

abenhadj posted this 11 January 2019

And there is zero gradient in cells having pure phase. Make it more basic and try to get the gradients overall instead in the vicinity of a boundary. You will need to look over all threads.

Best regards,

Amine

  • Liked by
  • tallred11
tallred11 posted this 11 January 2019

I tried the UDF below to loop over all cells in all threads within the domain and tried the mixture domain (Get_Domain(1)) and both subdomains (Get_Domain(2) and Get_Domain(3)) and it appears that C_VOF_G is Null in all of them. 

Conversely, if I use C_VOC_RG once again, it does print the appropriate message but all gradients are [0,0]. So, it does appear that the SV_ALLOCATED_P(t, SV_VOF_G) is working properly. 

I noticed frequently in forums people will assign C_VOF to a UDS and then calculate the gradient of the UDS. I've never really understood why since Fluent already tracks these variables in during VOF simulations, but perhaps the reason is because there is an issues with C_VOF_G?

abenhadj posted this 11 January 2019

I made a test and following the official way I can access the gradients in a on demand. The same UDF but changed to an Adjust tells that gradient is not accessible as they might have been cleared after they have been used.

Best regards,

Amine

tallred11 posted this 11 January 2019

Alright, so for whatever reason the /solve/set/expert setting isn't keeping it from being cleared? It should also work for an EXECUTE_AT_END right? 

I will try some other macro options. Thanks!

abenhadj posted this 14 January 2019

Why do you not use the RGs? 

Best regards,

Amine

tallred11 posted this 14 January 2019

Well - 1) I don't really understand what the RGs are. If you could give a brief explanation of them, I'd appreciate it. It isn't overly clear in the manual.

2) I did try these as mentioned previously. It doesn't give me any errors, but it gives me a gradient of [0,0] in every cell - even those that have a C_VOF between 0 and 1 - which must be incorrect.

abenhadj posted this 14 January 2019

1/RG are reconstruction gradients which are based on gradient being limited to avoid overshoots/undershoots in the solution equations.

2/Very strange. I cannot reproduce the issue.

3/Are you able to access the gradients in a DEFINE_ON_DEMAND?

Best regards,

Amine

tallred11 posted this 14 January 2019

Using the simpler code (named VOFGTest), I was able to get the gradients and RGs to calculate and obtained reasonable values using either a DEFINE_ON_DEMAND or DEFINE_EXECUTE_AT_END with the solve/set/expert settings set appropriately as you detailed. So, success there. Thanks for all your help!

For whatever reason, I'm still having issues getting it to work with the other code (named pinCL). I've changed it to an EXECUTE_AT_END and have verified that I'm on the appropriately face and cell threads by looking the THREAD_ID(t) in the code that is working. The only major thing I see that I'm doing differently is that I have a thread_loop_c in the one that is working and not in the one that isn't working, but I'm manually getting the appropriate threads in the one that isn't working because I only want to look at the cells adjacent to the boundary.

If you have anything thoughts on why this isn't working, let me know. Otherwise, I think the key issues have been resolved and I just need to do some troubleshooting on this UDF. Thanks for all your help!

 

abenhadj posted this 14 January 2019

As I said this might be related to the execution sequence of the define macros. Whenever the solution has been calculated / or prior to the iteration the gradients are not stored/available. I will update here whenever I have additional input. Just for your info: AT:´_END macro is executed at the end of the time step. 

Best regards,

Amine

tallred11 posted this 14 January 2019

Moreover I will split the UDF into a DEFINE_PROFILE and DEFINE_ADJUST where in the profile the VOF is prescribed. DEFINE_PROFILE is executed two times before the DEFINE_ADJUST.

I have a couple questions regarding this as well actually. I would very much like to implement setting the F_VOF in a DEFINE_PROFILE macro; however, I'm having issues hooking it up in this manner.

1) I know I can set contact angle, but this doesn't achieve the same effect. The only way setting the F_VOF via this macro would make sense to me would be if I were getting a volume fraction boundary condition at an inlet/outlet, but this is a wall. Can I set the F_VOF at the wall in this manner?

2) If so, how/where would I hook up the macro? There aren't really any options to hook up for this wall BC unless I enable wall adhesion, but if I don't want to set a contact angle can I still use this BC to hook it up?

If I can use this macro, it might circumvent some of the other issues I'm having.

Thanks!

abenhadj posted this 14 January 2019

That would not work. Either source terms for VOF or profile for contact angle. You can check degassing UDF example from the manual where the secondary phase is extracted and the primary getting reflected.

 

Best regards,

Amine

  • Liked by
  • tallred11
tallred11 posted this 14 January 2019

Ok, that's what a thought. Thanks for verifying. I'll check out the degassing UDF.

Close