Local variables to be added
integer          ifac, ii, iel
integer          idim
integer          izone,iesp
integer          ilelt, nlelt
 
double precision uref2, d2s3
double precision rhomoy, dhy
double precision z1   , z2
integer          ipotr, ipoti, f_id, ipotva
character(len=80) :: f_name
 
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: bfpro_rom
double precision, dimension(:,:), pointer :: cvara_potva
integer :: keyvar
  
Initialization and finalization
Initialization and finalization is similar to that of the base examples
Example 1
For boundary faces of color 1 assign an inlet and assign a cathode for "electric" variables.
call field_get_val_s(ibrom, bfpro_rom)
 
call getfbr(
'1', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  itypfb(ifac) = ientre
 
  
  izone = 1
 
  
  izfppp(ifac) = izone
 
  rcodcl(ifac,iu,1) = 0.d0
  rcodcl(ifac,iv,1) = 0.d0
  rcodcl(ifac,iw,1) = 0.d0
 
  
 
  if (itytur.eq.2 .or. itytur.eq.3                  &
       .or. iturb.eq.50 .or. iturb.eq.60            &
       .or. iturb.eq.70) then
 
    uref2 = rcodcl(ifac,iu,1)**2                    &
           +rcodcl(ifac,iv,1)**2                    &
           +rcodcl(ifac,iw,1)**2
    uref2 = max(uref2,1.d-12)
 
    
 
    
    
 
    
    
    
    
    
 
    
    
    
    
 
    
    dhy     = 0.075d0
 
    rhomoy = bfpro_rom(ifac)
 
    call turbulence_bc_inlet_hyd_diam &
  ( ifac, uref2, dhy, rhomoy, viscl0, rcodcl )
 
  endif
 
  
 
  
  
  
  
 
  ii = iscalt
  icodcl(ifac,isca(ii))   = 1
  rcodcl(ifac,isca(ii),1) = 1.d6
 
  
  
  
 
  
  
  
  
  
 
  icodcl(ifac,ipotr)   = 1
  rcodcl(ifac,ipotr,1) = 0.d0
 
  
 
  if (ngazge .gt. 1) then
    do iesp=1,ngazge-1
      write(f_name,'(a13,i2.2)') 'esl_fraction_',iesp
      call field_get_id(trim(f_name), f_id)
      call field_get_key_int(f_id, keyvar, ii)
      icodcl(ifac,ii)   = 1
      rcodcl(ifac,ii,1) = 0.d0
    enddo
  endif
 
  
  
 
  if (ippmod(ieljou).ge. 2) then
    icodcl(ifac,ipoti)   = 1
    rcodcl(ifac,ipoti,1) = 0.d0
  endif
 
  
  
  
 
  
  
  
  
  
  
 
  if (ippmod(ielarc).ge.2) then
      icodcl(ifac,ipotva    )   = 3
      rcodcl(ifac,ipotva    ,3) = 0.d0
      icodcl(ifac,ipotva + 1)   = 3
      rcodcl(ifac,ipotva + 1,3) = 0.d0
      icodcl(ifac,ipotva + 2)   = 3
      rcodcl(ifac,ipotva + 2,3) = 0.d0
  endif
 
enddo
  
Example 2
For boundary faces of color 5 assign an free outlet and example of electrode for Joule Effect by direct conduction.
call getfbr(
'5', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  itypfb(ifac)   = isolib
 
  
  izone = 2
 
  
 
  izfppp(ifac) = izone
 
  
 
  
  
 
  
  
  
 
  
 
  
  
  
  
  
  
 
  
  
 
  
  
 
  
  
 
  if (ippmod(ieljou).ge. 1) then
    icodcl(ifac,ipotr)   = 1
    if (ielcor.eq.1) then
      rcodcl(ifac,ipotr,1) = 500.d0*coejou
    else
      rcodcl(ifac,ipotr,1) = 500.d0
    endif
  endif
 
  if (ippmod(ieljou).ge. 2) then
    icodcl(ifac,ipoti)   = 1
    if (ielcor.eq.1) then
      rcodcl(ifac,ipoti,1) = sqrt(3.d0)*500.d0*coejou
    else
      rcodcl(ifac,ipoti,1) = sqrt(3.d0)*500.d0
    endif
  endif
 
enddo
  
Example 3
For boundary faces of color 2 assign a free outlet and example of anode for electric arc.
call getfbr(
'2', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  itypfb(ifac)   = isolib
 
  
  izone = 3
 
  
  izfppp(ifac) = izone
 
  
 
  
  
 
  
 
  
  
  
  
  
 
  
  
  
  
 
  
  
  
 
  
  
  
  
 
  
  
 
  
  
 
  icodcl(ifac,ipotr)   = 1
 
  if (ippmod(ielarc).ge.1 .and. ielcor .eq.1) then
    rcodcl(ifac,ipotr,1) = pot_diff
  else
    rcodcl(ifac,ipotr,1) = 1000.d0
  endif
 
  
  
  
 
  
  
  
 
enddo
  
Example 4
For boundary faces of color 3 assign a wall and example of potential vector Dirichlet condition
call getfbr(
'3', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  itypfb(ifac)   = iparoi
 
  
  izone = 4
 
  
  izfppp(ifac) = izone
 
  
  
  
 
  
  
  
 
  
  
  
 
  
  
 
  
 
  
  
 
  
  
  
  
  
 
  
  
  
 
  
  
  
  
 
  
  
  
 
  if (ippmod(ielarc).ge.2) then
    if (cdgfbo(1,ifac) .le.  2.249d-2  .or.                      &
        cdgfbo(1,ifac) .ge.  2.249d-2  .or.                      &
        cdgfbo(3,ifac) .le. -2.249d-2  .or.                      &
        cdgfbo(3,ifac) .ge.  2.249d-2      ) then
      call field_get_val_prev_v_by_name('vec_potential', cvara_potva)
      iel = ifabor(ifac)
      icodcl(ifac,ipotva)   = 1
      rcodcl(ifac,ipotva,1) = cvara_potva(1, iel)
 
      icodcl(ifac,ipotva + 1)   = 1
      rcodcl(ifac,ipotva + 1,1) = cvara_potva(2, iel)
 
      icodcl(ifac,ipotva + 2)   = 1
      rcodcl(ifac,ipotva + 2,1) = cvara_potva(3, iel)
    endif
  endif
 
enddo
  
Example 5
For boundary faces of color 51 assign a wall and restriking model for electric arc (anode boundaray condition).
call getfbr(
'51', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  itypfb(ifac)   = iparoi
 
  
  izone = 5
 
  
  izfppp(ifac) = izone
 
  
  
 
  ii=iscalt
  icodcl(ifac,isca(ii))   = 1
  rcodcl(ifac,isca(ii),1) = 2.d4
  rcodcl(ifac,isca(ii),2) = 1.d5
 
  
  
 
  icodcl(ifac,ipotr)   = 1
 
  if (ippmod(ielarc).ge.1 .and. ielcor .eq.1) then
    rcodcl(ifac,ipotr,1) = pot_diff
  else
    rcodcl(ifac,ipotr,1) = 100.d0
  endif
 
  
  
  
  
 
  if (ippmod(ielarc).ge.1 .and. ielcor .eq.1) then
    if (irestrike.eq.1 .and. ntcabs.le.ntdcla+30) then
      z1 = restrike_point_z - 2.d-4
      if (z1.le.0.d0) z1 = 0.d0
      z2 = restrike_point_z + 2.d-4
      if (z2.ge.2.d-2) z2 = 2.d-2
 
      if (cdgfbo(3,ifac).ge.z1 .and. cdgfbo(3,ifac).le.z2) then
        icodcl(ifac,isca(ii))   = 1
        rcodcl(ifac,isca(ii),1) = pot_diff
      else
        icodcl(ifac,isca(ii))   = 3
        rcodcl(ifac,isca(ii),3) = 0.d0
      endif
    endif
  endif
 
  
 
  if (ippmod(ielarc).ge.2) then
      icodcl(ifac,ipotva    )   = 3
      rcodcl(ifac,ipotva    ,3) = 0.d0
      icodcl(ifac,ipotva + 1)   = 3
      rcodcl(ifac,ipotva + 1,3) = 0.d0
      icodcl(ifac,ipotva + 2)   = 3
      rcodcl(ifac,ipotva + 2,3) = 0.d0
  endif
 
enddo
  
Example 6
For boundary faces of color 4 assign a symmetry.
call getfbr(
'4', nlelt, lstelt)
 
 
do ilelt = 1, nlelt
 
  ifac = lstelt(ilelt)
 
  
 
  itypfb(ifac)   = isymet
 
  
  izone = 6
 
  
  izfppp(ifac) = izone
 
  
  
 
  
  
  
 
  if (ippmod(ieljou).ge. 2) then
    icodcl(ifac,ipoti)   = 1
    rcodcl(ifac,ipoti,1) = 0.d0
  endif
 
enddo