face_normal_distance Function

public function face_normal_distance(mesh, bc, face_id, cell_id, nb) result(dist)

Calculates the normal distance between cell centers or cell-to-face.

Handles periodic boundary logic by accounting for the face pair offset.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh

The mesh.

type(bc_set_t), intent(in) :: bc

Boundary conditions.

integer, intent(in) :: face_id

Face index.

integer, intent(in) :: cell_id

Source cell index.

integer, intent(in) :: nb

Neighbor cell index (or 0 for boundaries).

Return Value real(kind=rk)


Calls

proc~~face_normal_distance~~CallsGraph proc~face_normal_distance mod_flow_projection::face_normal_distance proc~fatal_error mod_kinds::fatal_error proc~face_normal_distance->proc~fatal_error proc~outward_normal mod_flow_projection::outward_normal proc~face_normal_distance->proc~outward_normal proc~patch_type_for_face mod_bc::patch_type_for_face proc~face_normal_distance->proc~patch_type_for_face

Called by

proc~~face_normal_distance~~CalledByGraph proc~face_normal_distance mod_flow_projection::face_normal_distance proc~advance_species_transport mod_species::advance_species_transport proc~advance_species_transport->proc~face_normal_distance proc~compute_momentum_rhs mod_flow_projection::compute_momentum_rhs proc~compute_momentum_rhs->proc~face_normal_distance proc~correct_face_flux mod_flow_projection::correct_face_flux proc~correct_face_flux->proc~face_normal_distance proc~ensure_pressure_operator_cache mod_flow_projection::ensure_pressure_operator_cache proc~ensure_pressure_operator_cache->proc~face_normal_distance proc~advance_projection_step mod_flow_projection::advance_projection_step proc~advance_projection_step->proc~compute_momentum_rhs proc~advance_projection_step->proc~correct_face_flux proc~advance_projection_step->proc~ensure_pressure_operator_cache proc~solve_pressure_correction mod_flow_projection::solve_pressure_correction proc~advance_projection_step->proc~solve_pressure_correction proc~pressure_matvec mod_flow_projection::pressure_matvec proc~pressure_matvec->proc~ensure_pressure_operator_cache proc~solve_pressure_correction->proc~ensure_pressure_operator_cache proc~solve_pressure_correction->proc~pressure_matvec program~lowmach_react_hex lowmach_react_hex program~lowmach_react_hex->proc~advance_species_transport program~lowmach_react_hex->proc~advance_projection_step

Source Code

   function face_normal_distance(mesh, bc, face_id, cell_id, nb) result(dist)
      type(mesh_t), intent(in) :: mesh
      type(bc_set_t), intent(in) :: bc
      integer, intent(in) :: face_id
      integer, intent(in) :: cell_id
      integer, intent(in) :: nb
      real(rk) :: dist

      integer :: pair_face
      integer :: btype
      real(rk) :: nvec(3)

      nvec = outward_normal(mesh, face_id, cell_id)

      if (nb > 0) then
         if (mesh%faces(face_id)%neighbor == 0) then
            btype = patch_type_for_face(mesh, bc, face_id)

            if (btype == bc_periodic) then
               pair_face = mesh%faces(face_id)%periodic_face

               if (pair_face <= 0) then
                  call fatal_error('flow', 'periodic face has no paired face')
               end if

               dist = abs(dot_product(mesh%faces(face_id)%center - &
                                      mesh%cells(cell_id)%center, nvec)) + &
                      abs(dot_product(mesh%cells(nb)%center - &
                                      mesh%faces(pair_face)%center, nvec))

               dist = max(dist, tiny_safe)
               return
            end if
         end if

         dist = abs(dot_product(mesh%cells(nb)%center - &
                                mesh%cells(cell_id)%center, nvec))
      else
         dist = abs(dot_product(mesh%faces(face_id)%center - &
                                mesh%cells(cell_id)%center, nvec))
      end if

      dist = max(dist, tiny_safe)
   end function face_normal_distance