I.1.23 Get_Volume_Cells_Multi_Mesh Procedure

The main documentation of the Get_Volume_Cells_Multi_Mesh Procedure contains additional explanation of this code listing.

  subroutine Get_Volume_Cells_Multi_Mesh (Volume_Cells, Mesh)
  
    ! Input variable.
  
    type(Multi_Mesh_type), intent(inout) :: Mesh  ! Mesh object.

    ! Input/Output variable.
    
    type(real,1) :: Volume_Cells ! Volume_Cells BNV.

    ! Internal variable.

    ! BNV of coordinates of nodes of cells.
    type(real,3) :: Coordinates_Nodes_of_Cells 

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
    ! Verify requirements.
  
    VERIFY(Valid_State(Mesh),5)                       ! Mesh is valid.
    VERIFY(Valid_State(Volume_Cells),5)               ! Volume_Cells is valid.
    VERIFY(Mesh%NCells_PE == SIZE(Volume_Cells),5)    ! Correct dimensions.
 
    ! Get Coordinates of the Nodes if needed.

    if (Mesh%Uniformity == "Nonuniform") then

      call Initialize (Coordinates_Nodes_of_Cells, Mesh%NDimensions, &
                       Mesh%NCells_PE, Mesh%Nodes_per_Cell)
      call Get_Coordinates_Nodes_of_Cells (Coordinates_Nodes_of_Cells, Mesh)

    end if

    ! Set the cell volumes.

    if (Mesh%Uniformity == "Uniform") then

      ! For a uniform mesh, all volumes are the same.
      Volume_Cells = Mesh%Volume_All_Cells

    else if (Mesh%Orthogonality == "Orthogonal") then

      ! For an orthogonal mesh, the volume may be calculated from the 
      ! product of 1, 2 or 3 orthogonal edge lengths.
      select case (Mesh%NDimensions)
      case (1)
        ! Suppressed Y, Z.
        Volume_Cells = ( Coordinates_Nodes_of_Cells(1,:,2) &     ! Delta X -
                       - Coordinates_Nodes_of_Cells(1,:,1) )     ! Nodes 1 & 2
      case (2)
        ! Suppressed Z.
        Volume_Cells = ( Coordinates_Nodes_of_Cells(1,:,2) &     ! Delta X -
                       - Coordinates_Nodes_of_Cells(1,:,1) ) * & ! Nodes 1 & 2
                       ( Coordinates_Nodes_of_Cells(2,:,3) &     ! Delta Y -  
                       - Coordinates_Nodes_of_Cells(2,:,1) )     ! Nodes 1 & 3
      case (3)
        Volume_Cells = ( Coordinates_Nodes_of_Cells(1,:,2) &     ! Delta X -
                       - Coordinates_Nodes_of_Cells(1,:,1) ) * & ! Nodes 1 & 2
                       ( Coordinates_Nodes_of_Cells(2,:,3) &     ! Delta Y -  
                       - Coordinates_Nodes_of_Cells(2,:,1) ) * & ! Nodes 1 & 3
                       ( Coordinates_Nodes_of_Cells(3,:,5) &     ! Delta Z -  
                       - Coordinates_Nodes_of_Cells(3,:,1) )     ! Nodes 1 & 5
      end select

    else
      ! Coding for other mesh types not implemented yet.
      VERIFY(.false.,1)
    end if
  
    ! Finalize temporaries.

    if (Mesh%Uniformity == "Nonuniform") then
      call Finalize (Coordinates_Nodes_of_Cells)
    end if

    ! Verify guarantees.
  
    VERIFY(Valid_State(Mesh),5)          ! Mesh is valid.
    VERIFY(Valid_State(Volume_Cells),5)  ! Volume_Cells still valid.
  
    return
  end subroutine Get_Volume_Cells_Multi_Mesh



Michael L. Hall