Mapped inlet when there are another inlet faces

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Tsubasa
Posts: 164
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello I removed some part you pointed out.
Now message shows
SIGSEGV signal (forbidden memory area access) intercepted!
So what do I have to do for this?

Code: Select all

call getfbr('mapped_inlet_duct', nlfac, lstfac)

if (ntcabs == ntpabs+1) then
  allocate(lstcel(ncel))
  do iel = 1, ncel
    lstcel(iel) = iel
  enddo
  coord_shift(1,1) = -0.02
  coord_shift(2,1) = 0.d0
  coord_shift(3,1) = 0.d0
  inlet_l = boundary_conditions_map(mesh_location_cells, ncel,                &
                                    nlfac, lstcel, lstfac,                    &
                                    coord_shift, 0,                           &
                                    0.01d0)
  deallocate(lstcel)
endif

  call field_get_n_fields(n_fields)
  call field_get_key_id("velocity", keyvar)
  call field_get_key_id("scalar1", keysca)

  interpolate = 0

 do f_id = 0, n_fields-1
!    call field_get_key_int(f_id, keyvar, ivar)
!    call field_get_key_int(f_id, keysca, iscal)
    normalize = 0
    call boundary_conditions_mapped_set(f_id, inlet_l, MESH_LOCATION_CELLS, &
                                        normalize, interpolate,             &
                                        nlfac, lstfac, rvoid,               &
                                        nvar, rcodcl)
  enddo
Best regards,
Hamada
Yvan Fournier
Posts: 3814
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

Do you have a more complete stack trace for this ?

Regards,

Yvan
Tsubasa
Posts: 164
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

Please find the following.
SIGSEGV signal (forbidden memory area access) intercepted!

Call stack:
1: 0x7ff1ac7c566d <ple_locator_exchange_point_var+0x7d> (libple.so.2)
2: 0x7ff1ad7475e1 <cs_boundary_conditions_mapped_set+0x171> (libsaturne-6.0.so)
3: 0x7ff1ad748362 <cs_f_boundary_conditions_mapped_set+0x1d2> (libsaturne-6.0.so)
4: 0x55a375fa5563 <cs_f_user_boundary_conditions_+0x277> (cs_solver)
5: 0x7ff1ad71c406 <condli_ini_+0x9b> (libsaturne-6.0.so)
6: 0x7ff1ad6eea78 <caltri_+0xc73> (libsaturne-6.0.so)
7: 0x7ff1aee2b82f <cs_run+0x5ef> (libcs_solver-6.0.so)
8: 0x7ff1aee2b0f8 <main+0x178> (libcs_solver-6.0.so)
9: 0x7ff1ace8ec87 <__libc_start_main+0xe7> (libc.so.6)
10: 0x55a375fa4fba <_start+0x2a> (cs_solver)
End of stack
run_solver.log
(16.56 KiB) Downloaded 11 times
error.txt
(831 Bytes) Downloaded 10 times
Best regards,
Hamada
Yvan Fournier
Posts: 3814
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

Could you print the name of the variable in the loop in cs_f_user_boundary_conditions just before the call to cs_boundary_conditions_mapped_set to check which variable is causing issues here ?

Also, did you try this with version 7.0 in case some bug may have been fixed since ?

Best regards,

Yvan
Tsubasa
Posts: 164
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

Are these infomation enough for you?

Code: Select all

subroutine cs_f_user_boundary_conditions &
 ( nvar   , nscal  ,                                              &
   icodcl , itrifb , itypfb , izfppp ,                            &
   dt     ,                                                       &
   rcodcl )

!===============================================================================

!===============================================================================
! Module files
!===============================================================================

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 atsoil
use ctincl
use cs_fuel_incl
use mesh
use field
use turbomachinery
use iso_c_binding
use cs_c_bindings

!===============================================================================

implicit none

! Arguments

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)

! Local variables

!< [loc_var_dec]
integer          ifac, iel, ii, ivar, iscal, ilelt, nlfac

integer          keyvar, keysca
integer          n_fields, f_id, normalize, interpolate
double precision xdh, rhomoy
double precision fmprsc, uref2

integer, allocatable, dimension(:) :: lstfac, lstcel
double precision, dimension(:), pointer :: brom

double precision, dimension(:,:), pointer :: vel
double precision, dimension(3,1) :: coord_shift
double precision, dimension(1) :: rvoid

type(c_ptr), save :: inlet_l = c_null_ptr
!< [loc_var_dec]

!===============================================================================
! Initialization
!===============================================================================

!< [init]
allocate(lstfac(nfabor))  ! temporary array for boundary faces selection

! Map field arrays
call field_get_val_v(ivarfl(iu), vel)

call field_get_val_s(ibrom, brom)

fmprsc = 1.d0 ! mean prescribed velocity
!< [init]

!===============================================================================
! Assign a pseudo-periodic channel type inlet to a set of boundary faces,
! using boundary condition mapping.

! For each subset:
! - use selection criteria to filter boundary faces of a given subset
! - use boundary_conditions_map_set and boundary_conditions_mapped_set
!   to apply a profile from inside the domain to the inlet, renormalizing
!   for some variables.
!
! The impled feedback loop allows progressively reaching a state similar
! to that of a periodic channel at the inlet.
!===============================================================================

call getfbr('mapped_inlet_duct', nlfac, lstfac)

if (ntcabs == ntpabs+1) then
  allocate(lstcel(ncel))
  do iel = 1, ncel
    lstcel(iel) = iel
  enddo
  coord_shift(1,1) = -0.02
  coord_shift(2,1) = 0.d0
  coord_shift(3,1) = 0.d0
  inlet_l = boundary_conditions_map(mesh_location_cells, ncel,                &
                                    nlfac, lstcel, lstfac,                    &
                                    coord_shift, 0,                           &
                                    0.01d0)
  deallocate(lstcel)
endif

  call field_get_n_fields(n_fields)
  call field_get_key_id("velocity", keyvar)
  call field_get_key_id("scalar1", keysca)

  interpolate = 0

 do f_id = 0, n_fields-1
!    call field_get_key_int(f_id, keyvar, ivar)
!    call field_get_key_int(f_id, keysca, iscal)
    normalize = 0
    call boundary_conditions_mapped_set(f_id, inlet_l, MESH_LOCATION_CELLS, &
                                        normalize, interpolate,             &
                                        nlfac, lstfac, rvoid,               &
                                        nvar, rcodcl)
  enddo

!--------
! Formats
!--------

!----
! End
!----

deallocate(lstfac)  ! temporary array for boundary faces selection

return
end subroutine cs_f_user_boundary_conditions
cs_user_boundary_conditions-mapped_inlet.f90
(7.92 KiB) Downloaded 16 times
Best regards,
Tsubasa
Yvan Fournier
Posts: 3814
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

Sorry, I meant to add a "print" statement for get the field id after line 206, run the code, and post the ouptut (along with run_solver.log to identify the matching field).

Regards,

Yvan
Tsubasa
Posts: 164
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

I run the following code. Is it what you mean?

Code: Select all

 do f_id = 0, n_fields-1
    normalize = 0
    print *, f_id
    call boundary_conditions_mapped_set(f_id, inlet_l, MESH_LOCATION_CELLS, &
                                        normalize, interpolate,             &
                                        nlfac, lstfac, rvoid,               &
                                        nvar, rcodcl)
  enddo
Let me post some files.
run_solver.log
(16.52 KiB) Downloaded 11 times
error.txt
(832 Bytes) Downloaded 10 times
cs_user_boundary_conditions-mapped_inlet.f90
(7.94 KiB) Downloaded 15 times
Best regards,
Hamada
Yvan Fournier
Posts: 3814
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

THe "print *" output probably appears in the terminal you used to run the code, or in the batch output file if you are on a batch system. Can you check this ? An alternative is to replace
print *,

with

write(nfecra, *)

-If I remember correctly.

Otherwise if you have a very small test case, you can post it here.

Best regards,

Yvan
Tsubasa
Posts: 164
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

This is a small test.
You can download them.
Would you test them?
mapped_inlet.med
(620.28 KiB) Downloaded 10 times
test_mapped_inlet.zip
(437.39 KiB) Downloaded 10 times
Best regards,
Tsubasa
Yvan Fournier
Posts: 3814
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

The crash was due to a missing update in the example.

In cs_user_boundary_conditions.f90, line 182, replace "ntpabs+1" with simpley "ntpabs".

Best regards,

Yvan
Post Reply