-
-
March 23, 2021 at 10:40 am
Venky_94
SubscriberI've written a UDF for surface tension source term as per the below equations.
March 23, 2021 at 12:58 pmYasserSelima
Subscriberthe error is in line = C_UDSI_G ...nthe gradient has two components or three components .. x, y or x,y,z ... but n is defined as realnnmake it nreal n[ND_ND];nMarch 23, 2021 at 1:08 pmDrAmine
Ansys EmployeeWhat do you want to achieve with the UDF? That is the question which I have.nMarch 23, 2021 at 1:16 pmYasserSelima
Subscribersame problem will occur in k ... it should be declared k[ND_ND] ... and it can not fill C_UDSI , because they have different dimensionsnMarch 24, 2021 at 2:47 amVenky_94
SubscriberWhat do you want to achieve with the UDF? That is the question which I have.https://forum.ansys.com/discussion/comment/112138#Comment_112138
@DrAmine, I'm sorry I wasn't clearer earlier. Please refer to the picture in my original post above. I'm adding a source term to model the surface tension which is exactly the same as the CSF model by Brackbill et al. already implemented in Fluent, but there is one small change which is indicated in bold at the bottom of the image (I want to smoothen the interface by changing the definition of the cell phase fraction, and area-averaging it).nnMarch 24, 2021 at 4:19 amVenky_94
Subscriberthe error is in line n = C_UDSI_G ...the gradient has two components or three components .. x, y or x,y,z ... but "n" is defined as realmake it real n[ND_ND];https://forum.ansys.com/discussion/comment/112130#Comment_112130
Thanks for your suggestions. I've made some modifications to the code, and was able to declare n as a vector using real n[ND_ND] and perform the corresponding operation using NV_V(n, =, C_UDSI_G(c,t,0)).nThe below are the concepts I'm struggling with right now.nncap is a vector that has the value ( n/NV_MAG(n) ), where n is also a vector. How would I perform the operation of dividing a vector by a scalar? As the command as it is gives me an error 'error C2296: '/': illegal, left operand has type 'real [2]'' Is there a NV macro that can handle this?nI need to calculate the divergence of the vector ncap (or simply said - the Laplacian) and store it in k. How would I go about this?nMarch 24, 2021 at 12:19 pmYasserSelima
Subscribernfor the first one, try NV_S(n,/,NV_MAG(n)) ;nNot sure about the second, sorrynMarch 25, 2021 at 3:58 amVenky_94
Subscriberfor the first one, try NV_S(n,/,NV_MAG(n)) ;Not sure about the second, sorryhttps://forum.ansys.com/discussion/comment/112353#Comment_112353
Thanks. I tried out the below command, I declared n and ncap as real n[ND_ND] and real ncap[ND_ND] respectively and stored a gradient in n using NV_V(n, =, C_UDSI_G(c,t,0)).nncap = NV_S(n, /, NV_MAG(n));nHowever I'm getting the below error using the above command, I'm not quite sure what's wrong.nerror C2440: '=': cannot convert from 'real' to 'real [2]'nMarch 25, 2021 at 4:16 amVenky_94
Subscriberhttps://forum.ansys.com/discussion/comment/112138#Comment_112138@DrAmine I'm sorry I wasn't clearer earlier. Please refer to the picture in my original post above. I'm adding a source term to model the surface tension which is exactly the same as the CSF model by Brackbill et al. already implemented in Fluent, but there is one small change which is indicated in bold at the bottom of the image (I want to smoothen the interface by changing the definition of the cell phase fraction, and area-averaging it).https://forum.ansys.com/discussion/comment/112278#Comment_112278
@DrAmine, @Rob, Could you please guide on how to calculate the laplacian of a scalar? The scalar in this case is stored in UDS0 right now. I know that I can get the first derivative of that using UDSI_G for that UDS0. I can get the unit vector by dividing the gradient by its magnitude. But for getting the divergence of the unit vector, I'll have to get the derivative of that and sum the x and y components right? How do I go about doing that?nMarch 25, 2021 at 7:06 amDrAmine
Ansys EmployeeI am sure that smoothing is not required as it is anyway offered by Fluent. Check Smoothing steps under surface tension.nMarch 25, 2021 at 7:07 amDrAmine
Ansys EmployeeFor divergence calculation I recommend avoid using UDSS to get gradient of gradients. It is better to rely on Finite Volume Way to get gradients and to have then Laplacian. The code is bit tricky but very complex. nMarch 25, 2021 at 12:58 pmYasserSelima
SubscriberTry doing it this waynnNV_VS(ncap,= ,n,/ NV_MAG(n))nnThe rule that fluent use for this macro is ... V, stands for vector ... S, for scalar ... and D, for order .. try to arrange any operation using the three letters. The macros mentioned in the UDF manual are only examples. Some examples in many chapters used macros that were not mentioned.nMarch 25, 2021 at 3:12 pmVenky_94
SubscriberTry doing it this wayNV_VS(ncap,= ,n,/ NV_MAG(n))nThe rule that fluent use for this macro is ... V, stands for vector ... S, for scalar ... and D, for order .. try to arrange any operation using the three letters. The macros mentioned in the UDF manual are only examples. Some examples in many chapters used macros that were not mentioned.https://forum.ansys.com/discussion/comment/112558#Comment_112558
Thanks a lot. It worked out this time. I tried out the same command earlier, but it gave me an error. I'm not sure what data type I declared ncap as earlier and maybe it was because of that.nMarch 25, 2021 at 3:17 pmYasserSelima
SubscriberYou are welcome!nMarch 25, 2021 at 3:26 pmVenky_94
SubscriberFor divergence calculation I recommend avoid using UDSS to get gradient of gradients. It is better to rely on Finite Volume Way to get gradients and to have then Laplacian. The code is bit tricky but very complex.https://forum.ansys.com/discussion/comment/112508#Comment_112508
@DrAmine, Could you guide me on how to do that?nWith @YasserSelima, 's help, I was able to calculate and store the unit vector n̂. Now I just need to handle the term ∇⋅n̂, which is the divergence of the vector. Please suggest.nMarch 25, 2021 at 3:35 pmYasserSelima
Subscriberwhy don't you make an intermediate step and then store only the required component. nStore ncap components in 2/3 UDM and then recall the gradient .. take the required component onlynnMarch 25, 2021 at 4:07 pmVenky_94
Subscriberwhy don't you make an intermediate step and then store only the required component. Store ncap components in 2/3 UDM and then recall the gradient .. take the required component onlyhttps://forum.ansys.com/discussion/comment/112593#Comment_112593
This is my understanding of the above. Please correct me if I'm wrong.nStore the x and y component of ncap in 2 separate UDS (UDS1 and UDS2).nGet the x-component gradient of UDS1 by UDSG1[0] and x-component gradient of UDS2 by UDSG2[1] and add UDSG1[0] and UDSG2[1] to get the term ∇⋅n̂ .nIs my understanding right? If it is, just suggest on how to obtain only the x and y components of ncap in a UDS. Will ncap[0] or ncap[1] work?nMarch 25, 2021 at 4:16 pmVenky_94
Subscriberwhy don't you make an intermediate step and then store only the required component. Store ncap components in 2/3 UDM and then recall the gradient .. take the required component onlyhttps://forum.ansys.com/discussion/comment/112593#Comment_112593
This is the understanding of the above. Please correct me if I'm wrong.nGet the x and y components of the unit vector ncap and store them in 2 separate UDS (UDS1 and UDS2 respectively).nGet the x-component gradient of UDS1 as UDSG1[0] and y-component gradient of UDS2 as UDSG2[1]. Add the terms UDSG1[0] and UDSG[1] to get the term ∇⋅n̂.nIs the above approach what you suggested? If it is right, could you please suggest on how to obtain the x and y component of ncap separately? Would the commands ncap[0] and ncap[1] work?nMarch 25, 2021 at 4:33 pmYasserSelima
Subscriberyes, this is what I meant but UDM instead of UDS but still worknncap[0] is the x component of ncapnMarch 25, 2021 at 4:36 pmYasserSelima
SubscriberJust a hint ... the gradients you get will be a mix of the new values at the current iteration and the previous values, depending if the adjacent cells are updated or not nMarch 25, 2021 at 4:52 pmVenky_94
Subscriberyes, this is what I meant but UDM instead of UDS but still workncap[0] is the x component of ncaphttps://forum.ansys.com/discussion/comment/112612#Comment_112612
I understood that but I didn't think there was a Macro, say C_UDMI_G to get the gradients from a UDM automatically. I wasn't sure how I would be getting the gradients from a UDM.nMarch 25, 2021 at 4:57 pmYasserSelima
SubscriberI am not sure it exist but I assume ...nMarch 25, 2021 at 5:03 pmVenky_94
SubscriberJust a hint ... the gradients you get will be a mix of the new values at the current iteration and the previous values, depending if the adjacent cells are updated or nothttps://forum.ansys.com/discussion/comment/112615#Comment_112615
Can I avoid this if I do the entire calculation within a ADJUST udf and store the terms in UDMs, that I can call upon in my SOURCE udf?nSince ADJUST udfs are called before every iteration, this should ensure that the gradients are proper right?nMarch 25, 2021 at 5:18 pmYasserSelima
Subscriberyes, definitely ... Also if you want to have a gradient of a gradient inside Define adjust, you can use two separate loops and in between use PRF_GSYNC() to make sure no Node start the second loop until all finish the first. nMarch 25, 2021 at 5:19 pmYasserSelima
SubscriberDon't forget to disable solving the UDS equations where you store the valuesnMarch 25, 2021 at 5:48 pmVenky_94
SubscriberThanks a lot. I'll try it out today. nMarch 25, 2021 at 9:26 pmYasserSelima
SubscriberYou are welcome!nViewing 26 reply threads- You must be logged in to reply to this topic.
Ansys Innovation SpaceEarth 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.
Trending discussions- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
Top Contributors-
2524
-
2066
-
1279
-
1096
-
457
Top Rated Tags© 2023 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-