Allocates and resets temporary solver vectors. Calculates the normal distance between cell centers or cell-to-face.
Handles periodic boundary logic by accounting for the face pair offset.
Computes the linear interpolation weight for a neighbor cell.
| Type | Intent | Optional | 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). |
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