compute_metrics_2d Subroutine

public subroutine compute_metrics_2d(mesh, is_ok, message)

Compute finite-volume metrics from node coordinates already in mesh%x_node / mesh%y_node. Allocates (with stat=) and fills vol(nx,ny), s_xi(2,nx+1,ny), s_eta(2,nx,ny+1), xc(nx,ny), yc(nx,ny). Returns is_ok=.false. and a diagnostic message naming the first (i,j) with non-positive cell area.

Metric definitions

  • xi-face vector at column iface, row j: edge (iface,j)->(iface,j+1). s_xi = (dy, -dx), i.e. (+dy, -dx) where dx/dy are the edge increments.
  • eta-face vector at row jface, column i: edge (i,jface)->(i+1,jface). s_eta = (-dy, dx).
  • Cell area via diagonal cross-product (exact for arbitrary quads): vol = 0.5 * [(d1xd2y) - (d2xd1y)] where d1,d2 are the two diagonals.
  • Cell centre = arithmetic mean of four corners.

Arguments

Type IntentOptional Attributes Name
type(mesh_2d_t), intent(inout) :: mesh
logical, intent(out) :: is_ok
character(len=*), intent(out) :: message