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

New boundary condition: second derivative to zero

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2018, 09:41
Default New boundary condition: second derivative to zero
  #1
New Member
 
Join Date: Apr 2018
Posts: 3
Rep Power: 8
tbridel is on a distinguished road
Hello everybody,

I have looked through CFD-online, and I admit I found a few threads that are related to my question (for instance Second Derivative Zero - Boundary Condition) but ... well, I still have no idea where to start the implementation, so I seek your help.

The set-up: I have a channel, basic rectangular geometry.

The bocos : at inlet I have a UDF that induces a pressure pulse, and at outlet I would like to have the (in)famous convective boundary condition, i.e. du/dt + cdu/dx = D (d^2 u/dx^2) = 0.

The problem : I played with inlet UDFs, I played with UDFs to impose a velocity at a wall, to have this velocity depending on a normal gradient even ... but how do you impose a second derivative to be zero at an outlet boundary condition ?

Any help is welcome, thank you so much in advance.

T
tbridel is offline   Reply With Quote

Old   April 16, 2018, 10:55
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi there T,

I'm interested to hear any positive responses, but if you don't get any, I think you could conclude that Fluent is not going to make this easy for you. Try another code?

If I think about how I would try it in Fluent if forced at gunpoint, my brain melts slightly. We can follow the plan in that OpenFoam thread (which you linked to): we can calculate the inlet velocity retrospectively, one timestep behind. So we "only" need to calculate first and second derivatives of u, and use them to define the next step's inlet velocity.

(1) To get the timing right, we could do the calculations for the next timestep at the end of the current timestep, in DEFINE_EXECUTE_AT_END.

(2) We store the result from those calculations in User-Defined Memory... oh dear, probably not available for an inlet. Store it in the neighbouring cell, and arrange the mesh such that no cell contains more than one inlet face.

(3) How do we calculate the derivatives? You have a rectangular block, so you can have a structured mesh, so you could calculate it yourself if necessary. (If running in parallel, arrange the mesh partition that at least three layers of cells from the inlet are in the same partition.) You would need to look up the cell neighbouring the inlet, then find the cell downstream of that, and possibly the cell downstream of the downstream cell. (We are probably calculating derivatives at cell centres, even though we want them at faces. We assume hex cells, or at least prismatic.) With a bit of ingenuity, you could store the identities of those looked-up cells in User-Defined Memories. It would help to arrange the mesh to guarantee that there are is only one cell zone within three or four cells of the inlet.

(4) Alternatively, you can copy quantities like C_U into User-Defined Scalars, and get Fluent to calculate the derivatives of the scalars. Then copy those derivatives into other UDS(s), and get Fluent to calculate the derivative of that/those. (There are commands to force Fluent to calculate a set of derivatives -- see UDF-How to calculate gradient of a scalar . There is no official documentation that I know of, but you will get some semi-official hints if you search for Scalar_Derivatives etc in the ANSYS Customer Portal.) Now you have some sort of first and second derivatives. You would need to do some hard thinking and testing to see what boundary conditions are suitable for the UDSs at the inlet.

So I would estimate that as a couple of weeks of solid work (at least), to reach something which is not really what you asked for and is probably unstable. Are you sure you want to do this?

Ed
obscureed is offline   Reply With Quote

Old   April 16, 2018, 11:15
Default
  #3
New Member
 
Join Date: Apr 2018
Posts: 3
Rep Power: 8
tbridel is on a distinguished road
Hello Ed,

Thank you for your interest.

Quote:
Originally Posted by obscureed View Post
Try another code?
Ahah yea ... if only ..! Let us assume I am forced to use Fluent ... at gunpoint

Quote:
Originally Posted by obscureed View Post
If I think about how I would try it in Fluent if forced at gunpoint, my brain melts slightly. We can follow the plan in that OpenFoam thread (which you linked to): we can calculate the inlet velocity retrospectively, one timestep behind. So we "only" need to calculate first and second derivatives of u, and use them to define the next step's inlet velocity.
OK, I realize the "my problem" bullet in my ori post was very misleading. I only want to set the second derivative of the velocity to zero at an outlet. All those things I said about the walls and the inlet were to put things in the context of what I have already played with before.
Anyways your thoughts on the matter are very interesting to me.

Quote:
Originally Posted by obscureed View Post
(1) To get the timing right, we could do the calculations for the next timestep at the end of the current timestep, in DEFINE_EXECUTE_AT_END.
What about using the unsteady API already present in Fluent UDF facility, with things such as CURRENT_TIME and all ? I mean, I could hook an UDF up to a ... wall boco (?) to manipulate the velocity and with CURRENT_TIME and the other macros, get the value at the previous time. What do you think ?

Quote:
Originally Posted by obscureed View Post
(3) How do we calculate the derivatives? You have a rectangular block, so you can have a structured mesh, so you could calculate it yourself if necessary. (If running in parallel, arrange the mesh partition that at least three layers of cells from the inlet are in the same partition.) You would need to look up the cell neighbouring the inlet, then find the cell downstream of that, and possibly the cell downstream of the downstream cell. (We are probably calculating derivatives at cell centres, even though we want them at faces. We assume hex cells, or at least prismatic.) With a bit of ingenuity, you could store the identities of those looked-up cells in User-Defined Memories. It would help to arrange the mesh to guarantee that there are is only one cell zone within three or four cells of the inlet.

(4) Alternatively, you can copy quantities like C_U into User-Defined Scalars, and get Fluent to calculate the derivatives of the scalars. Then copy those derivatives into other UDS(s), and get Fluent to calculate the derivative of that/those. (There are commands to force Fluent to calculate a set of derivatives -- see UDF-How to calculate gradient of a scalar . There is no official documentation that I know of, but you will get some semi-official hints if you search for Scalar_Derivatives etc in the ANSYS Customer Portal.) Now you have some sort of first and second derivatives. You would need to do some hard thinking and testing to see what boundary conditions are suitable for the UDSs at the inlet.
Yes, computing derivatives close to a boco is tricky I agree. I found it often better to activate the /solve/set/expert mode to keep the temporary buffer to be deleted at every iteration so the macros defined in sg.h are accessible from an UDF, like C_DUDX and co. So I could have access to the first derivative of the velocity in the cell neighboring my outlet boco, and passing by a temporary storage in an UDS I could get the second derivative in the cell neighboring my boco. That, at least I think, would not be much trouble.
But
, one I know the value of the second derivative, any toughts on how to make it zero at each timestep ? In a way where Fluent gets the info and the flow behaves in consequence ?

Quote:
Originally Posted by obscureed View Post
Are you sure you want to do this?
Ehh ... gunpoint thing ... Or even if there is no gunpoint, I am in a situation where I cannot think of anything else to get my simulations to match the experimental data I have and it is kinda devouring me

Thanks everyone for any input !

T
tbridel 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
My radial inflow turbine Abo Anas CFX 27 May 11, 2018 02:44
Out File does not show Imbalance in % Mmaragann CFX 5 January 20, 2017 11:20
inlet velocity boundary condition murali CFX 5 August 3, 2012 09:56
External Radiation Boundary Condition for Grid Interface CFD XUE FLUENT 0 July 9, 2010 03:53
External Radiation Boundary Condition (Two sided wall), Grid Interface CFD XUE FLUENT 0 July 8, 2010 07:49


All times are GMT -4. The time now is 18:52.