compute_volumes Subroutine

private subroutine compute_volumes(cells, nodes)

Compute the grid cell volumes Each grid is a hexahedron, whose volume is calculated by splitting it into 5 tetrahedrons, whose volume is known

Arguments

Type IntentOptional AttributesName
type(celltype), intent(out), dimension(-2:imx+2,-2:jmx+2,-2:kmx+2):: cells

Cell center quanties: volume and coordiantes of cell center

type(nodetype), intent(in), dimension(-2:imx+3,-2:jmx+3,-2:kmx+3):: nodes

Grid points


Calls

proc~~compute_volumes~~CallsGraph proc~compute_volumes compute_volumes proc~vol_hexahedron vol_hexahedron proc~compute_volumes->proc~vol_hexahedron proc~vol_tetrahedron vol_tetrahedron proc~vol_hexahedron->proc~vol_tetrahedron

Called by

proc~~compute_volumes~~CalledByGraph proc~compute_volumes compute_volumes proc~setup_geometry setup_geometry proc~setup_geometry->proc~compute_volumes proc~setup_solver setup_solver proc~setup_solver->proc~setup_geometry proc~start_run start_run proc~start_run->proc~setup_solver program~main main program~main->proc~start_run

Contents

Source Code


Source Code

        subroutine compute_volumes(cells, nodes)
            !< Compute the grid cell volumes
            !< Each grid is a hexahedron, whose volume is calculated by
            !< splitting it into 5 tetrahedrons, whose volume is known
            !-----------------------------------------------------------

            implicit none
            type(celltype), dimension(-2:imx+2,-2:jmx+2,-2:kmx+2), intent(out) :: cells
            !< Cell center quanties: volume and coordiantes of cell center
            type(nodetype), dimension(-2:imx+3,-2:jmx+3,-2:kmx+3), intent(in)  :: nodes
            !< Grid points
            integer :: i,j,k
            real(wp), dimension(1:3, 1:8) :: p_list

            cells(:,:,:)%volume=1.
            do k = 0, kmx+0
                do j = 0, jmx+0
                    do i = 0, imx+0
                        p_list(:, :) = 0.
                        p_list(:, 1) = (/ nodes(i,j,k)%x, nodes(i,j,k)%y, nodes(i,j,k)%z /)
                        p_list(:, 2) = (/ nodes(i+1,j,k)%x, nodes(i+1,j,k)%y, nodes(i+1,j,k)%z /)
                        p_list(:, 3) = (/ nodes(i+1,j+1,k)%x, nodes(i+1,j+1,k)%y, nodes(i+1,j+1,k)%z /)
                        p_list(:, 4) = (/ nodes(i,j+1,k)%x, nodes(i,j+1,k)%y, nodes(i,j+1,k)%z /)
                        p_list(:, 5) = (/ nodes(i,j,k+1)%x, nodes(i,j,k+1)%y, nodes(i,j,k+1)%z /)
                        p_list(:, 6) = (/ nodes(i+1,j,k+1)%x, nodes(i+1,j,k+1)%y, nodes(i+1,j,k+1)%z /)
                        p_list(:, 7) = (/ nodes(i+1,j+1,k+1)%x, nodes(i+1,j+1,k+1)%y, nodes(i+1,j+1,k+1)%z /)
                        p_list(:, 8) = (/ nodes(i,j+1,k+1)%x, nodes(i,j+1,k+1)%y, nodes(i,j+1,k+1)%z /)
                        cells(i, j, k)%volume = (vol_hexahedron(p_list))
                        if(cells(i,j,k)%volume<=0.0) then
                          if(i==0 .or. i==imx .or. j==0 .or. j==jmx .or. k==0 .or. k==kmx) then
                            !print*, "Ghost Cell volume negative"
                            cells(i, j, k)%volume = (vol_hexahedron(p_list))
                          else
                            print*, process_id, i,j,k
                            print*, "negative volume :", (vol_hexahedron(p_list))
                            STOP
                          end if
                        end if
                    end do
                end do
            end do
            if(any(cells(:,:,:)%volume==0.0))then
              Fatal_error
            end if
            if(any((cells(:,:,:)%volume)<0.0))then
              Fatal_error
            end if
            
        end subroutine compute_volumes