compute_volumes Subroutine

private elemental subroutine compute_volumes(self)

Compute block volumes.

The volume of each cell is computed using the formula: $$ v = [(\vec n_7 - \vec n_1) + (\vec n_6 - \vec n_0), (\vec n_7 - \vec n_2), (\vec n_3 - \vec n_0)] + [(\vec n_6 - \vec n_0), (\vec n_7 - \vec n_2) + (\vec n_5 - \vec n_0), (\vec n_7 - \vec n_4)] + [(\vec n_7 - \vec n_1), (\vec n_5 - \vec n_0), (\vec n_7 - \vec n_4) + (\vec n_3 - \vec n_0)] $$ where \([\vec A, \vec B, \vec C]=\vec A \cdot (\vec B \times \vec C)\) is the triple product.

References

[1] Efficient computation of volume of hexahedral cells, Grandy J., 1997.

Arguments

Type IntentOptional AttributesName
class(block_object), intent(inout) :: self

Block.

Calls

proc~~compute_volumes~~CallsGraph proc~compute_volumes compute_volumes node node proc~compute_volumes->node
Help

Source Code


Source Code

   elemental subroutine compute_volumes(self)
   !< Compute block volumes.
   !<
   !< The volume of each cell is computed using the formula:
   !< $$
   !< v = [(\vec n_7 - \vec n_1) + (\vec n_6 - \vec n_0), (\vec n_7 - \vec n_2), (\vec n_3 - \vec n_0)] +
   !<     [(\vec n_6 - \vec n_0), (\vec n_7 - \vec n_2) + (\vec n_5 - \vec n_0), (\vec n_7 - \vec n_4)] +
   !<     [(\vec n_7 - \vec n_1), (\vec n_5 - \vec n_0), (\vec n_7 - \vec n_4) + (\vec n_3 - \vec n_0)]
   !< $$
   !< where \([\vec A, \vec B, \vec C]=\vec A \cdot (\vec B \times \vec C)\) is the triple product.
   !<
   !<### References
   !<
   !< [1] *Efficient computation of volume of hexahedral cells*, Grandy J., 1997.
   class(block_object), intent(inout) :: self         !< Block.
   type(vector)                       :: triplet(1:9) !< Dummy vectors.
   integer(I4P)                       :: i            !< Counter.
   integer(I4P)                       :: j            !< Counter.
   integer(I4P)                       :: k            !< Counter.

   associate(node=>self%node, ni=>self%signature%ni, nj=>self%signature%nj, nk=>self%signature%nk)
      do k=1, nk
         do j=1, nj
            do i=1, ni
               triplet(1) = node(i  , j  , k  )%vertex - node(i  , j-1, k-1)%vertex &
                          + node(i-1, j  , k  )%vertex - node(i-1, j-1, k-1)%vertex
               triplet(2) = node(i  , j  , k  )%vertex - node(i-1, j  , k-1)%vertex
               triplet(3) = node(i  , j  , k-1)%vertex - node(i-1, j-1, k-1)%vertex
               triplet(4) = node(i-1, j  , k  )%vertex - node(i-1, j-1, k-1)%vertex
               triplet(5) = node(i  , j  , k  )%vertex - node(i-1, j  , k-1)%vertex &
                          + node(i  , j-1, k  )%vertex - node(i-1, j-1, k-1)%vertex
               triplet(6) = node(i  , j  , k  )%vertex - node(i-1, j-1, k  )%vertex
               triplet(7) = node(i  , j  , k  )%vertex - node(i  , j-1, k-1)%vertex
               triplet(8) = node(i  , j-1, k  )%vertex - node(i-1, j-1, k-1)%vertex
               triplet(9) = node(i  , j  , k  )%vertex - node(i-1, j-1, k  )%vertex &
                          + node(i  , j  , k-1)%vertex - node(i-1, j-1, k-1)%vertex
               self%cell(i, j, k)%volume = ((triplet(1).dot.(triplet(2).cross.triplet(3))) + &
                                            (triplet(4).dot.(triplet(5).cross.triplet(6))) + &
                                            (triplet(7).dot.(triplet(8).cross.triplet(9)))) / 12.0_R8P
            enddo
         enddo
      enddo
   endassociate
   endsubroutine compute_volumes


adim_assign_adim allocate_blocks block_assign_block block_d_assign_block_d cell_assign_cell cells_number cells_number check cli_parse cli_parse cli_parse close compute_extents compute_faces_metrics compute_metrics compute_metrics compute_reference_values compute_space_operator compute_volumes correct_metrics cp create_linspace description description description description description description description description description destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy err_assign_err face_assign_face file_assign_file free_assign_free grid_d_assign_grid_d initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize initialize_unix initialize_windows integrate interpolate_at_nodes iolength iolength iopos_block_nodes is_the_end load_file_grid load_file_name_from_file load_file_parameters load_from_file load_from_file load_from_file load_from_file load_from_file load_from_file load_from_file load_grid_dimensions_from_file load_input_files load_nodes_from_file load_nodes_from_file mkdir node_assign_node node_to_center nodes_number nodes_number nullify_normals open os_assign_os parse_command_line_interface progress rm save_file_grid save_file_grid save_file_grid_tec save_file_grid_vtk save_file_name_into_file save_file_parameters save_grid_dimensions_into_file save_into_file save_into_file save_into_file save_into_file save_into_file save_into_file save_into_file save_nodes_into_file save_nodes_into_file set_command_line_interface set_stop solver_assign_solver time_assign_time update