Boundary conditions related to monitoring point temperature

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Steven Tang
Posts: 3
Joined: Thu May 12, 2022 6:38 am

Boundary conditions related to monitoring point temperature

Post by Steven Tang »

Dear all,

I am a newbie to code-saturne,recently,I'm learning how to extract the monitoring points I added on the GUI page in the cs_user_boundary_conditions.f90 file. For example, I define a monitoring point on the GUI page, how can I get the temperature of this monitoring point and use it as an input value for the inlet condition?
Can anyone give me some code to call my monitoring point temperature in real time if it is convenient?
Thank you very much for any ideas on this matter
Kind regards
Steven

------------------------------------------------
subroutine cs_f_user_boundary_conditions &
( nvar , nscal , &
icodcl , itrifb , itypfb , izfppp , &
dt , &
rcodcl )
use paramx
use numvar
use optcal
use cstphy
use cstnum
use entsor
use parall
use period
use ihmpre
use ppppar
use ppthch
use coincl
use cpincl
use ppincl
use ppcpfu
use atincl
use ctincl
use cs_fuel_incl
use mesh
use field
use cs_c_bindings
implicit none
integer nvar , nscal
integer icodcl(nfabor,nvar)
integer itrifb(nfabor), itypfb(nfabor)
integer izfppp(nfabor)
double precision dt(ncelet)
double precision rcodcl(nfabor,nvar,3)
integer ifac, iel, ii
integer ilelt, nlelt
double precision uref2
double precision rhomoy, xdh
double precision xitur
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: bfpro_rom
allocate(lstelt(nfabor)) ! temporary array for boundary faces selection
call field_get_val_s(ibrom, bfpro_rom)
call getfbr('in', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
itypfb(ifac) = ientre
rcodcl(ifac,iu,1) = 0.d0
rcodcl(ifac,iv,1) = 0.d0
rcodcl(ifac,iw,1) = 1.0d0
uref2 = rcodcl(ifac,iu,1)**2 &
+ rcodcl(ifac,iv,1)**2 &
+ rcodcl(ifac,iw,1)**2
uref2 = max(uref2,1.d-12)
xdh = 0.1d0
rhomoy = bfpro_rom(ifac)
call turbulence_bc_inlet_hyd_diam(ifac, uref2, xdh, rhomoy, viscl0, &
rcodcl)
if (nscal.gt.0) then
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! in this place, get the tempC of monitor 1, marked as probe_temp, and use the probe_temp to change the inlet temperature ("rcodcl(ifac,isca(ii),1)" ). can you give me some advice how to get the tempC of monitor 1, thanks !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do ii=1,nscasp
rcodcl(ifac,isca(ii),1) = 90.d0
enddo
endif
enddo


deallocate(lstelt) ! temporary array for boundary faces selection
return
end subroutine cs_f_user_boundary_conditions
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Boundary conditions related to monitoring point temperature

Post by Yvan Fournier »

Hello,

The monitoring point system is designed for filtering and extraction of outputs, but is not adapted to feedback to boundary conditions. More specifically, the lower-level code used for point location, which is shared between the mapped inlet option and probes, is a good fit, but the higher-level layer related to monitoring points is not.

If you need to re inject some variable values from a part of the fomain the the input, the "mapped inlet" feature may be useful (using it with the GUI, it is applied to all variables, but with user-defined functions, you can have finer control).

Otherwise, using simple functions linke findpt (Fortran) / cs_geom_closest_point (C) to query temperature values near a given point in space to compute a boundary inlet value is simplet. Check cs_user_extra_operations examples to see how values can be queried in this way.

Best regards,

Yvan
Steven Tang
Posts: 3
Joined: Thu May 12, 2022 6:38 am

Re: Boundary conditions related to monitoring point temperature

Post by Steven Tang »

Dear Yvan

Thank you very much, I read the method you mentioned carefully, it seems to work, but there seems to be a little problem. I tried the following:
--------------code-----------------------------------------
xx=0.5d0
yy=0.0d0
zz=3.0d0
call findpt(ncelet,ncel,xyzcen,xx,yy,zz,node,ndrang)
call field_get_val_s(ivarfl(isca(iscalt)),cvar_scalt)
temp=cvar_scalt(node)
call getfbr('in', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
itypfb(ifac) = ientre
rcodcl(ifac,iu,1) = 0.d0
rcodcl(ifac,iv,1) = 0.d0
rcodcl(ifac,iw,1) = 0.89d0
uref2 = rcodcl(ifac,iu,1)**2 &
+ rcodcl(ifac,iv,1)**2 &
+ rcodcl(ifac,iw,1)**2
uref2 = max(uref2,1.d-12)
xdh = 0.9d0
rhomoy = bfpro_rom(ifac)
call turbulence_bc_inlet_hyd_diam(ifac, uref2, xdh, rhomoy, viscl0, &
rcodcl)
do ii=1,nscal
rcodcl(ifac,isca(ii),1) = 100.d0+temp
enddo
enddo
--------------------------other code-----------------------------------------------
call getfbr('out',out1,lstelt) !! out is the the name of the outlet boundary
outfac=lstelt(out1)
out2=ifabor(outfac)
call field_get_val_s(ivarfl(isca(iscalt)),cvar_scalt)
temp=cvar_scalt(out2)
-------------------------code----------------------------------
as you can see in picture1,The temperature at the inlet was not uniform, the maximum temperature at the point I set was 130°C, but the temperature at the inlet was closer to 400°C. Can you give some advice on how to keep the temperature even at the inlet?(The lowermost area that can be seen in the picture is the inlet)
and If it is convenient, can you tell me that the code below can get the temperature at the outlet?

Best regards,

Steven
Attachments
picture1.png
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Boundary conditions related to monitoring point temperature

Post by Yvan Fournier »

Hello,

Could you use the code or quote tags in the forum editor to keep your copy/pasted code indented correctly ?
Without proper indentation, the code is less readable, and possible mistakes are harder to spot.

Also, are you running in parallel or in serial mode ? Your code may not always work in parallel, depending on how you domain partitioning (so basically, is is limited to serial runs).

Finally, and most important, if your output is non uniform, using a single point of measure for the input does not seem to be a good idea, unless it matches some control loop based on a single measure (which I double, as you do not have a delay or damping in your code).

Regards,

Yvan
Post Reply