Owned-cell fused thermo sync plus species sensible enthalpies.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(inout) | :: | flow | |||
| type(case_params_t), | intent(in) | :: | params | |||
| type(energy_fields_t), | intent(inout) | :: | energy | |||
| real(kind=rk), | intent(in) | :: | species_Y(:,:) | |||
| real(kind=rk), | intent(out) | :: | hk_species(:,:) |
subroutine recover_temperature_update_thermo_and_species_h_cantera_owned(mesh, flow, params, energy, species_Y, hk_species) type(mesh_t), intent(in) :: mesh type(flow_mpi_t), intent(inout) :: flow type(case_params_t), intent(in) :: params type(energy_fields_t), intent(inout) :: energy real(rk), intent(in) :: species_Y(:,:) real(rk), intent(out) :: hk_species(:,:) integer :: n_len, nloc, i, c, k real(rk) :: sum_Y real(rk), allocatable :: h_local(:), P_arr(:), Y_local(:,:) real(rk), allocatable :: T_local(:), cp_local(:), lambda_local(:), rho_local(:), hk_local(:,:) character(kind=c_char), allocatable :: c_names_flat(:) if (.not. params%enable_cantera_thermo) then call fatal_error('energy', 'fused thermo/species enthalpy sync requires Cantera thermo') end if if (params%nspecies <= 0) then call fatal_error('energy', 'fused thermo/species enthalpy sync requires at least one species') end if if (size(hk_species, 1) < params%nspecies .or. size(hk_species, 2) < mesh%ncells) then call fatal_error('energy', 'hk_species has incompatible shape in fused thermo/species enthalpy sync') end if nloc = max(0, flow%last_cell - flow%first_cell + 1) if (nloc <= 0) return allocate(h_local(nloc), P_arr(nloc), Y_local(max(1, params%nspecies), nloc)) allocate(T_local(nloc), cp_local(nloc), lambda_local(nloc), rho_local(nloc)) allocate(hk_local(params%nspecies, nloc)) P_arr = params%background_press do i = 1, nloc c = flow%first_cell + i - 1 h_local(i) = energy%h(c) sum_Y = zero do k = 1, params%nspecies Y_local(k, i) = max(zero, species_Y(k, c)) sum_Y = sum_Y + Y_local(k, i) end do if (sum_Y > tiny_safe) then Y_local(1:params%nspecies, i) = Y_local(1:params%nspecies, i) / sum_Y else Y_local(:, i) = zero Y_local(1, i) = 1.0_rk end if end do call build_c_species_names(params, c_names_flat, n_len) call cantera_recover_temperature_update_thermo_and_species_h_c(nloc, h_local, P_arr, params%nspecies, & Y_local, T_local, cp_local, lambda_local, rho_local, hk_local, & params%energy_reference_T, c_names_flat, n_len) do i = 1, nloc c = flow%first_cell + i - 1 energy%T(c) = T_local(i) energy%cp(c) = cp_local(i) energy%lambda(c) = lambda_local(i) energy%rho_thermo(c) = rho_local(i) do k = 1, params%nspecies hk_species(k, c) = hk_local(k, i) end do end do call flow_exchange_cell_matrix(flow, hk_species) deallocate(h_local, P_arr, Y_local, T_local, cp_local, lambda_local, rho_local, hk_local, c_names_flat) end subroutine recover_temperature_update_thermo_and_species_h_cantera_owned