module boundaries_neutrals_m ! Stores information on boundary conditions of fields for neutrals module use precision_grillix_m, only : GP, GP_NAN use error_handling_grillix_m, only : handle_error, error_info_t use status_codes_grillix_m, only : GRILLIX_ERR_OTHER ! From PARALLAX use screen_io_m, only : get_stdout use mesh_cart_m, only : mesh_cart_t use descriptors_m, only : BND_TYPE_DIRICHLET_ZERO, BND_TYPE_NEUMANN, & DISTRICT_CORE, DISTRICT_WALL, DISTRICT_DOME, DISTRICT_OUT ! Parameters use params_neut_boundaries_perp_m, only : & bnddescr_neut_dens_core, bndval_neut_dens_core, & bnddescr_neut_dens_wall, bndval_neut_dens_wall, & bnddescr_neut_dens_dome, bndval_neut_dens_dome, & bnddescr_neut_dens_out, bndval_neut_dens_out, & bnddescr_neut_parmom_core, bndval_neut_parmom_core, & bnddescr_neut_parmom_wall, bndval_neut_parmom_wall, & bnddescr_neut_parmom_dome, bndval_neut_parmom_dome, & bnddescr_neut_parmom_out, bndval_neut_parmom_out, & bnddescr_neut_pressure_core, bndval_neut_pressure_core, & bnddescr_neut_pressure_wall, bndval_neut_pressure_wall, & bnddescr_neut_pressure_dome, bndval_neut_pressure_dome, & bnddescr_neut_pressure_out, bndval_neut_pressure_out implicit none type, private :: bndgen_t !! Datatype for defining boundary type and value integer, allocatable, dimension(:) :: types !! Type of boundary condition real(GP), allocatable, dimension(:) :: vals !! Boundary values end type type, public :: boundaries_neutrals_t !! Datatype for boundary types and values of neutrals module type(bndgen_t), public :: neutrals_dens !! For neutrals density type(bndgen_t), public :: neutrals_parmom !! For neutrals parallel momentum type(bndgen_t), public :: neutrals_pressure !! For neutrals pressure contains procedure, public :: init => init_boundaries_neutrals final :: destructor end type contains subroutine init_boundaries_neutrals(self, mesh_cano, mesh_stag) !! Sets boundary types and values according to parameters class(boundaries_neutrals_t), intent(inout) :: self !! Instance of the type type(mesh_cart_t), intent(in) :: mesh_cano !! Mesh (canonical) type(mesh_cart_t), intent(in) :: mesh_stag !! Mesh (staggered) integer :: nbnds_cano, nbnds_stag, kb, l, district nbnds_cano = mesh_cano%get_n_points_boundary() nbnds_stag = mesh_stag%get_n_points_boundary() ! Boundary descriptors and values for quantities defined on canonical mesh allocate(self%neutrals_dens%types(nbnds_cano)) allocate(self%neutrals_dens%vals(nbnds_cano)) allocate(self%neutrals_pressure%types(nbnds_cano)) allocate(self%neutrals_pressure%vals(nbnds_cano)) !$omp parallel default(none) & !$omp private(kb, l, district), & !$omp shared(self, mesh_cano, & !$omp bnddescr_neut_dens_core, bndval_neut_dens_core, & !$omp bnddescr_neut_dens_wall, bndval_neut_dens_wall, & !$omp bnddescr_neut_dens_dome, bndval_neut_dens_dome, & !$omp bnddescr_neut_dens_out, bndval_neut_dens_out, & !$omp bnddescr_neut_pressure_core, bndval_neut_pressure_core, & !$omp bnddescr_neut_pressure_wall, bndval_neut_pressure_wall, & !$omp bnddescr_neut_pressure_dome, bndval_neut_pressure_dome, & !$omp bnddescr_neut_pressure_out, bndval_neut_pressure_out) !$omp do do kb = 1, mesh_cano%get_n_points_boundary() l = mesh_cano%boundary_indices(kb) district = mesh_cano%get_district(l) select case(district) case(DISTRICT_CORE) self%neutrals_dens%types(kb) = bnddescr_neut_dens_core self%neutrals_dens%vals(kb) = bndval_neut_dens_core self%neutrals_pressure%types(kb) = bnddescr_neut_pressure_core self%neutrals_pressure%vals(kb) = bndval_neut_pressure_core case(DISTRICT_WALL) self%neutrals_dens%types(kb) = bnddescr_neut_dens_wall self%neutrals_dens%vals(kb) = bndval_neut_dens_wall self%neutrals_pressure%types(kb) = bnddescr_neut_pressure_wall self%neutrals_pressure%vals(kb) = bndval_neut_pressure_wall case(DISTRICT_DOME) self%neutrals_dens%types(kb) = bnddescr_neut_dens_dome self%neutrals_dens%vals(kb) = bndval_neut_dens_dome self%neutrals_pressure%types(kb) = bnddescr_neut_pressure_dome self%neutrals_pressure%vals(kb) = bndval_neut_pressure_dome case(DISTRICT_OUT) self%neutrals_dens%types(kb) = bnddescr_neut_dens_out self%neutrals_dens%vals(kb) = bndval_neut_dens_out self%neutrals_pressure%types(kb) = bnddescr_neut_pressure_out self%neutrals_pressure%vals(kb) = bndval_neut_pressure_out case default !$omp critical call handle_error('District not valid', & GRILLIX_ERR_OTHER, __LINE__, __FILE__, & error_info_t('district: ', & [district])) !$omp end critical end select enddo !$omp end do !$omp end parallel ! Boundary descriptors and values for quantities defined on staggered mesh allocate(self%neutrals_parmom%types(nbnds_stag)) allocate(self%neutrals_parmom%vals(nbnds_stag)) !$omp parallel default(none) & !$omp private(kb, l, district), & !$omp shared(self, mesh_stag, & !$omp bnddescr_neut_parmom_core, bndval_neut_parmom_core, & !$omp bnddescr_neut_parmom_wall, bndval_neut_parmom_wall, & !$omp bnddescr_neut_parmom_dome, bndval_neut_parmom_dome, & !$omp bnddescr_neut_parmom_out, bndval_neut_parmom_out) !$omp do do kb = 1, mesh_stag%get_n_points_boundary() l = mesh_stag%boundary_indices(kb) district = mesh_stag%get_district(l) select case(district) case(DISTRICT_CORE) self%neutrals_parmom%types(kb) = bnddescr_neut_parmom_core self%neutrals_parmom%vals(kb) = bndval_neut_parmom_core case(DISTRICT_WALL) self%neutrals_parmom%types(kb) = bnddescr_neut_parmom_wall self%neutrals_parmom%vals(kb) = bndval_neut_parmom_wall case(DISTRICT_DOME) self%neutrals_parmom%types(kb) = bnddescr_neut_parmom_dome self%neutrals_parmom%vals(kb) = bndval_neut_parmom_dome case(DISTRICT_OUT) self%neutrals_parmom%types(kb) = bnddescr_neut_parmom_out self%neutrals_parmom%vals(kb) = bndval_neut_parmom_out case default !$omp critical call handle_error('District not valid', & GRILLIX_ERR_OTHER, __LINE__, __FILE__, & error_info_t('district: ', & [district])) !$omp end critical end select enddo !$omp end do !$omp end parallel end subroutine subroutine destructor(self) !! Frees memory associated with boundaries_neutrals type(boundaries_neutrals_t), intent(inout) :: self !! Instance of the type if (allocated(self%neutrals_dens%types)) deallocate(self%neutrals_dens%types) if (allocated(self%neutrals_dens%vals)) deallocate(self%neutrals_dens%vals) if (allocated(self%neutrals_parmom%types)) deallocate(self%neutrals_parmom%types) if (allocated(self%neutrals_parmom%vals)) deallocate(self%neutrals_parmom%vals) if (allocated(self%neutrals_pressure%types)) deallocate(self%neutrals_pressure%types) if (allocated(self%neutrals_pressure%vals)) deallocate(self%neutrals_pressure%vals) end subroutine end module