Can someone please guide me through/send links on how to hook UDFs for the inlet velocity BC? I want a particular profile input.
If I were to use a subroutine .f file, and give BC_V_g for the inlet, which subroutine should I use? What command do I put inside of that subroutine? I want a trapezoidal inlet profile and a parabolic inlet profile. For trapezoidal: It would be like U=ax till a certain x, after which it remains constant and then decreases again at U=-ax.
How do I do this?
Well if I just get the equivalent of BC_V_g(i) which specifies the velocity given the location, my work is done.
In the attached file is a UDF. I have also attached the mfx file. Can anyone please tell me why only one of the points is getting updated in the solution?
tfm2d.mfx (11.0 KB)
usr1.f (2.5 KB)
Hi @rkanchi. Thanks for attaching files, it’s always easier to provide support when we have a concrete example to work with.
First off - the variable c
should be declared integer, not real, since it’s being used as an array index. This leads to
Warning: Legacy Extension: REAL array index
when building the solver. This is not fatal but it’s better to avoid compiler warnings!
Now, I reached for the simplest tool in my toolbox, the write
statement:
DO I = BC_I_W(1), BC_I_E(1)
b=I*100
c=a+b
V_G(c)=0.9
write(*,*) "A= ", a, "B= ", b, "C= ", c, "V_G(c)=", V_G(c)
leads to:
START 2 END 32
A= 11 B= 200 C= 211.000000 V_G(c)= 0.89999997615814209
A= 11 B= 300 C= 311.000000 V_G(c)= 0.89999997615814209
A= 11 B= 400 C= 411.000000 V_G(c)= 0.89999997615814209
...
The 0.8999...
appears because 0.9
is not representable exactly in binary, and Fortran is too stupid to print the value as 0.9. This is normal.
So, it looks to me that multiple entries in the V_G
array are being set. What leads you to believe that only one point is being updated? Which point do you think it is?
When I use postmfix, I get the V_g (gas v velocity) at the boundary. At one of the points, this is getting updated. I wrote this UDF to understand what does what. I just want to spatially be able to give different values.
Perhaps, those entries you see may be inside the fluid domain. I am looking at only the boundary, hence only one of those points are coming up.
I want to understand how the IJK thing works and how V_g(i) can be used to give different values of velocity to different points of interest. That’s it.
The index for V_G
refers to cell index (we typically use IJK). This is not the same as the I index (x-direction).
You will need to do something similar to subroutine SET_BC0_VEL_INFLOW(BCV)
in set_bc0_flow.f
.
Oh you mean that nested loop?
DO K = BC_K_B(BCV), BC_K_T(BCV)
DO J = BC_J_S(BCV), BC_J_N(BCV)
DO I = BC_I_W(BCV), BC_I_E(BCV)
IF (.NOT.IS_ON_myPE_plus2layers(I,J,K)) CYCLE
IF (DEAD_CELL_AT(I,J,K)) CYCLE ! skip dead cells
IJK = BOUND_FUNIJK(I,J,K)
U_G(IJK) = BC_U_G(BCV)
V_G(IJK) = BC_V_G(BCV)
W_G(IJK) = BC_W_G(BCV)
IF (SMAX > 0) THEN
U_S(IJK,:SMAX) = BC_U_S(BCV,:SMAX)
V_S(IJK,:SMAX) = BC_V_S(BCV,:SMAX)
W_S(IJK,:SMAX) = BC_W_S(BCV,:SMAX)
ENDIF
Is this it?