CFD UDF

DiabqDiabq Member Posts: 4

I am trying to write a UDF that relates the changing cross-sectional diameter of 3D irregular channel to the viscosity.

To find the diameter I thought about finding the area of a cross section and find the diameter from there. Thus I need a UDF to add the facets area of a cross section of the channel.

Also can I use the same function to relate several cross sections to the following empirical equation to have changing viscosity along the segment? viscosity= 0.022* exp(Diameter^0.3)

Best Answers

  • YasserSelimaYasserSelima Posts: 944Member
    Accepted Answer

    Yes you can use it along the segment ... but it is really tough. There is a macro that loop over the cell faces ... and there is a macro that returns the cells on both sides of the face ... so, you can actually move from a cell to the next. But this is really long to be done every time step for every single cell. Alternatively, do it once through DEFINE_ON_DEMAND and save it in UDM .. then use it during simulations.

    However, I believe it is easier to use any CAD software and find the area/diameter as a function of X ...

  • YasserSelimaYasserSelima Posts: 944Member
    Accepted Answer

    Not sure about tutorial use UDM, but the procedure is easy ... first you need to set the number of user defined memory in your case. From the graphical user interface, User-Defined then memory and increase the number to 1 or more based on how many variable you need to save.

    Then, in your function, the macro is C_UDMI(c,t,i) ... for example C_UDMI(c,t,0) = 1; This saves  1 to the UDM number 0 for the cell c in the cell_thread t ... and when you need to use it, x=C_UDMI(c,t,0); and this makes equal to the value stored in the UDM

    For face, same macro but F_UDMI(f,t,i) .. and for nodes N_UDMI ... note that the number available for nodes is set separately.

Answers

Sign In or Register to comment.