Computes the linear interpolation weight for a neighbor cell.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| 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 |
function face_neighbor_weight(mesh, bc, face_id, cell_id, nb) result(w_nb) 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) :: w_nb integer :: pair_face integer :: btype real(rk) :: nvec(3) real(rk) :: d_owner real(rk) :: d_nb real(rk) :: d_total if (nb <= 0) then w_nb = zero return end if nvec = outward_normal(mesh, face_id, cell_id) d_owner = abs(dot_product(mesh%faces(face_id)%center - & mesh%cells(cell_id)%center, nvec)) 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 d_nb = abs(dot_product(mesh%cells(nb)%center - & mesh%faces(pair_face)%center, nvec)) else d_nb = abs(dot_product(mesh%cells(nb)%center - & mesh%faces(face_id)%center, nvec)) end if else d_nb = abs(dot_product(mesh%cells(nb)%center - & mesh%faces(face_id)%center, nvec)) end if d_total = max(d_owner + d_nb, tiny_safe) w_nb = d_owner / d_total end function face_neighbor_weight